variables stuff seem to be at least somewhat working

This commit is contained in:
Henry Jameson 2024-10-06 20:21:13 +03:00
parent 8725de3e91
commit 756ea63b67
6 changed files with 51 additions and 14 deletions

View file

@ -107,7 +107,7 @@ const updatePalette = (paletteKey, value) => {
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(3, 1fr) auto; grid-template-rows: repeat(3, 1fr) auto;
grid-gap: 0.5em; grid-gap: 0.5em;
align-items: space-between; align-items: baseline;
.palette-import-button { .palette-import-button {
grid-column: 1 / span 2; grid-column: 1 / span 2;

View file

@ -17,7 +17,7 @@ import ContrastRatio from 'src/components/contrast_ratio/contrast_ratio.vue'
import { init } from 'src/services/theme_data/theme_data_3.service.js' import { init } from 'src/services/theme_data/theme_data_3.service.js'
import { getCssRules } from 'src/services/theme_data/css_utils.js' import { getCssRules } from 'src/services/theme_data/css_utils.js'
import { serialize } from 'src/services/theme_data/iss_serializer.js' import { serialize } from 'src/services/theme_data/iss_serializer.js'
// import { deserialize } from 'src/services/theme_data/iss_deserializer.js' import { parseShadow /* , deserialize */ } from 'src/services/theme_data/iss_deserializer.js'
import { import {
// rgb2hex, // rgb2hex,
hex2rgb, hex2rgb,
@ -259,7 +259,7 @@ export default {
} }
}) })
const getEditedElement = (component, directive) => computed({ const getEditedElement = (component, directive, postProcess = x => x) => computed({
get () { get () {
let usedRule let usedRule
const fallback = editorFriendlyFallbackStructure.value const fallback = editorFriendlyFallbackStructure.value
@ -271,7 +271,11 @@ export default {
usedRule = get(fallback, path) usedRule = get(fallback, path)
} }
return usedRule if (directive === 'shadow') {
console.log('EDITED', usedRule)
console.log('PP', postProcess(usedRule))
}
return postProcess(usedRule)
}, },
set (value) { set (value) {
set(allEditedRules, getPath(component, directive), value) set(allEditedRules, getPath(component, directive), value)
@ -316,9 +320,22 @@ export default {
} }
} }
const normalizeShadows = (shadows) => {
console.log('NORMALIZE')
return shadows?.map(shadow => {
if (typeof shadow === 'object') {
return shadow
}
if (typeof shadow === 'string') {
return parseShadow(shadow)
}
return null
})
}
// Shadow is partially edited outside the ShadowControl // Shadow is partially edited outside the ShadowControl
// for better space utilization // for better space utilization
const editedShadow = getEditedElement(null, 'shadow') const editedShadow = getEditedElement(null, 'shadow', normalizeShadows)
const editedSubShadowId = ref(null) const editedSubShadowId = ref(null)
const editedSubShadow = computed(() => { const editedSubShadow = computed(() => {
if (editedShadow.value == null || editedSubShadowId.value == null) return null if (editedShadow.value == null || editedSubShadowId.value == null) return null
@ -511,8 +528,15 @@ export default {
const selectedVirtualDirectiveParsed = computed({ const selectedVirtualDirectiveParsed = computed({
get () { get () {
switch (selectedVirtualDirective.value.valType) { switch (selectedVirtualDirective.value.valType) {
case 'shadow': case 'shadow': {
return {} const directiveValue = selectedVirtualDirective.value.value
if (Array.isArray(directiveValue)) {
return normalizeShadows(directiveValue)
} else {
const splitShadow = directiveValue.split(/,/g).map(x => x.trim())
return normalizeShadows(splitShadow)
}
}
default: default:
return null return null
} }

View file

@ -93,7 +93,7 @@
"label editor" "label editor"
"selector editor" "selector editor"
"movement editor"; "movement editor";
grid-template-columns: auto 1fr; grid-template-columns: 10em 1fr;
grid-template-rows: auto 1fr auto; grid-template-rows: auto 1fr auto;
grid-gap: 0.5em; grid-gap: 0.5em;

View file

@ -245,6 +245,7 @@
> >
{{ $t('settings.style.themes3.editor.include_in_rule') }} {{ $t('settings.style.themes3.editor.include_in_rule') }}
</checkbox> </checkbox>
{{ editedShadow }}
<ShadowControl <ShadowControl
v-model="editedShadow" v-model="editedShadow"
:disabled="!isShadowPresent" :disabled="!isShadowPresent"
@ -327,11 +328,15 @@
@update:selectedId="e => selectedVirtualDirectiveId = e" @update:selectedId="e => selectedVirtualDirectiveId = e"
/> />
<div class="list-edit-area"> <div class="list-edit-area">
<Select>
<option value='shadow'>shadow</option>
<option value='shadow'>color</option>
<option value='shadow'>generic</option>
</Select>
<ShadowControl <ShadowControl
v-if="selectedVirtualDirective.valType === 'shadow'" v-if="selectedVirtualDirective.valType === 'shadow'"
v-model="selectedVirtualDirective.value" v-model="selectedVirtualDirectiveParsed"
/> />
{{ selectedVirtualDirective.valType }}
</div> </div>
</div> </div>
</tab-switcher> </tab-switcher>

View file

@ -45,6 +45,7 @@ export default {
], ],
emits: ['update:modelValue', 'subShadowSelected'], emits: ['update:modelValue', 'subShadowSelected'],
data () { data () {
console.log('MODEL VALUE', this.modelValue, this.fallback)
return { return {
selectedId: 0, selectedId: 0,
// TODO there are some bugs regarding display of array (it's not getting updated when deleting for some reason) // TODO there are some bugs regarding display of array (it's not getting updated when deleting for some reason)
@ -60,6 +61,9 @@ export default {
Popover, Popover,
ComponentPreview ComponentPreview
}, },
beforeUpdate () {
this.cValue = (this.modelValue ?? this.fallback ?? []).map(toModel)
},
computed: { computed: {
selectedType: { selectedType: {
get () { get () {

View file

@ -774,6 +774,9 @@
"extra3": "Extra 3", "extra3": "Extra 3",
"v2_unsupported": "Older v2 themes don't support palettes. Switch to v3 theme to make use of palettes" "v2_unsupported": "Older v2 themes don't support palettes. Switch to v3 theme to make use of palettes"
}, },
"variables": {
"label": "Variables"
},
"editor": { "editor": {
"title": "Style", "title": "Style",
"new_style": "New", "new_style": "New",
@ -800,7 +803,8 @@
"no-auto": "Disabled" "no-auto": "Disabled"
}, },
"component_tab": "Components style", "component_tab": "Components style",
"palette_tab": "Color presets" "palette_tab": "Color presets",
"variables_tab": "Variables (Advanced)"
}, },
"hacks": { "hacks": {
"underlay_overrides": "Change underlay", "underlay_overrides": "Change underlay",