css-zero 0.0.36 → 0.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/css_zero/version.rb +1 -1
  4. data/lib/generators/css_zero/add/USAGE +1 -1
  5. data/lib/generators/css_zero/add/resources.yml +10 -6
  6. data/lib/generators/css_zero/add/templates/app/assets/images/check.svg +1 -0
  7. data/lib/generators/css_zero/add/templates/app/assets/stylesheets/button.css +1 -5
  8. data/lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js +12 -4
  9. data/lib/generators/css_zero/add/templates/app/javascript/controllers/check_all_controller.js +1 -1
  10. data/lib/generators/css_zero/add/templates/app/javascript/controllers/copyable_input_controller.js +36 -0
  11. data/lib/generators/css_zero/add/templates/app/javascript/controllers/hotkey_controller.js +1 -3
  12. data/lib/generators/css_zero/add/templates/app/javascript/controllers/local_time_controller.js +29 -0
  13. data/lib/generators/css_zero/add/templates/app/javascript/controllers/revealable_input_controller.js +24 -0
  14. data/lib/generators/css_zero/add/templates/app/javascript/controllers/tabs_controller.js +15 -3
  15. data/lib/generators/css_zero/add/templates/app/javascript/controllers/upload_preview_controller.js +1 -1
  16. metadata +7 -5
  17. data/lib/generators/css_zero/add/templates/app/javascript/controllers/copy_button_controller.js +0 -13
  18. data/lib/generators/css_zero/add/templates/app/javascript/controllers/reveal_button_controller.js +0 -19
  19. /data/lib/generators/css_zero/add/templates/app/javascript/controllers/{clear_button_controller.js → clearable_input_controller.js} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02bf5fecc4db0a341a8e9787bf93ff11f447b0c36d71d02105fccfb544db431e
4
- data.tar.gz: 6c39de744cd1c74965873dc531e55b8c8229785d698bcbf355de88a6f5f4ff04
3
+ metadata.gz: 609a6d11cfe6b31670eda63d7104d2d76069f0fe352bc4b6f7b0d00e5e7c2ea1
4
+ data.tar.gz: b118ad5a3842de5ab4df410b5516e62d52b9e241d559ec88f9146cdcc729b68a
5
5
  SHA512:
6
- metadata.gz: eb4d6e6c8b0ec2b26e98eb4b3cd504d20024787ab435a65b0b624cbf1acdf044e5afe13be4118091bfb2b321e7f7d0e6afc5ab08b8e12bbcbdce93e9196fae0b
7
- data.tar.gz: d93dfdf03c9752c3c938c81282b48c4fef238b344f7409e35af9a4f5369eca79b8c2feed210c0301639c9b21e367258640a7e97c4142b83adb5e393129ac674c
6
+ metadata.gz: 4dafa265f72d212202676d56ae7e3b5d20ee92516829c802a78794c43d3786aa68a7ed274361a2e3077df2e893cd75d298610f3a420e83de2703c0498419771f
7
+ data.tar.gz: fd08c640bdc6b4409b046e86a8e817dd916fef129c28cc8cb8f0a04c77080bb27c4f372fec509897d17706473e7ef334c081fce1d0e7157717189e7c864a5f95
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 avatar badge breadcrumb button card carousel collapsible dialog flash fullscreen hotkey input input_concerns layouts lightbox pagination progress prose sheet skeleton switch table tabs upload_preview toggle web_share
22
+ bin/rails generate css_zero:add accordion alert avatar badge breadcrumb button card carousel collapsible dialog flash fullscreen hotkey input input_concerns layouts lightbox local_time pagination progress prose sheet skeleton switch table tabs upload_preview toggle web_share
23
23
  ```
24
24
 
25
25
  ### Requirements
@@ -1,3 +1,3 @@
1
1
  module CssZero
2
- VERSION = "0.0.36"
2
+ VERSION = "0.0.38"
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 avatar badge breadcrumb button card carousel collapsible dialog flash fullscreen hotkey input input_concerns layouts lightbox pagination progress prose sheet skeleton switch table tabs upload_preview toggle web_share
5
+ accordion alert avatar badge breadcrumb button card carousel collapsible dialog flash fullscreen hotkey input input_concerns layouts lightbox local_time pagination progress prose sheet skeleton switch table tabs upload_preview toggle web_share
6
6
 
7
7
  Example:
8
8
  bin/rails generate css_zero:add [components...]
@@ -40,22 +40,26 @@ input:
40
40
  - app/javascript/controllers/check_all_controller.js
41
41
  input_concerns:
42
42
  - app/javascript/controllers/autoselect_controller.js
43
- - app/javascript/controllers/clear_button_controller.js
44
- - app/assets/images/x.svg
45
- - app/javascript/controllers/reveal_button_controller.js
43
+ - app/javascript/controllers/copyable_input_controller.js
44
+ - app/javascript/controllers/clearable_input_controller.js
45
+ - app/javascript/controllers/revealable_input_controller.js
46
+ - app/assets/images/copy.svg
47
+ - app/assets/images/check.svg
46
48
  - app/assets/images/eye.svg
47
49
  - app/assets/images/eye-off.svg
48
- - app/javascript/controllers/copy_button_controller.js
49
- - app/assets/images/copy.svg
50
+ - app/assets/images/x.svg
50
51
  layouts:
51
52
  - app/assets/stylesheets/layouts.css
52
53
  - app/assets/images/menu.svg
53
54
  lightbox:
54
55
  - app/assets/stylesheets/lightbox.css
55
56
  - app/javascript/controllers/lightbox_controller.js
57
+ - app/javascript/controllers/web_share_controller.js
56
58
  - app/assets/images/download.svg
57
59
  - app/assets/images/share.svg
58
60
  - app/assets/images/x.svg
61
+ local_time:
62
+ - app/javascript/controllers/local_time_controller.js
59
63
  pagination:
60
64
  - app/assets/images/chevron-right.svg
61
65
  - app/assets/images/chevron-left.svg
@@ -70,9 +74,9 @@ sheet:
70
74
  - app/assets/images/x.svg
71
75
  skeleton:
72
76
  - app/assets/stylesheets/skeleton.css
73
- - app/javascript/controllers/form_controller.js
74
77
  switch:
75
78
  - app/assets/stylesheets/switch.css
79
+ - app/javascript/controllers/form_controller.js
76
80
  table:
77
81
  - app/assets/stylesheets/table.css
78
82
  tabs:
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check"><path d="M20 6 9 17l-5-5"/></svg>
@@ -66,18 +66,14 @@
66
66
  .btn--plain {
67
67
  --btn-background: transparent;
68
68
  --btn-border-color: transparent;
69
+ --btn-filter-hover: none;
69
70
  --btn-padding: 0;
70
71
  }
71
72
 
72
73
  .btn--rounded {
73
- --btn-padding: var(--size-2);
74
74
  --btn-radius: var(--rounded-full);
75
75
  }
76
76
 
77
- .btn--pressed:active {
78
- opacity: var(--opacity-50);
79
- }
80
-
81
77
  [aria-busy] .btn--loading:disabled {
82
78
  > * {
83
79
  visibility: hidden;
@@ -4,12 +4,20 @@ export default class extends Controller {
4
4
  static targets = [ "content" ]
5
5
 
6
6
  next() {
7
- this.contentTarget.scrollTo({ left: this.#scrollLeft + this.#slideSize, behavior: "smooth" })
7
+ this.contentTarget.scrollTo({ left: this.#nextPosition, behavior: "smooth" })
8
8
  }
9
9
 
10
- previous() {
11
- this.contentTarget.scrollTo({ left: this.#scrollLeft - this.#slideSize, behavior: "smooth" })
12
- }
10
+ prev() {
11
+ this.contentTarget.scrollTo({ left: this.#prevPosition, behavior: "smooth" })
12
+ }
13
+
14
+ get #nextPosition() {
15
+ return this.#scrollLeft + this.#slideSize
16
+ }
17
+
18
+ get #prevPosition() {
19
+ return this.#scrollLeft - this.#slideSize
20
+ }
13
21
 
14
22
  get #scrollLeft() {
15
23
  return this.contentTarget.scrollLeft
@@ -3,7 +3,7 @@ import { Controller } from "@hotwired/stimulus"
3
3
  export default class extends Controller {
4
4
  static targets = [ "dependent" ]
5
5
 
6
- check({target}) {
6
+ check({ target }) {
7
7
  this.dependentTargets.forEach(element => element.checked = target.checked)
8
8
  }
9
9
  }
@@ -0,0 +1,36 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static targets = [ "input", "copyIcon", "successIcon" ]
5
+ static values = { copied: Boolean }
6
+
7
+ #copiedTimeout = null
8
+
9
+ copiedValueChanged() {
10
+ this.#update()
11
+ }
12
+
13
+ copy() {
14
+ this.#copyToClipboard()
15
+ this.#reset()
16
+ }
17
+
18
+ #copyToClipboard() {
19
+ try {
20
+ navigator.clipboard.writeText(this.inputTarget.value)
21
+ this.copiedValue = true
22
+ } catch (error) {
23
+ console.warn(error.message);
24
+ }
25
+ }
26
+
27
+ #reset() {
28
+ clearTimeout(this.#copiedTimeout)
29
+ this.#copiedTimeout = setTimeout(() => { this.copiedValue = false }, 3000)
30
+ }
31
+
32
+ #update() {
33
+ this.copyIconTarget.hidden = this.copiedValue
34
+ this.successIconTarget.hidden = !this.copiedValue
35
+ }
36
+ }
@@ -2,9 +2,7 @@ import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
4
  click(event) {
5
- if (this.#isClickable && !this.#shouldIgnore(event)) {
6
- this.element.click()
7
- }
5
+ if (this.#isClickable && !this.#shouldIgnore(event)) this.element.click()
8
6
  }
9
7
 
10
8
  #shouldIgnore(event) {
@@ -0,0 +1,29 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static targets = [ "time", "date", "datetime" ]
5
+
6
+ initialize() {
7
+ this.timeFormatter = new Intl.DateTimeFormat(undefined, { timeStyle: "short" })
8
+ this.dateFormatter = new Intl.DateTimeFormat(undefined, { dateStyle: "long" })
9
+ this.dateTimeFormatter = new Intl.DateTimeFormat(undefined, { timeStyle: "short", dateStyle: "short" })
10
+ }
11
+
12
+ timeTargetConnected(target) {
13
+ this.#formatTime(this.timeFormatter, target)
14
+ }
15
+
16
+ dateTargetConnected(target) {
17
+ this.#formatTime(this.dateFormatter, target)
18
+ }
19
+
20
+ datetimeTargetConnected(target) {
21
+ this.#formatTime(this.dateTimeFormatter, target)
22
+ }
23
+
24
+ #formatTime(formatter, target) {
25
+ const dt = new Date(target.getAttribute("datetime"))
26
+ target.textContent = formatter.format(dt)
27
+ target.title = this.dateTimeFormatter.format(dt)
28
+ }
29
+ }
@@ -0,0 +1,24 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static targets = [ "input", "showIcon", "hideIcon" ]
5
+ static values = { revealed: Boolean }
6
+
7
+ revealedValueChanged() {
8
+ this.#update()
9
+ }
10
+
11
+ reveal() {
12
+ this.revealedValue = !this.revealedValue
13
+ }
14
+
15
+ #update() {
16
+ this.inputTarget.type = this.#inputType
17
+ this.showIconTarget.hidden = this.revealedValue
18
+ this.hideIconTarget.hidden = !this.revealedValue
19
+ }
20
+
21
+ get #inputType() {
22
+ return this.revealedValue ? "text" : "password"
23
+ }
24
+ }
@@ -2,14 +2,26 @@ import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = [ "button", "tab" ]
5
- static values = { index: Number, default: 0 }
5
+ static values = { index: Number }
6
+
7
+ indexValueChanged() {
8
+ this.#showSelectedTab()
9
+ }
6
10
 
7
11
  select({ target }) {
8
12
  this.indexValue = target.dataset.index
9
13
  }
10
14
 
11
- indexValueChanged() {
12
- this.#showSelectedTab()
15
+ prev() {
16
+ if (this.indexValue > 0) this.indexValue--
17
+ }
18
+
19
+ next() {
20
+ if (this.indexValue < this.#lastIndex) this.indexValue++
21
+ }
22
+
23
+ get #lastIndex() {
24
+ return this.tabTargets.length -1
13
25
  }
14
26
 
15
27
  #showSelectedTab() {
@@ -18,4 +18,4 @@ export default class extends Controller {
18
18
  this.imageTarget.src = this.defaultImageValue
19
19
  this.removeInputTarget.value = true
20
20
  }
21
- }
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.36
4
+ version: 0.0.38
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-09-23 00:00:00.000000000 Z
11
+ date: 2024-09-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: lazaronixon@hotmail.com
@@ -38,6 +38,7 @@ files:
38
38
  - lib/generators/css_zero/add/templates/app/assets/images/arrow-left.svg
39
39
  - lib/generators/css_zero/add/templates/app/assets/images/arrow-right.svg
40
40
  - lib/generators/css_zero/add/templates/app/assets/images/camera.svg
41
+ - lib/generators/css_zero/add/templates/app/assets/images/check.svg
41
42
  - lib/generators/css_zero/add/templates/app/assets/images/chevron-down.svg
42
43
  - lib/generators/css_zero/add/templates/app/assets/images/chevron-left.svg
43
44
  - lib/generators/css_zero/add/templates/app/assets/images/chevron-right.svg
@@ -79,16 +80,17 @@ files:
79
80
  - lib/generators/css_zero/add/templates/app/javascript/controllers/autoselect_controller.js
80
81
  - lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js
81
82
  - lib/generators/css_zero/add/templates/app/javascript/controllers/check_all_controller.js
82
- - lib/generators/css_zero/add/templates/app/javascript/controllers/clear_button_controller.js
83
+ - lib/generators/css_zero/add/templates/app/javascript/controllers/clearable_input_controller.js
83
84
  - lib/generators/css_zero/add/templates/app/javascript/controllers/collapsible_controller.js
84
- - lib/generators/css_zero/add/templates/app/javascript/controllers/copy_button_controller.js
85
+ - lib/generators/css_zero/add/templates/app/javascript/controllers/copyable_input_controller.js
85
86
  - lib/generators/css_zero/add/templates/app/javascript/controllers/dialog_controller.js
86
87
  - lib/generators/css_zero/add/templates/app/javascript/controllers/element_removal_controller.js
87
88
  - lib/generators/css_zero/add/templates/app/javascript/controllers/form_controller.js
88
89
  - lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
89
90
  - lib/generators/css_zero/add/templates/app/javascript/controllers/hotkey_controller.js
90
91
  - lib/generators/css_zero/add/templates/app/javascript/controllers/lightbox_controller.js
91
- - lib/generators/css_zero/add/templates/app/javascript/controllers/reveal_button_controller.js
92
+ - lib/generators/css_zero/add/templates/app/javascript/controllers/local_time_controller.js
93
+ - lib/generators/css_zero/add/templates/app/javascript/controllers/revealable_input_controller.js
92
94
  - lib/generators/css_zero/add/templates/app/javascript/controllers/tabs_controller.js
93
95
  - lib/generators/css_zero/add/templates/app/javascript/controllers/upload_preview_controller.js
94
96
  - lib/generators/css_zero/add/templates/app/javascript/controllers/web_share_controller.js
@@ -1,13 +0,0 @@
1
- import { Controller } from "@hotwired/stimulus"
2
-
3
- export default class extends Controller {
4
- static targets = [ "input" ]
5
-
6
- async copy() {
7
- try {
8
- await navigator.clipboard.writeText(this.inputTarget.value)
9
- } catch (error) {
10
- console.warn(error.message);
11
- }
12
- }
13
- }
@@ -1,19 +0,0 @@
1
- import { Controller } from "@hotwired/stimulus"
2
-
3
- export default class extends Controller {
4
- static targets = [ "input", "image" ]
5
- static values = { showImage: String, hideImage: String }
6
-
7
- reveal() {
8
- this.inputTarget.type = this.#inputType
9
- this.imageTarget.src = this.#imageSrc
10
- }
11
-
12
- get #inputType() {
13
- return this.inputTarget.type === "text" ? "password" : "text"
14
- }
15
-
16
- get #imageSrc() {
17
- return this.inputTarget.type === "text" ? this.hideImageValue : this.showImageValue
18
- }
19
- }