From 13790f205566fd1743ee4268fdd946a53a9bc402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20K=C3=BCng?= Date: Fri, 6 Feb 2026 13:25:41 +0100 Subject: [PATCH] feat(web): update color selector --- .../src/app/core/constants/colors.const.ts | 41 ++++++ .../calculator/calculator-page.component.ts | 7 +- .../upload-form/upload-form.component.html | 39 ++--- .../upload-form/upload-form.component.scss | 73 +++++++--- .../upload-form/upload-form.component.ts | 41 ++++-- .../services/quote-estimator.service.ts | 9 +- .../color-selector.component.html | 39 +++++ .../color-selector.component.scss | 136 ++++++++++++++++++ .../color-selector.component.ts | 40 ++++++ .../stl-viewer/stl-viewer.component.ts | 10 +- 10 files changed, 380 insertions(+), 55 deletions(-) create mode 100644 frontend/src/app/core/constants/colors.const.ts create mode 100644 frontend/src/app/shared/components/color-selector/color-selector.component.html create mode 100644 frontend/src/app/shared/components/color-selector/color-selector.component.scss create mode 100644 frontend/src/app/shared/components/color-selector/color-selector.component.ts diff --git a/frontend/src/app/core/constants/colors.const.ts b/frontend/src/app/core/constants/colors.const.ts new file mode 100644 index 0000000..66b1336 --- /dev/null +++ b/frontend/src/app/core/constants/colors.const.ts @@ -0,0 +1,41 @@ +export interface ColorOption { + label: string; + value: string; + hex: string; + outOfStock?: boolean; +} + +export interface ColorCategory { + name: string; // 'Glossy' | 'Matte' + colors: ColorOption[]; +} + +export const PRODUCT_COLORS: ColorCategory[] = [ + { + name: 'Lucidi', // Glossy + colors: [ + { label: 'Black', value: 'Black', hex: '#1a1a1a' }, // Not pure black for visibility + { label: 'White', value: 'White', hex: '#f5f5f5' }, + { label: 'Red', value: 'Red', hex: '#d32f2f', outOfStock: true }, + { label: 'Blue', value: 'Blue', hex: '#1976d2' }, + { label: 'Green', value: 'Green', hex: '#388e3c' }, + { label: 'Yellow', value: 'Yellow', hex: '#fbc02d' } + ] + }, + { + name: 'Opachi', // Matte + colors: [ + { label: 'Matte Black', value: 'Matte Black', hex: '#2c2c2c' }, // Lighter charcoal for matte + { label: 'Matte White', value: 'Matte White', hex: '#e0e0e0' }, + { label: 'Matte Gray', value: 'Matte Gray', hex: '#757575' } + ] + } +]; + +export function getColorHex(value: string): string { + for (const cat of PRODUCT_COLORS) { + const found = cat.colors.find(c => c.value === value); + if (found) return found.hex; + } + return '#facf0a'; // Default Brand Color if not found +} diff --git a/frontend/src/app/features/calculator/calculator-page.component.ts b/frontend/src/app/features/calculator/calculator-page.component.ts index ac8aefe..7122a4b 100644 --- a/frontend/src/app/features/calculator/calculator-page.component.ts +++ b/frontend/src/app/features/calculator/calculator-page.component.ts @@ -72,11 +72,14 @@ export class CalculatorPageComponent { details += `- File:\n`; req.items.forEach(item => { - details += ` * ${item.file.name} (Qtà: ${item.quantity})\n`; + details += ` * ${item.file.name} (Qtà: ${item.quantity}`; + if (item.color) { + details += `, Colore: ${item.color}`; + } + details += `)\n`; }); if (req.mode === 'advanced') { - if (req.color) details += `- Colore: ${req.color}\n`; if (req.infillDensity) details += `- Infill: ${req.infillDensity}%\n`; } diff --git a/frontend/src/app/features/calculator/components/upload-form/upload-form.component.html b/frontend/src/app/features/calculator/components/upload-form/upload-form.component.html index 334fd93..e89b46d 100644 --- a/frontend/src/app/features/calculator/components/upload-form/upload-form.component.html +++ b/frontend/src/app/features/calculator/components/upload-form/upload-form.component.html @@ -3,7 +3,10 @@
@if (selectedFile()) {
- + +
} @@ -29,15 +32,25 @@
-
- - +
+
+ + +
+ +
+ + + +