More colors
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 50s

This commit is contained in:
2026-09-20 12:50:40 +02:00
parent f19f482433
commit a5d5ead38a
8 changed files with 178 additions and 10 deletions

View File

@@ -22,9 +22,22 @@ const COLOR_HEX: Record<string, string> = {
yellow: '#e2cf3c',
green: '#5fae4e',
blue: '#4c8be0',
purple: '#9b59d0'
purple: '#9b59d0',
black: '#1a1a1a',
white: '#f2f2f2',
pink: '#e88fb3',
turquoise: '#40c4b8',
teal: '#17857c',
navy: '#34549c',
lavender: '#b98fe0',
magenta: '#cf479f',
lime: '#a8d14e',
coral: '#ef8368'
};
const orderSwatch = (order: any) =>
order.color === 'custom' ? order.customColor : COLOR_HEX[order.color] || 'transparent';
const formatUptime = (seconds: number) => {
const h = Math.floor(seconds / 3600);
const m = Math.floor((seconds % 3600) / 60);
@@ -153,8 +166,8 @@ const onLogout = () => redirectToLogin();
<td class="msg-cell">{{ order.message }}</td>
<td>
<span class="color-chip">
<span class="swatch" :style="{ background: COLOR_HEX[order.color] || 'transparent' }" aria-hidden="true"></span>
{{ $t(`order.hibolia.colors.${order.color}`) }}
<span class="swatch" :style="{ background: orderSwatch(order) }" aria-hidden="true"></span>
{{ $t(`order.hibolia.colors.${order.color}`) }}<template v-if="order.color === 'custom'"> {{ order.customColor }}</template>
</span>
</td>
<td class="msg-cell">{{ order.shipping }}</td>

View File

@@ -23,23 +23,37 @@ const COLOR_OPTIONS = [
{ value: 'black', hex: '#1a1a1a' },
{ value: 'white', hex: '#f2f2f2' },
{ value: 'pink', hex: '#e88fb3' },
{ value: 'turquoise', hex: '#40c4b8' },
{ value: 'teal', hex: '#17857c' },
{ value: 'navy', hex: '#34549c' },
{ value: 'lavender', hex: '#b98fe0' },
{ value: 'magenta', hex: '#cf479f' },
{ value: 'lime', hex: '#a8d14e' },
{ value: 'coral', hex: '#ef8368' },
{ value: 'custom', hex: '#40c4b8' },
{ value: 'none', hex: '#9e9e9e' }
];
const DEFAULT_CUSTOM_COLOR = '#40c4b8';
const HEX_COLOR_RE = /^#[0-9a-fA-F]{6}$/;
const form = reactive({
name: '',
surname: '',
email: '',
message: '',
color: '',
color: 'none',
customColor: DEFAULT_CUSTOM_COLOR,
shipping: ''
});
const DEFAULT_EDGE_COLOR = '#d8d2c6';
const selectedColorHex = computed(
() => COLOR_OPTIONS.find((o) => o.value === form.color)?.hex ?? DEFAULT_EDGE_COLOR
);
const selectedColorHex = computed(() => {
if (form.color === 'custom') return form.customColor;
if (form.color === 'none') return DEFAULT_EDGE_COLOR;
return COLOR_OPTIONS.find((o) => o.value === form.color)?.hex ?? DEFAULT_EDGE_COLOR;
});
const submitting = ref(false);
const errorMsg = ref('');
@@ -62,6 +76,11 @@ const onSubmit = async () => {
return;
}
if (form.color === 'custom' && !HEX_COLOR_RE.test(form.customColor)) {
errorMsg.value = $t('order.hibolia.error_invalid_color');
return;
}
submitting.value = true;
try {
await post('/hibolia/orders', {
@@ -70,13 +89,16 @@ const onSubmit = async () => {
email: form.email.trim(),
message: form.message.trim(),
color: form.color,
customColor:
form.color === 'custom' ? form.customColor.toLowerCase() : undefined,
shipping: form.shipping.trim()
});
form.name = '';
form.surname = '';
form.email = '';
form.message = '';
form.color = '';
form.color = 'none';
form.customColor = DEFAULT_CUSTOM_COLOR;
form.shipping = '';
await navigateTo(localePath('/projects/hibolia/thanks'));
} catch (e: any) {
@@ -185,10 +207,28 @@ const onSubmit = async () => {
:disabled="submitting"
:id="`order-color-${option.value}`"
/>
<span class="swatch" :style="{ background: option.hex }" aria-hidden="true"></span>
<span
class="swatch"
:style="{ background: option.value === 'custom' ? form.customColor : option.hex }"
aria-hidden="true"
></span>
<span class="color-name">{{ $t(`order.hibolia.colors.${option.value}`) }}</span>
</label>
</div>
<div v-if="form.color === 'custom'" class="custom-color-row">
<label for="order-custom-color">{{ $t('order.hibolia.custom_color_label') }}:</label>
<input
id="order-custom-color"
v-model="form.customColor"
type="color"
name="customColor"
:disabled="submitting"
/>
<span class="custom-color-hex">{{ form.customColor }}</span>
</div>
<p v-if="form.color === 'custom'" class="custom-color-note">
{{ $t('order.hibolia.custom_color_note') }}
</p>
</fieldset>
<p>{{ $t('order.hibolia.preview_note') }}</p>
@@ -383,6 +423,49 @@ const onSubmit = async () => {
gap: 8px;
}
.custom-color-row {
display: flex;
align-items: center;
gap: 10px;
margin-top: 10px;
label {
font-family: 'Hurmit', monospace;
font-size: 0.9rem;
color: var(--color-link);
min-width: 0;
text-align: left;
}
input[type='color'] {
width: 48px;
height: 30px;
padding: 2px;
background: var(--color-background);
border: 1px solid var(--color-border-color);
cursor: pointer;
&:focus-visible {
outline: 1px dashed var(--color-link);
outline-offset: 2px;
}
}
.custom-color-hex {
font-family: 'Hurmit', monospace;
font-size: 0.8rem;
color: var(--color-text);
}
}
.custom-color-note {
font-family: 'Hurmit', monospace;
font-size: 0.8rem;
color: var(--color-text);
opacity: 0.75;
margin: 8px 0 0;
}
.deck-preview {
height: 300px;
margin: 0 0 14px;