Skip to content

Commit 28a32b8

Browse files
committed
Reimplement flash component with popover and z-order fix
1 parent db43746 commit 28a32b8

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
- Extract dual range to dual_range component
88
- Add card-check to card.css
99
- Flash add animation-play-state stop on hover
10-
- Use".input" for "checkbox, radio and range".
10+
- Use".input" for "checkbox, radio and range"
11+
- Reimplement flash component (Fix z-order)
1112

1213
## 2.0.3 - 2025-08-08
1314
- Fix command component accessibility issues

lib/generators/css_zero/add/resources.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ dual_range:
6767
- app/javascript/controllers/dual_range_controller.js
6868
flash:
6969
- app/assets/stylesheets/flash.css
70-
- app/javascript/controllers/element_removal_controller.js
70+
- app/javascript/controllers/flash_controller.js
7171
form:
7272
- app/javascript/controllers/form_controller.js
7373
fullscreen:

lib/generators/css_zero/add/templates/app/assets/stylesheets/flash.css

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
.flash {
2-
align-items: center;
32
animation: appear-then-fade 4s 300ms both;
43
background-color: var(--flash-background, var(--color-text));
54
border-radius: var(--rounded-full);
65
color: var(--flash-color, var(--color-text-reversed));
7-
column-gap: var(--size-2);
8-
display: inline-flex;
9-
font-size: var(--text-fluid-base);
10-
justify-content: center;
11-
line-height: var(--leading-none);
126
margin-block-start: var(--flash-position, var(--size-5));
137
margin-inline: auto;
14-
min-block-size: var(--size-11);
15-
padding: var(--size-1) var(--size-4);
16-
text-align: center;
178

189
&:is(:hover, :focus-within) {
1910
animation-play-state: paused;
@@ -24,6 +15,18 @@
2415
}
2516
}
2617

18+
.flash__content {
19+
align-items: center;
20+
column-gap: var(--size-2);
21+
display: flex;
22+
font-size: var(--text-fluid-base);
23+
justify-content: center;
24+
line-height: var(--leading-none);
25+
min-block-size: var(--size-11);
26+
padding: var(--size-1) var(--size-4);
27+
text-align: center;
28+
}
29+
2730
.flash--positive {
2831
--flash-color: light-dark(var(--green-400), var(--green-600));
2932
}

lib/generators/css_zero/add/templates/app/javascript/controllers/element_removal_controller.js renamed to lib/generators/css_zero/add/templates/app/javascript/controllers/flash_controller.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { Controller } from "@hotwired/stimulus"
22

33
export default class extends Controller {
4+
connect() {
5+
this.element.showPopover()
6+
}
7+
48
remove() {
5-
this.element.remove()
9+
this.element.hidePopover()
610
}
711
}

lib/generators/css_zero/install/templates/app/views/layouts/application.html.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838

3939
<main id="main">
4040
<%% if notice.present? %>
41-
<%%= tag.div notice, popover: "manual", class: "flash", style: "--flash-position: 5rem", data: { controller: "element-removal", action: "animationend->element-removal#remove", role: "alert" } %>
41+
<div popover="manual" class="flash" data-controller="flash" data-action="animationend->flash#hide" role="alert">
42+
<div class="flash__content"><%%= notice %></div>
43+
</div>
4244
<%% end %>
4345
<div class="container">
4446
<%%= yield %>

0 commit comments

Comments
 (0)