klods-ruby 1.7.0 → 1.9.0
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.
- checksums.yaml +4 -4
- data/lib/klods/builders.rb +2 -0
- data/lib/klods/components/segmented.rb +42 -0
- data/lib/klods/components/status.rb +21 -0
- data/lib/klods/components.rb +2 -0
- data/lib/klods/icons.rb +2 -2
- data/lib/klods/version.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11f7d4a6457d9dfa17e344a1a3573db08040760ad3f4513b7d1a9db9715e73c8
|
|
4
|
+
data.tar.gz: 567d112587e59c9c022e43cf4b89c82c5826db2fea27f0407c906842e7f60ca0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 655d9db0706f57969ed44d85509d942430580cc9c7f516c52f3635c316ea540fdf4dae2268a18b1f0cea9717171a7373e09eee52387d729f3baf57e2dd482e47
|
|
7
|
+
data.tar.gz: 8fcc410fa3e6849faa8e44b77b777b8589c79d233f5e79c5d469b4a6855eebf30753125a9ab4986872b8b3abbcaee0b41bbf87821d0d236bb2a50b2a2a4d555e
|
data/lib/klods/builders.rb
CHANGED
|
@@ -19,6 +19,8 @@ module Klods
|
|
|
19
19
|
include Klods::Components::Modal
|
|
20
20
|
include Klods::Components::Nav
|
|
21
21
|
include Klods::Components::Prose
|
|
22
|
+
include Klods::Components::Segmented
|
|
23
|
+
include Klods::Components::Status
|
|
22
24
|
include Klods::Components::Toc
|
|
23
25
|
include Klods::Components::Table
|
|
24
26
|
include Klods::Components::Tabs
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Klods
|
|
2
|
+
module Components
|
|
3
|
+
# A row of radio buttons drawn as one pill, for picking one of a few short
|
|
4
|
+
# options. Arrow keys move between them, and the choice is sent with a form.
|
|
5
|
+
#
|
|
6
|
+
# segmented({name: "theme", label: "Theme", value: "auto",
|
|
7
|
+
# options: [{label: "Auto", value: "auto"}, {label: "Dark", value: "dark"}]})
|
|
8
|
+
# segmented({name: "view", "aria-labelledby": "view-label", options: ["Day", "Week"]})
|
|
9
|
+
#
|
|
10
|
+
# An option is a string (its text and value) or a hash with label, and
|
|
11
|
+
# optionally value and disabled. Use label: to name the group for screen
|
|
12
|
+
# readers, or aria-labelledby when a visible label names it.
|
|
13
|
+
module Segmented
|
|
14
|
+
def segmented(props)
|
|
15
|
+
props = props.transform_keys(&:to_s)
|
|
16
|
+
name = props.delete("name")
|
|
17
|
+
options = props.delete("options") || []
|
|
18
|
+
value = props.delete("value")
|
|
19
|
+
label = props.delete("label")
|
|
20
|
+
disabled = props.delete("disabled")
|
|
21
|
+
extra_class = props.delete("class")
|
|
22
|
+
|
|
23
|
+
items = options.map do |option|
|
|
24
|
+
option = option.is_a?(Hash) ? option.transform_keys(&:to_s) : {"label" => option}
|
|
25
|
+
text = option["label"]
|
|
26
|
+
option_value = option.fetch("value", text)
|
|
27
|
+
|
|
28
|
+
input_attrs = {"type" => "radio", "class" => "klods-segmented__input", "name" => name, "value" => option_value}
|
|
29
|
+
input_attrs["checked"] = true if option_value == value
|
|
30
|
+
input_attrs["disabled"] = true if disabled || option["disabled"]
|
|
31
|
+
Core.el("label", {"class" => "klods-segmented__option"}, [Node.new("input", input_attrs), text])
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
cls = Core.class_names("klods-segmented", Core.resolve_class(extra_class))
|
|
35
|
+
attrs = props.merge("role" => "radiogroup")
|
|
36
|
+
attrs["aria-label"] = label unless label.nil?
|
|
37
|
+
attrs["class"] = cls.empty? ? nil : cls
|
|
38
|
+
Core.el("div", attrs.compact, items)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Klods
|
|
2
|
+
module Components
|
|
3
|
+
# A colored dot beside text, for a live state like "Your turn" or "Online".
|
|
4
|
+
# The text must say the state on its own; add role: "status" when it changes
|
|
5
|
+
# while the page is open, so screen readers announce it.
|
|
6
|
+
module Status
|
|
7
|
+
def status(a = nil, b = nil, &block)
|
|
8
|
+
props, children = Core.normalize_args(a, b)
|
|
9
|
+
children = klods_capture(&block) if block
|
|
10
|
+
Core.build(
|
|
11
|
+
tag: "span", base: "klods-status",
|
|
12
|
+
modifiers: {
|
|
13
|
+
variant: ->(v) { (v && v.to_s != "default") ? "klods-status--#{v}" : nil },
|
|
14
|
+
pulse: "klods-status--pulse"
|
|
15
|
+
},
|
|
16
|
+
props: props, children: children
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lib/klods/components.rb
CHANGED
|
@@ -14,6 +14,8 @@ require_relative "components/list"
|
|
|
14
14
|
require_relative "components/modal"
|
|
15
15
|
require_relative "components/nav"
|
|
16
16
|
require_relative "components/prose"
|
|
17
|
+
require_relative "components/segmented"
|
|
18
|
+
require_relative "components/status"
|
|
17
19
|
require_relative "components/table"
|
|
18
20
|
require_relative "components/tabs"
|
|
19
21
|
require_relative "components/toc"
|
data/lib/klods/icons.rb
CHANGED
|
@@ -104,9 +104,9 @@ module Klods
|
|
|
104
104
|
def chev_up_icon(props = nil) = CHEV_UP_ICON.call(props)
|
|
105
105
|
def close_icon(props = nil) = CLOSE_ICON.call(props)
|
|
106
106
|
def copy_icon(props = nil) = COPY_ICON.call(props)
|
|
107
|
-
def danger_circle_icon(props = nil)= DANGER_CIRCLE_ICON.call(props)
|
|
107
|
+
def danger_circle_icon(props = nil) = DANGER_CIRCLE_ICON.call(props)
|
|
108
108
|
def edit_icon(props = nil) = EDIT_ICON.call(props)
|
|
109
|
-
def external_link_icon(props = nil)= EXTERNAL_LINK_ICON.call(props)
|
|
109
|
+
def external_link_icon(props = nil) = EXTERNAL_LINK_ICON.call(props)
|
|
110
110
|
def eye_icon(props = nil) = EYE_ICON.call(props)
|
|
111
111
|
def eye_off_icon(props = nil) = EYE_OFF_ICON.call(props)
|
|
112
112
|
def info_circle_icon(props = nil) = INFO_CIRCLE_ICON.call(props)
|
data/lib/klods/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: klods-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Drue Wilding
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -28,16 +28,16 @@ dependencies:
|
|
|
28
28
|
name: standard
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- -
|
|
31
|
+
- - '='
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: 1.57.0
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- -
|
|
38
|
+
- - '='
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
40
|
+
version: 1.57.0
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: actionview
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -93,6 +93,8 @@ files:
|
|
|
93
93
|
- lib/klods/components/modal.rb
|
|
94
94
|
- lib/klods/components/nav.rb
|
|
95
95
|
- lib/klods/components/prose.rb
|
|
96
|
+
- lib/klods/components/segmented.rb
|
|
97
|
+
- lib/klods/components/status.rb
|
|
96
98
|
- lib/klods/components/table.rb
|
|
97
99
|
- lib/klods/components/tabs.rb
|
|
98
100
|
- lib/klods/components/toast.rb
|