protos 0.3.0 → 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 +26 -7
- data/benchmarks/.keep +0 -0
- data/benchmarks/table.txt +12 -0
- data/examples/list.rb +2 -0
- data/lib/protos/accordion/item.rb +5 -6
- 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/breadcrumbs/crumb.rb +2 -2
- data/lib/protos/breadcrumbs.rb +1 -3
- 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 +2 -6
- data/lib/protos/combobox.rb +8 -24
- data/lib/protos/command/empty.rb +2 -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/trigger.rb +2 -2
- data/lib/protos/drawer.rb +3 -9
- data/lib/protos/dropdown/item.rb +2 -2
- 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/trigger.rb +2 -2
- data/lib/protos/modal.rb +5 -11
- data/lib/protos/popover/content.rb +2 -0
- 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 +2 -6
- 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 +7 -21
- data/lib/protos/tabs/tab.rb +3 -3
- 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 +1 -0
- 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 +14 -2
- metadata +6 -4
data/lib/protos/command.rb
CHANGED
@@ -6,41 +6,25 @@ module Protos
|
|
6
6
|
# filterable list of commands. Command modals are by default closable by
|
7
7
|
# clicking the overlay rather than a specific close button.
|
8
8
|
|
9
|
-
def view_template(&
|
10
|
-
div(**attrs, &
|
9
|
+
def view_template(&)
|
10
|
+
div(**attrs, &)
|
11
11
|
end
|
12
12
|
|
13
|
-
def input(...)
|
14
|
-
Input.new(...)
|
15
|
-
end
|
13
|
+
def input(...) = render Input.new(...)
|
16
14
|
|
17
|
-
def list(...)
|
18
|
-
List.new(...)
|
19
|
-
end
|
15
|
+
def list(...) = render List.new(...)
|
20
16
|
|
21
|
-
def trigger(...)
|
22
|
-
Trigger.new(...)
|
23
|
-
end
|
17
|
+
def trigger(...) = render Trigger.new(...)
|
24
18
|
|
25
|
-
def dialog(...)
|
26
|
-
Dialog.new(...)
|
27
|
-
end
|
19
|
+
def dialog(...) = render Dialog.new(...)
|
28
20
|
|
29
|
-
def title(...)
|
30
|
-
Title.new(...)
|
31
|
-
end
|
21
|
+
def title(...) = render Title.new(...)
|
32
22
|
|
33
|
-
def group(...)
|
34
|
-
Group.new(...)
|
35
|
-
end
|
23
|
+
def group(...) = render Group.new(...)
|
36
24
|
|
37
|
-
def item(...)
|
38
|
-
Item.new
|
39
|
-
end
|
25
|
+
def item(...) = render Item.new(...)
|
40
26
|
|
41
|
-
def empty(...)
|
42
|
-
Empty.new(...)
|
43
|
-
end
|
27
|
+
def empty(...) = render Empty.new(...)
|
44
28
|
|
45
29
|
private
|
46
30
|
|
data/lib/protos/component.rb
CHANGED
@@ -21,35 +21,24 @@ module Protos
|
|
21
21
|
default_attrs_method :default_attrs
|
22
22
|
|
23
23
|
# Theme can override the css hash and add additional styles
|
24
|
-
option :theme, as: :theme_override, default: -> { {} }, reader:
|
24
|
+
option :theme, as: :theme_override, default: -> { {} }, reader: false
|
25
25
|
# Class becomes the :container key in the css hash
|
26
|
-
option :class, as: :container_class, default: -> { "" }, reader:
|
27
|
-
option :html_options, default: -> { {} }, reader:
|
26
|
+
option :class, as: :container_class, default: -> { "" }, reader: false
|
27
|
+
option :html_options, default: -> { {} }, reader: false
|
28
28
|
|
29
29
|
# Adds non-defined options to the html_options hash
|
30
|
-
def initialize(*args, **kwargs, &
|
31
|
-
raise_block_in_initializer_error if block
|
32
|
-
|
30
|
+
def initialize(*args, **kwargs, &)
|
33
31
|
defined_keys = self.class.dry_initializer.definitions.keys
|
34
32
|
defined, undefined =
|
35
33
|
kwargs
|
36
34
|
.partition { |key, _| defined_keys.include?(key) }
|
37
|
-
.map(&:to_h)
|
35
|
+
.map!(&:to_h)
|
38
36
|
|
39
|
-
super(*args, html_options: undefined, **defined)
|
37
|
+
super(*args, html_options: undefined, **defined, &)
|
40
38
|
end
|
41
39
|
|
42
40
|
private
|
43
41
|
|
44
|
-
def raise_block_in_initializer_error
|
45
|
-
raise(
|
46
|
-
ArgumentError,
|
47
|
-
"It is unexpected to pass a block to the initializer of a component. " \
|
48
|
-
"You might have tried to render and passed a block but it went to " \
|
49
|
-
"the component.new. Check your render call."
|
50
|
-
)
|
51
|
-
end
|
52
|
-
|
53
42
|
def attrs
|
54
43
|
@attrs ||= build_attrs
|
55
44
|
end
|
@@ -59,33 +48,35 @@ module Protos
|
|
59
48
|
end
|
60
49
|
|
61
50
|
def build_attrs(...)
|
62
|
-
defaults = if respond_to?(
|
63
|
-
|
64
|
-
:include_private
|
65
|
-
)
|
66
|
-
send(self.class.default_attrs_method)
|
51
|
+
defaults = if respond_to?(default_attrs_method, :include_private)
|
52
|
+
send(default_attrs_method)
|
67
53
|
end
|
68
54
|
|
69
55
|
Attributes
|
70
56
|
.new(...)
|
71
57
|
.merge(defaults)
|
72
|
-
.merge(html_options)
|
58
|
+
.merge(@html_options)
|
73
59
|
.merge(class: css[:container])
|
74
60
|
end
|
75
61
|
|
76
62
|
def build_theme(...)
|
77
|
-
component_style = if respond_to?(
|
78
|
-
|
79
|
-
:include_private
|
80
|
-
)
|
81
|
-
send(self.class.theme_method)
|
63
|
+
component_style = if respond_to?(theme_method, :include_private)
|
64
|
+
send(theme_method)
|
82
65
|
end
|
83
66
|
|
84
67
|
Theme
|
85
68
|
.new(...)
|
86
69
|
.merge(component_style)
|
87
|
-
.merge(theme_override)
|
88
|
-
.merge(container: container_class)
|
70
|
+
.merge(@theme_override)
|
71
|
+
.merge(container: @container_class)
|
72
|
+
end
|
73
|
+
|
74
|
+
def theme_method
|
75
|
+
self.class.theme_method
|
76
|
+
end
|
77
|
+
|
78
|
+
def default_attrs_method
|
79
|
+
self.class.default_attrs_method
|
89
80
|
end
|
90
81
|
end
|
91
82
|
end
|
data/lib/protos/drawer.rb
CHANGED
@@ -16,17 +16,11 @@ module Protos
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def content(...)
|
20
|
-
Content.new(...)
|
21
|
-
end
|
19
|
+
def content(...) = render Content.new(...)
|
22
20
|
|
23
|
-
def side(
|
24
|
-
Side.new(*args, id:, **kwargs, &block)
|
25
|
-
end
|
21
|
+
def side(*, **, &) = render Side.new(*, id:, **, &)
|
26
22
|
|
27
|
-
def trigger(
|
28
|
-
Trigger.new(*args, id:, **kwargs, &block)
|
29
|
-
end
|
23
|
+
def trigger(*, **, &) = render Trigger.new(*, id:, **, &)
|
30
24
|
|
31
25
|
private
|
32
26
|
|
data/lib/protos/dropdown/item.rb
CHANGED
data/lib/protos/dropdown.rb
CHANGED
@@ -19,16 +19,10 @@ module Protos
|
|
19
19
|
reader: false,
|
20
20
|
type: TriggerTypes | Types::Array.of(TriggerTypes)
|
21
21
|
|
22
|
-
def item(...)
|
23
|
-
Item.new(...)
|
24
|
-
end
|
22
|
+
def item(...) = render Item.new(...)
|
25
23
|
|
26
|
-
def menu(...)
|
27
|
-
Menu.new(...)
|
28
|
-
end
|
24
|
+
def menu(...) = render Menu.new(...)
|
29
25
|
|
30
|
-
def trigger(...)
|
31
|
-
Trigger.new(...)
|
32
|
-
end
|
26
|
+
def trigger(...) = render Trigger.new(...)
|
33
27
|
end
|
34
28
|
end
|
data/lib/protos/hero/content.rb
CHANGED
data/lib/protos/hero/overlay.rb
CHANGED
data/lib/protos/hero.rb
CHANGED
@@ -6,17 +6,13 @@ module Protos
|
|
6
6
|
# optionally layout an image for a responsive layout.
|
7
7
|
# https://daisyui.com/components/hero/
|
8
8
|
|
9
|
-
def view_template(&
|
10
|
-
div(**attrs, &
|
9
|
+
def view_template(&)
|
10
|
+
div(**attrs, &)
|
11
11
|
end
|
12
12
|
|
13
|
-
def content(...)
|
14
|
-
Content.new(...)
|
15
|
-
end
|
13
|
+
def content(...) = render Content.new(...)
|
16
14
|
|
17
|
-
def overlay(...)
|
18
|
-
Overlay.new(...)
|
19
|
-
end
|
15
|
+
def overlay(...) = render Overlay.new(...)
|
20
16
|
|
21
17
|
private
|
22
18
|
|
data/lib/protos/list/item.rb
CHANGED
@@ -7,8 +7,8 @@ module Protos
|
|
7
7
|
# work for list items, including border radius. E.g. only the first and
|
8
8
|
# last items will have border radius on the top and bottom.
|
9
9
|
|
10
|
-
def view_template(&
|
11
|
-
li(**attrs, &
|
10
|
+
def view_template(&)
|
11
|
+
li(**attrs, &)
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
data/lib/protos/list.rb
CHANGED
@@ -7,13 +7,11 @@ module Protos
|
|
7
7
|
|
8
8
|
option :ordered, Types::Bool, default: -> { false }, reader: false
|
9
9
|
|
10
|
-
def view_template(&
|
11
|
-
send(element, **attrs, &
|
10
|
+
def view_template(&)
|
11
|
+
send(element, **attrs, &)
|
12
12
|
end
|
13
13
|
|
14
|
-
def item(...)
|
15
|
-
Item.new(...)
|
16
|
-
end
|
14
|
+
def item(...) = render Item.new(...)
|
17
15
|
|
18
16
|
private
|
19
17
|
|
data/lib/protos/modal/trigger.rb
CHANGED
data/lib/protos/modal.rb
CHANGED
@@ -5,21 +5,15 @@ module Protos
|
|
5
5
|
# DOCS: A modal component that can be triggered by a button or a link and
|
6
6
|
# will open a fullscreen modal, usually with a close button.
|
7
7
|
|
8
|
-
def view_template(&
|
9
|
-
div(**attrs, class: css[:container], &
|
8
|
+
def view_template(&)
|
9
|
+
div(**attrs, class: css[:container], &)
|
10
10
|
end
|
11
11
|
|
12
|
-
def close_button(...)
|
13
|
-
CloseButton.new(...)
|
14
|
-
end
|
12
|
+
def close_button(...) = render CloseButton.new(...)
|
15
13
|
|
16
|
-
def dialog(...)
|
17
|
-
Dialog.new(...)
|
18
|
-
end
|
14
|
+
def dialog(...) = render Dialog.new(...)
|
19
15
|
|
20
|
-
def trigger(...)
|
21
|
-
Trigger.new(...)
|
22
|
-
end
|
16
|
+
def trigger(...) = render Trigger.new(...)
|
23
17
|
|
24
18
|
private
|
25
19
|
|
@@ -7,6 +7,8 @@ module Protos
|
|
7
7
|
# added to the DOM by tippy.js to handle the position of the content.
|
8
8
|
# This means content in here will not be available in system tests that
|
9
9
|
# use rack_test.
|
10
|
+
#
|
11
|
+
# TODO: Move away from using template
|
10
12
|
|
11
13
|
def view_template(&block)
|
12
14
|
template_tag(**template_attrs) do
|
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 view_template(&
|
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 view_template(&
|
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
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 view_template(&
|
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
@@ -24,33 +24,19 @@ module Protos
|
|
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
|
|