css-zero 0.0.13 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9fa9b5a675b170c1792a89b840dea6339ee14768644531ec3a1d2b465068e4f5
4
- data.tar.gz: 165ee0886c7f61ffe76c06545b367c6b1c5a3cb883a49345433dd6965b748e6b
3
+ metadata.gz: 7304e9420f4574059f34a6be6f69f7dca6d94b3e2fd0be6d497cc59bdab99a52
4
+ data.tar.gz: ed1bc4913357f8eac01ab39cf26f05b60399bafd9c707520d1fb59853a55de5b
5
5
  SHA512:
6
- metadata.gz: f6c36eb3cc7eb625ee8ed8255bac1aaa409e30ae6202a3e1e6683df5f3be36c74f052d011ba49ed7fda0a1d91dc5fea3ef24aa15392e9ccf0b7c3b1431280dcb
7
- data.tar.gz: 52f6d8133c48e4b9e6fd0e6c57f844a7121a516d6cbef6fefac54a0db69759cf42224d9963431eabb05158d802b6a4f1271d869abf056988d034b9bced5d2120
6
+ metadata.gz: ac3e38e755a91f8b33a88f0880ceb12ff6a582a861bad0e5031147d070b0e794d779524b96e46bf4cc8640e002b8342f64b58c685afa76e04ae59c1f72484568
7
+ data.tar.gz: 82a577ab39f939842b1e1d1b30827f43cf692acb3cf6feeac56364793a8a6e95f0de33779971851d6ff17dfb7fc91a97d55348743674db3b309a682a0ac000da
data/README.md CHANGED
@@ -19,7 +19,7 @@ bin/rails generate css_zero:install
19
19
  Add only the components you need. (Optional)
20
20
 
21
21
  ```
22
- bin/rails generate css_zero:add accordion alert alert_dialog badge button card dialog input progress switch table
22
+ bin/rails generate css_zero:add accordion alert badge button card dialog input progress switch table
23
23
  ```
24
24
 
25
25
  ### Requirements
@@ -96,7 +96,7 @@ Check the [CSS files](app/assets/stylesheets) in the repository to see the avail
96
96
  <details>
97
97
  <summary>Show me the code</summary>
98
98
 
99
- ```html
99
+ ```html+erb
100
100
  <div class="accordion">
101
101
  <details name="my_accordion">
102
102
  <summary>Is it accessible?</summary>
@@ -132,32 +132,6 @@ Check the [CSS files](app/assets/stylesheets) in the repository to see the avail
132
132
  ```
133
133
  </details>
134
134
 
135
- ### Alert Dialog
136
-
137
- <img width="500" alt="alert_dialog" src="https://github.com/lazaronixon/css-zero/assets/2651240/483b00fc-0330-45b3-82c5-dc4118987564">
138
-
139
- <details>
140
- <summary>Show me the code</summary>
141
-
142
- ```html
143
- <div>
144
- <dialog id="my_alert_dialog" class="alert-dialog">
145
- <h1 class="text-lg font-semibold">Are you absolutely sure?</h1>
146
- <p class="text-sm text-subtle mbs-2">This action cannot be undone. This will permanently delete your account and remove your data from our servers.</p>
147
-
148
- <div class="flex justify-end gap-sm mbs-4">
149
- <form method="dialog"><button class="btn btn--outline">Cancel</button></form>
150
- <button class="btn btn--primary">Continue</button>
151
- </div>
152
- </dialog>
153
-
154
- <button class="btn" data-controller="dialog-control" data-dialog-control-target-value="my_alert_dialog" data-action="dialog-control#showModal">
155
- Show alert dialog
156
- </button>
157
- </div>
158
- ```
159
- </details>
160
-
161
135
  ### Badge
162
136
 
163
137
  <img width="400" alt="image" src="https://github.com/lazaronixon/css-zero/assets/2651240/6a700dc4-0fd5-46f6-9902-a9bde5f7febb">
@@ -165,7 +139,7 @@ Check the [CSS files](app/assets/stylesheets) in the repository to see the avail
165
139
  <details>
166
140
  <summary>Show me the code</summary>
167
141
 
168
- ```html
142
+ ```html+erb
169
143
  <div class="flex justify-start gap">
170
144
  <div class="badge">Badge</div>
171
145
  <div class="badge badge--secondary">Secondary</div>
@@ -183,7 +157,7 @@ Check the [CSS files](app/assets/stylesheets) in the repository to see the avail
183
157
  <details>
184
158
  <summary>Show me the code</summary>
185
159
 
186
- ```html
160
+ ```html+erb
187
161
  <div class="flex flex-wrap items-center gap" aria-busy>
188
162
  <button class="btn">Primary</button>
189
163
  <button class="btn btn--secondary">Secondary</button>
@@ -211,7 +185,7 @@ Check the [CSS files](app/assets/stylesheets) in the repository to see the avail
211
185
  <details>
212
186
  <summary>Show me the code</summary>
213
187
 
214
- ```html
188
+ ```html+erb
215
189
  <div class="card flex flex-col gap" style="width: 350px; gap: 1.5rem;">
216
190
  <div class="flex flex-col gap-sm">
217
191
  <h1 class="text-2xl font-semibold leading-none">Create project</h1>
@@ -245,19 +219,48 @@ Check the [CSS files](app/assets/stylesheets) in the repository to see the avail
245
219
 
246
220
  ### Dialog
247
221
 
248
- <img width="400" alt="dialog" src="https://github.com/lazaronixon/css-zero/assets/2651240/50c8af20-46bb-4bf9-a233-78877f49e086">
222
+ #### Alert Dialog
223
+
224
+ <img width="500" alt="alert_dialog" src="https://github.com/lazaronixon/css-zero/assets/2651240/483b00fc-0330-45b3-82c5-dc4118987564">
249
225
 
250
226
  <details>
251
227
  <summary>Show me the code</summary>
252
228
 
253
- ```html
254
- <artice class="flex flex-col pb-10 pi-2 mi-auto w-full" style="gap: 4rem; max-width: 32rem">
255
- <div>
256
- <dialog id="my_dialog" class="dialog" style="max-inline-size: 430px;" popover>
257
- <button class="btn btn--plain p-0 dialog__close" popovertarget="my_dialog" popovertargetaction="hide">
258
- <%= image_tag "x.svg", aria: { hidden: "true" }, size: 16 %>
259
- <span class="sr-only">Close</span>
260
- </button>
229
+ ```html+erb
230
+ <div data-controller="dialog">
231
+ <dialog data-dialog-target="box" class="dialog">
232
+ <h1 class="text-lg font-semibold">Are you absolutely sure?</h1>
233
+ <p class="text-sm text-subtle mbs-2">This action cannot be undone. This will permanently delete your account and remove your data from our servers.</p>
234
+
235
+ <div class="flex justify-end gap-sm mbs-4">
236
+ <form method="dialog"><button class="btn btn--outline">Cancel</button></form>
237
+ <button class="btn btn--primary">Continue</button>
238
+ </div>
239
+ </dialog>
240
+
241
+ <button class="btn" data-action="dialog#showModal">
242
+ Show dialog
243
+ </button>
244
+ </div>
245
+ ```
246
+ </details>
247
+
248
+ #### Dismissible Dialog
249
+
250
+ <img width="400" alt="dismissible_dialog" src="https://github.com/lazaronixon/css-zero/assets/2651240/50c8af20-46bb-4bf9-a233-78877f49e086">
251
+
252
+ <details>
253
+ <summary>Show me the code</summary>
254
+
255
+ ```html+erb
256
+ <div data-controller="dialog">
257
+ <dialog data-dialog-target="box" data-action="click->dialog#closeOnClickOutside" class="dialog" style="max-inline-size: 430px;">
258
+ <form method="dialog">
259
+ <button class="btn btn--plain p-0 dialog__close">
260
+ <%= image_tag "x.svg", aria: { hidden: "true" }, size: 16 %>
261
+ <span class="sr-only">Close</span>
262
+ </button>
263
+ </form>
261
264
 
262
265
  <div class="flex flex-col gap">
263
266
  <div class="flex flex-col gap-sm">
@@ -283,7 +286,7 @@ Check the [CSS files](app/assets/stylesheets) in the repository to see the avail
283
286
  </div>
284
287
  </dialog>
285
288
 
286
- <button class="btn" popovertarget="my_dialog">
289
+ <button class="btn" data-action="dialog#showModal">
287
290
  Show dialog
288
291
  </button>
289
292
  </div>
@@ -364,7 +367,7 @@ Check the [CSS files](app/assets/stylesheets) in the repository to see the avail
364
367
  <details>
365
368
  <summary>Show me the code</summary>
366
369
 
367
- ```html
370
+ ```html+erb
368
371
  <table class="table">
369
372
  <thead>
370
373
  <tr>
@@ -1,3 +1,3 @@
1
1
  module CssZero
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.15"
3
3
  end
@@ -2,7 +2,7 @@ Description:
2
2
  This will add components into your project.
3
3
 
4
4
  Components:
5
- accordion alert alert_dialog badge button card dialog input progress switch table
5
+ accordion alert badge button card dialog input progress switch table
6
6
 
7
7
  Example:
8
8
  bin/rails generate css_zero:add [components...]
@@ -3,9 +3,6 @@ accordion:
3
3
  - app/assets/images/chevron-down.svg
4
4
  alert:
5
5
  - app/assets/stylesheets/alert.css
6
- alert_dialog:
7
- - app/assets/stylesheets/alert_dialog.css
8
- - app/javascript/controllers/dialog_control_controller.js
9
6
  badge:
10
7
  - app/assets/stylesheets/badge.css
11
8
  button:
@@ -16,6 +13,7 @@ card:
16
13
  dialog:
17
14
  - app/assets/stylesheets/dialog.css
18
15
  - app/assets/images/x.svg
16
+ - app/javascript/controllers/dialog_controller.js
19
17
  input:
20
18
  - app/assets/stylesheets/input.css
21
19
  - app/assets/images/select-arrow.svg
@@ -7,6 +7,7 @@
7
7
  inline-size: var(--size-full);
8
8
  margin: auto;
9
9
  max-inline-size: var(--width-lg);
10
+ overflow: hidden;
10
11
  padding: var(--size-6);
11
12
 
12
13
  &::backdrop {
@@ -28,21 +29,21 @@
28
29
  }
29
30
 
30
31
  /* In animation */
31
- &:popover-open {
32
+ &[open] {
32
33
  opacity: 1; transform: var(--scale-100);
33
34
  }
34
35
 
35
- &:popover-open::backdrop {
36
+ &[open]::backdrop {
36
37
  opacity: 1;
37
38
  }
38
39
 
39
40
  /* Out animation */
40
41
  @starting-style {
41
- &:popover-open {
42
+ &[open] {
42
43
  opacity: 0; transform: var(--scale-95);
43
44
  }
44
45
 
45
- &:popover-open::backdrop {
46
+ &[open]::backdrop {
46
47
  opacity: 0;
47
48
  }
48
49
  }
@@ -59,6 +60,6 @@
59
60
  }
60
61
 
61
62
  /* Prevent page scroll when dialog is open */
62
- html:has(.dialog:popover-open) {
63
+ html:has(.dialog[open]) {
63
64
  overflow: hidden;
64
65
  }
@@ -0,0 +1,21 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static targets = [ "box" ]
5
+
6
+ show() {
7
+ this.boxTarget.show()
8
+ }
9
+
10
+ showModal() {
11
+ this.boxTarget.showModal()
12
+ }
13
+
14
+ close() {
15
+ this.boxTarget.close("dismiss")
16
+ }
17
+
18
+ closeOnClickOutside({ target }) {
19
+ if (target.nodeName === "DIALOG") this.close()
20
+ }
21
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lázaro Nixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-02 00:00:00.000000000 Z
11
+ date: 2024-07-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: lazaronixon@hotmail.com
@@ -43,7 +43,6 @@ files:
43
43
  - lib/generators/css_zero/add/templates/app/assets/images/x.svg
44
44
  - lib/generators/css_zero/add/templates/app/assets/stylesheets/accordion.css
45
45
  - lib/generators/css_zero/add/templates/app/assets/stylesheets/alert.css
46
- - lib/generators/css_zero/add/templates/app/assets/stylesheets/alert_dialog.css
47
46
  - lib/generators/css_zero/add/templates/app/assets/stylesheets/badge.css
48
47
  - lib/generators/css_zero/add/templates/app/assets/stylesheets/button.css
49
48
  - lib/generators/css_zero/add/templates/app/assets/stylesheets/card.css
@@ -52,7 +51,7 @@ files:
52
51
  - lib/generators/css_zero/add/templates/app/assets/stylesheets/progress.css
53
52
  - lib/generators/css_zero/add/templates/app/assets/stylesheets/switch.css
54
53
  - lib/generators/css_zero/add/templates/app/assets/stylesheets/table.css
55
- - lib/generators/css_zero/add/templates/app/javascript/controllers/dialog_control_controller.js
54
+ - lib/generators/css_zero/add/templates/app/javascript/controllers/dialog_controller.js
56
55
  - lib/generators/css_zero/install/USAGE
57
56
  - lib/generators/css_zero/install/install_generator.rb
58
57
  - lib/generators/css_zero/install/templates/app/assets/stylesheets/base.css
@@ -1,59 +0,0 @@
1
- .alert-dialog {
2
- background-color: var(--color-bg);
3
- border-width: var(--border);
4
- border-radius: var(--rounded-lg);
5
- box-shadow: var(--shadow-lg);
6
- color: var(--color-text);
7
- inline-size: var(--size-full);
8
- margin: auto;
9
- max-inline-size: var(--width-lg);
10
- padding: var(--size-6);
11
-
12
- &::backdrop {
13
- background-color: rgba(0, 0, 0, .8);
14
- }
15
-
16
- /* Setup animation */
17
- opacity: 0;
18
- transform: var(--scale-95);
19
- transition-behavior: allow-discrete;
20
- transition-duration: var(--time-150);
21
- transition-property: display overlay opacity transform;
22
-
23
- &::backdrop {
24
- opacity: 0;
25
- transition-behavior: allow-discrete;
26
- transition-duration: var(--time-150);
27
- transition-property: display overlay opacity;
28
- }
29
-
30
- /* In animation */
31
- &[open] {
32
- opacity: 1; transform: var(--scale-100);
33
- }
34
-
35
- &[open]::backdrop {
36
- opacity: 1;
37
- }
38
-
39
- /* Out animation */
40
- @starting-style {
41
- &[open] {
42
- opacity: 0; transform: var(--scale-95);
43
- }
44
-
45
- &[open]::backdrop {
46
- opacity: 0;
47
- }
48
- }
49
-
50
- /* Small screens */
51
- @media (width < 40rem) {
52
- border-radius: 0;
53
- }
54
- }
55
-
56
- /* Prevent page scroll when alert dialog is open */
57
- html:has(.alert-dialog[open]) {
58
- overflow: hidden;
59
- }
@@ -1,17 +0,0 @@
1
- import { Controller } from "@hotwired/stimulus"
2
-
3
- export default class extends Controller {
4
- static values = { target: String }
5
-
6
- close() {
7
- document.getElementById(this.targetValue).close()
8
- }
9
-
10
- show() {
11
- document.getElementById(this.targetValue).show()
12
- }
13
-
14
- showModal() {
15
- document.getElementById(this.targetValue).showModal()
16
- }
17
- }