feat: FASE 2 - Client Base (layout, login, navbar, tema, i18n)

Implementazione completa del frontend Flask:
- Layout base.html con TailwindCSS CDN, dark/light theme, flash messages
- Navbar responsive role-based (Maker, MeasurementTec, Metrologist, Admin)
- Login page professionale con form + API integration
- Profilo utente: nome, lingua, tema, badge ruoli
- Sistema tema dark/light: CSS variables + Alpine.js store + localStorage
- i18n completo IT/EN: Flask-Babel (.po) + alpinejs-i18n (JSON)
- API Client riscritto: error handling normalizzato, no crash su 4xx/5xx
- CSRF protection con Flask-WTF su tutti i form
- Logo aziendale dinamico da system_settings
- Asset SVG: tmflow-logo.svg + tmflow-icon.svg (favicon)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Adriano
2026-02-07 01:10:13 +01:00
parent d6508e0ae8
commit edd4580a5a
17 changed files with 2230 additions and 52 deletions
+374
View File
@@ -0,0 +1,374 @@
/* ============================================================
TieMeasureFlow - Theme System
CSS Custom Properties for Light / Dark mode
============================================================ */
/* ---- Light Theme (Default) ---- */
:root {
--color-primary: #2563EB;
--color-primary-dark: #1E40AF;
--color-primary-light: #3B82F6;
--color-secondary: #64748B;
--color-accent: #1E40AF;
--color-pass: #059669;
--color-warning: #D97706;
--color-fail: #DC2626;
--bg-primary: #F8FAFC;
--bg-secondary: #F1F5F9;
--bg-card: #FFFFFF;
--bg-card-hover: #F8FAFC;
--text-primary: #0F172A;
--text-secondary: #475569;
--text-muted: #94A3B8;
--border-color: #E2E8F0;
--border-focus: #2563EB;
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
--scrollbar-track: #F1F5F9;
--scrollbar-thumb: #CBD5E1;
--scrollbar-thumb-hover: #94A3B8;
}
/* ---- Dark Theme ---- */
.dark {
--bg-primary: #0F172A;
--bg-secondary: #1E293B;
--bg-card: #334155;
--bg-card-hover: #3B4A63;
--text-primary: #F1F5F9;
--text-secondary: #94A3B8;
--text-muted: #64748B;
--border-color: #475569;
--border-focus: #3B82F6;
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
--scrollbar-track: #1E293B;
--scrollbar-thumb: #475569;
--scrollbar-thumb-hover: #64748B;
}
/* ============================================================
Global Transitions
============================================================ */
*,
*::before,
*::after {
transition-property: background-color, border-color, color, box-shadow;
transition-duration: 0s;
}
/* Enable smooth transitions only after page load (avoid flash) */
html.theme-transitions *,
html.theme-transitions *::before,
html.theme-transitions *::after {
transition-duration: 0.3s;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
/* ============================================================
Focus Ring
============================================================ */
*:focus-visible {
outline: 2px solid var(--border-focus);
outline-offset: 2px;
border-radius: 4px;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
outline: none;
box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--border-focus);
}
/* ============================================================
Custom Scrollbar
============================================================ */
/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
background: var(--scrollbar-thumb);
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--scrollbar-thumb-hover);
}
/* Firefox */
* {
scrollbar-width: thin;
scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
/* ============================================================
Utility: Card
============================================================ */
.tmf-card {
background: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: 0.75rem;
box-shadow: var(--shadow-sm);
transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.tmf-card:hover {
box-shadow: var(--shadow-md);
}
.tmf-card-header {
padding: 1rem 1.25rem;
border-bottom: 1px solid var(--border-color);
font-weight: 600;
font-size: 0.875rem;
color: var(--text-primary);
}
.tmf-card-body {
padding: 1.25rem;
}
.tmf-card-footer {
padding: 0.75rem 1.25rem;
border-top: 1px solid var(--border-color);
background: var(--bg-secondary);
border-radius: 0 0 0.75rem 0.75rem;
}
/* ============================================================
Utility: Badges (Pass / Warning / Fail)
============================================================ */
.badge {
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0.125rem 0.625rem;
font-size: 0.75rem;
font-weight: 600;
border-radius: 9999px;
line-height: 1.5;
white-space: nowrap;
}
.badge-pass {
background: rgba(5, 150, 105, 0.1);
color: #059669;
border: 1px solid rgba(5, 150, 105, 0.25);
}
.dark .badge-pass {
background: rgba(5, 150, 105, 0.15);
color: #34D399;
border-color: rgba(5, 150, 105, 0.3);
}
.badge-warning {
background: rgba(217, 119, 6, 0.1);
color: #D97706;
border: 1px solid rgba(217, 119, 6, 0.25);
}
.dark .badge-warning {
background: rgba(217, 119, 6, 0.15);
color: #FBBF24;
border-color: rgba(217, 119, 6, 0.3);
}
.badge-fail {
background: rgba(220, 38, 38, 0.1);
color: #DC2626;
border: 1px solid rgba(220, 38, 38, 0.25);
}
.dark .badge-fail {
background: rgba(220, 38, 38, 0.15);
color: #F87171;
border-color: rgba(220, 38, 38, 0.3);
}
.badge-neutral {
background: var(--bg-secondary);
color: var(--text-secondary);
border: 1px solid var(--border-color);
}
/* ============================================================
Utility: Buttons
============================================================ */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 0.5rem 1rem;
font-size: 0.875rem;
font-weight: 500;
border-radius: 0.5rem;
cursor: pointer;
transition: all 0.2s ease;
border: 1px solid transparent;
}
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.btn-primary {
background: var(--color-primary);
color: #FFFFFF;
border-color: var(--color-primary);
}
.btn-primary:hover:not(:disabled) {
background: var(--color-primary-dark);
border-color: var(--color-primary-dark);
}
.btn-secondary {
background: transparent;
color: var(--text-secondary);
border-color: var(--border-color);
}
.btn-secondary:hover:not(:disabled) {
background: var(--bg-secondary);
color: var(--text-primary);
border-color: var(--text-secondary);
}
.btn-danger {
background: var(--color-fail);
color: #FFFFFF;
border-color: var(--color-fail);
}
.btn-danger:hover:not(:disabled) {
background: #B91C1C;
border-color: #B91C1C;
}
/* ============================================================
Utility: Form Inputs
============================================================ */
.tmf-input {
width: 100%;
padding: 0.5rem 0.75rem;
font-size: 0.875rem;
line-height: 1.5;
color: var(--text-primary);
background: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: 0.5rem;
transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.tmf-input::placeholder {
color: var(--text-muted);
}
.tmf-input:focus {
outline: none;
border-color: var(--border-focus);
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.dark .tmf-input:focus {
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.tmf-label {
display: block;
font-size: 0.8125rem;
font-weight: 500;
color: var(--text-secondary);
margin-bottom: 0.375rem;
}
/* ============================================================
Utility: Measurement Value Display
============================================================ */
.measure-value {
font-family: 'JetBrains Mono', ui-monospace, monospace;
font-weight: 500;
letter-spacing: -0.025em;
font-variant-numeric: tabular-nums;
}
/* ============================================================
Utility: Table
============================================================ */
.tmf-table {
width: 100%;
font-size: 0.875rem;
border-collapse: collapse;
}
.tmf-table th {
padding: 0.625rem 1rem;
text-align: left;
font-weight: 600;
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--text-secondary);
background: var(--bg-secondary);
border-bottom: 1px solid var(--border-color);
}
.tmf-table td {
padding: 0.625rem 1rem;
color: var(--text-primary);
border-bottom: 1px solid var(--border-color);
}
.tmf-table tbody tr:hover {
background: var(--bg-card-hover);
}
/* ============================================================
Alpine.js x-cloak (hide until Alpine loads)
============================================================ */
[x-cloak] {
display: none !important;
}
+27
View File
@@ -0,0 +1,27 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="none">
<!-- Stylized Caliper Icon for Favicon -->
<!-- Caliper outer frame -->
<rect x="2" y="3" width="5" height="26" rx="1.5" fill="#2563EB"/>
<rect x="2" y="3" width="19" height="5" rx="1.5" fill="#2563EB"/>
<rect x="2" y="24" width="19" height="5" rx="1.5" fill="#2563EB"/>
<!-- Sliding jaw -->
<rect x="12" y="8" width="4.5" height="6.5" rx="1" fill="#1E40AF"/>
<rect x="12" y="17.5" width="4.5" height="6.5" rx="1" fill="#1E40AF"/>
<!-- Depth rod -->
<rect x="4" y="14" width="12" height="3.5" rx="1" fill="#3B82F6" opacity="0.55"/>
<!-- Scale markings -->
<rect x="8" y="5" width="1" height="2.5" rx="0.5" fill="#FFFFFF" opacity="0.65"/>
<rect x="11" y="5" width="1" height="2.5" rx="0.5" fill="#FFFFFF" opacity="0.65"/>
<rect x="14" y="5" width="1" height="2.5" rx="0.5" fill="#FFFFFF" opacity="0.65"/>
<rect x="17" y="5" width="1" height="2.5" rx="0.5" fill="#FFFFFF" opacity="0.65"/>
<!-- Flow arrow -->
<path d="M22 16 C25 16, 26.5 11, 29 11"
stroke="#3B82F6" stroke-width="2.2" stroke-linecap="round" fill="none"/>
<path d="M27 8.5 L29.5 11 L27 13.5"
stroke="#3B82F6" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

+41
View File
@@ -0,0 +1,41 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 220 44" fill="none">
<!-- Stylized Caliper Icon -->
<g transform="translate(2, 2)">
<!-- Caliper outer frame -->
<rect x="0" y="4" width="6" height="32" rx="1.5" fill="#2563EB"/>
<rect x="0" y="4" width="24" height="6" rx="1.5" fill="#2563EB"/>
<rect x="0" y="30" width="24" height="6" rx="1.5" fill="#2563EB"/>
<!-- Caliper sliding jaw -->
<rect x="14" y="10" width="5" height="8" rx="1" fill="#1E40AF"/>
<rect x="14" y="22" width="5" height="8" rx="1" fill="#1E40AF"/>
<!-- Caliper depth rod -->
<rect x="2" y="18" width="16" height="4" rx="1" fill="#3B82F6" opacity="0.6"/>
<!-- Scale markings -->
<rect x="7" y="7" width="1" height="3" rx="0.5" fill="#FFFFFF" opacity="0.7"/>
<rect x="10" y="7" width="1" height="3" rx="0.5" fill="#FFFFFF" opacity="0.7"/>
<rect x="13" y="7" width="1" height="3" rx="0.5" fill="#FFFFFF" opacity="0.7"/>
<rect x="16" y="7" width="1" height="3" rx="0.5" fill="#FFFFFF" opacity="0.7"/>
<rect x="19" y="7" width="1" height="3" rx="0.5" fill="#FFFFFF" opacity="0.7"/>
<!-- Flow arrow (smooth curve) -->
<path d="M26 20 C30 20, 32 14, 36 14 C40 14, 40 20, 36 20"
stroke="#2563EB" stroke-width="2.5" stroke-linecap="round" fill="none"/>
<path d="M34 17 L37 20 L34 23" stroke="#2563EB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
</g>
<!-- Text: TieMeasureFlow -->
<g transform="translate(48, 0)">
<!-- "Tie" in bold primary -->
<text x="0" y="28" font-family="Inter, system-ui, sans-serif" font-size="20" font-weight="700" fill="#2563EB"
letter-spacing="-0.5">Tie</text>
<!-- "Measure" in medium dark -->
<text x="32" y="28" font-family="Inter, system-ui, sans-serif" font-size="20" font-weight="500" fill="#1E40AF"
letter-spacing="-0.5">Measure</text>
<!-- "Flow" in bold primary -->
<text x="120" y="28" font-family="Inter, system-ui, sans-serif" font-size="20" font-weight="700" fill="#2563EB"
letter-spacing="-0.5">Flow</text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

+126
View File
@@ -0,0 +1,126 @@
/**
* TieMeasureFlow - Alpine.js Theme Initialization
*
* This script MUST load before Alpine.js (which uses defer).
* It reads the saved theme from localStorage or the system preference,
* applies the 'dark' class to <html> immediately (no flash), and
* registers an Alpine.store('theme') for reactive toggling.
*/
(function () {
'use strict';
// ---- Immediate theme application (before paint) ----
var STORAGE_KEY = 'tmf-theme';
/**
* Resolve the initial dark-mode state.
* Priority: localStorage > system preference > light (default).
*/
function getInitialDark() {
var stored = null;
try {
stored = localStorage.getItem(STORAGE_KEY);
} catch (_) {
// localStorage may be unavailable (private browsing, etc.)
}
if (stored === 'dark') return true;
if (stored === 'light') return false;
// Fall back to OS preference
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
return true;
}
return false;
}
var isDark = getInitialDark();
// Apply immediately to prevent flash of wrong theme
if (isDark) {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
// ---- Enable smooth transitions after first paint ----
// Use requestAnimationFrame to wait one frame, then enable transitions
// so the initial theme application does not animate.
if (typeof requestAnimationFrame === 'function') {
requestAnimationFrame(function () {
requestAnimationFrame(function () {
document.documentElement.classList.add('theme-transitions');
});
});
}
// ---- Alpine.js Store Registration ----
// Alpine.store is registered via the alpine:init event, which fires
// when Alpine begins initialization but before it processes x-data.
document.addEventListener('alpine:init', function () {
Alpine.store('theme', {
dark: isDark,
toggle: function () {
this.dark = !this.dark;
this._apply();
},
set: function (dark) {
this.dark = dark;
this._apply();
},
_apply: function () {
if (this.dark) {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
try {
localStorage.setItem(STORAGE_KEY, this.dark ? 'dark' : 'light');
} catch (_) {
// Silently ignore storage errors
}
}
});
});
// ---- Listen for system preference changes ----
if (window.matchMedia) {
try {
var mq = window.matchMedia('(prefers-color-scheme: dark)');
mq.addEventListener('change', function (e) {
// Only auto-switch if the user hasn't manually set a preference
var stored = null;
try {
stored = localStorage.getItem(STORAGE_KEY);
} catch (_) {}
if (!stored) {
var newDark = e.matches;
if (typeof Alpine !== 'undefined' && Alpine.store('theme')) {
Alpine.store('theme').set(newDark);
} else {
// Alpine not loaded yet, apply directly
if (newDark) {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
}
}
});
} catch (_) {
// Older browsers may not support addEventListener on matchMedia
}
}
})();
+76
View File
@@ -0,0 +1,76 @@
{
"numpad": {
"title": "Numeric Keypad",
"clear": "Clear",
"submit": "Confirm",
"decimal": "Decimal",
"close": "Close"
},
"measurement": {
"pass": "Pass",
"warning": "Warning",
"fail": "Fail",
"value": "Value",
"next": "Next measurement"
},
"common": {
"loading": "Loading...",
"save": "Save",
"cancel": "Cancel",
"confirm": "Confirm",
"delete": "Delete",
"edit": "Edit",
"search": "Search...",
"noResults": "No results",
"close": "Close",
"error": "Error",
"success": "Success",
"warning": "Warning",
"info": "Info",
"page": "Page",
"of": "of",
"previous": "Previous",
"next": "Next"
},
"theme": {
"light": "Light",
"dark": "Dark",
"toggle": "Toggle theme"
},
"language": {
"switch": "Switch language",
"it": "Italian",
"en": "English"
},
"auth": {
"login": "Sign in to your account",
"username": "Username",
"password": "Password",
"signIn": "Sign In",
"invalidCredentials": "Invalid credentials",
"enterCredentials": "Enter username and password",
"forgotPassword": "Forgot password? Contact administrator",
"welcome": "Welcome, {name}!",
"logoutSuccess": "Logged out successfully",
"loginRequired": "Please log in to continue"
},
"nav": {
"measurements": "Measurements",
"recipes": "Recipes",
"statistics": "Statistics",
"admin": "Admin",
"users": "Users",
"settings": "Settings",
"profile": "Profile",
"logout": "Logout"
},
"profile": {
"title": "User Profile",
"displayName": "Display Name",
"language": "Language",
"theme": "Theme",
"roles": "Roles",
"saveChanges": "Save Changes",
"updateSuccess": "Profile updated successfully"
}
}
+76
View File
@@ -0,0 +1,76 @@
{
"numpad": {
"title": "Tastierino Numerico",
"clear": "Cancella",
"submit": "Conferma",
"decimal": "Virgola",
"close": "Chiudi"
},
"measurement": {
"pass": "Conforme",
"warning": "Attenzione",
"fail": "Non Conforme",
"value": "Valore",
"next": "Prossima misura"
},
"common": {
"loading": "Caricamento...",
"save": "Salva",
"cancel": "Annulla",
"confirm": "Conferma",
"delete": "Elimina",
"edit": "Modifica",
"search": "Cerca...",
"noResults": "Nessun risultato",
"close": "Chiudi",
"error": "Errore",
"success": "Successo",
"warning": "Attenzione",
"info": "Info",
"page": "Pagina",
"of": "di",
"previous": "Precedente",
"next": "Successivo"
},
"theme": {
"light": "Chiaro",
"dark": "Scuro",
"toggle": "Cambia tema"
},
"language": {
"switch": "Cambia lingua",
"it": "Italiano",
"en": "English"
},
"auth": {
"login": "Accedi al sistema",
"username": "Username",
"password": "Password",
"signIn": "Accedi",
"invalidCredentials": "Credenziali non valide",
"enterCredentials": "Inserisci username e password",
"forgotPassword": "Hai dimenticato la password? Contatta l'amministratore",
"welcome": "Benvenuto, {name}!",
"logoutSuccess": "Logout effettuato",
"loginRequired": "Effettua il login per continuare"
},
"nav": {
"measurements": "Misure",
"recipes": "Ricette",
"statistics": "Statistiche",
"admin": "Admin",
"users": "Utenti",
"settings": "Impostazioni",
"profile": "Profilo",
"logout": "Esci"
},
"profile": {
"title": "Profilo Utente",
"displayName": "Nome Visualizzato",
"language": "Lingua",
"theme": "Tema",
"roles": "Ruoli",
"saveChanges": "Salva Modifiche",
"updateSuccess": "Profilo aggiornato con successo"
}
}