css-zero 0.0.47 → 0.0.49
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/css_zero/version.rb +1 -1
- data/lib/generators/css_zero/add/USAGE +1 -1
- data/lib/generators/css_zero/add/resources.yml +2 -1
- data/lib/generators/css_zero/add/templates/app/javascript/controllers/form_controller.js +4 -0
- data/lib/generators/css_zero/add/templates/app/javascript/controllers/menu_controller.js +26 -20
- data/lib/generators/css_zero/add/templates/app/javascript/controllers/popover_controller.js +0 -11
- data/lib/generators/css_zero/add/templates/app/javascript/controllers/tabs_controller.js +13 -21
- data/lib/generators/css_zero/install/install_generator.rb +10 -0
- data/lib/generators/css_zero/install/templates/app/javascript/initializers/index.js +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20f634891b019d8f1daeb601e8c4f095ad0bc4a0e17e4dc8af56a265a8d578d3
|
4
|
+
data.tar.gz: 1be7e6e2f94347c1419523f814f60f11bac915072c171a3d657d50cf576b8ab0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e49c19d5180e28cbfce2db4d3f7c21205de6708d8ef4cd340622846b52a4d089a7a32f829859e41577d68251e9d4f64cbaad629bf0d114ea9ad86087cdbe55d4
|
7
|
+
data.tar.gz: d2855e45ea3959712e2736746fdc1da91e0266da4bff2c0db1629317e5cff53eb4b32392841ef93b3b42e218ed369dc375bdc8249776c30e62a3cb6a8e640f2d
|
data/lib/css_zero/version.rb
CHANGED
@@ -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 check_all command collapsible dialog dropdown flash fullscreen hotkey input input_concerns layouts lightbox local_time pagination progress prose sheet skeleton switch table tabs upload_preview toggle web_share
|
5
|
+
accordion alert avatar badge breadcrumb button card carousel check_all command collapsible dialog dropdown flash form 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,6 +40,8 @@ dropdown:
|
|
40
40
|
flash:
|
41
41
|
- app/assets/stylesheets/flash.css
|
42
42
|
- app/javascript/controllers/element_removal_controller.js
|
43
|
+
form:
|
44
|
+
- app/javascript/controllers/form_controller.js
|
43
45
|
fullscreen:
|
44
46
|
- app/javascript/controllers/fullscreen_controller.js
|
45
47
|
hotkey:
|
@@ -88,7 +90,6 @@ skeleton:
|
|
88
90
|
- app/assets/stylesheets/skeleton.css
|
89
91
|
switch:
|
90
92
|
- app/assets/stylesheets/switch.css
|
91
|
-
- app/javascript/controllers/form_controller.js
|
92
93
|
table:
|
93
94
|
- app/assets/stylesheets/table.css
|
94
95
|
tabs:
|
@@ -4,37 +4,43 @@ export default class extends Controller {
|
|
4
4
|
static targets = [ "item" ]
|
5
5
|
static values = { index: Number }
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
#observer
|
8
|
+
|
9
|
+
initialize() {
|
10
|
+
this.#observer = new IntersectionObserver(this.#resetOnVisible.bind(this))
|
9
11
|
}
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
hasPrevious && this.indexValue--
|
14
|
-
hasPrevious && this.#focusCurrentItem()
|
13
|
+
connect() {
|
14
|
+
this.#observer.observe(this.element)
|
15
15
|
}
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
disconnect() {
|
18
|
+
this.#observer.disconnect()
|
19
|
+
}
|
20
|
+
|
21
|
+
indexValueChanged(index, previousIndex) {
|
22
|
+
this.#updateTabstops(previousIndex !== undefined)
|
21
23
|
}
|
22
24
|
|
23
|
-
|
24
|
-
this.indexValue
|
25
|
-
this.#focusCurrentItem()
|
25
|
+
prev() {
|
26
|
+
this.indexValue > 0 && this.indexValue--
|
26
27
|
}
|
27
28
|
|
28
|
-
|
29
|
-
this.
|
29
|
+
next() {
|
30
|
+
this.indexValue < this.itemTargets.length -1 && this.indexValue++
|
30
31
|
}
|
31
32
|
|
32
|
-
#
|
33
|
-
|
34
|
-
this.itemTargets[this.indexValue].focus()
|
33
|
+
#resetOnVisible([ entry ]) {
|
34
|
+
if (entry.isIntersecting) this.indexValue = 0
|
35
35
|
}
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
#updateTabstops(shouldFocus) {
|
38
|
+
this.itemTargets.forEach((element, index) => {
|
39
|
+
element.tabIndex = index == this.indexValue ? 0 : -1
|
40
|
+
})
|
41
|
+
|
42
|
+
if (shouldFocus) {
|
43
|
+
this.itemTargets[this.indexValue].focus()
|
44
|
+
}
|
39
45
|
}
|
40
46
|
}
|
@@ -6,10 +6,7 @@ export default class extends Controller {
|
|
6
6
|
static targets = [ "button", "menu" ]
|
7
7
|
static classes = [ "flip" ]
|
8
8
|
|
9
|
-
#closeTimer
|
10
|
-
|
11
9
|
show() {
|
12
|
-
this.#resetTimer()
|
13
10
|
this.menuTarget.show()
|
14
11
|
this.#updateExpanded()
|
15
12
|
this.#orient()
|
@@ -20,10 +17,6 @@ export default class extends Controller {
|
|
20
17
|
this.#updateExpanded()
|
21
18
|
}
|
22
19
|
|
23
|
-
closeLater() {
|
24
|
-
this.#closeTimer = setTimeout(() => this.close(), 300)
|
25
|
-
}
|
26
|
-
|
27
20
|
toggle() {
|
28
21
|
this.menuTarget.open ? this.close() : this.show()
|
29
22
|
}
|
@@ -32,10 +25,6 @@ export default class extends Controller {
|
|
32
25
|
!this.element.contains(target) && this.close()
|
33
26
|
}
|
34
27
|
|
35
|
-
#resetTimer() {
|
36
|
-
clearTimeout(this.#closeTimer)
|
37
|
-
}
|
38
|
-
|
39
28
|
#orient() {
|
40
29
|
this.menuTarget.classList.toggle(this.flipClass, this.#distanceToBottom < BOTTOM_THRESHOLD)
|
41
30
|
}
|
@@ -4,8 +4,8 @@ export default class extends Controller {
|
|
4
4
|
static targets = [ "button", "tab" ]
|
5
5
|
static values = { index: Number }
|
6
6
|
|
7
|
-
indexValueChanged() {
|
8
|
-
this.#showCurrentTab()
|
7
|
+
indexValueChanged(index, previousIndex) {
|
8
|
+
this.#showCurrentTab(previousIndex !== undefined)
|
9
9
|
}
|
10
10
|
|
11
11
|
select({ target }) {
|
@@ -13,33 +13,25 @@ export default class extends Controller {
|
|
13
13
|
}
|
14
14
|
|
15
15
|
prev() {
|
16
|
-
|
17
|
-
hasPrevious && this.indexValue--
|
18
|
-
hasPrevious && this.#focusCurrentButton()
|
16
|
+
this.indexValue > 0 && this.indexValue--
|
19
17
|
}
|
20
18
|
|
21
19
|
next() {
|
22
|
-
|
23
|
-
hasNext && this.indexValue++
|
24
|
-
hasNext && this.#focusCurrentButton()
|
20
|
+
this.indexValue < this.tabTargets.length -1 && this.indexValue++
|
25
21
|
}
|
26
22
|
|
27
|
-
#showCurrentTab() {
|
28
|
-
this.buttonTargets.forEach((
|
29
|
-
|
30
|
-
|
23
|
+
#showCurrentTab(shouldFocus) {
|
24
|
+
this.buttonTargets.forEach((element, index) => {
|
25
|
+
element.ariaSelected = index == this.indexValue
|
26
|
+
element.tabIndex = index == this.indexValue ? 0 : -1
|
31
27
|
})
|
32
28
|
|
33
|
-
this.tabTargets.forEach((
|
34
|
-
|
29
|
+
this.tabTargets.forEach((element, index) => {
|
30
|
+
element.hidden = index !== this.indexValue
|
35
31
|
})
|
36
|
-
}
|
37
|
-
|
38
|
-
#focusCurrentButton() {
|
39
|
-
this.buttonTargets[this.indexValue].focus()
|
40
|
-
}
|
41
32
|
|
42
|
-
|
43
|
-
|
33
|
+
if (shouldFocus) {
|
34
|
+
this.buttonTargets[this.indexValue].focus()
|
35
|
+
}
|
44
36
|
}
|
45
37
|
}
|
@@ -16,6 +16,16 @@ class CssZero::InstallGenerator < Rails::Generators::Base
|
|
16
16
|
append_to_file "config/importmap.rb", %(pin_all_from "app/javascript/helpers", under: "helpers"\n)
|
17
17
|
end
|
18
18
|
|
19
|
+
def copy_javascript_initializers
|
20
|
+
copy_file "app/javascript/initializers/index.js"
|
21
|
+
end
|
22
|
+
|
23
|
+
def pin_javascript_initializers
|
24
|
+
return unless install_with_importmap?
|
25
|
+
append_to_file "config/importmap.rb", %(pin_all_from "app/javascript/initializers", under: "initializers"\n)
|
26
|
+
append_to_file "app/javascript/application.js", %(import "initializers"\n)
|
27
|
+
end
|
28
|
+
|
19
29
|
private
|
20
30
|
def install_with_importmap?
|
21
31
|
Rails.root.join("config/importmap.rb").exist?
|
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.
|
4
|
+
version: 0.0.49
|
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-10-
|
11
|
+
date: 2024-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: lazaronixon@hotmail.com
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- lib/generators/css_zero/install/templates/app/assets/stylesheets/base.css
|
106
106
|
- lib/generators/css_zero/install/templates/app/javascript/helpers/cookie_helpers.js
|
107
107
|
- lib/generators/css_zero/install/templates/app/javascript/helpers/timing_helpers.js
|
108
|
+
- lib/generators/css_zero/install/templates/app/javascript/initializers/index.js
|
108
109
|
homepage: https://github.com/lazaronixon/css-zero
|
109
110
|
licenses:
|
110
111
|
- MIT
|