Commit b537388
committed
[Refactor] Clone Toast slot buttons from <template> targets
Drops ~25 lines of hardcoded Tailwind classes from toaster_controller.js.
Phlex now owns the single source of truth for ToastAction, ToastCancel,
and ToastClose styling.
- Region renders three additional <template>s next to the variant
skeletons: actionTpl, cancelTpl, closeTpl. Each renders the
corresponding Phlex component once, with default classes.
- Toaster controller declares actionTplTarget / cancelTplTarget /
closeTplTarget. _spawn clones from these instead of building DOM
elements with hand-written className strings.
- _cloneSlot helper centralizes the clone-firstElementChild pattern.
Both delivery paths benefit from a single Tailwind source:
- Server-pushed (Turbo Stream append) — already used Phlex Items
end-to-end; unchanged.
- Client-spawned (window.RubyUI.toast.*) — now also Phlex-sourced.
Update Tailwind/style tweaks in Action/Cancel/Close .rb files and JS
picks them up automatically; @source scan continues to see the
classes in the gem files.1 parent b668372 commit b537388
3 files changed
Lines changed: 29 additions & 40 deletions
File tree
- docs/app/javascript/controllers/ruby_ui
- gem/lib/ruby_ui/toast
Lines changed: 11 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
| 120 | + | |
| 121 | + | |
125 | 122 | | |
126 | 123 | | |
127 | 124 | | |
| |||
131 | 128 | | |
132 | 129 | | |
133 | 130 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 131 | + | |
| 132 | + | |
140 | 133 | | |
141 | 134 | | |
142 | 135 | | |
143 | 136 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 137 | + | |
| 138 | + | |
152 | 139 | | |
153 | 140 | | |
154 | 141 | | |
| |||
172 | 159 | | |
173 | 160 | | |
174 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
175 | 166 | | |
176 | 167 | | |
177 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| |||
75 | 78 | | |
76 | 79 | | |
77 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
78 | 85 | | |
79 | 86 | | |
80 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
| 120 | + | |
| 121 | + | |
125 | 122 | | |
126 | 123 | | |
127 | 124 | | |
| |||
131 | 128 | | |
132 | 129 | | |
133 | 130 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 131 | + | |
| 132 | + | |
140 | 133 | | |
141 | 134 | | |
142 | 135 | | |
143 | 136 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 137 | + | |
| 138 | + | |
152 | 139 | | |
153 | 140 | | |
154 | 141 | | |
| |||
172 | 159 | | |
173 | 160 | | |
174 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
175 | 166 | | |
176 | 167 | | |
177 | 168 | | |
| |||
0 commit comments