From eeb2dbcb604e269257b42d0bfa6c759730d42478 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Fri, 11 Oct 2024 17:22:33 +0300 Subject: [PATCH] fix SelectMotion not working properly on palettes/vDirectives --- .../tabs/style_tab/style_tab.js | 29 +++++++++++++++++-- .../tabs/style_tab/style_tab.scss | 7 +++++ .../tabs/style_tab/style_tab.vue | 26 ++++++++++++----- src/i18n/en.json | 5 ++-- 4 files changed, 54 insertions(+), 13 deletions(-) diff --git a/src/components/settings_modal/tabs/style_tab/style_tab.js b/src/components/settings_modal/tabs/style_tab/style_tab.js index 394c2f0a..35b21418 100644 --- a/src/components/settings_modal/tabs/style_tab/style_tab.js +++ b/src/components/settings_modal/tabs/style_tab/style_tab.js @@ -121,9 +121,22 @@ export default { border: '#d8e6f9' } ]) + + // This is kinda dumb but you cannot "replace" reactive() object + // and so v-model simply fails when you try to chage (increase only?) + // length of the array. Since linter complains about mutating modelValue + // inside SelectMotion, the next best thing is to just wipe existing array + // and replace it with new one. + + const onPalettesUpdate = (e) => { + palettes.splice(0, palettes.length) + palettes.push(...e) + } + const selectedPaletteId = ref(0) const selectedPalette = computed({ get () { + console.log(palettes, toValue(palettes)) return palettes[selectedPaletteId.value] }, set (newPalette) { @@ -542,6 +555,12 @@ export default { } }) const virtualDirectives = reactive(allCustomVirtualDirectives) + + const onVirtualDirectivesUpdate = (e) => { + virtualDirectives.splice(0, virtualDirectives.length) + virtualDirectives.push(...e) + } + const selectedVirtualDirectiveId = ref(0) const selectedVirtualDirective = computed({ get () { @@ -601,7 +620,7 @@ export default { } }) - const getNewDirective = () => ({ + const getNewVirtualDirective = () => ({ name: 'newDirective', valType: 'generic', value: 'foobar' @@ -656,13 +675,15 @@ export default { const editorComponents = parsed.filter(x => x.component.startsWith('@')) const rules = parsed.filter(x => !x.component.startsWith('@')) const metaIn = editorComponents.find(x => x.component === '@meta').directives - const palettesIn = editorComponents.filter(x => x.component === '@palette').directives + const palettesIn = editorComponents.filter(x => x.component === '@palette') name.value = metaIn.name license.value = metaIn.license author.value = metaIn.author website.value = metaIn.website + console.log('PALETTES', palettesIn) + Object.keys(allEditedRules).forEach((k) => delete allEditedRules[k]) rules.forEach(rule => { @@ -699,6 +720,7 @@ export default { // ## Palette palettes, + onPalettesUpdate, selectedPalette, selectedPaletteId, getNewPalette, @@ -757,11 +779,12 @@ export default { // ## Variables virtualDirectives, + onVirtualDirectivesUpdate, selectedVirtualDirective, selectedVirtualDirectiveId, selectedVirtualDirectiveParsed, selectedVirtualDirectiveValType, - getNewDirective, + getNewVirtualDirective, // ## Export and Import exportStyle, diff --git a/src/components/settings_modal/tabs/style_tab/style_tab.scss b/src/components/settings_modal/tabs/style_tab/style_tab.scss index 33b00ec6..1f63e9c6 100644 --- a/src/components/settings_modal/tabs/style_tab/style_tab.scss +++ b/src/components/settings_modal/tabs/style_tab/style_tab.scss @@ -159,7 +159,14 @@ width: min-content; .list-edit-area { + display: grid; align-self: baseline; + grid-template-rows: subgrid; + grid-template-columns: 1fr; + } + + .palette-editor-single { + grid-row: 2 / span 2; } } diff --git a/src/components/settings_modal/tabs/style_tab/style_tab.vue b/src/components/settings_modal/tabs/style_tab/style_tab.vue index 971dd7e7..d6a752a4 100644 --- a/src/components/settings_modal/tabs/style_tab/style_tab.vue +++ b/src/components/settings_modal/tabs/style_tab/style_tab.vue @@ -302,15 +302,24 @@ - +
+ + {{ $t('settings.style.themes3.palette.name_label') }} + + +