fix SelectMotion not working properly on palettes/vDirectives
This commit is contained in:
parent
0afe69ce28
commit
eeb2dbcb60
|
@ -121,9 +121,22 @@ export default {
|
||||||
border: '#d8e6f9'
|
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 selectedPaletteId = ref(0)
|
||||||
const selectedPalette = computed({
|
const selectedPalette = computed({
|
||||||
get () {
|
get () {
|
||||||
|
console.log(palettes, toValue(palettes))
|
||||||
return palettes[selectedPaletteId.value]
|
return palettes[selectedPaletteId.value]
|
||||||
},
|
},
|
||||||
set (newPalette) {
|
set (newPalette) {
|
||||||
|
@ -542,6 +555,12 @@ export default {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const virtualDirectives = reactive(allCustomVirtualDirectives)
|
const virtualDirectives = reactive(allCustomVirtualDirectives)
|
||||||
|
|
||||||
|
const onVirtualDirectivesUpdate = (e) => {
|
||||||
|
virtualDirectives.splice(0, virtualDirectives.length)
|
||||||
|
virtualDirectives.push(...e)
|
||||||
|
}
|
||||||
|
|
||||||
const selectedVirtualDirectiveId = ref(0)
|
const selectedVirtualDirectiveId = ref(0)
|
||||||
const selectedVirtualDirective = computed({
|
const selectedVirtualDirective = computed({
|
||||||
get () {
|
get () {
|
||||||
|
@ -601,7 +620,7 @@ export default {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const getNewDirective = () => ({
|
const getNewVirtualDirective = () => ({
|
||||||
name: 'newDirective',
|
name: 'newDirective',
|
||||||
valType: 'generic',
|
valType: 'generic',
|
||||||
value: 'foobar'
|
value: 'foobar'
|
||||||
|
@ -656,13 +675,15 @@ export default {
|
||||||
const editorComponents = parsed.filter(x => x.component.startsWith('@'))
|
const editorComponents = parsed.filter(x => x.component.startsWith('@'))
|
||||||
const rules = parsed.filter(x => !x.component.startsWith('@'))
|
const rules = parsed.filter(x => !x.component.startsWith('@'))
|
||||||
const metaIn = editorComponents.find(x => x.component === '@meta').directives
|
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
|
name.value = metaIn.name
|
||||||
license.value = metaIn.license
|
license.value = metaIn.license
|
||||||
author.value = metaIn.author
|
author.value = metaIn.author
|
||||||
website.value = metaIn.website
|
website.value = metaIn.website
|
||||||
|
|
||||||
|
console.log('PALETTES', palettesIn)
|
||||||
|
|
||||||
Object.keys(allEditedRules).forEach((k) => delete allEditedRules[k])
|
Object.keys(allEditedRules).forEach((k) => delete allEditedRules[k])
|
||||||
|
|
||||||
rules.forEach(rule => {
|
rules.forEach(rule => {
|
||||||
|
@ -699,6 +720,7 @@ export default {
|
||||||
|
|
||||||
// ## Palette
|
// ## Palette
|
||||||
palettes,
|
palettes,
|
||||||
|
onPalettesUpdate,
|
||||||
selectedPalette,
|
selectedPalette,
|
||||||
selectedPaletteId,
|
selectedPaletteId,
|
||||||
getNewPalette,
|
getNewPalette,
|
||||||
|
@ -757,11 +779,12 @@ export default {
|
||||||
|
|
||||||
// ## Variables
|
// ## Variables
|
||||||
virtualDirectives,
|
virtualDirectives,
|
||||||
|
onVirtualDirectivesUpdate,
|
||||||
selectedVirtualDirective,
|
selectedVirtualDirective,
|
||||||
selectedVirtualDirectiveId,
|
selectedVirtualDirectiveId,
|
||||||
selectedVirtualDirectiveParsed,
|
selectedVirtualDirectiveParsed,
|
||||||
selectedVirtualDirectiveValType,
|
selectedVirtualDirectiveValType,
|
||||||
getNewDirective,
|
getNewVirtualDirective,
|
||||||
|
|
||||||
// ## Export and Import
|
// ## Export and Import
|
||||||
exportStyle,
|
exportStyle,
|
||||||
|
|
|
@ -159,7 +159,14 @@
|
||||||
width: min-content;
|
width: min-content;
|
||||||
|
|
||||||
.list-edit-area {
|
.list-edit-area {
|
||||||
|
display: grid;
|
||||||
align-self: baseline;
|
align-self: baseline;
|
||||||
|
grid-template-rows: subgrid;
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.palette-editor-single {
|
||||||
|
grid-row: 2 / span 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -302,16 +302,25 @@
|
||||||
</Select>
|
</Select>
|
||||||
<SelectMotion
|
<SelectMotion
|
||||||
class="list-select-movement"
|
class="list-select-movement"
|
||||||
v-model="palettes"
|
:modelValue="palettes"
|
||||||
:get-add-value="getNewPalette"
|
@update:modelValue="onPalettesUpdate"
|
||||||
:selected-id="selectedPaletteId"
|
:selected-id="selectedPaletteId"
|
||||||
|
:get-add-value="getNewPalette"
|
||||||
@update:selectedId="e => selectedPaletteId = e"
|
@update:selectedId="e => selectedPaletteId = e"
|
||||||
/>
|
/>
|
||||||
|
<div class="list-edit-area">
|
||||||
|
<StringSetting
|
||||||
|
class="palette-name-input"
|
||||||
|
v-model="selectedPalette.name"
|
||||||
|
>
|
||||||
|
{{ $t('settings.style.themes3.palette.name_label') }}
|
||||||
|
</StringSetting>
|
||||||
<PaletteEditor
|
<PaletteEditor
|
||||||
class="list-edit-area"
|
class="palette-editor-single"
|
||||||
v-model="selectedPalette"
|
v-model="selectedPalette"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
key="variables"
|
key="variables"
|
||||||
:label="$t('settings.style.themes3.editor.variables_tab')"
|
:label="$t('settings.style.themes3.editor.variables_tab')"
|
||||||
|
@ -328,7 +337,7 @@
|
||||||
id="variables-selector"
|
id="variables-selector"
|
||||||
v-model="selectedVirtualDirectiveId"
|
v-model="selectedVirtualDirectiveId"
|
||||||
class="list-select"
|
class="list-select"
|
||||||
size="9"
|
size="20"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
v-for="(p, index) in virtualDirectives"
|
v-for="(p, index) in virtualDirectives"
|
||||||
|
@ -340,7 +349,8 @@
|
||||||
</Select>
|
</Select>
|
||||||
<SelectMotion
|
<SelectMotion
|
||||||
class="list-select-movement"
|
class="list-select-movement"
|
||||||
v-model="virtualDirectives"
|
:modelValue="virtualDirectives"
|
||||||
|
@update:modelValue="onVirtualDirectivesUpdate"
|
||||||
:selected-id="selectedVirtualDirectiveId"
|
:selected-id="selectedVirtualDirectiveId"
|
||||||
:get-add-value="getNewVirtualDirective"
|
:get-add-value="getNewVirtualDirective"
|
||||||
@update:selectedId="e => selectedVirtualDirectiveId = e"
|
@update:selectedId="e => selectedVirtualDirectiveId = e"
|
||||||
|
|
|
@ -757,7 +757,8 @@
|
||||||
"themes3": {
|
"themes3": {
|
||||||
"define": "Override",
|
"define": "Override",
|
||||||
"palette": {
|
"palette": {
|
||||||
"label": "Palettes",
|
"label": "Color schemes",
|
||||||
|
"name_label": "Color scheme name",
|
||||||
"import": "Import",
|
"import": "Import",
|
||||||
"export": "Export",
|
"export": "Export",
|
||||||
"bg": "Panel background",
|
"bg": "Panel background",
|
||||||
|
@ -803,7 +804,7 @@
|
||||||
"no-auto": "Disabled"
|
"no-auto": "Disabled"
|
||||||
},
|
},
|
||||||
"component_tab": "Components style",
|
"component_tab": "Components style",
|
||||||
"palette_tab": "Color presets",
|
"palette_tab": "Color schemes",
|
||||||
"variables_tab": "Variables (Advanced)",
|
"variables_tab": "Variables (Advanced)",
|
||||||
"variables": {
|
"variables": {
|
||||||
"label": "Variables",
|
"label": "Variables",
|
||||||
|
|
Loading…
Reference in a new issue