Skip to content

Pluggable UI component library with DaisyUI support#8

Open
jimsynz wants to merge 4 commits into
mainfrom
daisy
Open

Pluggable UI component library with DaisyUI support#8
jimsynz wants to merge 4 commits into
mainfrom
daisy

Conversation

@jimsynz
Copy link
Copy Markdown
Collaborator

@jimsynz jimsynz commented Mar 30, 2026

Summary

  • Add --css and --ui options to the installer for pluggable CSS framework and UI component library selection
  • DaisyUI is the new default (--ui daisy), matching Phoenix 1.8's phx.new output
  • Plain Tailwind available via --ui tailwind for users who don't want DaisyUI
  • Validates incompatible options (e.g. --ui daisy --css none)

Architecture

Follows the same pluggable pattern used for JavaScript bundlers:

CSS pipeline — each task creates its own CSS file and appends @import to app.css (Tailwind v4 flattens imports before processing directives):

  • assets/css.ex orchestrator selects CSS framework via --css flag
  • assets/css/tailwind.ex creates phx-tailwind.css with Tailwind foundation
  • html/daisy.ex creates phx-daisy.css with DaisyUI plugin/theme config
  • heroicons.ex creates phx-heroicons.css

HTML componentshtml.ex refactored into orchestrator + variants:

  • html/daisy.ex — DaisyUI components (toast flash, btn classes, fieldset inputs, theme toggle, dark/light theming, vendor JS downloaded from GitHub releases)
  • html/tailwind.ex — plain Tailwind components (previous behaviour)

Data display componentscomponents.ex refactored similarly:

  • components/daisy.ex — gettext-aware table actions
  • components/tailwind.ex — plain string table actions

Pagepage.ex dispatches to variant-specific homepage templates

Test plan

  • mix test — 174 tests pass (17 new, 0 failures)
  • Verify mix phx.install produces DaisyUI output matching .resources/example/
  • Verify mix phx.install --ui tailwind produces plain Tailwind output
  • Verify mix phx.install --ui daisy --css none fails with clear error
  • Manual test: generated DaisyUI app compiles and runs with theme toggle working
  • Manual test: generated Tailwind-only app compiles and runs

jimsynz added 4 commits March 30, 2026 15:07
Restructure the asset pipeline and HTML component generation to support
pluggable CSS frameworks (`--css`) and UI component libraries (`--ui`).

CSS pipeline:
- `assets.ex` creates a bare `app.css` shell
- New `assets/css.ex` orchestrator selects CSS framework dynamically
- `assets/css/tailwind.ex` creates `phx-tailwind.css` with Tailwind foundation
- Each task creates its own CSS file and appends `@import` to `app.css`
- Heroicons now creates `phx-heroicons.css` instead of inline string replacement

HTML components:
- `html.ex` refactored into orchestrator keeping shared infrastructure
  (ErrorHTML, web module helpers, browser pipeline)
- `html/tailwind.ex` provides plain Tailwind CSS components (extracted from html.ex)
- `html/daisy.ex` provides DaisyUI components matching `phx.new` output:
  toast-based flash, DaisyUI form inputs, navbar layout with theme toggle,
  dark/light theme support, vendor JS downloaded from GitHub releases
- `live.ex` passes `--ui` through to `html` composition

DaisyUI is the new default (`--ui daisy`), plain Tailwind available via
`--ui tailwind`.
- Refactor `components.ex` into orchestrator with `--ui` flag, delegating
  to `components/daisy.ex` (gettext-aware) and `components/tailwind.ex`
- Add `--css` and `--ui` options to main `phx.install` orchestrator and
  `phx_install.install` entry point
- Validate incompatible options: `--ui daisy --css none` produces a clear
  error via `Igniter.add_issue`
- Add `--ui` option to `page.ex` with DaisyUI homepage template using
  `badge`, `rounded-box`, `base-content`, theme toggle, and
  `Layouts.flash_group`
- Add tests for DaisyUI html, components, page, and validation paths
  (174 tests total, up from 157)
- README: add UI/CSS options section, update task table descriptions
- CLAUDE.md: document pluggable architecture, CSS composition, updated
  task dependency graph
- `phx_install.install.ex`: add --css and --ui to moduledoc options list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant