variables work + i18n cleanup

This commit is contained in:
Henry Jameson 2024-10-09 09:59:37 +03:00
parent 54c740c252
commit 5a2080570f
4 changed files with 73 additions and 20 deletions

View file

@ -20,7 +20,7 @@ import {
getCssRules, getCssRules,
getScopedVersion getScopedVersion
} from 'src/services/theme_data/css_utils.js' } from 'src/services/theme_data/css_utils.js'
import { serialize } from 'src/services/theme_data/iss_serializer.js' import { serializeShadow, serialize } from 'src/services/theme_data/iss_serializer.js'
import { parseShadow /* , deserialize */ } from 'src/services/theme_data/iss_deserializer.js' import { parseShadow /* , deserialize */ } from 'src/services/theme_data/iss_deserializer.js'
import { import {
// rgb2hex, // rgb2hex,
@ -537,7 +537,33 @@ export default {
}) })
const virtualDirectives = reactive(allCustomVirtualDirectives) const virtualDirectives = reactive(allCustomVirtualDirectives)
const selectedVirtualDirectiveId = ref(0) const selectedVirtualDirectiveId = ref(0)
const selectedVirtualDirective = computed(() => virtualDirectives[selectedVirtualDirectiveId.value]) const selectedVirtualDirective = computed({
get () {
return virtualDirectives[selectedVirtualDirectiveId.value]
},
set (value) {
console.log('SET', value)
virtualDirectives[selectedVirtualDirectiveId.value].value = value
}
})
const selectedVirtualDirectiveValType = computed({
get () {
return virtualDirectives[selectedVirtualDirectiveId.value].valType
},
set (value) {
virtualDirectives[selectedVirtualDirectiveId.value].valType = value
switch (value) {
case 'shadow':
virtualDirectives[selectedVirtualDirectiveId.value].value = '0 0 0 #000000'
break
case 'color':
virtualDirectives[selectedVirtualDirectiveId.value].value = '#000000'
break
default:
virtualDirectives[selectedVirtualDirectiveId.value].value = 'none'
}
}
})
const selectedVirtualDirectiveParsed = computed({ const selectedVirtualDirectiveParsed = computed({
get () { get () {
switch (selectedVirtualDirective.value.valType) { switch (selectedVirtualDirective.value.valType) {
@ -550,8 +576,21 @@ export default {
return normalizeShadows(splitShadow) return normalizeShadows(splitShadow)
} }
} }
case 'color':
console.log('COLOR', selectedVirtualDirective.value.value)
return selectedVirtualDirective.value.value
default: default:
return null return selectedVirtualDirective.value.value
}
},
set (value) {
switch (selectedVirtualDirective.value.valType) {
case 'shadow': {
virtualDirectives[selectedVirtualDirectiveId.value].value = value.map(x => serializeShadow(x)).join(', ')
break
}
default:
virtualDirectives[selectedVirtualDirectiveId.value].value = value
} }
} }
}) })
@ -684,6 +723,7 @@ export default {
selectedVirtualDirective, selectedVirtualDirective,
selectedVirtualDirectiveId, selectedVirtualDirectiveId,
selectedVirtualDirectiveParsed, selectedVirtualDirectiveParsed,
selectedVirtualDirectiveValType,
getNewDirective, getNewDirective,
// ## Export and Import // ## Export and Import

View file

@ -321,7 +321,7 @@
class="list-select-label" class="list-select-label"
for="variables-selector" for="variables-selector"
> >
{{ $t('settings.style.themes3.variables.label') }} {{ $t('settings.style.themes3.editor.variables.label') }}
{{ ' ' }} {{ ' ' }}
</label> </label>
<Select <Select
@ -351,7 +351,7 @@
class="variable-name-label" class="variable-name-label"
for="variables-selector" for="variables-selector"
> >
{{ $t('settings.style.themes3.variables.name_label') }} {{ $t('settings.style.themes3.editor.variables.name_label') }}
{{ ' ' }} {{ ' ' }}
</label> </label>
<input <input
@ -362,25 +362,34 @@
class="variable-type-label" class="variable-type-label"
for="variables-selector" for="variables-selector"
> >
{{ $t('settings.style.themes3.variables.type_label') }} {{ $t('settings.style.themes3.editor.variables.type_label') }}
{{ ' ' }} {{ ' ' }}
</label> </label>
<Select <Select
v-model="selectedVirtualDirective.valType" v-model="selectedVirtualDirectiveValType"
> >
<option value='shadow'> <option value='shadow'>
{{ $t('settings.style.themes3.variables.type_label') }} {{ $t('settings.style.themes3.editor.variables.type_shadow') }}
shadow</option> </option>
<option value='shadow'>color</option> <option value='color'>
<option value='shadow'>generic</option> {{ $t('settings.style.themes3.editor.variables.type_color') }}
</option>
<option value='generic'>
{{ $t('settings.style.themes3.editor.variables.type_generic') }}
</option>
</Select> </Select>
</div> </div>
<ShadowControl <ShadowControl
v-if="selectedVirtualDirective.valType === 'shadow'" v-if="selectedVirtualDirectiveValType === 'shadow'"
v-model="selectedVirtualDirectiveParsed" v-model="selectedVirtualDirectiveParsed"
:compact="true" :compact="true"
/> />
</div> <ColorInput
v-if="selectedVirtualDirectiveValType === 'color'"
v-model="selectedVirtualDirectiveParsed"
:label="$t('settings.style.themes3.editor.variables.virtual_color')"
/>
</div>
</div> </div>
</tab-switcher> </tab-switcher>
</div> </div>

View file

@ -774,11 +774,6 @@
"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",
"name_label": "Name:",
"type_label": "Type:"
},
"editor": { "editor": {
"title": "Style", "title": "Style",
"new_style": "New", "new_style": "New",
@ -809,7 +804,16 @@
}, },
"component_tab": "Components style", "component_tab": "Components style",
"palette_tab": "Color presets", "palette_tab": "Color presets",
"variables_tab": "Variables (Advanced)" "variables_tab": "Variables (Advanced)",
"variables": {
"label": "Variables",
"name_label": "Name:",
"type_label": "Type:",
"type_shadow": "Shadow",
"type_color": "Color",
"type_generic": "Generic",
"virtual_color": "Variable color value"
},
}, },
"hacks": { "hacks": {
"underlay_overrides": "Change underlay", "underlay_overrides": "Change underlay",

View file

@ -1,6 +1,6 @@
import { unroll } from './iss_utils.js' import { unroll } from './iss_utils.js'
const serializeShadow = s => { export const serializeShadow = s => {
if (typeof s === 'object') { if (typeof s === 'object') {
return `${s.inset ? 'inset ' : ''}${s.x} ${s.y} ${s.blur} ${s.spread} ${s.color} / ${s.alpha}` return `${s.inset ? 'inset ' : ''}${s.x} ${s.y} ${s.blur} ${s.spread} ${s.color} / ${s.alpha}`
} else { } else {