palette editor done

This commit is contained in:
Henry Jameson 2024-09-29 21:14:31 +03:00
parent d5571216fe
commit d2cce99086
5 changed files with 160 additions and 20 deletions

View file

@ -15,7 +15,7 @@
:model-value="present" :model-value="present"
:disabled="disabled" :disabled="disabled"
class="opt" class="opt"
@update:modelValue="update(typeof modelValue === 'undefined' ? fallback : undefined)" @update:modelValue="updateValue(typeof modelValue === 'undefined' ? fallback : undefined)"
/> />
<div <div
class="input color-input-field" class="input color-input-field"

View file

@ -56,21 +56,45 @@ export default {
const license = ref('') const license = ref('')
const website = ref('') const website = ref('')
// ### Initialization stuff // ### Palette stuff
const palette = { const palettes = reactive({
// These are here just to establish order, light: {
// themes should override those bg: '#f2f6f9',
bg: '#121a24', fg: '#d6dfed',
fg: '#182230', text: '#304055',
text: '#b9b9ba', underlay: '#5d6086',
link: '#d8a070', accent: '#f55b1b',
accent: '#d8a070', cBlue: '#0095ff',
cRed: '#FF0000', cRed: '#d31014',
cBlue: '#0095ff', cGreen: '#0fa00f',
cGreen: '#0fa00f', cOrange: '#ffa500',
cOrange: '#ffa500' border: '#d8e6f9'
} },
dark: {
bg: '#121a24',
fg: '#182230',
text: '#b9b9ba',
link: '#d8a070',
accent: '#d8a070',
cRed: '#FF0000',
cBlue: '#0095ff',
cGreen: '#0fa00f',
cOrange: '#ffa500'
}
})
const editedPalette = ref('dark')
const palette = computed({
get () {
return palettes[editedPalette.value]
},
set (newPalette) {
console.log(newPalette)
palettes[editedPalette.value] = newPalette
}
})
// ### I18n stuff
// The paths in i18n are getting ridicously long, this effectively shortens them // The paths in i18n are getting ridicously long, this effectively shortens them
const getI18nPath = (componentName) => `settings.style.themes3.editor.components.${componentName}` const getI18nPath = (componentName) => `settings.style.themes3.editor.components.${componentName}`
const getFriendlyNamePath = (componentName) => getI18nPath(componentName) + '.friendlyName' const getFriendlyNamePath = (componentName) => getI18nPath(componentName) + '.friendlyName'
@ -85,6 +109,7 @@ export default {
: `${getI18nPath(componentName)}.states.${state}` : `${getI18nPath(componentName)}.states.${state}`
} }
// ### Initialization stuff
// Getting existing components // Getting existing components
const componentsContext = require.context('src', true, /\.style.js(on)?$/) const componentsContext = require.context('src', true, /\.style.js(on)?$/)
const componentKeysAll = componentsContext.keys() const componentKeysAll = componentsContext.keys()
@ -356,7 +381,7 @@ export default {
previewRules.push(...init({ previewRules.push(...init({
inputRuleset: editorFriendlyToOriginal.value, inputRuleset: editorFriendlyToOriginal.value,
initialStaticVars: { initialStaticVars: {
...palette ...palette.value
}, },
ultimateBackgroundColor: '#000000', ultimateBackgroundColor: '#000000',
rootComponentName: selectedComponentName.value, rootComponentName: selectedComponentName.value,
@ -377,6 +402,16 @@ export default {
updatePreview updatePreview
) )
watch(
palettes,
updatePreview
)
watch(
editedPalette,
updatePreview
)
watch( watch(
selectedComponentName, selectedComponentName,
updateSelectedComponent updateSelectedComponent
@ -417,6 +452,8 @@ export default {
author, author,
license, license,
website, website,
palette,
editedPalette,
componentKeys, componentKeys,
componentsMap, componentsMap,
selectedComponent, selectedComponent,

View file

@ -9,16 +9,13 @@
margin-right: 0.5em; margin-right: 0.5em;
flex: 1 1 0; flex: 1 1 0;
line-height: 2; line-height: 2;
min-height: 2em;
} }
&.suboption { &.suboption {
margin-left: 1em; margin-left: 1em;
} }
.opt {
margin: 0.5em;
}
.color-input { .color-input {
flex: 0 0 0; flex: 0 0 0;
} }
@ -90,6 +87,21 @@
} }
} }
.palette-editor {
> label:not(.Select) {
font-weight: bold;
justify-self: right;
}
.colors {
display: grid;
justify-content: space-around;
grid-template-columns: repeat(4, min-content);
grid-template-rows: repeat(auto-fit, min-content);
grid-gap: 0.5em;
}
}
.component-editor { .component-editor {
display: grid; display: grid;
grid-template-columns: 6fr 3fr 4fr; grid-template-columns: 6fr 3fr 4fr;

View file

@ -51,6 +51,80 @@
</li> </li>
</ul> </ul>
</div> </div>
<div class="setting-item palette-editor">
<div class="label">
<label for="palette-selector">
{{ $t('settings.style.themes3.editor.palette.label') }}
{{ ' ' }}
</label>
<Select
v-model="editedPalette"
id="palette-selector"
>
<option key="dark" value="dark">
{{ $t('settings.style.themes3.editor.palette.dark') }}
</option>
<option key="light" value="light">
{{ $t('settings.style.themes3.editor.palette.light') }}
</option>
</Select>
</div>
<div class="colors">
<ColorInput
v-model="palette.bg"
:label="$t('settings.style.themes3.editor.palette.bg')"
/>
<ColorInput
v-model="palette.fg"
:label="$t('settings.style.themes3.editor.palette.fg')"
/>
<ColorInput
v-model="palette.text"
:label="$t('settings.style.themes3.editor.palette.text')"
/>
<ColorInput
v-model="palette.link"
:label="$t('settings.style.themes3.editor.palette.link')"
:fallback="palette.accent"
/>
<ColorInput
v-model="palette.accent"
:label="$t('settings.style.themes3.editor.palette.accent')"
:fallback="palette.link"
/>
<ColorInput
v-model="palette.cRed"
:label="$t('settings.style.themes3.editor.palette.cRed')"
/>
<ColorInput
v-model="palette.cBlue"
:label="$t('settings.style.themes3.editor.palette.cBlue')"
/>
<ColorInput
v-model="palette.cGreen"
:label="$t('settings.style.themes3.editor.palette.cGreen')"
/>
<ColorInput
v-model="palette.cOrange"
:label="$t('settings.style.themes3.editor.palette.cOrange')"
/>
<ColorInput
v-model="palette.extra1"
fallback="#000000"
:label="$t('settings.style.themes3.editor.palette.extra1')"
/>
<ColorInput
v-model="palette.extra2"
fallback="#000000"
:label="$t('settings.style.themes3.editor.palette.extra2')"
/>
<ColorInput
v-model="palette.extra3"
fallback="#000000"
:label="$t('settings.style.themes3.editor.palette.extra3')"
/>
</div>
</div>
<div class="setting-item component-editor"> <div class="setting-item component-editor">
<div class="component-selector"> <div class="component-selector">
<label for="component-selector"> <label for="component-selector">

View file

@ -778,6 +778,23 @@
"preserve": "Keep color", "preserve": "Keep color",
"no-auto": "Disabled" "no-auto": "Disabled"
}, },
"palette": {
"label": "Edited palette",
"dark": "Dark mode",
"light": "Light mode",
"bg": "Panel background",
"fg": "Buttons etc.",
"text": "Text",
"link": "Links",
"accent": "Accent color",
"cRed": "Red color",
"cBlue": "Blue color",
"cGreen": "Green color",
"cOrange": "Orange color",
"extra1": "Extra 1",
"extra2": "Extra 2",
"extra3": "Extra 3"
},
"components": { "components": {
"normal": { "normal": {
"state": "Normal", "state": "Normal",