Skip to content

Commit 20198d6

Browse files
0.6.0 (#38)
1 parent 969e1a6 commit 20198d6

24 files changed

Lines changed: 427 additions & 328 deletions

File tree

.claude/skills/layered-ui-rails/SKILL.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ bin/rails generate layered:ui:install
2222

2323
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`.
2424

25-
Then render the engine layout from your application layout:
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:
2626

2727
```erb
28+
<% content_for :l_ui_body_class, "l-ui-body--always-show-navigation" %>
29+
30+
<% content_for :l_ui_navigation_items do %>
31+
<%= l_ui_navigation_item("Dashboard", dashboard_path) %>
32+
<%= l_ui_navigation_item("Users", users_path) %>
33+
<% end %>
34+
2835
<%= render template: "layouts/layered_ui/application" %>
2936
```
3037

@@ -34,7 +41,7 @@ The engine layout provides a fixed header (63px), optional sidebar navigation (2
3441

3542
### Content blocks
3643

37-
Populate layout regions with `content_for`:
44+
Populate layout regions with `content_for` (always above the render call):
3845

3946
```erb
4047
<%# Navigation sidebar items %>
@@ -139,7 +146,7 @@ All controllers use the `l-ui--` namespace and are auto-registered via importmap
139146
| Panel resize | `l-ui--panel-resize` | Panel width drag handle |
140147
| Modal | `l-ui--modal` | Native `<dialog>` with focus trap |
141148
| Tabs | `l-ui--tabs` | Accessible tabbed interface |
142-
| Search form | `l-ui--search-form` | Multi-scope search with Turbo support |
149+
| Search form | `l-ui--search-form` | Multi-scope search with Turbo support and pagination param preservation |
143150

144151
## Theming
145152

@@ -157,7 +164,7 @@ Override CSS custom properties after the engine import. Values are space-separat
157164
}
158165
```
159166

160-
Key tokens: `--accent`, `--accent-foreground`, `--background`, `--foreground`, `--foreground-muted`, `--border`, `--border-control`, `--surface`, `--surface-active`, `--danger`, `--header-height`.
167+
Key tokens: `--accent`, `--accent-foreground`, `--background`, `--foreground`, `--foreground-muted`, `--border`, `--border-control`, `--surface`, `--surface-highlighted`, `--danger`, `--header-height`.
161168

162169
## Asset overrides
163170

@@ -167,7 +174,7 @@ Place files in `app/assets/images/layered_ui/` to replace engine defaults:
167174

168175
## Optional integrations
169176

170-
- **Devise** - auto-detected. Provides styled auth views, header login/register buttons, sidebar user info and logout.
177+
- **Devise** - auto-detected. Provides styled auth views, header login/register buttons, sidebar user info and logout. Setup: `bundle add devise`, run `devise:install` and `devise User` generators, add `devise_for :users` to routes. Configure `Layered::Ui.current_user_method` if not using `:current_user`. Helpers: `l_ui_devise_installed?`, `l_ui_user_signed_in?`.
171178
- **Pagy** - auto-detected. Use `l_ui_pagy(@pagy)` for styled pagination.
172179
- **Ransack** - auto-detected. Use `l_ui_search_form` and `l_ui_sort_link` for styled search and sortable tables.
173180

.claude/skills/layered-ui-rails/references/CONTROLLERS.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Drag handle for resizing the panel width on desktop.
139139
Manages multi-scope search forms with parameter preservation and Turbo frame support.
140140

141141
**Values:** `scope` (String, default `"q"`)
142-
**Actions:** `preserve`, `clear`
142+
**Actions:** `preserve`, `clear`, `rewriteLink`
143143

144144
```html
145145
<form data-controller="l-ui--search-form"
@@ -153,4 +153,17 @@ Manages multi-scope search forms with parameter preservation and Turbo frame sup
153153
</form>
154154
```
155155

156-
When multiple search forms exist on one page (each with a different `scope` value), submitting one form automatically preserves the other forms' query parameters.
156+
When multiple search forms exist on one page (each with a different `scope` value), submitting one form automatically preserves the other forms' query parameters. The `page` param and any scoped page param matching the scope (e.g. `users_page` for scope `users_q`) are reset on submit so pagination returns to page 1.
157+
158+
**`rewriteLink`** - merges current URL params into a clicked link's href. Useful for pagination links inside Turbo Frames where the server-rendered href may be missing params from other scopes. Attach to a parent element (e.g. the Turbo Frame):
159+
160+
```html
161+
&lt;%= turbo_frame_tag "users_collection", data: { turbo_action: "advance",
162+
controller: "l-ui--search-form", l_ui__search_form_scope_value: "users_q",
163+
action: "click->l-ui--search-form#rewriteLink" } do %&gt;
164+
&lt;%= l_ui_search_form(@users_q, url: users_path, fields: [:name, :email],
165+
clear: true, turbo_frame: "users_collection") %&gt;
166+
&lt;%= l_ui_table(@users, ..., query: @users_q, turbo_frame: "users_collection") %&gt;
167+
&lt;%= l_ui_pagy(@users_pagy) %&gt;
168+
&lt;% end %&gt;
169+
```

0 commit comments

Comments
 (0)