Day 11 - Component Challenge

Challenge UI with Livewire & Alpine.js

Day 11

Day 11

Date Picker & Stat Card

Native Alpine.js date picker and dashboard statistics cards

Stat Cards

Dashboard statistics cards for displaying key metrics with trend indicators.

Features

  • Dynamic icon support (Lucide)
  • Trend indicators (up/down)
  • 5 color variants
  • Optional slot for extra content

Dashboard Example

Revenus Total

2.450.000 FCFA

+12.5% vs mois dernier

Nouveaux Clients

1,247

+8.2% vs mois dernier

Commandes

3,892

-3.1% vs mois dernier

Taux de Conversion

4.28%

+0.5% vs mois dernier

With Extra Content

Ventes du Jour

845.000 FCFA

+23%
Objectif journalier 1.000.000 FCFA

Date Picker

Native Alpine.js date picker with French locale - no external dependencies.

Features

  • 100% Alpine.js (no dependencies)
  • wire:model support
  • French locale by default
  • Min/Max date constraints
  • Today button
  • Clearable input

With Livewire Binding

Valeur: Aucune

With Date Constraints

minDate: aujourd'hui (dates passées désactivées)

Sizes

Disabled State

Usage Examples

Stat Card Usage

Stat Card Component

The <x-ui.stat-card> component displays key metrics with trend indicators. 100% Tailwind CSS.

Basic Usage

<x-ui.stat-card
title="Total Revenue"
value="2.450.000 FCFA"
icon="wallet"
/>

With Trend Indicator

<x-ui.stat-card
title="New Users"
value="1,247"
icon="users"
trend="up"
trendValue="+12.5%"
trendLabel="vs last month"
/>
 
<x-ui.stat-card
title="Bounce Rate"
value="32.5%"
icon="trending-down"
trend="down"
trendValue="-5.2%"
/>

Variants

{{-- Default --}}
<x-ui.stat-card title="Default" value="100" variant="default" />
 
{{-- Primary --}}
<x-ui.stat-card title="Primary" value="200" variant="primary" icon="star" />
 
{{-- Success --}}
<x-ui.stat-card title="Success" value="300" variant="success" icon="check" />
 
{{-- Warning --}}
<x-ui.stat-card title="Warning" value="400" variant="warning" icon="alert-triangle" />
 
{{-- Danger --}}
<x-ui.stat-card title="Danger" value="500" variant="danger" icon="x-circle" />

With Extra Content (Slot)

<x-ui.stat-card
title="Daily Sales"
value="845.000 FCFA"
icon="credit-card"
trend="up"
trendValue="+23%"
variant="success"
>
{{-- Progress bar --}}
<div class="flex items-center justify-between text-sm">
<span class="text-muted-foreground">Daily Goal</span>
<span class="font-medium">1.000.000 FCFA</span>
</div>
<div class="mt-2 h-2 bg-muted rounded-full overflow-hidden">
<div class="h-full bg-green-500" style="width: 84.5%"></div>
</div>
</x-ui.stat-card>

Props Reference

Prop Type Default Description
title string '' Card title
value string '0' Main metric value
icon string 'activity' Lucide icon name
trend string null 'up', 'down', or null
trendValue string '' Trend percentage text
trendLabel string '' Additional trend context
variant string 'default' Color variant

Date Picker Usage

Date Picker Component

The <x-ui.date-picker> component provides native date selection with Alpine.js. 100% Tailwind CSS, no external dependencies.

Basic Usage

<x-ui.date-picker placeholder="Select a date" />

With Livewire Binding

{{-- In your Livewire component --}}
public string $selectedDate = '';
 
{{-- In your blade view --}}
<x-ui.date-picker
wire:model.live="selectedDate"
placeholder="Choose a date"
/>

With Date Constraints

{{-- Only future dates --}}
<x-ui.date-picker
minDate="{{ now()->format('Y-m-d') }}"
placeholder="Future dates only"
/>
 
{{-- Date range --}}
<x-ui.date-picker
minDate="2025-01-01"
maxDate="2025-12-31"
placeholder="2025 only"
/>

Sizes

<x-ui.date-picker size="sm" placeholder="Small" />
<x-ui.date-picker size="md" placeholder="Medium" />
<x-ui.date-picker size="lg" placeholder="Large" />

Custom Icon

<x-ui.date-picker
icon="calendar-check"
placeholder="With custom icon"
/>

Disabled State

<x-ui.date-picker
:disabled="true"
placeholder="Disabled"
/>

Props Reference

Prop Type Default Description
placeholder string 'Sélectionner une date' Input placeholder
disabled bool false Disable input
icon string 'calendar' Lucide icon name
clearable bool true Show clear button
size string 'md' 'sm', 'md', 'lg'
minDate string null Minimum date (Y-m-d format)
maxDate string null Maximum date (Y-m-d format)

Events

{{-- Listen to change event --}}
<x-ui.date-picker
@change="console.log($event.detail)"
/>
 
{{-- Listen to clear event --}}
<x-ui.date-picker
@clear="handleClear()"
/>