Add project-specific UI checklist, component organization, LiveView structure, toast patterns, and routing conventions above the usage-rules managed section. Widen trigger description.
5.0 KiB
name, description, metadata
| name | description | metadata | ||
|---|---|---|---|---|
| ui-framework | Use this skill when working with LiveViews, UI components using the Phoenix framework, and in general ANY FILE THAT CONTAINS HTML. Use proactively when editing .heex files, LiveView modules, LiveComponents, or any component module under lib/music_library_web/components/. |
|
Project UI Conventions
Before writing or modifying UI code, follow these project-specific rules. They take precedence over the generic reference material below.
Checklist
-
Gettext all user-facing strings. Every string visible to users must be wrapped in
gettext/1orpgettext/2. After adding new strings, runmix gettext.extract --mergeto update.pot/.pofiles. -
Dark mode always paired. Every color class needs its dark variant:
text-zinc-900 dark:text-zinc-100,bg-zinc-50 dark:bg-zinc-800, etc. -
Wishlisted items get dimmed styling:
opacity-60 hover:opacity-100 transition-opacity. -
Icons inside buttons use the
iconclass — not explicit size classes likeh-5 w-5orsize-3.5. Fluxon auto-sizes icons based on the button'ssizeprop. -
Artist names use
joinphrasefrom MusicBrainz — never join artist names with a literal", ". -
Streams for all collections. Use LiveView streams, not list assigns. See the LiveView reference below for stream patterns.
Component organization
- Generic UI →
CoreComponents - Record-specific →
RecordComponents - Scrobble-specific →
ScrobbleComponents - Search-specific →
SearchComponents - Stats-specific →
StatsComponents,ChartComponents - Extract a function component when identical markup appears in 3+ places.
LiveView structure
mount/3sets@current_sectionhandle_params/3loads data and sets@page_title(via pattern-matched privatepage_title/2)handle_info/2receives LiveComponent messages- LiveComponents communicate with parent via
send(self(), {__MODULE__, msg})
Toast notifications
- In LiveViews:
put_toast(socket, :info, "message")(arity 3) - In LiveComponents:
put_toast!(:info, "message")(arity 2) - User-facing error reasons go through
ErrorMessages.friendly_message/1— neverinspect(reason)
Routes
- Three routes per resource with show modals:
:show,:edit(at/show/edit),:add_* - Modals close via
JS.patchback to the base route - Search state in URL query params via
push_patch - Conditional links:
purchased_atdetermines/collection/vs/wishlist/paths
Fluxon components
Read references/fluxon.md when you need to use a specific Fluxon component —
it contains the full attribute/slot API for each component. You can also search with:
mix usage_rules.search_docs "component_name" -p fluxon
Additional References
- ecto
- elixir
- html
- liveview
- phoenix
- phoenix_ecto
- phoenix_html
- phoenix_live_dashboard
- phoenix_live_reload
- phoenix_live_view
- fluxon
Searching Documentation
mix usage_rules.search_docs "search term" -p phoenix -p phoenix_ecto -p phoenix_html -p phoenix_live_dashboard -p phoenix_live_reload -p phoenix_live_view -p fluxon
Available Mix Tasks
mix compile.phoenixmix phx- Prints Phoenix help informationmix phx.digest- Digests and compresses static filesmix phx.digest.clean- Removes old versions of static assets.mix phx.gen- Lists all available Phoenix generatorsmix phx.gen.auth- Generates authentication logic for a resourcemix phx.gen.auth.hashing_librarymix phx.gen.auth.injectormix phx.gen.auth.migrationmix phx.gen.cert- Generates a self-signed certificate for HTTPS testingmix phx.gen.channel- Generates a Phoenix channelmix phx.gen.context- Generates a context with functions around an Ecto schemamix phx.gen.embedded- Generates an embedded Ecto schema filemix phx.gen.html- Generates context and controller for an HTML resourcemix phx.gen.json- Generates context and controller for a JSON resourcemix phx.gen.live- Generates LiveView, templates, and context for a resourcemix phx.gen.notifier- Generates a notifier that delivers emails by defaultmix phx.gen.presence- Generates a Presence trackermix phx.gen.release- Generates release files and optional Dockerfile for release-based deploymentsmix phx.gen.schema- Generates an Ecto schema and migration filemix phx.gen.secret- Generates a secretmix phx.gen.socket- Generates a Phoenix socket handlermix phx.routes- Prints all routesmix phx.server- Starts applications and their serversmix compile.phoenix_live_viewmix phoenix_live_view.upgrade