UPD: LED Color data in LEDsConfig

This commit is contained in:
Robert Kossessa
2024-01-26 17:28:02 +01:00
parent d625b71583
commit 11c66766bf
2 changed files with 32 additions and 11 deletions

View File

@@ -8,9 +8,8 @@
<h2 class="p-6">{{ $t('config_options.light_designer.led_mode') }}</h2> <h2 class="p-6">{{ $t('config_options.light_designer.led_mode') }}</h2>
</ConfigSection> </ConfigSection>
<div class="h-6" /> <div class="h-6" />
<!-- TODO: Instead of 3 color pickers, add a context select above -->
<ConfigSection :title="$t('config_options.light_designer.led_colors')" :icon-component="Palette"> <ConfigSection :title="$t('config_options.light_designer.led_colors')" :icon-component="Palette">
<PaletteInput /> <PaletteInput v-model="colors" />
</ConfigSection> </ConfigSection>
</ScrollArea> </ScrollArea>
</div> </div>
@@ -21,4 +20,21 @@ import { ScrollArea } from '@/components/ui/scroll-area/index.js'
import { Lightbulb, Palette } from 'lucide-vue-next' import { Lightbulb, Palette } from 'lucide-vue-next'
import ConfigSection from '@/components/config/ConfigSection.vue' import ConfigSection from '@/components/config/ConfigSection.vue'
import PaletteInput from '@/components/config/pages/PaletteInput.vue' import PaletteInput from '@/components/config/pages/PaletteInput.vue'
import Color from 'color'
import { ref } from 'vue'
const colors = ref({
primary: {
key: 'config_options.light_designer.primary_color',
color: Color('#ff0000'),
},
secondary: {
key: 'config_options.light_designer.secondary_color',
color: Color('#00ff00'),
},
pointer: {
key: 'config_options.light_designer.pointer_color',
color: Color('#0000ff'),
},
})
</script> </script>

View File

@@ -6,7 +6,7 @@
:class="currentOption!==key ? 'hover:bg-zinc-800 text-zinc-200' : 'text-black bg-zinc-200 hover:bg-zinc-100'" :class="currentOption!==key ? 'hover:bg-zinc-800 text-zinc-200' : 'text-black bg-zinc-200 hover:bg-zinc-100'"
@click="currentOption = key"> @click="currentOption = key">
{{ $t(option.key) }} {{ $t(option.key) }}
<div class="h-4 w-full mt-2" :style="{background: option.color.hex()}"/> <div class="h-4 w-full mt-2" :style="{background: option.color.hex()}" />
</button> </button>
</div> </div>
<HSVInput v-model="options[currentOption].color" class="relative z-20" /> <HSVInput v-model="options[currentOption].color" class="relative z-20" />
@@ -14,23 +14,23 @@
<script setup> <script setup>
import HSVInput from '@/components/HSVInput.vue' import HSVInput from '@/components/HSVInput.vue'
import Color from 'color' import Color from 'color'
import { reactive, ref } from 'vue' import { onBeforeMount, reactive, ref } from 'vue'
const currentOption = ref('primary') const currentOption = ref(null)
const model = defineModel({ const model = defineModel({
type: Object, type: Object,
default: () => ({ default: () => ({
primary: { one: {
key: 'config_options.light_designer.primary_color', key: 'One',
color: Color('#ff0000'), color: Color('#ff0000'),
}, },
secondary: { two: {
key: 'config_options.light_designer.secondary_color', key: 'Two',
color: Color('#00ff00'), color: Color('#00ff00'),
}, },
pointer: { three: {
key: 'config_options.light_designer.pointer_color', key: 'Three',
color: Color('#0000ff'), color: Color('#0000ff'),
}, },
}), }),
@@ -38,4 +38,9 @@ const model = defineModel({
const options = reactive(model.value) const options = reactive(model.value)
onBeforeMount(() => {
if (currentOption.value === null)
currentOption.value = Object.keys(options)[0]
})
</script> </script>