Skip to content

Commit

Permalink
feat: split menu entries into mobileEntries.js
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <luka@nextcloud.com>
  • Loading branch information
luka-nextcloud committed Jun 29, 2022
1 parent 7946260 commit 54e08f4
Show file tree
Hide file tree
Showing 2 changed files with 391 additions and 4 deletions.
42 changes: 38 additions & 4 deletions src/components/Menu/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,26 @@
<HelpModal v-if="displayHelp" @close="hideHelp" />

<div v-if="$isRichEditor" ref="menubar" class="text-menubar__entries">
<ActionEntry v-for="actionEntry of visibleEntries"
v-bind="{ actionEntry }"
:key="`text-action--${actionEntry.key}`"
@call:help="showHelp" />
<template v-if="!isMobile">
<ActionEntry v-for="actionEntry of visibleEntries"
v-bind="{ actionEntry }"
:key="`text-action--${actionEntry.key}`"
@call:help="showHelp" />
</template>
<template v-else>
<div class="top">
<ActionEntry v-for="actionEntry of topEntries"
v-bind="{ actionEntry }"
:key="`text-action--${actionEntry.key}`"
@call:help="showHelp" />
</div>
<div class="bottom">
<ActionEntry v-for="actionEntry of bottomEntries"
v-bind="{ actionEntry }"
:key="`text-action--${actionEntry.key}`"
@call:help="showHelp" />
</div>
</template>
</div>
<div class="text-menubar__slot">
<slot />
Expand All @@ -50,13 +66,15 @@ import debounce from 'debounce'

import HelpModal from '../HelpModal.vue'
import actionsFullEntries from './entries.js'
import mobileEntries from './mobileEntries.js'
import ActionEntry from './ActionEntry.js'
import { DotsHorizontal } from '../icons.js'
import {
useEditorMixin,
useIsRichEditorMixin,
useIsRichWorkspaceMixin,
} from '../EditorWrapper.provider.js'
import isMobile from '../../mixins/isMobile.js'

export default {
name: 'MenuBar',
Expand All @@ -65,6 +83,7 @@ export default {
useEditorMixin,
useIsRichEditorMixin,
useIsRichWorkspaceMixin,
isMobile,
],
props: {
autohide: {
Expand Down Expand Up @@ -128,6 +147,12 @@ export default {
return priority !== undefined && priority > this.iconsLimit
})
},
topEntries() {
return [...mobileEntries].filter(({ position }) => position === 'top')
},
bottomEntries() {
return [...mobileEntries].filter(({ position }) => position === 'bottom')
},
remainAction() {
return {
key: 'remain',
Expand Down Expand Up @@ -261,8 +286,17 @@ export default {
@media (max-width: 660px) {
.text-menubar__entries {
margin-left: 0;
}

.top {
display: flex;
}

.bottom {
display: flex;
position: fixed;
top: calc(100vh - 100px);
left: 0;
}
}
}
Expand Down
Loading

0 comments on commit 54e08f4

Please sign in to comment.