++ fix e controlli
This commit is contained in:
61
resources/views/components/btn.blade.php
Normal file
61
resources/views/components/btn.blade.php
Normal file
@@ -0,0 +1,61 @@
|
||||
{{--
|
||||
Pulsante unico dell'applicazione.
|
||||
|
||||
Esiste per un motivo preciso: prima ogni pagina si scriveva i propri
|
||||
pulsanti, e in quattro modi diversi — style= inline con i colori a mano (piu'
|
||||
onmouseover per l'hover), catene di utility Tailwind ripetute a memoria,
|
||||
.btn-action* in sei tinte, .btn-primary-* in due. La stessa azione cambiava
|
||||
aspetto da una pagina all'altra, e nessuno di quei pulsanti aveva uno stato
|
||||
di focus. Le classi stanno in resources/css/app.css.
|
||||
|
||||
variante:
|
||||
primary l'azione principale. Una sola per schermata o per zona.
|
||||
secondary tutto il resto: dettaglio, modifica, scarica, filtra.
|
||||
danger SOLO dove si cancellano o si sovrascrivono dati.
|
||||
ghost annulla, chiudi, pulisci.
|
||||
|
||||
tono:
|
||||
solido il pieno (default). Per le azioni isolate.
|
||||
tenue la tinta chiara. Per le azioni dentro le righe di un elenco,
|
||||
dove cinquanta pulsanti pieni diventano rumore.
|
||||
velato per i comandi sopra una superficie colorata (la testata). Il
|
||||
colore lo dà lo sfondo; qui `variante` non ha effetto.
|
||||
|
||||
dimensione: sm per le righe di elenco.
|
||||
icona: true per i pulsanti di sola icona. Richiede un aria-label,
|
||||
altrimenti chi usa un lettore di schermo trova un pulsante
|
||||
senza nome — title non basta.
|
||||
|
||||
Con href rende un <a>, altrimenti un <button type=button> — il tipo si puo'
|
||||
sovrascrivere (type=submit) come qualsiasi altro attributo.
|
||||
|
||||
ATTENZIONE, per disabilitarlo: si scrive :disabled="$condizione", NON
|
||||
@disabled($condizione). Dentro un tag di componente le direttive Blade non
|
||||
vengono compilate: il tag <x-btn> resta letterale nel PHP generato mentre il
|
||||
</x-btn> viene invece chiuso, e la vista muore con "syntax error, unexpected
|
||||
token endif". Il binding funziona come ci si aspetta perche' la borsa degli
|
||||
attributi salta i valori false e rende disabled="disabled" per i true.
|
||||
--}}
|
||||
@props([
|
||||
'variante' => 'secondary',
|
||||
'tono' => 'solido',
|
||||
'dimensione' => null,
|
||||
'icona' => false,
|
||||
'href' => null,
|
||||
])
|
||||
|
||||
@php
|
||||
$classi = implode(' ', array_filter([
|
||||
'tm-btn',
|
||||
'tm-btn-' . $variante,
|
||||
in_array($tono, ['tenue', 'velato'], true) ? 'tm-btn-' . $tono : null,
|
||||
$dimensione === 'sm' ? 'tm-btn-sm' : null,
|
||||
$icona ? 'tm-btn-icona' : null,
|
||||
]));
|
||||
@endphp
|
||||
|
||||
@if ($href)
|
||||
<a href="{{ $href }}" {{ $attributes->class($classi) }}>{{ $slot }}</a>
|
||||
@else
|
||||
<button type="{{ $attributes->get('type', 'button') }}" {{ $attributes->except('type')->class($classi) }}>{{ $slot }}</button>
|
||||
@endif
|
||||
@@ -15,12 +15,13 @@
|
||||
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
||||
<div class="flex h-16 items-center justify-between">
|
||||
<div class="flex items-center gap-3">
|
||||
<button @click="sidebarOpen = !sidebarOpen" class="lg:hidden text-white p-2 rounded-lg" style="background:rgba(255,255,255,0.1)"
|
||||
x-data x-on:click="$dispatch('toggle-sidebar')">
|
||||
<svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<x-btn tono="velato" icona class="lg:hidden"
|
||||
x-data x-on:click="$dispatch('toggle-sidebar')"
|
||||
aria-label="Apri il menu di navigazione">
|
||||
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true" style="width:22px;height:22px">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"/>
|
||||
</svg>
|
||||
</button>
|
||||
</x-btn>
|
||||
@php $settings = \App\Models\Setting::first(); @endphp
|
||||
@if($settings && $settings->logo_path)
|
||||
<img src="{{ asset('storage/' . $settings->logo_path) }}" alt="Logo" class="h-9 w-9 rounded-lg shadow-sm" style="border:2px solid rgba(255,255,255,0.3)">
|
||||
@@ -32,21 +33,20 @@
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<a href="{{ route('profile') }}" title="Il mio profilo"
|
||||
class="hidden sm:flex items-center gap-2 px-3 py-1.5 rounded-lg transition {{ request()->routeIs('profile') ? 'ring-1 ring-white/40' : '' }}"
|
||||
style="background:rgba(255,255,255,0.1)" onmouseover="this.style.background='rgba(255,255,255,0.2)'" onmouseout="this.style.background='rgba(255,255,255,0.1)'">
|
||||
<svg class="h-5 w-5 flex-none" style="color:rgba(255,255,255,0.7)" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/></svg>
|
||||
<x-btn tono="velato" dimensione="sm" :href="route('profile')" title="Il mio profilo"
|
||||
class="hidden sm:flex {{ request()->routeIs('profile') ? 'ring-1 ring-white/40' : '' }}">
|
||||
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true" style="width:20px;height:20px;opacity:.75"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/></svg>
|
||||
<span class="flex flex-col leading-tight text-left">
|
||||
<span class="text-sm font-medium" style="color:rgba(255,255,255,0.95)">{{ auth()->user()->name }}</span>
|
||||
<span class="text-xs" style="color:rgba(255,255,255,0.6)">{{ auth()->user()->email }} · {{ ucfirst(auth()->user()->roles->first()?->name ?? 'utente') }}</span>
|
||||
<span class="text-sm font-medium">{{ auth()->user()->name }}</span>
|
||||
<span class="text-xs" style="opacity:.7">{{ auth()->user()->email }} · {{ ucfirst(auth()->user()->roles->first()?->name ?? 'utente') }}</span>
|
||||
</span>
|
||||
</a>
|
||||
</x-btn>
|
||||
<form method="POST" action="{{ route('logout') }}">
|
||||
@csrf
|
||||
<button type="submit" class="flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-lg transition" style="color:rgba(255,255,255,0.8);background:rgba(255,255,255,0.1)" onmouseover="this.style.background='rgba(255,255,255,0.2)'" onmouseout="this.style.background='rgba(255,255,255,0.1)'">
|
||||
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"/></svg>
|
||||
<x-btn tono="velato" dimensione="sm" type="submit">
|
||||
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"/></svg>
|
||||
Esci
|
||||
</button>
|
||||
</x-btn>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -192,9 +192,10 @@
|
||||
class="mb-4 rounded-lg p-4 text-sm border flex items-center gap-3" style="background:#fef2f2;border-color:#fecaca;color:#991b1b">
|
||||
<svg class="h-5 w-5 flex-shrink-0" style="color:#ef4444" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
|
||||
{{ session('error') }}
|
||||
<button @click="show = false" class="ml-auto" style="color:#991b1b;opacity:0.5" onmouseover="this.style.opacity='1'" onmouseout="this.style.opacity='0.5'">
|
||||
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
|
||||
</button>
|
||||
<x-btn variante="ghost" dimensione="sm" icona class="ml-auto"
|
||||
@click="show = false" aria-label="Chiudi il messaggio">
|
||||
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
|
||||
</x-btn>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user