protos 0.2.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -5
- data/CHANGELOG.md +11 -0
- data/README.md +82 -67
- data/benchmarks/.keep +0 -0
- data/benchmarks/table.txt +12 -0
- data/examples/list.rb +3 -1
- data/examples/navbar.rb +1 -1
- data/lib/protos/accordion/item.rb +7 -8
- data/lib/protos/accordion.rb +6 -10
- data/lib/protos/alert/actions.rb +2 -2
- data/lib/protos/alert/icon.rb +2 -2
- data/lib/protos/alert.rb +4 -8
- data/lib/protos/attributes.rb +7 -8
- data/lib/protos/avatar.rb +1 -1
- data/lib/protos/breadcrumbs/crumb.rb +2 -2
- data/lib/protos/breadcrumbs.rb +2 -4
- data/lib/protos/card/actions.rb +2 -2
- data/lib/protos/card/body.rb +2 -2
- data/lib/protos/card/image.rb +2 -2
- data/lib/protos/card/title.rb +2 -2
- data/lib/protos/card.rb +6 -14
- data/lib/protos/carousel/actions.rb +2 -2
- data/lib/protos/carousel/item.rb +2 -2
- data/lib/protos/carousel.rb +4 -8
- data/lib/protos/chat_bubble/content.rb +2 -2
- data/lib/protos/chat_bubble/footer.rb +2 -2
- data/lib/protos/chat_bubble/header.rb +2 -2
- data/lib/protos/chat_bubble/image.rb +2 -2
- data/lib/protos/chat_bubble.rb +6 -14
- data/lib/protos/collapse/content.rb +2 -2
- data/lib/protos/collapse/title.rb +3 -3
- data/lib/protos/collapse.rb +4 -8
- data/lib/protos/combobox.rb +8 -24
- data/lib/protos/command/dialog.rb +1 -1
- data/lib/protos/command/empty.rb +2 -2
- data/lib/protos/command/group.rb +1 -1
- data/lib/protos/command/input.rb +3 -2
- data/lib/protos/command/item.rb +2 -2
- data/lib/protos/command/list.rb +2 -2
- data/lib/protos/command/title.rb +2 -2
- data/lib/protos/command/trigger.rb +2 -2
- data/lib/protos/command.rb +10 -26
- data/lib/protos/component.rb +21 -30
- data/lib/protos/drawer/content.rb +2 -2
- data/lib/protos/drawer/side.rb +1 -1
- data/lib/protos/drawer/trigger.rb +2 -2
- data/lib/protos/drawer.rb +5 -11
- data/lib/protos/dropdown/item.rb +2 -2
- data/lib/protos/dropdown/menu.rb +1 -1
- data/lib/protos/dropdown.rb +3 -9
- data/lib/protos/hero/content.rb +2 -2
- data/lib/protos/hero/overlay.rb +2 -2
- data/lib/protos/hero.rb +4 -8
- data/lib/protos/list/item.rb +2 -2
- data/lib/protos/list.rb +3 -5
- data/lib/protos/modal/close_button.rb +1 -1
- data/lib/protos/modal/dialog.rb +1 -1
- data/lib/protos/modal/trigger.rb +2 -2
- data/lib/protos/modal.rb +5 -11
- data/lib/protos/popover/content.rb +3 -1
- data/lib/protos/popover/trigger.rb +2 -2
- data/lib/protos/popover.rb +4 -8
- data/lib/protos/stats/actions.rb +2 -2
- data/lib/protos/stats/description.rb +2 -2
- data/lib/protos/stats/figure.rb +2 -2
- data/lib/protos/stats/stat.rb +2 -2
- data/lib/protos/stats/title.rb +2 -2
- data/lib/protos/stats/value.rb +2 -2
- data/lib/protos/stats.rb +8 -20
- data/lib/protos/swap/off.rb +2 -2
- data/lib/protos/swap/on.rb +2 -2
- data/lib/protos/swap.rb +5 -10
- data/lib/protos/table/body.rb +2 -2
- data/lib/protos/table/caption.rb +3 -3
- data/lib/protos/table/cell.rb +2 -2
- data/lib/protos/table/footer.rb +2 -2
- data/lib/protos/table/head.rb +2 -2
- data/lib/protos/table/header.rb +2 -2
- data/lib/protos/table/row.rb +2 -2
- data/lib/protos/table.rb +8 -22
- data/lib/protos/tabs/tab.rb +5 -4
- data/lib/protos/tabs.rb +3 -5
- data/lib/protos/theme.rb +34 -45
- data/lib/protos/timeline/center.rb +2 -2
- data/lib/protos/timeline/item.rb +2 -2
- data/lib/protos/timeline/left.rb +2 -2
- data/lib/protos/timeline/right.rb +2 -2
- data/lib/protos/timeline.rb +6 -14
- data/lib/protos/toast/close_button.rb +2 -1
- data/lib/protos/toast.rb +3 -5
- data/lib/protos/token_list.rb +18 -31
- data/lib/protos/typography/heading.rb +2 -2
- data/lib/protos/typography/inline_link.rb +3 -3
- data/lib/protos/typography/paragraph.rb +2 -2
- data/lib/protos/typography.rb +12 -12
- data/lib/protos/version.rb +1 -1
- data/protos.gemspec +15 -3
- metadata +8 -6
data/lib/protos/popover.rb
CHANGED
@@ -80,17 +80,13 @@ module Protos
|
|
80
80
|
reader: false,
|
81
81
|
type: TriggerTypes | Types::Array.of(TriggerTypes)
|
82
82
|
|
83
|
-
def
|
84
|
-
div(**attrs, &
|
83
|
+
def view_template(&)
|
84
|
+
div(**attrs, &)
|
85
85
|
end
|
86
86
|
|
87
|
-
def content(...)
|
88
|
-
Content.new(...)
|
89
|
-
end
|
87
|
+
def content(...) = render Content.new(...)
|
90
88
|
|
91
|
-
def trigger(...)
|
92
|
-
Trigger.new(...)
|
93
|
-
end
|
89
|
+
def trigger(...) = render Trigger.new(...)
|
94
90
|
|
95
91
|
private
|
96
92
|
|
data/lib/protos/stats/actions.rb
CHANGED
data/lib/protos/stats/figure.rb
CHANGED
data/lib/protos/stats/stat.rb
CHANGED
data/lib/protos/stats/title.rb
CHANGED
data/lib/protos/stats/value.rb
CHANGED
data/lib/protos/stats.rb
CHANGED
@@ -5,33 +5,21 @@ module Protos
|
|
5
5
|
# DOCS: Stats component that contains a collection of stats
|
6
6
|
# https://daisyui.com/components/stat/
|
7
7
|
|
8
|
-
def
|
9
|
-
div(**attrs, &
|
8
|
+
def view_template(&)
|
9
|
+
div(**attrs, &)
|
10
10
|
end
|
11
11
|
|
12
|
-
def actions(...)
|
13
|
-
Actions.new(...)
|
14
|
-
end
|
12
|
+
def actions(...) = render Actions.new(...)
|
15
13
|
|
16
|
-
def description(...)
|
17
|
-
Description.new(...)
|
18
|
-
end
|
14
|
+
def description(...) = render Description.new(...)
|
19
15
|
|
20
|
-
def figure(...)
|
21
|
-
Figure.new(...)
|
22
|
-
end
|
16
|
+
def figure(...) = render Figure.new(...)
|
23
17
|
|
24
|
-
def stat(...)
|
25
|
-
Stat.new(...)
|
26
|
-
end
|
18
|
+
def stat(...) = render Stat.new(...)
|
27
19
|
|
28
|
-
def title(...)
|
29
|
-
Title.new(...)
|
30
|
-
end
|
20
|
+
def title(...) = render Title.new(...)
|
31
21
|
|
32
|
-
def value(...)
|
33
|
-
Value.new(...)
|
34
|
-
end
|
22
|
+
def value(...) = render Value.new(...)
|
35
23
|
|
36
24
|
private
|
37
25
|
|
data/lib/protos/swap/off.rb
CHANGED
data/lib/protos/swap/on.rb
CHANGED
data/lib/protos/swap.rb
CHANGED
@@ -6,27 +6,22 @@ module Protos
|
|
6
6
|
# display different content.
|
7
7
|
# https://daisyui.com/components/swap/
|
8
8
|
|
9
|
-
def
|
9
|
+
def view_template
|
10
10
|
label(**attrs) do
|
11
|
-
input(type: :checkbox, class: css[:input])
|
11
|
+
input(type: :checkbox, class: css[:input], autocomplete: :off)
|
12
12
|
yield if block_given?
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def on(...)
|
17
|
-
On.new(...)
|
18
|
-
end
|
16
|
+
def on(...) = render On.new(...)
|
19
17
|
|
20
|
-
def off(...)
|
21
|
-
Off.new(...)
|
22
|
-
end
|
18
|
+
def off(...) = render Off.new(...)
|
23
19
|
|
24
20
|
private
|
25
21
|
|
26
22
|
def theme
|
27
23
|
{
|
28
|
-
container: tokens("swap")
|
29
|
-
input: tokens("hidden")
|
24
|
+
container: tokens("swap")
|
30
25
|
}
|
31
26
|
end
|
32
27
|
end
|
data/lib/protos/table/body.rb
CHANGED
data/lib/protos/table/caption.rb
CHANGED
@@ -5,15 +5,15 @@ module Protos
|
|
5
5
|
class Caption < Component
|
6
6
|
# DOCS: The caption of a table
|
7
7
|
|
8
|
-
def
|
9
|
-
caption(**attrs, &
|
8
|
+
def view_template(&)
|
9
|
+
caption(**attrs, &)
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def theme
|
15
15
|
{
|
16
|
-
container: tokens("caption-bottom"
|
16
|
+
container: tokens("caption-bottom")
|
17
17
|
}
|
18
18
|
end
|
19
19
|
end
|
data/lib/protos/table/cell.rb
CHANGED
data/lib/protos/table/footer.rb
CHANGED
data/lib/protos/table/head.rb
CHANGED
data/lib/protos/table/header.rb
CHANGED
data/lib/protos/table/row.rb
CHANGED
data/lib/protos/table.rb
CHANGED
@@ -18,39 +18,25 @@ module Protos
|
|
18
18
|
:lg
|
19
19
|
)
|
20
20
|
|
21
|
-
def
|
21
|
+
def view_template(&block)
|
22
22
|
div(**attrs) do
|
23
23
|
table(class: css[:table], &block)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def body(...)
|
28
|
-
Body.new(...)
|
29
|
-
end
|
27
|
+
def body(...) = render Body.new(...)
|
30
28
|
|
31
|
-
def caption(...)
|
32
|
-
Caption.new(...)
|
33
|
-
end
|
29
|
+
def caption(...) = render Caption.new(...)
|
34
30
|
|
35
|
-
def cell(...)
|
36
|
-
Cell.new(...)
|
37
|
-
end
|
31
|
+
def cell(...) = render Cell.new(...)
|
38
32
|
|
39
|
-
def footer(...)
|
40
|
-
Footer.new(...)
|
41
|
-
end
|
33
|
+
def footer(...) = render Footer.new(...)
|
42
34
|
|
43
|
-
def head(...)
|
44
|
-
Head.new(...)
|
45
|
-
end
|
35
|
+
def head(...) = render Head.new(...)
|
46
36
|
|
47
|
-
def header(...)
|
48
|
-
Header.new(...)
|
49
|
-
end
|
37
|
+
def header(...) = render Header.new(...)
|
50
38
|
|
51
|
-
def row(...)
|
52
|
-
Row.new(...)
|
53
|
-
end
|
39
|
+
def row(...) = render Row.new(...)
|
54
40
|
|
55
41
|
private
|
56
42
|
|
data/lib/protos/tabs/tab.rb
CHANGED
@@ -5,20 +5,21 @@ module Protos
|
|
5
5
|
class Tab < Component
|
6
6
|
# DOCS: A single tab in a tabs component
|
7
7
|
|
8
|
-
|
8
|
+
option :id
|
9
9
|
option :label
|
10
10
|
option :active, default: -> { false }
|
11
11
|
option :disabled, default: -> { false }
|
12
12
|
|
13
|
-
def
|
13
|
+
def view_template(&)
|
14
14
|
input(
|
15
15
|
type: :radio,
|
16
16
|
class: css[:input],
|
17
17
|
name: id,
|
18
18
|
role: :tab,
|
19
|
-
aria_label: label
|
19
|
+
aria_label: label,
|
20
|
+
autocomplete: :off
|
20
21
|
)
|
21
|
-
div(**attrs, &
|
22
|
+
div(**attrs, &)
|
22
23
|
end
|
23
24
|
|
24
25
|
private
|
data/lib/protos/tabs.rb
CHANGED
data/lib/protos/theme.rb
CHANGED
@@ -13,13 +13,24 @@ module Protos
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def initialize(theme = {}, **kwargs)
|
17
|
-
@
|
16
|
+
def initialize(theme = {}, tailwind_merge: true, **kwargs)
|
17
|
+
@tailwind_merge = tailwind_merge
|
18
|
+
|
19
|
+
@theme = Hash.new do |hash, key|
|
20
|
+
hash[key] = TokenList.new
|
21
|
+
end
|
22
|
+
|
23
|
+
theme.merge!(kwargs).each do |key, value|
|
24
|
+
@theme[key].add(value)
|
25
|
+
end
|
18
26
|
end
|
19
27
|
|
20
28
|
def [](key)
|
21
|
-
|
22
|
-
|
29
|
+
return nil unless key?(key)
|
30
|
+
|
31
|
+
value = @theme[key].to_s
|
32
|
+
return nil if value.empty?
|
33
|
+
return value unless @tailwind_merge
|
23
34
|
|
24
35
|
self.class.merger.merge(value)
|
25
36
|
end
|
@@ -29,66 +40,44 @@ module Protos
|
|
29
40
|
end
|
30
41
|
|
31
42
|
def add(key, value)
|
32
|
-
|
33
|
-
.add(@theme.fetch(key, ""))
|
34
|
-
.add(value)
|
35
|
-
.to_s
|
36
|
-
.tap do |tokens|
|
37
|
-
@theme[key] = tokens
|
38
|
-
end
|
43
|
+
@theme[key].add(value)
|
39
44
|
end
|
40
45
|
|
41
46
|
def remove(key, value)
|
42
|
-
|
43
|
-
|
44
|
-
.remove(value)
|
45
|
-
.to_s
|
46
|
-
.tap do |tokens|
|
47
|
-
@theme[key] = tokens
|
48
|
-
end
|
47
|
+
@theme[key].remove(value)
|
48
|
+
@theme.delete(key) if @theme[key].empty?
|
49
49
|
end
|
50
50
|
|
51
51
|
def set(key, value)
|
52
|
-
|
53
|
-
@theme[key] = value
|
54
|
-
else
|
55
|
-
TokenList
|
56
|
-
.parse(value)
|
57
|
-
.to_s
|
58
|
-
.tap do |tokens|
|
59
|
-
@theme[key] = tokens
|
60
|
-
end
|
61
|
-
end
|
52
|
+
@theme[key].clear.add(value)
|
62
53
|
end
|
63
54
|
|
64
55
|
def merge(hash)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
set(no_bang, hash[key])
|
77
|
-
else
|
78
|
-
set(key, hash[key])
|
79
|
-
end
|
56
|
+
return self unless hash
|
57
|
+
|
58
|
+
hash.each do |key, value|
|
59
|
+
if key?(key)
|
60
|
+
add(key, value)
|
61
|
+
elsif negation?(key)
|
62
|
+
remove(key[1..].to_sym, value)
|
63
|
+
elsif override?(key)
|
64
|
+
set(key[..-2].to_sym, value)
|
65
|
+
else
|
66
|
+
set(key, value)
|
80
67
|
end
|
81
68
|
end
|
69
|
+
|
70
|
+
self
|
82
71
|
end
|
83
72
|
|
84
73
|
private
|
85
74
|
|
86
75
|
def negation?(key)
|
87
|
-
key.
|
76
|
+
key.start_with?("!")
|
88
77
|
end
|
89
78
|
|
90
79
|
def override?(key)
|
91
|
-
key.
|
80
|
+
key.end_with?("!")
|
92
81
|
end
|
93
82
|
end
|
94
83
|
end
|
data/lib/protos/timeline/item.rb
CHANGED
data/lib/protos/timeline/left.rb
CHANGED
@@ -6,8 +6,8 @@ module Protos
|
|
6
6
|
# DOCS: Content on the left (on daisyui "start") side of a timeline.
|
7
7
|
# We chose not to use start/end because of the keywork conflict with ruby.
|
8
8
|
|
9
|
-
def
|
10
|
-
div(**attrs, &
|
9
|
+
def view_template(&)
|
10
|
+
div(**attrs, &)
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
@@ -6,8 +6,8 @@ module Protos
|
|
6
6
|
# DOCS: Content on the right (on daisyui "end") side of a timeline.
|
7
7
|
# We chose not to use start/end because of the keywork conflict with ruby.
|
8
8
|
|
9
|
-
def
|
10
|
-
div(**attrs, &
|
9
|
+
def view_template(&)
|
10
|
+
div(**attrs, &)
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
data/lib/protos/timeline.rb
CHANGED
@@ -7,25 +7,17 @@ module Protos
|
|
7
7
|
|
8
8
|
option :vertical, type: Types::Bool, default: -> { false }
|
9
9
|
|
10
|
-
def
|
11
|
-
ul(**attrs, &
|
10
|
+
def view_template(&)
|
11
|
+
ul(**attrs, &)
|
12
12
|
end
|
13
13
|
|
14
|
-
def item(...)
|
15
|
-
Item.new(...)
|
16
|
-
end
|
14
|
+
def item(...) = render Item.new(...)
|
17
15
|
|
18
|
-
def left(...)
|
19
|
-
Left.new(...)
|
20
|
-
end
|
16
|
+
def left(...) = render Left.new(...)
|
21
17
|
|
22
|
-
def center(...)
|
23
|
-
Center.new(...)
|
24
|
-
end
|
18
|
+
def center(...) = render Center.new(...)
|
25
19
|
|
26
|
-
def right(...)
|
27
|
-
Right.new(...)
|
28
|
-
end
|
20
|
+
def right(...) = render Right.new(...)
|
29
21
|
|
30
22
|
private
|
31
23
|
|
@@ -5,11 +5,12 @@ module Protos
|
|
5
5
|
class CloseButton < Component
|
6
6
|
# DOCS: A close button for a toast
|
7
7
|
|
8
|
-
def
|
8
|
+
def view_template(&block)
|
9
9
|
form(method: :dialog, class: css[:form]) do
|
10
10
|
button(
|
11
11
|
autofocus: true,
|
12
12
|
formmethod: :dialog,
|
13
|
+
formnovalidate: true,
|
13
14
|
**attrs,
|
14
15
|
&block
|
15
16
|
)
|
data/lib/protos/toast.rb
CHANGED
@@ -23,13 +23,11 @@ module Protos
|
|
23
23
|
default: -> { :bottom_end },
|
24
24
|
reader: false
|
25
25
|
|
26
|
-
def
|
27
|
-
dialog(**attrs, &
|
26
|
+
def view_template(&)
|
27
|
+
dialog(**attrs, &)
|
28
28
|
end
|
29
29
|
|
30
|
-
def close_button(...)
|
31
|
-
CloseButton.new(...)
|
32
|
-
end
|
30
|
+
def close_button(...) = render CloseButton.new(...)
|
33
31
|
|
34
32
|
private
|
35
33
|
|