New color palette logic
parent
3b00f66917
commit
f4e1ba7241
|
@ -53,7 +53,7 @@ export default {
|
||||||
activateTheme: this.activateTheme,
|
activateTheme: this.activateTheme,
|
||||||
applyTheme: this.applyTheme,
|
applyTheme: this.applyTheme,
|
||||||
applyFont: this.applyFont,
|
applyFont: this.applyFont,
|
||||||
replaceColorPalette: this.replaceColorPalette
|
resolveColor: this.resolveColor
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -207,11 +207,6 @@ export default {
|
||||||
// silent fail as some fonts may have not all the font weights
|
// silent fail as some fonts may have not all the font weights
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
replaceColorPalette() {
|
|
||||||
this.$appState.designer.theme.preset.semantic.primary = this.$appState.designer.theme.preset.primitive.emerald;
|
|
||||||
this.$appState.designer.theme.preset.semantic.colorScheme.light.surface = { ...{ 0: '#ffffff' }, ...this.$appState.designer.theme.preset.primitive.slate };
|
|
||||||
this.$appState.designer.theme.preset.semantic.colorScheme.dark.surface = { ...{ 0: '#ffffff' }, ...this.$appState.designer.theme.preset.primitive.zinc };
|
|
||||||
},
|
|
||||||
toggleDarkMode() {
|
toggleDarkMode() {
|
||||||
EventBus.emit('dark-mode-toggle', { dark: !this.$appState.darkTheme });
|
EventBus.emit('dark-mode-toggle', { dark: !this.$appState.darkTheme });
|
||||||
},
|
},
|
||||||
|
@ -240,6 +235,14 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
},
|
||||||
|
resolveColor(token) {
|
||||||
|
if (token.startsWith('{') && token.endsWith('}')) {
|
||||||
|
let cssVariable = $dt(token).variable.slice(4, -1);
|
||||||
|
return getComputedStyle(document.documentElement).getPropertyValue(cssVariable);
|
||||||
|
} else {
|
||||||
|
return token;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -210,7 +210,6 @@ export default {
|
||||||
this.designerService.applyFont('Inter var');
|
this.designerService.applyFont('Inter var');
|
||||||
document.documentElement.style.fontSize = '14px';
|
document.documentElement.style.fontSize = '14px';
|
||||||
|
|
||||||
this.designerService.replaceColorPalette();
|
|
||||||
usePreset(preset);
|
usePreset(preset);
|
||||||
this.designerService.refreshACTokens();
|
this.designerService.refreshACTokens();
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-1 border border-surface rounded-l-lg rounded-r-lg overflow-hidden">
|
<div class="flex flex-1 border border-surface rounded-l-lg rounded-r-lg overflow-hidden">
|
||||||
<div v-for="color of value" :key="color" class="flex-1 h-8" :style="{ backgroundColor: color }" :title="color"></div>
|
<div v-for="color of value" :key="color" class="flex-1 h-8" :style="{ backgroundColor: designerService.resolveColor(color) }" :title="color"></div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
inject: ['designerService'],
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<section v-if="key !== 'borderRadius'" class="flex justify-between items-center mb-4 gap-8">
|
<section v-if="key !== 'borderRadius'" class="flex justify-between items-center mb-4 gap-8">
|
||||||
<div class="flex gap-2 items-center">
|
<div class="flex gap-2 items-center">
|
||||||
<span class="text-sm capitalize block w-20">{{ key }}</span>
|
<span class="text-sm capitalize block w-20">{{ key }}</span>
|
||||||
<input :value="$appState.designer.theme.preset.primitive[key]['500']" @input="onColorChange($event, key)" type="color" />
|
<input :value="designerService.resolveColor($appState.designer.theme.preset.primitive[key]['500'])" @input="onColorChange($event, key)" type="color" />
|
||||||
</div>
|
</div>
|
||||||
<DesignColorPalette :value="$appState.designer.theme.preset.primitive[key]" />
|
<DesignColorPalette :value="$appState.designer.theme.preset.primitive[key]" />
|
||||||
</section>
|
</section>
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
import { palette } from '@primeuix/themes';
|
import { palette } from '@primeuix/themes';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
inject: ['designerService'],
|
||||||
methods: {
|
methods: {
|
||||||
onColorChange(event, color) {
|
onColorChange(event, color) {
|
||||||
this.$appState.designer.theme.preset.primitive[color] = palette(event.target.value);
|
this.$appState.designer.theme.preset.primitive[color] = palette(event.target.value);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<section class="flex justify-between items-center mb-5 gap-8">
|
<section class="flex justify-between items-center mb-5 gap-8">
|
||||||
<div class="flex gap-2 items-center">
|
<div class="flex gap-2 items-center">
|
||||||
<span class="text-sm">Primary</span>
|
<span class="text-sm">Primary</span>
|
||||||
<input :value="$appState.designer.theme.preset.semantic.primary['500']" @input="onPrimaryColorChange($event)" type="color" />
|
<input :value="designerService.resolveColor($appState.designer.theme.preset.semantic.primary['500'])" @input="onPrimaryColorChange($event)" type="color" class="w-0 h-0" />
|
||||||
</div>
|
</div>
|
||||||
<DesignColorPalette :value="$appState.designer.theme.preset.semantic.primary" />
|
<DesignColorPalette :value="$appState.designer.theme.preset.semantic.primary" />
|
||||||
</section>
|
</section>
|
||||||
|
@ -52,6 +52,7 @@
|
||||||
import { palette } from '@primeuix/themes';
|
import { palette } from '@primeuix/themes';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
inject: ['designerService'],
|
||||||
methods: {
|
methods: {
|
||||||
onPrimaryColorChange(event) {
|
onPrimaryColorChange(event) {
|
||||||
this.$appState.designer.theme.preset.semantic.primary = palette(event.target.value);
|
this.$appState.designer.theme.preset.semantic.primary = palette(event.target.value);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<section class="flex justify-between items-center mb-5 gap-8">
|
<section class="flex justify-between items-center mb-5 gap-8">
|
||||||
<div class="flex gap-2 items-center">
|
<div class="flex gap-2 items-center">
|
||||||
<span class="text-sm">Surface</span>
|
<span class="text-sm">Surface</span>
|
||||||
<input :value="$colorScheme.surface['500']" @input="onSurfaceColorChange($event)" type="color" />
|
<input :value="designerService.resolveColor($colorScheme.surface['500'])" @input="onSurfaceColorChange($event)" type="color" />
|
||||||
</div>
|
</div>
|
||||||
<DesignColorPalette :value="$colorScheme.surface" />
|
<DesignColorPalette :value="$colorScheme.surface" />
|
||||||
</section>
|
</section>
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
import { palette } from '@primeuix/themes';
|
import { palette } from '@primeuix/themes';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ['$colorScheme'],
|
inject: ['$colorScheme', 'designerService'],
|
||||||
methods: {
|
methods: {
|
||||||
onSurfaceColorChange(event) {
|
onSurfaceColorChange(event) {
|
||||||
this.$colorScheme.surface = { ...{ 0: '#ffffff' }, ...palette(event.target.value) };
|
this.$colorScheme.surface = { ...{ 0: '#ffffff' }, ...palette(event.target.value) };
|
||||||
|
|
Loading…
Reference in New Issue