Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppNavigationItem improved editing mode and AppNavigationNewItem component #1277

Merged
merged 45 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
19cfc93
Update AppNavigationItem.vue
JonathanTreffler Aug 11, 2020
3d4f217
changed name to newItem
JonathanTreffler Aug 12, 2020
86de79e
fixed missing comma and linting errors
JonathanTreffler Aug 18, 2020
7c6c6fd
implemented newItem behaviour
JonathanTreffler Aug 18, 2020
23decec
renamed variables and classes
JonathanTreffler Aug 19, 2020
f7d6d07
started updating the documentation
JonathanTreffler Aug 19, 2020
09ef60e
added a icon to the new item example in the documentation
JonathanTreffler Aug 19, 2020
3990691
improved comment
JonathanTreffler Aug 19, 2020
1227569
moved newItem Code into own block, to not have an a element that mess…
JonathanTreffler Aug 19, 2020
02409f1
fixed style issues
JonathanTreffler Aug 19, 2020
5d7a37b
fixed linting errors
JonathanTreffler Aug 19, 2020
ffcadbf
fixed a few errors
JonathanTreffler Aug 19, 2020
b2dc51b
changed documentation event alert text
JonathanTreffler Aug 19, 2020
e1e90e0
added icon to the editing mode
JonathanTreffler Aug 19, 2020
8f311ed
changed pretty much everything
JonathanTreffler Aug 19, 2020
5e7e395
improved design
JonathanTreffler Aug 19, 2020
14ef594
seperated editing and newItem completely
JonathanTreffler Aug 27, 2020
2891535
sorted methods
JonathanTreffler Aug 27, 2020
05089e5
added a icon to the editable item example in the docs
JonathanTreffler Aug 29, 2020
7d8f3e2
modified the alert messages of editable and new Item in the documenta…
JonathanTreffler Aug 29, 2020
d70b838
moved the input with confirm and cancel buttons into an own component
JonathanTreffler Sep 2, 2020
c5d6715
cleaned up scss
JonathanTreffler Sep 2, 2020
7f4f257
updated the documentation
JonathanTreffler Sep 2, 2020
027554a
prevent editable item from getting selected when clicking on the text…
JonathanTreffler Sep 2, 2020
3215b06
started moving newItem into a dedicated component
JonathanTreffler Sep 9, 2020
df1deff
fixed navElement (no longer a link)
JonathanTreffler Sep 9, 2020
ab60a99
no longer using nav-element for newItem
JonathanTreffler Sep 9, 2020
bccbf9c
updated docs and cleaned up old comments
JonathanTreffler Sep 26, 2020
48884bb
fixed icons in AppNavigationNewItem
JonathanTreffler Sep 26, 2020
40ca549
improved AppNavigationNewItem style, so the text does not move when a…
JonathanTreffler Sep 26, 2020
f797164
updated docs
JonathanTreffler Sep 26, 2020
285a595
fixed app-navigation-new-item__title style being overwritten by app-n…
JonathanTreffler Sep 26, 2020
a747bc4
cleaned up messy css from the seperation into two components
JonathanTreffler Sep 26, 2020
a1c2870
fixed stylelint warnings
JonathanTreffler Sep 26, 2020
0ae014c
Update AppNavigationNewItem.vue
JonathanTreffler Sep 30, 2020
ef5ede3
added the loading state to the docs of AppNavigationNewItem
JonathanTreffler Nov 5, 2020
4f38ffc
fixing loading mode visual bug in AppNavigationNewItem
JonathanTreffler Nov 5, 2020
b05ce3c
can no longer click on a AppNavigationNewItem while loading
JonathanTreffler Nov 5, 2020
0ad6375
fixed linting errors
JonathanTreffler Nov 5, 2020
8633c59
added documentation for InputConfirmCancel
JonathanTreffler Nov 5, 2020
6ab92bf
fixed the copyright headers
JonathanTreffler Nov 5, 2020
508645d
fixed linting errors
JonathanTreffler Nov 5, 2020
3bd8def
started re-implementing the automatic focus of the editing and newIte…
JonathanTreffler Nov 5, 2020
694d0ee
continued development of the automatic input focus
JonathanTreffler Nov 5, 2020
10fc1d9
re-implementing auto focus done
JonathanTreffler Nov 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 40 additions & 88 deletions src/components/AppNavigationItem/AppNavigationItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ prevent the user from collapsing the items.
</AppNavigationItem>
```
### Editable element
Add the prop `:editable=true` and an edit placeholder if you need it. By devault
Add the prop `:editable=true` and an edit placeholder if you need it. By default
the placeholder is the previous title of the element.

```
<AppNavigationItem title="Editable Item" :editable="true"
editPlaceholder="your_placeholder_here" />
editPlaceholder="your_placeholder_here" icon="icon-folder" @update:title="function(value){alert(value)}" />
```
### Undo element
Just set the `undo` and `title` props. When clicking the undo button, an `undo` event is emitted.
Expand All @@ -111,14 +111,14 @@ Just set the `pinned` prop.
'app-navigation-entry--no-icon': !isIconShown,
'app-navigation-entry--opened': opened,
'app-navigation-entry--pinned': pinned,
'app-navigation-entry--editing' : editing,
'app-navigation-entry--editing' : editingActive,
'app-navigation-entry--deleted': undo,
'app-navigation-entry--collapsible': collapsible,
'active': isActive
}"
class="app-navigation-entry">
<!-- Icon and title -->
<a v-if="!undo && !editing"
<a v-if="!undo"
class="app-navigation-entry-link"
href="#"
@click="onClick">
Expand All @@ -129,9 +129,15 @@ Just set the `pinned` prop.
class="app-navigation-entry-icon">
<slot v-if="!loading" v-show="isIconShown" name="icon" />
</div>
<span class="app-navigation-entry__title" :title="title">
<span v-if="!editingActive" class="app-navigation-entry__title" :title="title">
{{ title }}
</span>
<div v-if="editingActive" class="editingContainer">
<InputConfirmCancel v-model="editingValue"
:placeholder="editPlaceholder !== '' ? editPlaceholder : title"
@cancel="cancelEditing"
@confirm="handleEditingDone" />
</div>
</a>

<AppNavigationIconCollapsible v-if="collapsible" :open="opened" @click.prevent.stop="toggleCollapse" />
Expand All @@ -150,31 +156,14 @@ Just set the `pinned` prop.
:force-menu="forceMenu"
:default-icon="menuIcon"
@update:open="onMenuToggle">
<ActionButton v-if="editable && !editing" icon="icon-rename" @click="handleEdit">
<ActionButton v-if="editable && !editingActive" icon="icon-rename" @click="handleEdit">
{{ editLabel }}
</ActionButton>
<ActionButton v-if="undo" icon="app-navigation-entry__deleted-button icon-history" @click="handleUndo" />
<slot name="actions" />
</Actions>
</div>

<!-- edit entry -->
<div v-if="editing" class="app-navigation-entry__edit">
<form @submit.prevent="handleRename" @keydown.esc.exact.prevent="cancelEdit">
<input ref="inputTitle"
v-model="newTitle"
type="text"
class="app-navigation-entry__edit-input"
:placeholder="editPlaceholder !== '' ? editPlaceholder : title">
<button type="submit"
class="icon-confirm"
@click.stop.prevent="handleRename" />
<button type="reset"
class="icon-close"
@click.stop.prevent="cancelEdit" />
</form>
</div>

<!-- Children elements -->
<ul v-if="canHaveChildren && hasChildren" class="app-navigation-entry__children">
<slot />
Expand All @@ -188,6 +177,7 @@ import Actions from '../Actions/Actions'
import ActionButton from '../ActionButton/ActionButton'
import AppNavigationIconCollapsible from './AppNavigationIconCollapsible'
import isMobile from '../../mixins/isMobile'
import InputConfirmCancel from './InputConfirmCancel.vue'

export default {
name: 'AppNavigationItem',
Expand All @@ -196,6 +186,7 @@ export default {
Actions,
ActionButton,
AppNavigationIconCollapsible,
InputConfirmCancel,
},
directives: {
ClickOutside,
Expand Down Expand Up @@ -267,7 +258,7 @@ export default {
default: '',
},
/**
* Only for 'editable' items, sets placeholder text for the editing form.
* Only for items in 'editable' mode, sets the placeholder text for the editing form.
*/
editPlaceholder: {
type: String,
Expand Down Expand Up @@ -321,9 +312,9 @@ export default {

data() {
return {
newTitle: '',
editingValue: '',
opened: this.open,
editing: false,
editingActive: false,
}
},
computed: {
Expand Down Expand Up @@ -405,20 +396,20 @@ export default {

// Edition methods
handleEdit() {
this.newTitle = this.title
this.editing = true
this.editingValue = this.title
this.editingActive = true
this.onMenuToggle(false)
this.$nextTick(() => {
this.$refs.inputTitle.focus()
// this.$refs.editingInput.focus()
})
},
cancelEdit() {
this.editing = false
cancelEditing() {
this.editingActive = false
},
handleRename() {
this.$emit('update:title', this.newTitle)
this.newTitle = ''
this.editing = false
handleEditingDone() {
this.$emit('update:title', this.editingValue)
this.editingValue = ''
this.editingActive = false
},

// Undo methods
Expand All @@ -429,7 +420,7 @@ export default {
}
</script>

<style lang="scss" scoped>
<style lang="scss">
@import '../../fonts/scss/iconfont-vue';

.app-navigation-entry {
Expand Down Expand Up @@ -468,16 +459,21 @@ export default {
}
}

&:not(.app-navigation-entry--editing) {
.app-navigation-entry-link, .app-navigation-entry-div {
padding-right: $icon-margin;
}
}

// Main entry link
.app-navigation-entry-link {
.app-navigation-entry-link, .app-navigation-entry-div {
z-index: 100; /* above the bullet to allow click*/
display: flex;
overflow: hidden;
flex: 1 1 0;
box-sizing: border-box;
min-height: $clickable-area;
padding: 0;
padding-right: $icon-margin;
white-space: nowrap;
color: var(--color-main-text);
background-repeat: no-repeat;
Expand All @@ -500,6 +496,12 @@ export default {
max-width: 100%;
white-space: nowrap;
text-overflow: ellipsis;
padding-left: 6px;
}

.editingContainer {
width: calc(100% - #{$clickable-area});
margin: auto;
}
}

Expand Down Expand Up @@ -534,56 +536,6 @@ export default {
}
}

.app-navigation-entry__edit {
flex: 1 0 100%;
/* Ugly hack for overriding the main entry link */
/* align the input correctly with the link text
44px-6px padding for the input */
padding-left: $clickable-area - $icon-margin - 6px !important;
form {
display: flex;
width: 100%;
.app-navigation-entry__edit-input {
flex: 1 1 100%;
}

// submit and cancel buttons
button {
display: flex;
align-items: center;
justify-content: center;
width: $clickable-area !important;
color: var(--color-main-text);
background: none;
font-size: 16px;

// icon hover/focus feedback
&::before {
opacity: $opacity_normal;
}
&:hover,
&:focus {
&::before {
opacity: $opacity_full;
}
}

&.icon-confirm {
@include iconfont('confirm');
}

&.icon-close {
@include iconfont('close');
}
}
.icon-close {
margin: 0;
border: none;
background-color: transparent;
}
}
}

/* Makes the icon of the collapsible element disappear
* When hovering on the root element */
.app-navigation-entry--collapsible {
Expand Down
Loading