palettes editor done

This commit is contained in:
Henry Jameson 2024-10-06 01:16:24 +03:00
parent 3f55c08693
commit bae4836349
5 changed files with 82 additions and 50 deletions

View file

@ -1,6 +1,5 @@
<template> <template>
<div class="PaletteEditor"> <div class="PaletteEditor">
<div class="colors">
<ColorInput <ColorInput
v-for="key in paletteKeys" v-for="key in paletteKeys"
:key="key" :key="key"
@ -9,24 +8,21 @@
:label="$t('settings.style.themes3.palette.' + key)" :label="$t('settings.style.themes3.palette.' + key)"
@update:modelValue="value => updatePalette(key, value)" @update:modelValue="value => updatePalette(key, value)"
/> />
</div>
<div class="controls">
<button <button
class="btn button-default" class="btn button-default palette-import-button"
@click="importPalette" @click="importPalette"
> >
<FAIcon icon="file-import" /> <FAIcon icon="file-import" />
{{ $t('settings.style.themes3.palette.import') }} {{ $t('settings.style.themes3.palette.import') }}
</button> </button>
<button <button
class="btn button-default" class="btn button-default palette-export-button"
@click="exportPalette" @click="exportPalette"
> >
<FAIcon icon="file-export" /> <FAIcon icon="file-export" />
{{ $t('settings.style.themes3.palette.export') }} {{ $t('settings.style.themes3.palette.export') }}
</button> </button>
</div> </div>
</div>
</template> </template>
<script setup> <script setup>
@ -106,18 +102,23 @@ const updatePalette = (paletteKey, value) => {
<style lang="scss"> <style lang="scss">
.PaletteEditor { .PaletteEditor {
.colors {
display: grid; display: grid;
justify-content: space-around; justify-content: space-around;
grid-template-columns: repeat(4, min-content); grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(auto-fit, min-content); grid-template-rows: repeat(3, 1fr) auto;
grid-gap: 0.5em; grid-gap: 0.5em;
align-items: space-between;
.palette-import-button {
grid-column: 1 / span 2;
} }
.controls { .palette-export-button {
display: grid; grid-column: 3 / span 2;
grid-template-columns: 1fr 1fr; }
grid-gap: 0.5em;
.color-input.style-control {
margin: 0;
} }
} }
</style> </style>

View file

@ -72,8 +72,9 @@ export default {
}) })
// ### Palette stuff // ### Palette stuff
const palettes = reactive({ const palettes = reactive([
light: { {
name: 'light',
bg: '#f2f6f9', bg: '#f2f6f9',
fg: '#d6dfed', fg: '#d6dfed',
text: '#304055', text: '#304055',
@ -85,7 +86,8 @@ export default {
cOrange: '#ffa500', cOrange: '#ffa500',
border: '#d8e6f9' border: '#d8e6f9'
}, },
dark: { {
name: 'dark',
bg: '#121a24', bg: '#121a24',
fg: '#182230', fg: '#182230',
text: '#b9b9ba', text: '#b9b9ba',
@ -96,10 +98,11 @@ export default {
cGreen: '#0fa00f', cGreen: '#0fa00f',
cOrange: '#ffa500' cOrange: '#ffa500'
} }
}) ])
const palettesOut = computed(() => { const palettesOut = computed(() => {
return Object.entries(palettes).map(([name, palette]) => { console.log('WORK DAMN', palettes)
return palettes.map(({ name, ...palette }) => {
const entries = Object const entries = Object
.entries(palette) .entries(palette)
.map(([slot, data]) => ` ${slot}: ${data};`) .map(([slot, data]) => ` ${slot}: ${data};`)
@ -109,9 +112,10 @@ export default {
}).join('\n\n') }).join('\n\n')
}) })
const editedPalette = ref('dark') const editedPalette = ref(0)
const palette = computed({ const palette = computed({
get () { get () {
console.log(palettes, editedPalette.value)
return palettes[editedPalette.value] return palettes[editedPalette.value]
}, },
set (newPalette) { set (newPalette) {
@ -435,10 +439,12 @@ export default {
const updatePreview = () => { const updatePreview = () => {
try { try {
const { name, ...paletteData } = palette.value
console.log('WORK', paletteData)
const rules = init({ const rules = init({
inputRuleset: editorFriendlyToOriginal.value, inputRuleset: editorFriendlyToOriginal.value,
initialStaticVars: { initialStaticVars: {
...palette.value ...paletteData
}, },
ultimateBackgroundColor: '#000000', ultimateBackgroundColor: '#000000',
rootComponentName: selectedComponentName.value, rootComponentName: selectedComponentName.value,
@ -529,6 +535,7 @@ export default {
license, license,
website, website,
palette, palette,
palettes,
editedPalette, editedPalette,
getNewPalette, getNewPalette,
componentKeys, componentKeys,

View file

@ -89,10 +89,33 @@
.palette-editor { .palette-editor {
display: grid; display: grid;
grid-template-areas:
"label editor"
"selector editor"
"motion editor";
grid-template-columns: auto 1fr;
grid-template-rows: auto 1fr auto;
grid-gap: 0.5em;
.palette-editor-edit {
grid-area: editor;
}
.palette-selector { .palette-selector {
&-label { &-label {
font-weight: bold; font-weight: bold;
grid-area: label;
margin: 0;
}
}
.palette-list {
grid-area: selector;
margin: 0;
&-movement {
grid-area: motion;
margin: 0;
} }
} }
} }

View file

@ -271,14 +271,14 @@
id="palette-selector" id="palette-selector"
v-model="editedPalette" v-model="editedPalette"
class="palette-list" class="palette-list"
size="10" size="9"
> >
<option <option
v-for="(p, index) in palettes" v-for="(p, index) in palettes"
:key="p" :key="p.name"
:value="index" :value="index"
> >
{{ p }} {{ p.name }}
</option> </option>
</Select> </Select>
<SelectMotion <SelectMotion
@ -286,9 +286,12 @@
v-model="palettes" v-model="palettes"
:selected-id="editedPalette" :selected-id="editedPalette"
:get-add-value="getNewPalette" :get-add-value="getNewPalette"
@update:selectedId="e => editecPalette = e" @update:selectedId="e => editedPalette = e"
/>
<PaletteEditor
class="palette-editor-edit"
v-model="palette"
/> />
<PaletteEditor v-model="palette" />
</div> </div>
</tab-switcher> </tab-switcher>
</div> </div>

View file

@ -760,8 +760,6 @@
"label": "Palette", "label": "Palette",
"import": "Import", "import": "Import",
"export": "Export", "export": "Export",
"dark": "Dark mode",
"light": "Light mode",
"bg": "Panel background", "bg": "Panel background",
"fg": "Buttons etc.", "fg": "Buttons etc.",
"text": "Text", "text": "Text",