klods-ruby 1.0.0 → 1.2.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 +12 -0
- data/lib/klods/components/alert.rb +2 -1
- data/lib/klods/components/badge.rb +2 -1
- data/lib/klods/components/box.rb +2 -1
- data/lib/klods/components/breadcrumb.rb +2 -1
- data/lib/klods/components/button.rb +17 -10
- data/lib/klods/components/card.rb +8 -4
- data/lib/klods/components/code.rb +10 -5
- data/lib/klods/components/details.rb +4 -2
- data/lib/klods/components/dl.rb +6 -3
- data/lib/klods/components/form.rb +8 -4
- data/lib/klods/components/list.rb +4 -2
- data/lib/klods/components/modal.rb +16 -8
- data/lib/klods/components/nav.rb +14 -7
- data/lib/klods/components/prose.rb +8 -4
- data/lib/klods/components/table.rb +14 -7
- data/lib/klods/components/tabs.rb +2 -1
- data/lib/klods/components/toast.rb +4 -2
- data/lib/klods/html.rb +4 -2
- data/lib/klods/layout.rb +24 -12
- data/lib/klods/utilities.rb +4 -2
- data/lib/klods/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 842444db671201072610617f2e5923c7e988af12bbd0bb8762dee48875ef2e0e
|
|
4
|
+
data.tar.gz: d0433ca5b0ba0d8eda5c22ac9dd98833d40aa178e15d8e922348cdba0dc6aad2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: df4da704c8e48bb6213248f878e8aa80dc784afd4d6f2d107de9550a7c927131c3f60744278beef48919c0e8deb1e6ff557720b382d7d81da12acbc8b10057ba
|
|
7
|
+
data.tar.gz: 7a7d724a0801c7bf427e4358f2226f6577dab8182ecf5919f05b160219b11d829fc7e29afc0d8b43924a5a47b3d869241b84a37b246dd44aa5abe558cd4993c9
|
data/lib/klods/builders.rb
CHANGED
|
@@ -31,5 +31,17 @@ module Klods
|
|
|
31
31
|
def raw(html)
|
|
32
32
|
Core.raw(html)
|
|
33
33
|
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
# Captures the rendered output of a HAML/ERB block and returns it as a
|
|
38
|
+
# single-element children array containing raw HTML. Relies on ActionView's
|
|
39
|
+
# `capture` helper — returns nil outside a Rails view context so the caller
|
|
40
|
+
# falls back to its regular children argument.
|
|
41
|
+
def klods_capture(&block)
|
|
42
|
+
return nil unless block
|
|
43
|
+
return nil unless respond_to?(:capture)
|
|
44
|
+
[Core.raw(capture(&block).to_s)]
|
|
45
|
+
end
|
|
34
46
|
end
|
|
35
47
|
end
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Components
|
|
3
3
|
module Alert
|
|
4
|
-
def alert(a = nil, b = nil)
|
|
4
|
+
def alert(a = nil, b = nil, &block)
|
|
5
5
|
props, children = Core.normalize_args(a, b)
|
|
6
|
+
children = klods_capture(&block) if block
|
|
6
7
|
merged = {"role" => "alert"}.merge(props.transform_keys(&:to_s))
|
|
7
8
|
Core.build(
|
|
8
9
|
tag: "div", base: "klods-alert",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Components
|
|
3
3
|
module Badge
|
|
4
|
-
def badge(a = nil, b = nil)
|
|
4
|
+
def badge(a = nil, b = nil, &block)
|
|
5
5
|
props, children = Core.normalize_args(a, b)
|
|
6
|
+
children = klods_capture(&block) if block
|
|
6
7
|
Core.build(
|
|
7
8
|
tag: "span", base: "klods-badge",
|
|
8
9
|
modifiers: {
|
data/lib/klods/components/box.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Components
|
|
3
3
|
module Box
|
|
4
|
-
def box(a = nil, b = nil)
|
|
4
|
+
def box(a = nil, b = nil, &block)
|
|
5
5
|
props, children = Core.normalize_args(a, b)
|
|
6
|
+
children = klods_capture(&block) if block
|
|
6
7
|
Core.build(tag: "div", base: "klods-box", props: props, children: children)
|
|
7
8
|
end
|
|
8
9
|
end
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Components
|
|
3
3
|
module Breadcrumb
|
|
4
|
-
def crumb(a = nil, b = nil)
|
|
4
|
+
def crumb(a = nil, b = nil, &block)
|
|
5
5
|
props, children = Core.normalize_args(a, b)
|
|
6
|
+
children = klods_capture(&block) if block
|
|
6
7
|
href = props.delete(:href) || props.delete("href")
|
|
7
8
|
attrs = href ? props.merge("data-crumb-href" => href) : props
|
|
8
9
|
Core.el("li", attrs, children)
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Components
|
|
3
3
|
module Button
|
|
4
|
-
|
|
4
|
+
BUTTON_MODIFIERS = {
|
|
5
|
+
variant: ->(v) { (v && v.to_s != "default") ? "klods-button--#{v}" : nil }
|
|
6
|
+
}.freeze
|
|
7
|
+
|
|
8
|
+
def button(a = nil, b = nil, &block)
|
|
5
9
|
props, children = Core.normalize_args(a, b)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
modifiers:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
children = klods_capture(&block) if block
|
|
11
|
+
str_props = props.transform_keys(&:to_s)
|
|
12
|
+
if str_props.key?("href")
|
|
13
|
+
Core.build(tag: "a", base: "klods-button", modifiers: BUTTON_MODIFIERS, props: str_props, children: children)
|
|
14
|
+
else
|
|
15
|
+
Core.build(
|
|
16
|
+
tag: "button", base: "klods-button", modifiers: BUTTON_MODIFIERS,
|
|
17
|
+
props: {"type" => "button"}.merge(str_props), children: children
|
|
18
|
+
)
|
|
19
|
+
end
|
|
14
20
|
end
|
|
15
21
|
|
|
16
|
-
def button_group(a = nil, b = nil)
|
|
22
|
+
def button_group(a = nil, b = nil, &block)
|
|
17
23
|
props, children = Core.normalize_args(a, b)
|
|
24
|
+
children = klods_capture(&block) if block
|
|
18
25
|
Core.build(tag: "div", base: "klods-button-group", props: props, children: children)
|
|
19
26
|
end
|
|
20
27
|
end
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Components
|
|
3
3
|
module Card
|
|
4
|
-
def card(a = nil, b = nil)
|
|
4
|
+
def card(a = nil, b = nil, &block)
|
|
5
5
|
props, children = Core.normalize_args(a, b)
|
|
6
|
+
children = klods_capture(&block) if block
|
|
6
7
|
Core.build(
|
|
7
8
|
tag: "div", base: "klods-card",
|
|
8
9
|
modifiers: {elevated: "klods-card--elevated"},
|
|
@@ -10,18 +11,21 @@ module Klods
|
|
|
10
11
|
)
|
|
11
12
|
end
|
|
12
13
|
|
|
13
|
-
def card_title(a = nil, b = nil)
|
|
14
|
+
def card_title(a = nil, b = nil, &block)
|
|
14
15
|
props, children = Core.normalize_args(a, b)
|
|
16
|
+
children = klods_capture(&block) if block
|
|
15
17
|
Core.build(tag: "h3", base: "klods-card__title", props: props, children: children)
|
|
16
18
|
end
|
|
17
19
|
|
|
18
|
-
def card_body(a = nil, b = nil)
|
|
20
|
+
def card_body(a = nil, b = nil, &block)
|
|
19
21
|
props, children = Core.normalize_args(a, b)
|
|
22
|
+
children = klods_capture(&block) if block
|
|
20
23
|
Core.build(tag: "div", base: "klods-card__body", props: props, children: children)
|
|
21
24
|
end
|
|
22
25
|
|
|
23
|
-
def card_footer(a = nil, b = nil)
|
|
26
|
+
def card_footer(a = nil, b = nil, &block)
|
|
24
27
|
props, children = Core.normalize_args(a, b)
|
|
28
|
+
children = klods_capture(&block) if block
|
|
25
29
|
Core.build(tag: "div", base: "klods-card__footer", props: props, children: children)
|
|
26
30
|
end
|
|
27
31
|
end
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Components
|
|
3
3
|
module Code
|
|
4
|
-
def code_block(a = nil, b = nil)
|
|
4
|
+
def code_block(a = nil, b = nil, &block)
|
|
5
5
|
props, content = Core.normalize_args(a, b)
|
|
6
|
+
content = klods_capture(&block) if block
|
|
6
7
|
props = props.transform_keys(&:to_s)
|
|
7
8
|
extra_class = props.delete("class")
|
|
8
9
|
cls = Core.class_names("klods-pre", Core.resolve_class(extra_class))
|
|
@@ -10,8 +11,9 @@ module Klods
|
|
|
10
11
|
Core.el("pre", attrs, Core.el("code", {}, content))
|
|
11
12
|
end
|
|
12
13
|
|
|
13
|
-
def inline_code(a = nil, b = nil)
|
|
14
|
+
def inline_code(a = nil, b = nil, &block)
|
|
14
15
|
props, content = Core.normalize_args(a, b)
|
|
16
|
+
content = klods_capture(&block) if block
|
|
15
17
|
props = props.transform_keys(&:to_s)
|
|
16
18
|
extra_class = props.delete("class")
|
|
17
19
|
cls = Core.class_names("klods-code", Core.resolve_class(extra_class))
|
|
@@ -19,18 +21,21 @@ module Klods
|
|
|
19
21
|
Core.el("code", attrs, content)
|
|
20
22
|
end
|
|
21
23
|
|
|
22
|
-
def kbd(a = nil, b = nil)
|
|
24
|
+
def kbd(a = nil, b = nil, &block)
|
|
23
25
|
props, children = Core.normalize_args(a, b)
|
|
26
|
+
children = klods_capture(&block) if block
|
|
24
27
|
Core.build(tag: "kbd", base: "klods-kbd", props: props, children: children)
|
|
25
28
|
end
|
|
26
29
|
|
|
27
|
-
def samp(a = nil, b = nil)
|
|
30
|
+
def samp(a = nil, b = nil, &block)
|
|
28
31
|
props, children = Core.normalize_args(a, b)
|
|
32
|
+
children = klods_capture(&block) if block
|
|
29
33
|
Core.build(tag: "samp", base: "klods-samp", props: props, children: children)
|
|
30
34
|
end
|
|
31
35
|
|
|
32
|
-
def var_el(a = nil, b = nil)
|
|
36
|
+
def var_el(a = nil, b = nil, &block)
|
|
33
37
|
props, children = Core.normalize_args(a, b)
|
|
38
|
+
children = klods_capture(&block) if block
|
|
34
39
|
Core.build(tag: "var", base: "klods-var", props: props, children: children)
|
|
35
40
|
end
|
|
36
41
|
end
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Components
|
|
3
3
|
module Details
|
|
4
|
-
def details(a = nil, b = nil)
|
|
4
|
+
def details(a = nil, b = nil, &block)
|
|
5
5
|
props, children = Core.normalize_args(a, b)
|
|
6
|
+
children = klods_capture(&block) if block
|
|
6
7
|
Core.build(
|
|
7
8
|
tag: "details", base: "klods-details",
|
|
8
9
|
modifiers: {open: "klods-details--open"},
|
|
@@ -10,8 +11,9 @@ module Klods
|
|
|
10
11
|
)
|
|
11
12
|
end
|
|
12
13
|
|
|
13
|
-
def summary(a = nil, b = nil)
|
|
14
|
+
def summary(a = nil, b = nil, &block)
|
|
14
15
|
props, children = Core.normalize_args(a, b)
|
|
16
|
+
children = klods_capture(&block) if block
|
|
15
17
|
Core.el("summary", props, children)
|
|
16
18
|
end
|
|
17
19
|
end
|
data/lib/klods/components/dl.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Components
|
|
3
3
|
module Dl
|
|
4
|
-
def dl(a = nil, b = nil)
|
|
4
|
+
def dl(a = nil, b = nil, &block)
|
|
5
5
|
props, children = Core.normalize_args(a, b)
|
|
6
|
+
children = klods_capture(&block) if block
|
|
6
7
|
Core.build(
|
|
7
8
|
tag: "dl", base: "klods-dl",
|
|
8
9
|
modifiers: {inline: "klods-dl--inline"},
|
|
@@ -10,13 +11,15 @@ module Klods
|
|
|
10
11
|
)
|
|
11
12
|
end
|
|
12
13
|
|
|
13
|
-
def dt(a = nil, b = nil)
|
|
14
|
+
def dt(a = nil, b = nil, &block)
|
|
14
15
|
props, children = Core.normalize_args(a, b)
|
|
16
|
+
children = klods_capture(&block) if block
|
|
15
17
|
Core.build(tag: "dt", base: "klods-dt", props: props, children: children)
|
|
16
18
|
end
|
|
17
19
|
|
|
18
|
-
def dd(a = nil, b = nil)
|
|
20
|
+
def dd(a = nil, b = nil, &block)
|
|
19
21
|
props, children = Core.normalize_args(a, b)
|
|
22
|
+
children = klods_capture(&block) if block
|
|
20
23
|
Core.build(tag: "dd", base: "klods-dd", props: props, children: children)
|
|
21
24
|
end
|
|
22
25
|
end
|
|
@@ -4,8 +4,9 @@ module Klods
|
|
|
4
4
|
FORM_CONTROLS = %w[input select textarea].freeze
|
|
5
5
|
private_constant :FORM_CONTROLS
|
|
6
6
|
|
|
7
|
-
def form(a = nil, b = nil)
|
|
7
|
+
def form(a = nil, b = nil, &block)
|
|
8
8
|
props, children = Core.normalize_args(a, b)
|
|
9
|
+
children = klods_capture(&block) if block
|
|
9
10
|
Core.build(tag: "form", base: "klods-form", props: props, children: children)
|
|
10
11
|
end
|
|
11
12
|
|
|
@@ -80,19 +81,22 @@ module Klods
|
|
|
80
81
|
end
|
|
81
82
|
end
|
|
82
83
|
|
|
83
|
-
def select(a = nil, b = nil)
|
|
84
|
+
def select(a = nil, b = nil, &block)
|
|
84
85
|
props, children = Core.normalize_args(a, b)
|
|
86
|
+
children = klods_capture(&block) if block
|
|
85
87
|
inner = Core.build(tag: "select", base: "klods-select", props: props, children: children)
|
|
86
88
|
Core.el("div", {"class" => "klods-select-wrapper"}, inner)
|
|
87
89
|
end
|
|
88
90
|
|
|
89
|
-
def option(a = nil, b = nil)
|
|
91
|
+
def option(a = nil, b = nil, &block)
|
|
90
92
|
props, children = Core.normalize_args(a, b)
|
|
93
|
+
children = klods_capture(&block) if block
|
|
91
94
|
Core.el("option", props, children)
|
|
92
95
|
end
|
|
93
96
|
|
|
94
|
-
def textarea(a = nil, b = nil)
|
|
97
|
+
def textarea(a = nil, b = nil, &block)
|
|
95
98
|
props, children = Core.normalize_args(a, b)
|
|
99
|
+
children = klods_capture(&block) if block
|
|
96
100
|
Core.build(tag: "textarea", base: "klods-textarea", props: props, children: children)
|
|
97
101
|
end
|
|
98
102
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Components
|
|
3
3
|
module List
|
|
4
|
-
def list(a = nil, b = nil)
|
|
4
|
+
def list(a = nil, b = nil, &block)
|
|
5
5
|
props, children = Core.normalize_args(a, b)
|
|
6
|
+
children = klods_capture(&block) if block
|
|
6
7
|
Core.build(
|
|
7
8
|
tag: "ul", base: "klods-list",
|
|
8
9
|
modifiers: {flush: "klods-list--flush"},
|
|
@@ -10,8 +11,9 @@ module Klods
|
|
|
10
11
|
)
|
|
11
12
|
end
|
|
12
13
|
|
|
13
|
-
def list_item(a = nil, b = nil)
|
|
14
|
+
def list_item(a = nil, b = nil, &block)
|
|
14
15
|
props, children = Core.normalize_args(a, b)
|
|
16
|
+
children = klods_capture(&block) if block
|
|
15
17
|
props = props.transform_keys(&:to_s)
|
|
16
18
|
|
|
17
19
|
lead = props.delete("lead")
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Components
|
|
3
3
|
module Modal
|
|
4
|
-
def modal(a = nil, b = nil)
|
|
4
|
+
def modal(a = nil, b = nil, &block)
|
|
5
5
|
props, children = Core.normalize_args(a, b)
|
|
6
|
+
children = klods_capture(&block) if block
|
|
6
7
|
props = props.transform_keys(&:to_s)
|
|
7
8
|
open_attr = props.delete("open")
|
|
8
9
|
extra_class = props.delete("class")
|
|
@@ -12,28 +13,33 @@ module Klods
|
|
|
12
13
|
Core.el("dialog", attrs, children)
|
|
13
14
|
end
|
|
14
15
|
|
|
15
|
-
def modal_panel(a = nil, b = nil)
|
|
16
|
+
def modal_panel(a = nil, b = nil, &block)
|
|
16
17
|
props, children = Core.normalize_args(a, b)
|
|
18
|
+
children = klods_capture(&block) if block
|
|
17
19
|
Core.build(tag: "div", base: "klods-modal__panel", props: props, children: children)
|
|
18
20
|
end
|
|
19
21
|
|
|
20
|
-
def modal_header(a = nil, b = nil)
|
|
22
|
+
def modal_header(a = nil, b = nil, &block)
|
|
21
23
|
props, children = Core.normalize_args(a, b)
|
|
24
|
+
children = klods_capture(&block) if block
|
|
22
25
|
Core.build(tag: "div", base: "klods-modal__header", props: props, children: children)
|
|
23
26
|
end
|
|
24
27
|
|
|
25
|
-
def modal_title(a = nil, b = nil)
|
|
28
|
+
def modal_title(a = nil, b = nil, &block)
|
|
26
29
|
props, children = Core.normalize_args(a, b)
|
|
30
|
+
children = klods_capture(&block) if block
|
|
27
31
|
Core.build(tag: "h2", base: "klods-modal__title", props: props, children: children)
|
|
28
32
|
end
|
|
29
33
|
|
|
30
|
-
def modal_body(a = nil, b = nil)
|
|
34
|
+
def modal_body(a = nil, b = nil, &block)
|
|
31
35
|
props, children = Core.normalize_args(a, b)
|
|
36
|
+
children = klods_capture(&block) if block
|
|
32
37
|
Core.build(tag: "div", base: "klods-modal__body", props: props, children: children)
|
|
33
38
|
end
|
|
34
39
|
|
|
35
|
-
def modal_actions(a = nil, b = nil)
|
|
40
|
+
def modal_actions(a = nil, b = nil, &block)
|
|
36
41
|
props, children = Core.normalize_args(a, b)
|
|
42
|
+
children = klods_capture(&block) if block
|
|
37
43
|
Core.build(tag: "div", base: "klods-modal__actions", props: props, children: children)
|
|
38
44
|
end
|
|
39
45
|
|
|
@@ -56,8 +62,9 @@ module Klods
|
|
|
56
62
|
|
|
57
63
|
# Button that closes the containing <dialog> when clicked.
|
|
58
64
|
# Accepts the same props as button (e.g. variant:).
|
|
59
|
-
def modal_dismiss(a = nil, b = nil)
|
|
65
|
+
def modal_dismiss(a = nil, b = nil, &block)
|
|
60
66
|
props, children = Core.normalize_args(a, b)
|
|
67
|
+
children = klods_capture(&block) if block
|
|
61
68
|
merged = {
|
|
62
69
|
"type" => "button",
|
|
63
70
|
"onclick" => "this.closest('dialog').close()"
|
|
@@ -73,8 +80,9 @@ module Klods
|
|
|
73
80
|
|
|
74
81
|
# Button that opens the next sibling <dialog> as a modal when clicked.
|
|
75
82
|
# Accepts the same props as button (e.g. variant:).
|
|
76
|
-
def modal_trigger(a = nil, b = nil)
|
|
83
|
+
def modal_trigger(a = nil, b = nil, &block)
|
|
77
84
|
props, children = Core.normalize_args(a, b)
|
|
85
|
+
children = klods_capture(&block) if block
|
|
78
86
|
merged = {
|
|
79
87
|
"type" => "button",
|
|
80
88
|
"onclick" => "this.nextElementSibling.showModal()"
|
data/lib/klods/components/nav.rb
CHANGED
|
@@ -9,8 +9,9 @@ module Klods
|
|
|
9
9
|
|
|
10
10
|
private_constant :MENU_SVG
|
|
11
11
|
|
|
12
|
-
def nav(a = nil, b = nil)
|
|
12
|
+
def nav(a = nil, b = nil, &block)
|
|
13
13
|
props, children = Core.normalize_args(a, b)
|
|
14
|
+
children = klods_capture(&block) if block
|
|
14
15
|
Core.build(
|
|
15
16
|
tag: "nav", base: "klods-nav",
|
|
16
17
|
modifiers: {collapse: "klods-nav--collapse"},
|
|
@@ -18,13 +19,15 @@ module Klods
|
|
|
18
19
|
)
|
|
19
20
|
end
|
|
20
21
|
|
|
21
|
-
def nav_list(a = nil, b = nil)
|
|
22
|
+
def nav_list(a = nil, b = nil, &block)
|
|
22
23
|
props, children = Core.normalize_args(a, b)
|
|
24
|
+
children = klods_capture(&block) if block
|
|
23
25
|
Core.build(tag: "ul", base: "klods-nav__list", props: props, children: children)
|
|
24
26
|
end
|
|
25
27
|
|
|
26
|
-
def nav_link(a = nil, b = nil)
|
|
28
|
+
def nav_link(a = nil, b = nil, &block)
|
|
27
29
|
props, children = Core.normalize_args(a, b)
|
|
30
|
+
children = klods_capture(&block) if block
|
|
28
31
|
link = Core.build(
|
|
29
32
|
tag: "a", base: "klods-nav__link",
|
|
30
33
|
modifiers: {active: "klods-nav__link--active"},
|
|
@@ -33,16 +36,18 @@ module Klods
|
|
|
33
36
|
Core.el("li", {}, link)
|
|
34
37
|
end
|
|
35
38
|
|
|
36
|
-
def nav_toggle(a = nil, b = nil)
|
|
39
|
+
def nav_toggle(a = nil, b = nil, &block)
|
|
37
40
|
props, children = Core.normalize_args(a, b)
|
|
41
|
+
children = klods_capture(&block) if block
|
|
38
42
|
props = {"type" => "button", "aria-label" => "Toggle navigation", "class" => "klods-nav__toggle"}
|
|
39
43
|
.merge(props.transform_keys(&:to_s))
|
|
40
44
|
default_icon = Core.el("span", {"aria-hidden" => "true", "class" => "klods-icon"}, Core.raw(MENU_SVG))
|
|
41
45
|
Core.el("button", props, children || default_icon)
|
|
42
46
|
end
|
|
43
47
|
|
|
44
|
-
def toc(a = nil, b = nil)
|
|
48
|
+
def toc(a = nil, b = nil, &block)
|
|
45
49
|
props, children = Core.normalize_args(a, b)
|
|
50
|
+
children = klods_capture(&block) if block
|
|
46
51
|
Core.build(
|
|
47
52
|
tag: "ul", base: "klods-toc",
|
|
48
53
|
modifiers: {sub: "klods-toc--sub"},
|
|
@@ -50,13 +55,15 @@ module Klods
|
|
|
50
55
|
)
|
|
51
56
|
end
|
|
52
57
|
|
|
53
|
-
def toc_item(a = nil, b = nil)
|
|
58
|
+
def toc_item(a = nil, b = nil, &block)
|
|
54
59
|
props, children = Core.normalize_args(a, b)
|
|
60
|
+
children = klods_capture(&block) if block
|
|
55
61
|
Core.el("li", props, children)
|
|
56
62
|
end
|
|
57
63
|
|
|
58
|
-
def toc_link(a = nil, b = nil)
|
|
64
|
+
def toc_link(a = nil, b = nil, &block)
|
|
59
65
|
props, children = Core.normalize_args(a, b)
|
|
66
|
+
children = klods_capture(&block) if block
|
|
60
67
|
Core.el("a", props, children)
|
|
61
68
|
end
|
|
62
69
|
end
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Components
|
|
3
3
|
module Prose
|
|
4
|
-
def prose(a = nil, b = nil)
|
|
4
|
+
def prose(a = nil, b = nil, &block)
|
|
5
5
|
props, children = Core.normalize_args(a, b)
|
|
6
|
+
children = klods_capture(&block) if block
|
|
6
7
|
Core.build(tag: "div", base: "klods-prose", props: props, children: children)
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
def muted(a = nil, b = nil)
|
|
10
|
+
def muted(a = nil, b = nil, &block)
|
|
10
11
|
props, children = Core.normalize_args(a, b)
|
|
12
|
+
children = klods_capture(&block) if block
|
|
11
13
|
Core.build(tag: "span", base: "klods-muted", props: props, children: children)
|
|
12
14
|
end
|
|
13
15
|
|
|
14
|
-
def lead(a = nil, b = nil)
|
|
16
|
+
def lead(a = nil, b = nil, &block)
|
|
15
17
|
props, children = Core.normalize_args(a, b)
|
|
18
|
+
children = klods_capture(&block) if block
|
|
16
19
|
Core.build(tag: "p", base: "klods-lead", props: props, children: children)
|
|
17
20
|
end
|
|
18
21
|
|
|
19
|
-
def text_center(a = nil, b = nil)
|
|
22
|
+
def text_center(a = nil, b = nil, &block)
|
|
20
23
|
props, children = Core.normalize_args(a, b)
|
|
24
|
+
children = klods_capture(&block) if block
|
|
21
25
|
Core.build(tag: "div", base: "klods-text-center", props: props, children: children)
|
|
22
26
|
end
|
|
23
27
|
end
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Components
|
|
3
3
|
module Table
|
|
4
|
-
def table_wrap(a = nil, b = nil)
|
|
4
|
+
def table_wrap(a = nil, b = nil, &block)
|
|
5
5
|
props, children = Core.normalize_args(a, b)
|
|
6
|
+
children = klods_capture(&block) if block
|
|
6
7
|
Core.build(tag: "div", base: "klods-table-wrap", props: props, children: children)
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
def table(a = nil, b = nil)
|
|
10
|
+
def table(a = nil, b = nil, &block)
|
|
10
11
|
props, children = Core.normalize_args(a, b)
|
|
12
|
+
children = klods_capture(&block) if block
|
|
11
13
|
Core.build(
|
|
12
14
|
tag: "table", base: "klods-table",
|
|
13
15
|
modifiers: {
|
|
@@ -18,28 +20,33 @@ module Klods
|
|
|
18
20
|
)
|
|
19
21
|
end
|
|
20
22
|
|
|
21
|
-
def thead(a = nil, b = nil)
|
|
23
|
+
def thead(a = nil, b = nil, &block)
|
|
22
24
|
props, children = Core.normalize_args(a, b)
|
|
25
|
+
children = klods_capture(&block) if block
|
|
23
26
|
Core.el("thead", props, children)
|
|
24
27
|
end
|
|
25
28
|
|
|
26
|
-
def tbody(a = nil, b = nil)
|
|
29
|
+
def tbody(a = nil, b = nil, &block)
|
|
27
30
|
props, children = Core.normalize_args(a, b)
|
|
31
|
+
children = klods_capture(&block) if block
|
|
28
32
|
Core.el("tbody", props, children)
|
|
29
33
|
end
|
|
30
34
|
|
|
31
|
-
def tr(a = nil, b = nil)
|
|
35
|
+
def tr(a = nil, b = nil, &block)
|
|
32
36
|
props, children = Core.normalize_args(a, b)
|
|
37
|
+
children = klods_capture(&block) if block
|
|
33
38
|
Core.el("tr", props, children)
|
|
34
39
|
end
|
|
35
40
|
|
|
36
|
-
def th(a = nil, b = nil)
|
|
41
|
+
def th(a = nil, b = nil, &block)
|
|
37
42
|
props, children = Core.normalize_args(a, b)
|
|
43
|
+
children = klods_capture(&block) if block
|
|
38
44
|
Core.el("th", props, children)
|
|
39
45
|
end
|
|
40
46
|
|
|
41
|
-
def td(a = nil, b = nil)
|
|
47
|
+
def td(a = nil, b = nil, &block)
|
|
42
48
|
props, children = Core.normalize_args(a, b)
|
|
49
|
+
children = klods_capture(&block) if block
|
|
43
50
|
Core.el("td", props, children)
|
|
44
51
|
end
|
|
45
52
|
end
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Components
|
|
3
3
|
module Tabs
|
|
4
|
-
def tab_panel(a = nil, b = nil)
|
|
4
|
+
def tab_panel(a = nil, b = nil, &block)
|
|
5
5
|
props, children = Core.normalize_args(a, b)
|
|
6
|
+
children = klods_capture(&block) if block
|
|
6
7
|
label = props.delete(:label) || props.delete("label")
|
|
7
8
|
attrs = label ? props.merge("data-tab-label" => label.to_s) : props
|
|
8
9
|
Core.el("div", attrs, children)
|
|
@@ -4,8 +4,9 @@ module Klods
|
|
|
4
4
|
# Renders the live region container. Mount this once in your layout;
|
|
5
5
|
# individual toasts are appended inside it (via JS on the client, or
|
|
6
6
|
# server-rendered for SSR pre-populated notifications).
|
|
7
|
-
def toast_region(a = nil, b = nil)
|
|
7
|
+
def toast_region(a = nil, b = nil, &block)
|
|
8
8
|
props, children = Core.normalize_args(a, b)
|
|
9
|
+
children = klods_capture(&block) if block
|
|
9
10
|
attrs = {
|
|
10
11
|
"class" => "klods-toast-region",
|
|
11
12
|
"aria-live" => "polite",
|
|
@@ -16,8 +17,9 @@ module Klods
|
|
|
16
17
|
Core.el("div", attrs, children)
|
|
17
18
|
end
|
|
18
19
|
|
|
19
|
-
def toast(a = nil, b = nil)
|
|
20
|
+
def toast(a = nil, b = nil, &block)
|
|
20
21
|
props, children = Core.normalize_args(a, b)
|
|
22
|
+
children = klods_capture(&block) if block
|
|
21
23
|
props = props.transform_keys(&:to_s)
|
|
22
24
|
variant = props.delete("variant")
|
|
23
25
|
extra_class = props.delete("class")
|
data/lib/klods/html.rb
CHANGED
|
@@ -8,15 +8,17 @@ module Klods
|
|
|
8
8
|
%w[a abbr address article b blockquote br caption cite code col colgroup
|
|
9
9
|
data dfn div em figcaption figure h1 h2 h3 h4 h5 h6 hr i img ins
|
|
10
10
|
legend li mark ol p pre q s small span strong sub sup time u ul].each do |tag|
|
|
11
|
-
define_method(tag) do |a = nil, b = nil|
|
|
11
|
+
define_method(tag) do |a = nil, b = nil, &block|
|
|
12
12
|
props, children = Core.normalize_args(a, b)
|
|
13
|
+
children = klods_capture(&block) if block
|
|
13
14
|
Core.el(tag, props, children)
|
|
14
15
|
end
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
# `var` is a reserved word in some linters; named var_el to match klods-js.
|
|
18
|
-
def var_el(a = nil, b = nil)
|
|
19
|
+
def var_el(a = nil, b = nil, &block)
|
|
19
20
|
props, children = Core.normalize_args(a, b)
|
|
21
|
+
children = klods_capture(&block) if block
|
|
20
22
|
Core.el("var", props, children)
|
|
21
23
|
end
|
|
22
24
|
end
|
data/lib/klods/layout.rb
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Layout
|
|
3
|
-
def page(a = nil, b = nil)
|
|
3
|
+
def page(a = nil, b = nil, &block)
|
|
4
4
|
props, children = Core.normalize_args(a, b)
|
|
5
|
+
children = klods_capture(&block) if block
|
|
5
6
|
Core.build(
|
|
6
7
|
tag: "div", base: "klods-page",
|
|
7
8
|
modifiers: {
|
|
@@ -13,18 +14,21 @@ module Klods
|
|
|
13
14
|
)
|
|
14
15
|
end
|
|
15
16
|
|
|
16
|
-
def header(a = nil, b = nil)
|
|
17
|
+
def header(a = nil, b = nil, &block)
|
|
17
18
|
props, children = Core.normalize_args(a, b)
|
|
19
|
+
children = klods_capture(&block) if block
|
|
18
20
|
Core.build(tag: "header", base: "klods-header", props: props, children: children)
|
|
19
21
|
end
|
|
20
22
|
|
|
21
|
-
def sidebar(a = nil, b = nil)
|
|
23
|
+
def sidebar(a = nil, b = nil, &block)
|
|
22
24
|
props, children = Core.normalize_args(a, b)
|
|
25
|
+
children = klods_capture(&block) if block
|
|
23
26
|
Core.build(tag: "aside", base: "klods-sidebar", props: props, children: children)
|
|
24
27
|
end
|
|
25
28
|
|
|
26
|
-
def content(a = nil, b = nil)
|
|
29
|
+
def content(a = nil, b = nil, &block)
|
|
27
30
|
props, children = Core.normalize_args(a, b)
|
|
31
|
+
children = klods_capture(&block) if block
|
|
28
32
|
Core.build(
|
|
29
33
|
tag: "main", base: "klods-content",
|
|
30
34
|
modifiers: {narrow: "klods-content--narrow"},
|
|
@@ -32,18 +36,21 @@ module Klods
|
|
|
32
36
|
)
|
|
33
37
|
end
|
|
34
38
|
|
|
35
|
-
def footer(a = nil, b = nil)
|
|
39
|
+
def footer(a = nil, b = nil, &block)
|
|
36
40
|
props, children = Core.normalize_args(a, b)
|
|
41
|
+
children = klods_capture(&block) if block
|
|
37
42
|
Core.build(tag: "footer", base: "klods-footer", props: props, children: children)
|
|
38
43
|
end
|
|
39
44
|
|
|
40
|
-
def section(a = nil, b = nil)
|
|
45
|
+
def section(a = nil, b = nil, &block)
|
|
41
46
|
props, children = Core.normalize_args(a, b)
|
|
47
|
+
children = klods_capture(&block) if block
|
|
42
48
|
Core.build(tag: "section", base: "klods-section", props: props, children: children)
|
|
43
49
|
end
|
|
44
50
|
|
|
45
|
-
def stack(a = nil, b = nil)
|
|
51
|
+
def stack(a = nil, b = nil, &block)
|
|
46
52
|
props, children = Core.normalize_args(a, b)
|
|
53
|
+
children = klods_capture(&block) if block
|
|
47
54
|
Core.build(
|
|
48
55
|
tag: "div", base: "klods-stack",
|
|
49
56
|
modifiers: {gap: ->(v) { v ? "klods-stack--gap-#{v}" : nil }},
|
|
@@ -51,8 +58,9 @@ module Klods
|
|
|
51
58
|
)
|
|
52
59
|
end
|
|
53
60
|
|
|
54
|
-
def cluster(a = nil, b = nil)
|
|
61
|
+
def cluster(a = nil, b = nil, &block)
|
|
55
62
|
props, children = Core.normalize_args(a, b)
|
|
63
|
+
children = klods_capture(&block) if block
|
|
56
64
|
Core.build(
|
|
57
65
|
tag: "div", base: "klods-cluster",
|
|
58
66
|
modifiers: {gap: ->(v) { v ? "klods-cluster--gap-#{v}" : nil }},
|
|
@@ -60,8 +68,9 @@ module Klods
|
|
|
60
68
|
)
|
|
61
69
|
end
|
|
62
70
|
|
|
63
|
-
def row(a = nil, b = nil)
|
|
71
|
+
def row(a = nil, b = nil, &block)
|
|
64
72
|
props, children = Core.normalize_args(a, b)
|
|
73
|
+
children = klods_capture(&block) if block
|
|
65
74
|
Core.build(
|
|
66
75
|
tag: "div", base: "klods-row",
|
|
67
76
|
modifiers: {
|
|
@@ -72,8 +81,9 @@ module Klods
|
|
|
72
81
|
)
|
|
73
82
|
end
|
|
74
83
|
|
|
75
|
-
def grid(a = nil, b = nil)
|
|
84
|
+
def grid(a = nil, b = nil, &block)
|
|
76
85
|
props, children = Core.normalize_args(a, b)
|
|
86
|
+
children = klods_capture(&block) if block
|
|
77
87
|
Core.build(
|
|
78
88
|
tag: "div", base: "klods-grid",
|
|
79
89
|
modifiers: {
|
|
@@ -85,13 +95,15 @@ module Klods
|
|
|
85
95
|
)
|
|
86
96
|
end
|
|
87
97
|
|
|
88
|
-
def center(a = nil, b = nil)
|
|
98
|
+
def center(a = nil, b = nil, &block)
|
|
89
99
|
props, children = Core.normalize_args(a, b)
|
|
100
|
+
children = klods_capture(&block) if block
|
|
90
101
|
Core.build(tag: "div", base: "klods-center", props: props, children: children)
|
|
91
102
|
end
|
|
92
103
|
|
|
93
|
-
def spread(a = nil, b = nil)
|
|
104
|
+
def spread(a = nil, b = nil, &block)
|
|
94
105
|
props, children = Core.normalize_args(a, b)
|
|
106
|
+
children = klods_capture(&block) if block
|
|
95
107
|
Core.build(tag: "div", base: "klods-spread", props: props, children: children)
|
|
96
108
|
end
|
|
97
109
|
|
data/lib/klods/utilities.rb
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
module Klods
|
|
2
2
|
module Utilities
|
|
3
|
-
def push(a = nil, b = nil)
|
|
3
|
+
def push(a = nil, b = nil, &block)
|
|
4
4
|
props, children = Core.normalize_args(a, b)
|
|
5
|
+
children = klods_capture(&block) if block
|
|
5
6
|
Core.build(tag: "span", base: "klods-push", props: props, children: children)
|
|
6
7
|
end
|
|
7
8
|
|
|
8
|
-
def fill(a = nil, b = nil)
|
|
9
|
+
def fill(a = nil, b = nil, &block)
|
|
9
10
|
props, children = Core.normalize_args(a, b)
|
|
11
|
+
children = klods_capture(&block) if block
|
|
10
12
|
Core.build(tag: "div", base: "klods-fill", props: props, children: children)
|
|
11
13
|
end
|
|
12
14
|
end
|
data/lib/klods/version.rb
CHANGED