Fix the ColorsPicker to use the new palette

This commit is contained in:
2024-10-06 00:13:54 -04:00
parent 7e6dae9848
commit 3bf7ef5be0

View File

@@ -8,50 +8,99 @@ const props = defineProps({
}, },
colorName: { colorName: {
type: String, type: String,
default: 'bannerTop' default: 'primary'
} }
}); });
const emits = defineEmits(['closeRequested']); const emits = defineEmits(['closeRequested']);
const bannerTopColor = ref(props.creator.colors.bannerTop) const primaryColor = ref(props.creator.colors.primary)
const bannerBottomColor = ref(props.creator.colors.bannerBottom) const secondaryColor = ref(props.creator.colors.secondary)
const accentColor = ref(props.creator.colors.accent) const backgroundColor = ref(props.creator.colors.background)
const menuColor = ref(props.creator.colors.menu) const errorColor = ref(props.creator.colors.error)
const surfaceColor = ref(props.creator.colors.surface)
const onPrimaryColor = ref(props.creator.colors.onPrimary)
const onSecondaryColor = ref(props.creator.colors.onSecondary)
const onBackgroundColor = ref(props.creator.colors.onBackground)
const onErrorColor = ref(props.creator.colors.onError)
const onSurfaceColor = ref(props.creator.colors.onSurface)
const selectedColorName = ref(props.colorName); const selectedColorName = ref(props.colorName);
const selectedColor = computed({ const selectedBackgroundColor = computed({
get() { get() {
switch (selectedColorName.value) { switch (selectedColorName.value) {
case 'bannerTop': case 'primary':
return bannerTopColor.value; return primaryColor.value
case 'bannerBottom': case 'secondary':
return bannerBottomColor.value; return secondaryColor.value
case 'accent': case 'background':
return accentColor.value; return backgroundColor.value
case 'menu': case 'error':
return menuColor.value; return errorColor.value
case 'surface':
return surfaceColor.value
default: default:
return bannerTopColor.value; return '#e42aad';
} }
}, },
set(value) { set(value) {
switch (selectedColorName.value) { switch (selectedColorName.value) {
case 'bannerTop': case 'primary':
bannerTopColor.value = value; primaryColor.value = value
break; break
case 'bannerBottom': case 'secondary':
bannerBottomColor.value = value; secondaryColor.value = value
break; break
case 'accent': case 'background':
accentColor.value = value; backgroundColor.value = value
break; break
case 'menu': case 'error':
menuColor.value = value; errorColor.value = value
break; break
case 'surface':
surfaceColor.value = value
break
} }
} }
}); })
const selectedTextColor = computed({
get() {
switch (selectedColorName.value) {
case 'primary':
return onPrimaryColor.value
case 'secondary':
return onSecondaryColor.value
case 'background':
return onBackgroundColor.value
case 'error':
return onErrorColor.value
case 'surface':
return onSurfaceColor.value
default:
return '#e42aad';
}
},
set(value) {
switch (selectedColorName.value) {
case 'primary':
onPrimaryColor.value = value
break
case 'secondary':
onSecondaryColor.value = value
break
case 'background':
onBackgroundColor.value = value
break
case 'error':
onErrorColor.value = value
break
case 'surface':
onSurfaceColor.value = value
break
}
}
})
const selectColor = (colorName) => { const selectColor = (colorName) => {
selectedColorName.value = colorName; selectedColorName.value = colorName;
@@ -63,16 +112,28 @@ const save = async () => {
await client.post( await client.post(
`/api/creators/${props.creator.id}/colors`, `/api/creators/${props.creator.id}/colors`,
{ {
"bannerTop": bannerTopColor.value || null, 'primary': primaryColor.value,
"bannerBottom": bannerBottomColor.value || null, 'secondary': secondaryColor.value,
"accent": accentColor.value || null, 'background': backgroundColor.value,
"menu": menuColor.value || null 'error': errorColor.value,
'surface': surfaceColor.value,
'onPrimary': onPrimaryColor.value,
'onSecondary': onSecondaryColor.value,
'onBackground': onBackgroundColor.value,
'onError': onErrorColor.value,
'onSurface': onSurfaceColor.value,
}); });
props.creator.colors.bannerTop = bannerTopColor.value; props.creator.colors.primary = primaryColor.value
props.creator.colors.bannerBottom = bannerBottomColor.value; props.creator.colors.secondary = secondaryColor.value
props.creator.colors.accent = accentColor.value; props.creator.colors.background = backgroundColor.value
props.creator.colors.menu = menuColor.value; props.creator.colors.error = errorColor.value
props.creator.colors.surface = surfaceColor.value
props.creator.colors.onPrimary = onPrimaryColor.value
props.creator.colors.onSecondary = onSecondaryColor.value
props.creator.colors.onBackground = onBackgroundColor.value
props.creator.colors.onError = onErrorColor.value
props.creator.colors.onSurface = onSurfaceColor.value
emits('closeRequested'); emits('closeRequested');
} catch (error) { } catch (error) {
@@ -90,50 +151,76 @@ const cancel = () => {
Palette de Couleurs Palette de Couleurs
</h2> </h2>
<div class="flex gap-6 justify-center items-start mt-5"> <div class="flex flex-column gap-6 justify-center items-start mt-5">
<div class="grid grid-cols-2 grid-rows-2 gap-4"> <div class="grid grid-cols-5 grid-rows-1 gap-4">
<div <div
class="color-square" class="color-square"
:class="{ selected: selectedColorName === 'bannerTop' }" :class="{ selected: selectedColorName === 'primary' }"
:style="{ backgroundColor: bannerTopColor }" :style="{ backgroundColor: primaryColor }"
@click="selectColor('bannerTop')" @click="selectColor('primary')"
> >
<span class="color-name">Haut Banniere</span> <span class="color-name"
:style="{ color: onPrimaryColor }">
Primary
</span>
</div> </div>
<div <div
class="color-square" class="color-square"
:class="{ selected: selectedColorName === 'bannerBottom' }" :class="{ selected: selectedColorName === 'secondary' }"
:style="{ backgroundColor: bannerBottomColor }" :style="{ backgroundColor: secondaryColor }"
@click="selectColor('bannerBottom')" @click="selectColor('secondary')"
> >
<span class="color-name">Bas Banniere</span> <span class="color-name"
:style="{ color: onSecondaryColor }">
Secondary
</span>
</div> </div>
<div <div
class="color-square" class="color-square"
:class="{ selected: selectedColorName === 'accent' }" :class="{ selected: selectedColorName === 'surface' }"
:style="{ backgroundColor: accentColor }" :style="{ backgroundColor: surfaceColor }"
@click="selectColor('accent')" @click="selectColor('surface')"
> >
<span class="color-name">Accent</span> <span class="color-name"
:style="{ color: onSurfaceColor }">
Surface
</span>
</div> </div>
<div <div
class="color-square" class="color-square"
:class="{ selected: selectedColorName === 'menu' }" :class="{ selected: selectedColorName === 'background' }"
:style="{ backgroundColor: menuColor }" :style="{ backgroundColor: backgroundColor }"
@click="selectColor('menu')" @click="selectColor('background')"
> >
<span class="color-name">Menu</span> <span class="color-name"
:style="{ color: onBackgroundColor }">
Background
</span>
</div>
<div
class="color-square"
:class="{ selected: selectedColorName === 'error' }"
:style="{ backgroundColor: errorColor }"
@click="selectColor('error')"
>
<span class="color-name"
:style="{ color: onErrorColor }"
>
Error
</span>
</div> </div>
</div> </div>
<div class="w-px bg-gray-300 h-full"></div> <div class=" flex flex-row flex-grow">
<span>TEXT</span>
<div class="flex-grow"> <v-color-picker v-model="selectedTextColor"></v-color-picker>
<v-color-picker v-model="selectedColor"></v-color-picker> <span>Background</span>
<v-color-picker v-model="selectedBackgroundColor"></v-color-picker>
</div> </div>
</div> </div>
@@ -148,7 +235,7 @@ const cancel = () => {
@apply w-[150px] h-[150px]; @apply w-[150px] h-[150px];
@apply flex rounded-md cursor-pointer relative; @apply flex rounded-md cursor-pointer relative;
@apply items-center justify-center; @apply items-center justify-center;
@apply font-bold text-white; @apply font-bold text-2xl;
} }
.color-square.selected { .color-square.selected {