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/chat_bubble.rb
CHANGED
@@ -15,25 +15,17 @@ module Protos
|
|
15
15
|
:end
|
16
16
|
)
|
17
17
|
|
18
|
-
def
|
19
|
-
div(**attrs, &
|
18
|
+
def view_template(&)
|
19
|
+
div(**attrs, &)
|
20
20
|
end
|
21
21
|
|
22
|
-
def content(...)
|
23
|
-
Content.new(...)
|
24
|
-
end
|
22
|
+
def content(...) = render Content.new(...)
|
25
23
|
|
26
|
-
def footer(...)
|
27
|
-
Footer.new(...)
|
28
|
-
end
|
24
|
+
def footer(...) = render Footer.new(...)
|
29
25
|
|
30
|
-
def header(...)
|
31
|
-
Header.new(...)
|
32
|
-
end
|
26
|
+
def header(...) = render Header.new(...)
|
33
27
|
|
34
|
-
def image(...)
|
35
|
-
Image.new(...)
|
36
|
-
end
|
28
|
+
def image(...) = render Image.new(...)
|
37
29
|
|
38
30
|
private
|
39
31
|
|
@@ -10,11 +10,11 @@ module Protos
|
|
10
10
|
reader: false,
|
11
11
|
default: -> { "" }
|
12
12
|
|
13
|
-
def
|
13
|
+
def view_template(&)
|
14
14
|
if @id.size.positive?
|
15
|
-
label(for: @id, **attrs, &
|
15
|
+
label(for: @id, **attrs, &)
|
16
16
|
else
|
17
|
-
div(**attrs, &
|
17
|
+
div(**attrs, &)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/lib/protos/collapse.rb
CHANGED
@@ -11,20 +11,16 @@ module Protos
|
|
11
11
|
default: -> { "collapse-#{SecureRandom.hex(4)}" },
|
12
12
|
type: Types::String
|
13
13
|
|
14
|
-
def
|
14
|
+
def view_template
|
15
15
|
div(**attrs) do
|
16
|
-
input(type: "checkbox", id:) if @checkbox
|
16
|
+
input(type: "checkbox", id:, autocomplete: :off) if @checkbox
|
17
17
|
yield if block_given?
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def title(
|
22
|
-
Title.new(*args, id:, **kwargs, &block)
|
23
|
-
end
|
21
|
+
def title(*, **, &) = render Title.new(*, id:, **, &)
|
24
22
|
|
25
|
-
def content(...)
|
26
|
-
Content.new(...)
|
27
|
-
end
|
23
|
+
def content(...) = render Content.new(...)
|
28
24
|
|
29
25
|
private
|
30
26
|
|
data/lib/protos/combobox.rb
CHANGED
@@ -11,37 +11,21 @@ module Protos
|
|
11
11
|
reader: false,
|
12
12
|
type: TriggerTypes | Types::Array.of(TriggerTypes)
|
13
13
|
|
14
|
-
def trigger(...)
|
15
|
-
Popover::Trigger.new(...)
|
16
|
-
end
|
14
|
+
def trigger(...) = render Popover::Trigger.new(...)
|
17
15
|
|
18
|
-
def content(...)
|
19
|
-
Popover::Content.new(...)
|
20
|
-
end
|
16
|
+
def content(...) = render Popover::Content.new(...)
|
21
17
|
|
22
|
-
def input(...)
|
23
|
-
Command::Input.new(...)
|
24
|
-
end
|
18
|
+
def input(...) = render Command::Input.new(...)
|
25
19
|
|
26
|
-
def group(...)
|
27
|
-
Command::Group.new(...)
|
28
|
-
end
|
20
|
+
def group(...) = render Command::Group.new(...)
|
29
21
|
|
30
|
-
def item(...)
|
31
|
-
Command::Item.new(...)
|
32
|
-
end
|
22
|
+
def item(...) = render Command::Item.new(...)
|
33
23
|
|
34
|
-
def list(...)
|
35
|
-
Command::List.new(...)
|
36
|
-
end
|
24
|
+
def list(...) = render Command::List.new(...)
|
37
25
|
|
38
|
-
def title(...)
|
39
|
-
Command::Title.new(...)
|
40
|
-
end
|
26
|
+
def title(...) = render Command::Title.new(...)
|
41
27
|
|
42
|
-
def empty(...)
|
43
|
-
Command::Empty.new(...)
|
44
|
-
end
|
28
|
+
def empty(...) = render Command::Empty.new(...)
|
45
29
|
|
46
30
|
private
|
47
31
|
|
@@ -6,7 +6,7 @@ module Protos
|
|
6
6
|
# DOCS: The dialog for a command wraps the command content and provides a
|
7
7
|
# modal backdrop for the command when it is opened.
|
8
8
|
|
9
|
-
def
|
9
|
+
def view_template(&block)
|
10
10
|
dialog(**attrs) do
|
11
11
|
div(class: css[:modal], &block)
|
12
12
|
form(method: :dialog, class: css[:form]) do
|
data/lib/protos/command/empty.rb
CHANGED
data/lib/protos/command/group.rb
CHANGED
data/lib/protos/command/input.rb
CHANGED
@@ -11,7 +11,7 @@ module Protos
|
|
11
11
|
},
|
12
12
|
reader: :private
|
13
13
|
|
14
|
-
def
|
14
|
+
def view_template(&block)
|
15
15
|
div(**attrs) do
|
16
16
|
label(class: css[:label]) do
|
17
17
|
div(class: css[:icon], &block) if block
|
@@ -19,7 +19,8 @@ module Protos
|
|
19
19
|
type: :text,
|
20
20
|
data: { action: "protos--command#filter" },
|
21
21
|
class: css[:input],
|
22
|
-
placeholder
|
22
|
+
placeholder:,
|
23
|
+
autocomplete: :off
|
23
24
|
)
|
24
25
|
end
|
25
26
|
end
|
data/lib/protos/command/item.rb
CHANGED
data/lib/protos/command/list.rb
CHANGED
data/lib/protos/command/title.rb
CHANGED
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
|
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/side.rb
CHANGED
data/lib/protos/drawer.rb
CHANGED
@@ -9,24 +9,18 @@ module Protos
|
|
9
9
|
|
10
10
|
option :id, type: Types::Coercible::String
|
11
11
|
|
12
|
-
def
|
12
|
+
def view_template
|
13
13
|
div(**attrs) do
|
14
|
-
input(id:, type: :checkbox, class: css[:toggle])
|
14
|
+
input(id:, type: :checkbox, class: css[:toggle], autocomplete: :off)
|
15
15
|
yield if block_given?
|
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/menu.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
|
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
|
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
|
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/dialog.rb
CHANGED
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
|
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,8 +7,10 @@ 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
|
-
def
|
13
|
+
def view_template(&block)
|
12
14
|
template_tag(**template_attrs) do
|
13
15
|
div(**attrs, &block)
|
14
16
|
end
|