Skip to content

Commit

Permalink
feat(pdf): configuration base
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Sep 28, 2021
1 parent 2d1902c commit d6c0c32
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 11 deletions.
37 changes: 32 additions & 5 deletions src/components/editor/aside/pdf/PDFConfiguration.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<template>
<div class="flex flex-col justify-start items-start">
<HeroIcon class="absolute right-0 wb-icon" @click.prevent="onClose">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
clip-rule="evenodd"
/>
</svg>
</HeroIcon>
<PDFConfigurationSlot>
<template #title>
<h2 class="text-2xl font-bold font-poppins">Paragraph</h2>
Expand All @@ -13,11 +27,12 @@
justify-between
p-2
border
rounded-xl
rounded-lg
border-gray-300
dark:border-gray-800
bg-gray-300
dark:hover:bg-gray-800
dark:bg-gray-800
shadow-lg
w-32
"
>
Expand All @@ -32,13 +47,18 @@
</div>
</div>
</PDFConfigurationSlot>
<button @click.prevent="onSetConfiguration">test</button>
<button
class="wb-text mt-5 ml-5 px-4 py-2 bg-gray-600 dark:bg-gray-600"
@click.prevent="onSetConfiguration"
>
{{ t('editor.pdf.custom.save') }}
</button>
</div>
</template>

<script setup lang="ts">
import { useDefines } from '@/use/defines'
import { reactive } from 'vue'
import { reactive, nextTick } from 'vue'
import { useI18n } from 'vue-i18n'
import { useStore } from 'vuex'
Expand All @@ -61,9 +81,16 @@
decorationColor: '' as string,
})
const onSetConfiguration = () => {
const onSetConfiguration = async () => {
store.commit('pdf/setStyles', {
paragraph,
})
await nextTick
store.commit('absolute/switchPdfConfiguration', false)
}
const onClose = () => {
store.commit('absolute/switchPdfConfiguration', false)
}
</script>
8 changes: 3 additions & 5 deletions src/components/material/TextSelect.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<Listbox v-model="cmp" class="w-auto">
<div class="relative mt-1">
<div class="relative">
<ListboxButton
class="
relative
Expand All @@ -11,9 +11,8 @@
text-left
bg-gray-200
dark:bg-gray-600
rounded-lg
shadow-md
cursor-default
cursor-pointer
focus:outline-none
focus-visible:ring-2
focus-visible:ring-opacity-75
Expand Down Expand Up @@ -83,8 +82,7 @@
>
<li
:class="[
active ? 'text-amber-900 bg-amber-100' : 'text-gray-900',
'cursor-default select-none relative py-2 pl-10 pr-4',
'cursor-pointer hover:bg-gray-500 dark:hover:bg-gray-800 select-none relative py-2 pl-10 pr-4',
]"
>
<span
Expand Down
1 change: 1 addition & 0 deletions src/lang/br/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
paragraph: {
font: 'Font',
},
save: 'Salvar',
},
},
aside: {
Expand Down
1 change: 1 addition & 0 deletions src/lang/en/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
paragraph: {
font: 'Font',
},
save: 'Save',
},
},
aside: {
Expand Down
5 changes: 4 additions & 1 deletion src/store/module/absolute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
},
logger: false,
pdf: {
configuration: true,
configuration: false,
},
} as AbsoluteState),
mutations: {
Expand All @@ -37,6 +37,9 @@ export default {
switchLogger(state: any, b: boolean) {
state.logger = b
},
switchPdfConfiguration(state: any, b: boolean) {
state.pdf.configuration = b
},
},
actions: {},
getters: {},
Expand Down
1 change: 1 addition & 0 deletions src/store/module/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
generatePDF: useDefines().shortcuts('generatePDF'),
switcherRawText: useDefines().shortcuts('switcherRawText'),
logger: useDefines().shortcuts('logger'),
configurationPDF: useDefines().shortcuts('configurationPDF'),
} as ShortcutsState),
mutations: {},
actions: {},
Expand Down
1 change: 1 addition & 0 deletions src/use/defines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const useDefines: Callback<any> = () => {
newProject: ['CTRL + Shift + Q', 'ctrl > shift > q'],
newChapter: ['CTRL + Q', 'ctrl > q'],
deleteChapter: ['CTRL + D', 'ctrl > d'],
configurationPDF: ['CTRL + Shift + G', 'ctrl > shift > g'],
generatePDF: ['CTRL + G', 'ctrl > g'],
switcherRawText: ['CTRL + H', 'ctrl > h'],
logger: ['CTRL + L', 'ctrl > l'],
Expand Down
12 changes: 12 additions & 0 deletions src/use/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const useKeyboard: Callback<any> = () => {
generatePDF()
switcherRawText()
logger()
configurationPDF()
}

const destroy = () => {
Expand Down Expand Up @@ -95,5 +96,16 @@ export const useKeyboard: Callback<any> = () => {
})
}

const configurationPDF = () => {
keyboard.bind(store.state.shortcuts.configurationPDF[1], (e: Event) => {
useUtils().prevent(e)

store.commit(
'absolute/switchPdfConfiguration',
!store.state.absolute.pdf.configuration
)
})
}

return { init, destroy }
}

0 comments on commit d6c0c32

Please sign in to comment.