feat: design system, layout e componenti di base
- token, font self-hosted (Fraunces e Inter, sottoinsieme latin) con preload - BaseLayout con head completo (SEO, Open Graph, favicon) e JSON-LD dello studio - intestazione con barra superiore, navigazione e sottomenu servizi accessibili - menu mobile con dialog modale e alternativa senza JavaScript - footer con P.IVA, recapiti, servizi, orari e link legali - componenti: Logo, Icon (Lucide inline), Hero, card servizio, scheda professionista, badge abilitazione, card sede, mappa click-to-load, modulo di contatto, banda CTA, breadcrumb, intestazioni di sezione - generate-icons.mjs: marchio, favicon, apple-touch-icon e immagine OG - collection dei servizi e dei link utili con schemi Zod Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zJ9ZWGKvoKoxYwbmnRKdJ
This commit is contained in:
58 files changed
+5077
-16
No files matched your search
@@ -0,0 +1,365 @@
|
||||
---
|
||||
/**
|
||||
* Modulo di contatto (brief §10.1). La modalità si imposta in src/data/studio.ts
|
||||
* (`contactForm.mode`):
|
||||
* - `off` (predefinita): nessun modulo, al suo posto la card «Scrivici una e-mail»;
|
||||
* - `php`: invio a /contact.php (deploy/optional-php-form/contact.php);
|
||||
* - `endpoint`: invio all'URL configurato.
|
||||
*
|
||||
* Anti-spam senza cookie né servizi terzi: campo trappola nascosto (honeypot) e tempo minimo
|
||||
* di compilazione (`ts`). Validazione HTML5 nativa; con JavaScript i messaggi d'errore sono in
|
||||
* italiano, accanto ai campi e annunciati dagli screen reader.
|
||||
*/
|
||||
import { contactForm, studio } from '../data/studio';
|
||||
import { modulo, scriviEmail } from '../data/testi';
|
||||
import { mailtoHref, telHref } from '../lib/format';
|
||||
import Icon from './Icon.astro';
|
||||
|
||||
const mode = contactForm.mode;
|
||||
const action = mode === 'php' ? contactForm.phpAction : contactForm.endpoint;
|
||||
if (mode === 'endpoint' && !/^https:\/\//.test(action)) {
|
||||
throw new Error('contactForm.mode = "endpoint" richiede un URL https:// in contactForm.endpoint');
|
||||
}
|
||||
const telefono = studio.telefoni[0];
|
||||
const c = modulo.campi;
|
||||
---
|
||||
|
||||
{mode === 'off' ? (
|
||||
<div class="mail-card" data-contact-mode="off">
|
||||
<h2>{scriviEmail.titolo}</h2>
|
||||
<p>{scriviEmail.testo}</p>
|
||||
<a class="btn btn--primary btn--block" href={mailtoHref(studio.email, scriviEmail.oggetto)}>
|
||||
<Icon name="mail" size={18} />
|
||||
{scriviEmail.pulsante} {studio.email}
|
||||
</a>
|
||||
<p class="mail-card__note">
|
||||
{scriviEmail.nota} <a href={telHref(telefono)}>{telefono.display}</a>.
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<form
|
||||
class="contact-form"
|
||||
action={action}
|
||||
method="post"
|
||||
accept-charset="UTF-8"
|
||||
data-contact-form
|
||||
data-min-seconds={contactForm.tempoMinimoSecondi}
|
||||
data-contact-mode={mode}
|
||||
aria-labelledby="modulo-titolo"
|
||||
>
|
||||
<h2 id="modulo-titolo">{modulo.titolo}</h2>
|
||||
<p class="contact-form__intro">{modulo.intro}</p>
|
||||
<p class="contact-form__legend">{modulo.legenda}</p>
|
||||
|
||||
<div class="contact-form__summary" data-form-summary tabindex="-1" hidden>
|
||||
<p>{modulo.errori.titolo}</p>
|
||||
<ul data-form-summary-list />
|
||||
</div>
|
||||
<p class="visually-hidden" aria-live="polite" data-form-status />
|
||||
|
||||
<div class="field__row">
|
||||
<div class="field">
|
||||
<label for="cf-nome">
|
||||
{c.nome.label} <span aria-hidden="true">*</span>
|
||||
</label>
|
||||
<input
|
||||
id="cf-nome"
|
||||
name="nome"
|
||||
type="text"
|
||||
autocomplete="name"
|
||||
required
|
||||
maxlength="120"
|
||||
placeholder={c.nome.placeholder}
|
||||
aria-describedby="cf-nome-err"
|
||||
/>
|
||||
<p class="field__error" id="cf-nome-err" hidden />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="cf-email">
|
||||
{c.email.label} <span aria-hidden="true">*</span>
|
||||
</label>
|
||||
<input
|
||||
id="cf-email"
|
||||
name="email"
|
||||
type="email"
|
||||
autocomplete="email"
|
||||
inputmode="email"
|
||||
required
|
||||
maxlength="160"
|
||||
placeholder={c.email.placeholder}
|
||||
aria-describedby="cf-email-err"
|
||||
/>
|
||||
<p class="field__error" id="cf-email-err" hidden />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field__row">
|
||||
<div class="field">
|
||||
<label for="cf-telefono">
|
||||
{c.telefono.label} <span aria-hidden="true">*</span>
|
||||
</label>
|
||||
<input
|
||||
id="cf-telefono"
|
||||
name="telefono"
|
||||
type="tel"
|
||||
autocomplete="tel"
|
||||
inputmode="tel"
|
||||
required
|
||||
minlength="6"
|
||||
maxlength="25"
|
||||
pattern="[0-9 +().\/\-]{6,25}"
|
||||
placeholder={c.telefono.placeholder}
|
||||
aria-describedby="cf-telefono-err"
|
||||
/>
|
||||
<p class="field__error" id="cf-telefono-err" hidden />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="cf-oggetto">
|
||||
{c.oggetto.label} <span aria-hidden="true">*</span>
|
||||
</label>
|
||||
<input
|
||||
id="cf-oggetto"
|
||||
name="oggetto"
|
||||
type="text"
|
||||
required
|
||||
maxlength="160"
|
||||
placeholder={c.oggetto.placeholder}
|
||||
aria-describedby="cf-oggetto-err"
|
||||
/>
|
||||
<p class="field__error" id="cf-oggetto-err" hidden />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="cf-messaggio">
|
||||
{c.messaggio.label} <span aria-hidden="true">*</span>
|
||||
</label>
|
||||
<textarea
|
||||
id="cf-messaggio"
|
||||
name="messaggio"
|
||||
rows="6"
|
||||
required
|
||||
minlength="10"
|
||||
maxlength="5000"
|
||||
placeholder={c.messaggio.placeholder}
|
||||
aria-describedby="cf-messaggio-err"
|
||||
/>
|
||||
<p class="field__error" id="cf-messaggio-err" hidden />
|
||||
</div>
|
||||
|
||||
<div class="contact-form__trap" aria-hidden="true">
|
||||
<label for="cf-sito">Lascia vuoto questo campo</label>
|
||||
<input id="cf-sito" name="sito_web" type="text" tabindex="-1" autocomplete="off" />
|
||||
</div>
|
||||
<input type="hidden" name="ts" value="" data-form-ts />
|
||||
|
||||
<div class="consent">
|
||||
<input
|
||||
id="cf-privacy"
|
||||
name="privacy"
|
||||
type="checkbox"
|
||||
value="1"
|
||||
required
|
||||
aria-describedby="cf-privacy-err"
|
||||
/>
|
||||
<label for="cf-privacy">
|
||||
{modulo.consenso.prima}
|
||||
<a href="/privacy-policy/">{modulo.consenso.link}</a>
|
||||
{modulo.consenso.dopo} <span aria-hidden="true">*</span>
|
||||
</label>
|
||||
</div>
|
||||
<p class="field__error" id="cf-privacy-err" hidden />
|
||||
|
||||
<button class="btn btn--primary btn--block" type="submit">
|
||||
{modulo.invia}
|
||||
<Icon name="arrow-right" size={18} />
|
||||
</button>
|
||||
|
||||
<p class="contact-form__note">
|
||||
{modulo.informativa} <a href="/privacy-policy/">Privacy policy</a>.
|
||||
</p>
|
||||
<p class="contact-form__note">{modulo.nota}</p>
|
||||
</form>
|
||||
)}
|
||||
|
||||
{mode !== 'off' && <script>
|
||||
import '../scripts/form';
|
||||
</script>}
|
||||
|
||||
<style>
|
||||
.mail-card,
|
||||
.contact-form {
|
||||
padding: var(--space-6);
|
||||
background: var(--white);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-md);
|
||||
}
|
||||
|
||||
.mail-card h2,
|
||||
.contact-form h2 {
|
||||
font-size: 1.5rem;
|
||||
margin-bottom: 0.4rem;
|
||||
}
|
||||
|
||||
.mail-card > p {
|
||||
color: var(--ink-600);
|
||||
}
|
||||
|
||||
.mail-card .btn {
|
||||
margin-block: var(--space-3);
|
||||
overflow-wrap: anywhere;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.mail-card__note {
|
||||
margin: 0;
|
||||
font-size: var(--fs-sm);
|
||||
}
|
||||
|
||||
.contact-form__intro {
|
||||
color: var(--ink-600);
|
||||
font-size: var(--fs-sm);
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.contact-form__summary {
|
||||
margin-bottom: var(--space-4);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
border: 1px solid var(--error);
|
||||
border-left-width: 4px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: #fdf3f2;
|
||||
color: var(--ink-900);
|
||||
font-size: var(--fs-sm);
|
||||
}
|
||||
|
||||
.contact-form__summary p {
|
||||
margin: 0 0 0.25rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.contact-form__summary ul {
|
||||
padding-left: 1.2rem;
|
||||
}
|
||||
|
||||
.contact-form__summary a {
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
.field {
|
||||
display: grid;
|
||||
gap: 0.4rem;
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.field label {
|
||||
font-size: var(--fs-sm);
|
||||
font-weight: 600;
|
||||
color: var(--ink-700);
|
||||
}
|
||||
|
||||
.field label span,
|
||||
.consent label span {
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
.field input,
|
||||
.field textarea {
|
||||
width: 100%;
|
||||
min-height: var(--tap);
|
||||
padding: 0.75rem 0.95rem;
|
||||
border-radius: var(--radius-sm);
|
||||
border: 1px solid #b9c3cf;
|
||||
background: var(--white);
|
||||
color: var(--ink-900);
|
||||
font-size: var(--fs-sm);
|
||||
}
|
||||
|
||||
.field input::placeholder,
|
||||
.field textarea::placeholder {
|
||||
color: var(--ink-600);
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.field input:focus,
|
||||
.field textarea:focus {
|
||||
border-color: var(--navy-700);
|
||||
box-shadow: 0 0 0 4px var(--navy-100);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.field input[aria-invalid='true'],
|
||||
.field textarea[aria-invalid='true'] {
|
||||
border-color: var(--error);
|
||||
}
|
||||
|
||||
.field textarea {
|
||||
min-height: 140px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.field__row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0 var(--space-4);
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.field__row {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
.field__error {
|
||||
margin: 0;
|
||||
color: var(--error);
|
||||
font-size: var(--fs-xs);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.contact-form__trap {
|
||||
position: absolute;
|
||||
left: -10000px;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.consent {
|
||||
display: flex;
|
||||
gap: 0.65rem;
|
||||
align-items: flex-start;
|
||||
margin: var(--space-4) 0 var(--space-2);
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--ink-600);
|
||||
}
|
||||
|
||||
.consent input {
|
||||
flex: none;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
margin-top: 0.1rem;
|
||||
accent-color: var(--navy-800);
|
||||
}
|
||||
|
||||
.consent label {
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.contact-form .btn {
|
||||
margin-top: var(--space-4);
|
||||
}
|
||||
|
||||
.contact-form__legend {
|
||||
margin: 0 0 var(--space-5);
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--ink-600);
|
||||
}
|
||||
|
||||
.contact-form__note {
|
||||
margin: var(--space-3) 0 0;
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--ink-600);
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user