You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Serve engine CSS via tailwindcss-rails engine support (#88)
* Serve engine CSS via tailwindcss-rails engine support
Replace the copy-based CSS install with tailwindcss-rails' Rails engine
support: the engine's stylesheet is now imported straight from the gem,
so it stays in sync with the installed version instead of being copied
into the host app at install time.
- Move app/assets/tailwind/layered/ui/styles.css to the convention path
app/assets/tailwind/layered_ui/engine.css (engine_name is layered_ui)
- Remove CopyAssetsGenerator; ImportCssGenerator now injects
@import "../builds/tailwind/layered_ui";
- Switch the engine layout to stylesheet_link_tag "tailwind" so propshaft's
:app glob no longer emits a stray link to the generated intermediate file
- Update README, gemspec post-install message, SKILL.md, AGENTS.md, dummy
install docs, and CHANGELOG (flagging the breaking install-flow change)
Compiled output is byte-identical to the previous build; fonts and masked
SVG icons resolve unchanged. All tests pass.
* Build dummy Tailwind CSS before running tests
The engine layout now links the compiled build via
stylesheet_link_tag "tailwind", which propshaft requires to exist - unlike
the previous :app glob that silently tolerated a missing build. On a clean
checkout (e.g. CI) there is no app/assets/builds/tailwind.css, so the
integration tests raised "asset 'tailwind.css' was not found in the load
path". Make the test task depend on app:tailwindcss:build so the CSS (and
the engine entry point under builds/tailwind/) is compiled first.
* Update AGENTS/CLAUDE generator description for engine-support install flow
Copy file name to clipboardExpand all lines: .claude/skills/layered-ui-rails/SKILL.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ bundle add layered-ui-rails
20
20
bin/rails generate layered:ui:install
21
21
```
22
22
23
-
The generator copies `layered_ui.css` into `app/assets/tailwind/`, adds the CSS import to `application.css`, and adds the JS import to `application.js`.
23
+
The generator adds `@import "../builds/tailwind/layered_ui";` to `application.css` (the engine's CSS is served straight from the gem via tailwindcss-rails' engine support), creates a `layered_ui_overrides.css` file for theme customisations, and adds the JS import to `application.js`.
24
24
25
25
Then render the engine layout from your application layout. Place all `content_for` blocks **above** the render call - the engine layout reads them when it renders, so they must be defined first:
26
26
@@ -181,7 +181,7 @@ All controllers use the `l-ui--` namespace and are auto-registered via importmap
181
181
Override CSS custom properties after the engine import. Values are full CSS colors - `oklch()` is recommended for perceptually uniform mixing and consistent contrast, but `#hex`, `rgb()`, and keywords also work. A converter such as https://oklch.com/ can help translate from hex/rgb.
-**Tailwind classes not generated** - The host app's Tailwind build only sees classes in the host app's templates. Use `l-ui-` classes (which are in the copied CSS) rather than raw Tailwind utilities when styling engine-provided patterns.
221
-
-**Missing styles** - Ensure `@import "./layered_ui";` is in `app/assets/tailwind/application.css`.
220
+
-**Tailwind classes not generated** - The host app's Tailwind build only sees classes in the host app's templates. Use `l-ui-` classes (which are defined in the engine CSS) rather than raw Tailwind utilities when styling engine-provided patterns.
221
+
-**Missing styles** - Ensure `@import "../builds/tailwind/layered_ui";` is in `app/assets/tailwind/application.css`. The import resolves to a file generated by tailwindcss-rails' engine support; it is created automatically by `tailwindcss:build`/`watch` (and `assets:precompile`), so run a build (e.g. `bin/dev`) if the file is missing.
222
222
-**Missing JS controllers** - Ensure `import "layered_ui"` is in `app/javascript/application.js`.
-**CSS**`app/assets/tailwind/layered_ui/engine.css` (the tailwindcss-rails engine entry point): OKLCH tokens, `.dark` on `<html>`, `@theme` utilities (`bg-background`, etc.), BEM components (`.l-ui-button--primary`, etc.). Layout: 63px header, 256px sidebar, 320px panel. WCAG 2.2 AA.
10
10
-**CSS `@apply`:** Multi-line with grouping, following the Prettier Tailwind plugin order: layout → sizing → spacing → typography → backgrounds → borders → effects → transitions → interactivity. Within each group, follow Tailwind's own ordering (not alphabetical). State variants (`hover:`, `focus:`, `active:`, `disabled:`) and responsive prefixes (`sm:`, `md:`, `lg:`) are grouped with their base utility. Single utilities may stay on one line.
-`:l_ui_body_class` modifiers: `l-ui-body--always-show-navigation` (pins nav as sidebar on desktop), `l-ui-body--hide-header` (hides header and collapses its space)
Copy file name to clipboardExpand all lines: CHANGELOG.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,22 @@
2
2
3
3
All notable changes to this project will be documented in this file. This project follows [Semantic Versioning](https://semver.org/).
4
4
5
+
## [Unreleased]
6
+
7
+
### Changed
8
+
9
+
-**Breaking (install flow):** the engine's CSS is now served directly from the gem using [tailwindcss-rails' engine support](https://github.com/rails/tailwindcss-rails#rails-engines-support-experimental) instead of being copied into the host app. The install generator no longer creates `app/assets/tailwind/layered_ui.css`; instead it adds `@import "../builds/tailwind/layered_ui";` to your `application.css`. The CSS now stays in sync with the installed gem version automatically - no need to re-run the generator after upgrading.
10
+
- The engine layout now links the compiled Tailwind build explicitly (`stylesheet_link_tag "tailwind"`) rather than the `:app` bundle, matching tailwindcss-rails' own convention and avoiding a stray link to the engine's intermediate build file.
11
+
- Moved the engine's source stylesheet from `app/assets/tailwind/layered/ui/styles.css` to `app/assets/tailwind/layered_ui/engine.css` (the path tailwindcss-rails' engine support expects).
12
+
13
+
### Removed
14
+
15
+
-`CopyAssetsGenerator` (`layered:ui:copy_assets`), which copied the engine CSS into the host app. It is replaced by the engine-support import above.
16
+
17
+
### Migration
18
+
19
+
Re-run `bin/rails generate layered:ui:install` (it adds the new import without duplicating existing ones), then delete the now-unused copied file at `app/assets/tailwind/layered_ui.css` and remove its `@import "./layered_ui";` line from `application.css`. Your `layered_ui_overrides.css` and any customisations are unaffected.
-Add `@import "./layered_ui";` to your `application.css`
79
+
-Add `@import "../builds/tailwind/layered_ui";` to your `application.css` (the engine's CSS is served straight from the gem via [tailwindcss-rails' engine support](https://github.com/rails/tailwindcss-rails#rails-engines-support-experimental), so it stays in sync when you upgrade)
80
+
-Create `app/assets/tailwind/layered_ui_overrides.css` for your theme customisations (never overwritten on re-install)
81
81
- Add `import "layered_ui"` to your `application.js`
82
82
83
83
Then update your application layout to render the engine layout. Place any `content_for` blocks **above** the render call - the engine layout reads them when it renders, so they must be defined first:
@@ -101,7 +101,7 @@ All colors are CSS custom properties on `:root` using a two-tier system:
0 commit comments