Current section
Files
Jump to
Current section
Files
lib/pyraui_web/live/docs/countdown_docs.ex
defmodule PyrauiWeb.DocsLive.CountdownDocs do
use PyrauiWeb, :html
def render(assigns) do
~H"""
<div class="text-gray-900">
<h1 class="text-4xl font-bold mb-4 text-gray-900">Countdown</h1>
<div class="mb-8">
<p class="text-gray-700 text-lg">
Countdown timer component for events, offers, or games. Updates in real-time and dispatches events when complete.
</p>
</div>
<div class="space-y-8">
<section>
<h2 class="text-2xl font-semibold mb-4 text-gray-900">Compact Format</h2>
<div class="bg-white p-6 rounded-lg border border-gray-200 mb-4 shadow-sm">
<Pyraui.Components.Countdown.countdown
id="docs-countdown-1"
target_date={@future_date}
format={:compact}
/>
</div>
<div class="bg-gray-100 p-4 rounded-lg overflow-x-auto border border-gray-200">
<pre class="text-gray-800"><code phx-no-curly-interpolation>
<.countdown id="sale-timer" target_date={~U[2024-12-31 23:59:59Z]} />
</code></pre>
</div>
</section>
<section>
<h2 class="text-2xl font-semibold mb-4 text-gray-900">Detailed Format</h2>
<div class="bg-white p-6 rounded-lg border border-gray-200 mb-4 shadow-sm">
<Pyraui.Components.Countdown.countdown
id="docs-countdown-2"
target_date={@future_date}
format={:detailed}
/>
</div>
<div class="bg-gray-100 p-4 rounded-lg overflow-x-auto border border-gray-200">
<pre class="text-gray-800"><code phx-no-curly-interpolation>
<.countdown id="event-timer" target_date={@event_date} format={:detailed} />
</code></pre>
</div>
</section>
<section>
<h2 class="text-2xl font-semibold mb-4 text-gray-900">With Completion Event</h2>
<div class="bg-gray-100 p-4 rounded-lg overflow-x-auto border border-gray-200">
<pre class="text-gray-800"><code phx-no-curly-interpolation>
<.countdown
id="timer"
target_date={@target_date}
on_complete="countdown-complete"
/>
</code></pre>
</div>
</section>
<section>
<h2 class="text-2xl font-semibold mb-4 text-gray-900">Props</h2>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200 border border-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase">
Prop
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase">
Type
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase">
Default
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase">
Description
</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">id</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">string</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">-</td>
<td class="px-6 py-4 text-sm text-gray-700">Unique ID for the countdown</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
target_date
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">
DateTime | NaiveDateTime | string
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">-</td>
<td class="px-6 py-4 text-sm text-gray-700">Target date/time for countdown</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
format
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">atom</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">:compact</td>
<td class="px-6 py-4 text-sm text-gray-700">
Display format (:compact or :detailed)
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
on_complete
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">string</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">nil</td>
<td class="px-6 py-4 text-sm text-gray-700">
Event name to dispatch when countdown completes
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</div>
"""
end
end