adds extended menu
This commit is contained in:
parent
e7b5cdcbde
commit
e259186d4c
2 changed files with 48 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="menu-bar" :class="{ active }">
|
<menu class="menu-bar" :class="{ active }">
|
||||||
<button class="editor-button-bold" :class="{ active: value.bold }" @click="menuAction('bold')" />
|
<button class="editor-button-bold" :class="{ active: value.bold }" @click="menuAction('bold')" />
|
||||||
<button class="editor-button-italic" :class="{ active: value.italic }" @click="menuAction('italic')" />
|
<button class="editor-button-italic" :class="{ active: value.italic }" @click="menuAction('italic')" />
|
||||||
|
|
||||||
|
@ -9,21 +9,27 @@
|
||||||
|
|
||||||
<button class="editor-button-bullet-list" :class="{ active: value.bulletList }" @click="menuAction('bulletList')" />
|
<button class="editor-button-bullet-list" :class="{ active: value.bulletList }" @click="menuAction('bulletList')" />
|
||||||
<button class="editor-button-horizontal-rule" :class="{ active: value.separator}" @click="menuAction('separator')" />
|
<button class="editor-button-horizontal-rule" :class="{ active: value.separator}" @click="menuAction('separator')" />
|
||||||
<button class="editor-button-horizontal-rule" :class="{ active: value.spacer}" @click="menuAction('spacer')" />
|
|
||||||
|
|
||||||
<button class="editor-button-stat-block" :class="{ active: value.statBlock }" @click="menuAction('statBlock')" />
|
<button class="editor-button-dropdown" :class="{ active: dropdownOpen }" @click="toggleDropdown" />
|
||||||
|
|
||||||
|
<div class="extended-menu" v-show="dropdownOpen">
|
||||||
|
<button class="extended-menu-button" @click="extMenuAction('statBlock')">Stat Block (DnD5e)</button>
|
||||||
|
<button class="extended-menu-button" @click="extMenuAction('boxes')">Empty Boxes</button>
|
||||||
</div>
|
</div>
|
||||||
|
</menu>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Prop, Vue } from 'vue-property-decorator'
|
import { Component, Prop, Vue } from 'vue-property-decorator'
|
||||||
import { blocks, State } from '@/editor'
|
import { blocks, marks, State } from '@/editor'
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default class DeckCardEditorMenu extends Vue {
|
export default class DeckCardEditorMenu extends Vue {
|
||||||
@Prop() public readonly active!: boolean
|
@Prop() public readonly active!: boolean
|
||||||
@Prop() public readonly value!: State
|
@Prop() public readonly value!: State
|
||||||
|
|
||||||
|
private dropdownOpen = false
|
||||||
|
|
||||||
private menuAction (name: string) {
|
private menuAction (name: string) {
|
||||||
const newState = { ...this.value }
|
const newState = { ...this.value }
|
||||||
|
|
||||||
|
@ -32,13 +38,23 @@ export default class DeckCardEditorMenu extends Vue {
|
||||||
newState[block] = false
|
newState[block] = false
|
||||||
})
|
})
|
||||||
newState[name] = true
|
newState[name] = true
|
||||||
} else { // marks behave like checkboxes
|
} else if (marks.indexOf(name)) { // marks behave like checkboxes
|
||||||
newState[name] = !newState[name]
|
newState[name] = !newState[name]
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$emit('input', newState)
|
this.$emit('input', newState)
|
||||||
this.$emit('action', name)
|
this.$emit('action', name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private toggleDropdown () {
|
||||||
|
this.dropdownOpen = !this.dropdownOpen
|
||||||
|
this.$emit('action', 'refocus')
|
||||||
|
}
|
||||||
|
|
||||||
|
private extMenuAction (name: string) {
|
||||||
|
this.menuAction(name)
|
||||||
|
this.dropdownOpen = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -92,4 +108,29 @@ export default class DeckCardEditorMenu extends Vue {
|
||||||
.editor-button-horizontal-rule:after { content: '—'; }
|
.editor-button-horizontal-rule:after { content: '—'; }
|
||||||
|
|
||||||
.editor-button-stat-block:after { content: 'ST'; }
|
.editor-button-stat-block:after { content: 'ST'; }
|
||||||
|
|
||||||
|
.menu-bar > button.editor-button-dropdown {
|
||||||
|
width: 3.6rem;
|
||||||
|
}
|
||||||
|
.menu-bar > button.editor-button-dropdown:after {
|
||||||
|
content: ' more ';
|
||||||
|
width: 90%;
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.extended-menu {
|
||||||
|
width: 100%;
|
||||||
|
height: 4rem;
|
||||||
|
padding-top: .5rem;
|
||||||
|
background: var(--highlight-color);
|
||||||
|
}
|
||||||
|
.extended-menu-button {
|
||||||
|
width: 97%;
|
||||||
|
height: 1.6rem;
|
||||||
|
margin: 0 .1rem;
|
||||||
|
background-color: #EEE;
|
||||||
|
color: black;
|
||||||
|
font-size: 1rem;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -83,7 +83,7 @@ export default class DeckCardEditor extends Vue {
|
||||||
content.focus()
|
content.focus()
|
||||||
|
|
||||||
const cmd = menuActionToCommand[action]
|
const cmd = menuActionToCommand[action]
|
||||||
cmd()
|
if (cmd) cmd()
|
||||||
|
|
||||||
this.$nextTick(() => this.syncMenuState())
|
this.$nextTick(() => this.syncMenuState())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue