-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(effects): add icons & improved dialog options
- Loading branch information
Showing
5 changed files
with
190 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<template> | ||
<Select | ||
id="icon-selector" | ||
class="w-full" | ||
filter | ||
filter-match-mode="contains" | ||
:model-value="modelValue" | ||
option-label="name" | ||
option-value="value" | ||
:options="options" | ||
placeholder="Icon (optional)" | ||
show-clear | ||
:virtual-scroller-options="{ itemSize: 40 }" | ||
@update:model-value="(v) => $emit('update:modelValue', v)" | ||
> | ||
<template #value="slotProps"> | ||
<div v-if="slotProps.value" class="flex items-center gap-2"> | ||
<i :class="slotProps.value" /> | ||
{{ getNameFromValue(slotProps.value) }} | ||
</div> | ||
<div v-else>{{ slotProps.placeholder }}</div> | ||
</template> | ||
<template #option="slotProps"> | ||
<div v-if="slotProps.option.value" class="flex items-center gap-2"> | ||
<i :class="slotProps.option.value" /> | ||
{{ slotProps.option.name }} | ||
</div> | ||
</template> | ||
</Select> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { PrimeIcons } from '@primevue/core/api'; | ||
import { computed } from 'vue'; | ||
defineProps<{ | ||
modelValue?: string; | ||
}>(); | ||
defineEmits<{ | ||
'update:modelValue': [icon: string]; | ||
}>(); | ||
const getNameFromValue = (value: string) => { | ||
const nameParts: string[] = value.split(' ')[1].split('-'); | ||
nameParts.splice(0, 1); | ||
let name = nameParts.join(' '); | ||
name = name.charAt(0).toUpperCase() + name.slice(1); | ||
return name; | ||
}; | ||
const options = computed(() => { | ||
return Object.values(PrimeIcons).map((value: string) => { | ||
const name = getNameFromValue(value); | ||
return { value, name }; | ||
}); | ||
}); | ||
</script> | ||
|
||
<style scoped></style> |
35 changes: 35 additions & 0 deletions
35
src/components/lights/effects/EffectControllerButtonContent.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<template> | ||
<div class="flex flex-row gap-2 justify-center items-center"> | ||
<div v-if="editing"> | ||
<span class="pi pi-pencil text-3xl" /> | ||
</div> | ||
<div class="flex flex-col gap-1"> | ||
<div> | ||
<span v-if="button.icon" :class="['pi', button.icon]" /> | ||
{{ button.name }} | ||
</div> | ||
<div v-if="button.properties.type === 'LightsButtonColors'" class="flex flex-row gap-1"> | ||
<ColorBox | ||
v-for="color in (button.properties as LightsButtonColors).colors" | ||
:key="color" | ||
:color="colorStore.getHexColor(color as RgbColor)" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { type LightsButtonColors, type LightsPredefinedEffectResponse, RgbColor } from '@/api'; | ||
import ColorBox from '@/components/lights/effects/ColorBox.vue'; | ||
import { useColorStore } from '@/stores/color.store'; | ||
const colorStore = useColorStore(); | ||
defineProps<{ | ||
button: LightsPredefinedEffectResponse; | ||
editing?: boolean; | ||
}>(); | ||
</script> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters