defmodule Raxol.Examples.Showcase do @moduledoc """ Interactive component showcase demonstrating all Raxol components. Run with: mix raxol.examples showcase """ use Raxol.Core.Runtime.Application import Raxol.LiveView, only: [assign: 2, assign: 3, update_in: 3, put_in: 3] alias Raxol.UI.Components.{ Box, Text, Button, TextInput, Select, Table, ProgressBar, Tabs } @components [ %{id: "text", name: "Text & Typography", icon: "[TEXT]"}, %{id: "buttons", name: "Buttons", icon: "[BTN]"}, %{id: "inputs", name: "Form Inputs", icon: "[FORM]"}, %{id: "layout", name: "Layout", icon: "[LAYOUT]"}, %{id: "data", name: "Data Display", icon: "[DATA]"}, %{id: "feedback", name: "Feedback", icon: "[CHAT]"}, %{id: "navigation", name: "Navigation", icon: "[NAV]"}, %{id: "advanced", name: "Advanced", icon: "[ADV]"} ] @impl true def mount(_params, socket) do {:ok, socket |> assign(selected_component: "text") |> assign(theme: "dark") |> assign(demo_state: initial_demo_state())} end defp initial_demo_state do %{ # Text demo text_style: "normal", # Button demo button_variant: "primary", button_clicks: 0, # Input demo text_value: "", select_value: nil, checkbox_value: false, radio_value: "option1", # Table demo table_data: generate_sample_data(), selected_row: nil, # Progress demo progress_value: 65, # Tabs demo active_tab: "overview" } end @impl true def render(assigns) do ~H""" <%= get_component_title(@selected_component) %> <%= render_component_demo(@selected_component, @demo_state, assigns) %> Example Code <%= get_component_code(@selected_component) %> """ end # Component Demos defp render_component_demo("text", state, assigns) do ~H""" Normal text Bold text Italic text Underlined text Strikethrough text Colored text Text with background Small text Large text Heading 1 Heading 2 Heading 3 const example = "inline code"; function hello(name) { console.log(`Hello, ${name}!`); } """ end defp render_component_demo("buttons", state, assigns) do ~H""" """ end defp render_component_demo("inputs", state, assigns) do ~H"""