protos 0.2.1 → 0.2.2
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/README.md +262 -70
- data/examples/list.rb +34 -0
- data/lib/protos/accordion/item.rb +6 -4
- data/lib/protos/accordion.rb +5 -0
- data/lib/protos/alert/actions.rb +2 -0
- data/lib/protos/alert/icon.rb +3 -0
- data/lib/protos/alert.rb +4 -0
- data/lib/protos/attributes.rb +8 -0
- data/lib/protos/avatar.rb +3 -0
- data/lib/protos/breadcrumbs/crumb.rb +2 -0
- data/lib/protos/breadcrumbs.rb +3 -0
- data/lib/protos/card/actions.rb +2 -0
- data/lib/protos/card/body.rb +2 -0
- data/lib/protos/card/image.rb +4 -0
- data/lib/protos/card/title.rb +2 -0
- data/lib/protos/card.rb +3 -0
- data/lib/protos/carousel/actions.rb +2 -0
- data/lib/protos/carousel/item.rb +2 -0
- data/lib/protos/carousel.rb +4 -0
- data/lib/protos/chat_bubble/content.rb +3 -0
- data/lib/protos/chat_bubble/footer.rb +2 -0
- data/lib/protos/chat_bubble/header.rb +3 -0
- data/lib/protos/chat_bubble/image.rb +3 -0
- data/lib/protos/chat_bubble.rb +5 -0
- data/lib/protos/collapse/content.rb +3 -0
- data/lib/protos/collapse/title.rb +3 -0
- data/lib/protos/collapse.rb +4 -0
- data/lib/protos/combobox.rb +4 -0
- data/lib/protos/command/dialog.rb +9 -1
- data/lib/protos/command/empty.rb +3 -0
- data/lib/protos/command/group.rb +4 -0
- data/lib/protos/command/input.rb +2 -0
- data/lib/protos/command/item.rb +2 -0
- data/lib/protos/command/list.rb +2 -0
- data/lib/protos/command/title.rb +3 -0
- data/lib/protos/command/trigger.rb +2 -0
- data/lib/protos/command.rb +4 -0
- data/lib/protos/component.rb +21 -9
- data/lib/protos/drawer/content.rb +3 -0
- data/lib/protos/drawer/side.rb +8 -1
- data/lib/protos/drawer/trigger.rb +3 -0
- data/lib/protos/drawer.rb +6 -1
- data/lib/protos/dropdown/item.rb +2 -0
- data/lib/protos/dropdown/menu.rb +4 -0
- data/lib/protos/dropdown/trigger.rb +2 -0
- data/lib/protos/dropdown.rb +8 -0
- data/lib/protos/engine.rb +3 -0
- data/lib/protos/hero/content.rb +3 -0
- data/lib/protos/hero/overlay.rb +4 -0
- data/lib/protos/hero.rb +4 -0
- data/lib/protos/list/item.rb +4 -0
- data/lib/protos/list.rb +3 -0
- data/lib/protos/modal/close_button.rb +2 -0
- data/lib/protos/modal/dialog.rb +9 -1
- data/lib/protos/modal/trigger.rb +2 -0
- data/lib/protos/modal.rb +3 -0
- data/lib/protos/popover/content.rb +5 -0
- data/lib/protos/popover/trigger.rb +3 -0
- data/lib/protos/popover.rb +8 -1
- data/lib/protos/stats/actions.rb +2 -0
- data/lib/protos/stats/description.rb +2 -0
- data/lib/protos/stats/figure.rb +2 -0
- data/lib/protos/stats/stat.rb +2 -0
- data/lib/protos/stats/title.rb +2 -0
- data/lib/protos/stats/value.rb +2 -0
- data/lib/protos/stats.rb +3 -0
- data/lib/protos/swap/off.rb +2 -0
- data/lib/protos/swap/on.rb +2 -0
- data/lib/protos/swap.rb +4 -0
- data/lib/protos/table/body.rb +2 -0
- data/lib/protos/table/caption.rb +2 -0
- data/lib/protos/table/cell.rb +2 -0
- data/lib/protos/table/footer.rb +2 -0
- data/lib/protos/table/head.rb +2 -0
- data/lib/protos/table/header.rb +3 -0
- data/lib/protos/table/row.rb +2 -0
- data/lib/protos/table.rb +3 -0
- data/lib/protos/tabs/tab.rb +2 -0
- data/lib/protos/tabs.rb +3 -0
- data/lib/protos/theme.rb +5 -0
- data/lib/protos/timeline/center.rb +3 -0
- data/lib/protos/timeline/item.rb +4 -0
- data/lib/protos/timeline/left.rb +3 -0
- data/lib/protos/timeline/right.rb +3 -0
- data/lib/protos/timeline.rb +3 -0
- data/lib/protos/toast/close_button.rb +2 -0
- data/lib/protos/toast.rb +4 -0
- data/lib/protos/token_list.rb +7 -1
- data/lib/protos/typography/heading.rb +3 -0
- data/lib/protos/typography/inline_link.rb +2 -0
- data/lib/protos/typography/paragraph.rb +2 -0
- data/lib/protos/typography.rb +3 -0
- data/lib/protos/version.rb +1 -1
- metadata +3 -2
data/lib/protos/chat_bubble.rb
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
module Protos
|
4
4
|
class ChatBubble < Component
|
5
|
+
# DOCS: A chat bubble component that contains a message an possibly some
|
6
|
+
# metadata and an image. Each chat bubble would represent a single message
|
7
|
+
# in a larger chat history.
|
8
|
+
# https://daisyui.com/components/chat/
|
9
|
+
|
5
10
|
option :align,
|
6
11
|
default: -> { :start },
|
7
12
|
reader: false,
|
data/lib/protos/collapse.rb
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
module Protos
|
4
4
|
class Collapse < Component
|
5
|
+
# DOCS: A collapsible container that can be expanded or collapsed. The title
|
6
|
+
# is visible at all times, and the content is only visible when expanded.
|
7
|
+
# https://daisyui.com/components/collapse/
|
8
|
+
|
5
9
|
def template(&block)
|
6
10
|
div(**attrs, &block)
|
7
11
|
end
|
data/lib/protos/combobox.rb
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
module Protos
|
4
4
|
class Combobox < Popover
|
5
|
+
# DOCS: A combobox is a combination of a text input and a list of options.
|
6
|
+
# It makes selecting values from a large list easier by filtering the list.
|
7
|
+
# Comboboxes use popovers and command to create the list of options.
|
8
|
+
|
5
9
|
option :trigger,
|
6
10
|
default: -> { :click },
|
7
11
|
reader: false,
|
@@ -3,6 +3,9 @@
|
|
3
3
|
module Protos
|
4
4
|
class Command
|
5
5
|
class Dialog < Component
|
6
|
+
# DOCS: The dialog for a command wraps the command content and provides a
|
7
|
+
# modal backdrop for the command when it is opened.
|
8
|
+
|
6
9
|
def template(&block)
|
7
10
|
dialog(**attrs) do
|
8
11
|
div(class: css[:modal], &block)
|
@@ -22,7 +25,12 @@ module Protos
|
|
22
25
|
|
23
26
|
def theme
|
24
27
|
{
|
25
|
-
container: tokens(
|
28
|
+
container: tokens(
|
29
|
+
"modal",
|
30
|
+
"modal-bottom",
|
31
|
+
"backdrop-blur-sm",
|
32
|
+
"sm:modal-middle"
|
33
|
+
),
|
26
34
|
modal: tokens("modal-box", "p-0"),
|
27
35
|
form: tokens("modal-backdrop")
|
28
36
|
}
|
data/lib/protos/command/empty.rb
CHANGED
data/lib/protos/command/group.rb
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
module Protos
|
4
4
|
class Command
|
5
5
|
class Group < Component
|
6
|
+
# DOCS: An optional group for holding a heading and a list of options.
|
7
|
+
# Items in the group will have a divider line on the left side and can
|
8
|
+
# optionally have a title.
|
9
|
+
|
6
10
|
def template(&block)
|
7
11
|
li(**attrs) do
|
8
12
|
ul(class: css[:list], &block)
|
data/lib/protos/command/input.rb
CHANGED
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
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
module Protos
|
4
4
|
class Command < Component
|
5
|
+
# DOCS: A command pallete component that can be used to trigger a modal with
|
6
|
+
# filterable list of commands. Command modals are by default closable by
|
7
|
+
# clicking the overlay rather than a specific close button.
|
8
|
+
|
5
9
|
def template(&block)
|
6
10
|
div(**attrs, &block)
|
7
11
|
end
|
data/lib/protos/component.rb
CHANGED
@@ -2,17 +2,23 @@
|
|
2
2
|
|
3
3
|
module Protos
|
4
4
|
class Component < Phlex::HTML
|
5
|
-
# DOCS: Base component
|
5
|
+
# DOCS: Base component for all Protos::Components. You can inherit from this
|
6
|
+
# class to gain flexible components you can style from the outside using css
|
7
|
+
# slots, default attrs and themes.
|
8
|
+
#
|
9
|
+
# This component extends Dry::Initializer and Dry::Core::ClassAttributes to
|
10
|
+
# make configuring each class much easier. It also enables gathering up all
|
11
|
+
# undefined options and adding them to the html_options hash.
|
6
12
|
|
7
13
|
extend Dry::Initializer
|
8
14
|
extend Dry::Core::ClassAttributes
|
9
15
|
|
10
16
|
# Define methods for css and attrs. Each is expected to return a hash
|
11
|
-
defines :
|
12
|
-
defines :
|
17
|
+
defines :theme_method, type: Types::Symbol
|
18
|
+
defines :default_attrs_method, type: Types::Symbol
|
13
19
|
|
14
|
-
|
15
|
-
|
20
|
+
theme_method :theme
|
21
|
+
default_attrs_method :default_attrs
|
16
22
|
|
17
23
|
# Theme can override the css hash and add additional styles
|
18
24
|
option :theme, as: :theme_override, default: -> { {} }, reader: :private
|
@@ -53,8 +59,11 @@ module Protos
|
|
53
59
|
end
|
54
60
|
|
55
61
|
def build_attrs(...)
|
56
|
-
defaults = if respond_to?(
|
57
|
-
|
62
|
+
defaults = if respond_to?(
|
63
|
+
self.class.default_attrs_method,
|
64
|
+
:include_private
|
65
|
+
)
|
66
|
+
send(self.class.default_attrs_method)
|
58
67
|
end
|
59
68
|
|
60
69
|
Attributes
|
@@ -65,8 +74,11 @@ module Protos
|
|
65
74
|
end
|
66
75
|
|
67
76
|
def build_theme(...)
|
68
|
-
component_style = if respond_to?(
|
69
|
-
|
77
|
+
component_style = if respond_to?(
|
78
|
+
self.class.theme_method,
|
79
|
+
:include_private
|
80
|
+
)
|
81
|
+
send(self.class.theme_method)
|
70
82
|
end
|
71
83
|
|
72
84
|
Theme
|
data/lib/protos/drawer/side.rb
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
module Protos
|
4
4
|
class Drawer
|
5
5
|
class Side < Component
|
6
|
+
# DOCS: The content that will be shown when you open the drawer using the
|
7
|
+
# trigger. This would be hidden until triggered.
|
8
|
+
|
6
9
|
option :id, type: Types::Coercible::String
|
7
10
|
|
8
11
|
def template
|
@@ -16,7 +19,11 @@ module Protos
|
|
16
19
|
|
17
20
|
def theme
|
18
21
|
{
|
19
|
-
container: tokens(
|
22
|
+
container: tokens(
|
23
|
+
"drawer-side",
|
24
|
+
"z-20",
|
25
|
+
"peer-checked:backdrop-blur-sm"
|
26
|
+
),
|
20
27
|
toggle: tokens("drawer-overlay")
|
21
28
|
}
|
22
29
|
end
|
data/lib/protos/drawer.rb
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
module Protos
|
4
4
|
class Drawer < Component
|
5
|
+
# DOCS: A drawer component that can be toggled via a trigger. The content of
|
6
|
+
# a drawer is displayed at all times and overlapped by the side when the
|
7
|
+
# trigger is clicked.
|
8
|
+
# https://daisyui.com/components/drawer/
|
9
|
+
|
5
10
|
option :id, type: Types::Coercible::String
|
6
11
|
|
7
12
|
def template
|
@@ -28,7 +33,7 @@ module Protos
|
|
28
33
|
def theme
|
29
34
|
{
|
30
35
|
container: tokens("drawer"),
|
31
|
-
toggle: tokens("drawer-toggle")
|
36
|
+
toggle: tokens("drawer-toggle", "peer")
|
32
37
|
}
|
33
38
|
end
|
34
39
|
end
|
data/lib/protos/dropdown/item.rb
CHANGED
data/lib/protos/dropdown/menu.rb
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
module Protos
|
4
4
|
class Dropdown
|
5
5
|
class Menu < Popover::Content
|
6
|
+
# DOCS: The container for items in a dropdown. This is a restyled
|
7
|
+
# Protos::Popover::Content component as the main functionality for
|
8
|
+
# dropdowns comes from there.
|
9
|
+
|
6
10
|
def template(&block)
|
7
11
|
template_tag(**template_attrs) do
|
8
12
|
ul(**attrs, &block)
|
data/lib/protos/dropdown.rb
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
module Protos
|
4
4
|
class Dropdown < Popover
|
5
|
+
# DOCS: A dropdown component is basically a popover with a specific list of
|
6
|
+
# items in a menu. It should be preferred to a popover when the content is
|
7
|
+
# a list of actions rather than some content in its own right.
|
8
|
+
#
|
9
|
+
# Dropdowns, and popovers in general, use tippy.js to position content
|
10
|
+
# rather than pure CSS for accessibility. The layout of pure CSS was too
|
11
|
+
# tricky to get right and we felt the dependency tradeoff was worthwhile.
|
12
|
+
|
5
13
|
option :position,
|
6
14
|
type: PositionTypes,
|
7
15
|
default: -> { :bottom },
|
data/lib/protos/engine.rb
CHANGED
data/lib/protos/hero/content.rb
CHANGED
data/lib/protos/hero/overlay.rb
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
module Protos
|
4
4
|
class Hero
|
5
5
|
class Overlay < Component
|
6
|
+
# DOCS: The overlay of a hero. This would be used with images to reduce
|
7
|
+
# their opacity through the opacity of the overlay. This can be useful to
|
8
|
+
# make text readable on noisy images.
|
9
|
+
|
6
10
|
def template(&block)
|
7
11
|
div(**attrs, &block)
|
8
12
|
end
|
data/lib/protos/hero.rb
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
module Protos
|
4
4
|
class Hero < Component
|
5
|
+
# DOCS: A hero component for a page. It will center the content an
|
6
|
+
# optionally layout an image for a responsive layout.
|
7
|
+
# https://daisyui.com/components/hero/
|
8
|
+
|
5
9
|
def template(&block)
|
6
10
|
div(**attrs, &block)
|
7
11
|
end
|
data/lib/protos/list/item.rb
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
module Protos
|
4
4
|
class List
|
5
5
|
class Item < Component
|
6
|
+
# DOCS: A single item within a list. Items are joined so that borders will
|
7
|
+
# work for list items, including border radius. E.g. only the first and
|
8
|
+
# last items will have border radius on the top and bottom.
|
9
|
+
|
6
10
|
def template(&block)
|
7
11
|
li(**attrs, &block)
|
8
12
|
end
|
data/lib/protos/list.rb
CHANGED
data/lib/protos/modal/dialog.rb
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
module Protos
|
4
4
|
class Modal
|
5
5
|
class Dialog < Component
|
6
|
+
# DOCS: A modal dialog. This is the place for the main content of the
|
7
|
+
# modal that will be displayed when the trigger is clicked.
|
8
|
+
|
6
9
|
def template(&block)
|
7
10
|
dialog(**attrs) do
|
8
11
|
div(class: css[:modal], &block)
|
@@ -13,7 +16,12 @@ module Protos
|
|
13
16
|
|
14
17
|
def theme
|
15
18
|
{
|
16
|
-
container: tokens(
|
19
|
+
container: tokens(
|
20
|
+
"modal",
|
21
|
+
"modal-bottom",
|
22
|
+
"backdrop-blur-sm",
|
23
|
+
"sm:modal-middle"
|
24
|
+
),
|
17
25
|
modal: tokens("modal-box", "flex", "flex-col", "gap-xs")
|
18
26
|
}
|
19
27
|
end
|
data/lib/protos/modal/trigger.rb
CHANGED
data/lib/protos/modal.rb
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Protos
|
4
4
|
class Modal < Protos::Component
|
5
|
+
# DOCS: A modal component that can be triggered by a button or a link and
|
6
|
+
# will open a fullscreen modal, usually with a close button.
|
7
|
+
|
5
8
|
def template(&block)
|
6
9
|
div(**attrs, class: css[:container], &block)
|
7
10
|
end
|
@@ -3,6 +3,11 @@
|
|
3
3
|
module Protos
|
4
4
|
class Popover
|
5
5
|
class Content < Component
|
6
|
+
# DOCS: The content of a popover. We use a <template> element that is
|
7
|
+
# added to the DOM by tippy.js to handle the position of the content.
|
8
|
+
# This means content in here will not be available in system tests that
|
9
|
+
# use rack_test.
|
10
|
+
|
6
11
|
def template(&block)
|
7
12
|
template_tag(**template_attrs) do
|
8
13
|
div(**attrs, &block)
|
data/lib/protos/popover.rb
CHANGED
@@ -3,7 +3,14 @@
|
|
3
3
|
module Protos
|
4
4
|
class Popover < Component
|
5
5
|
# DOCS: Like a dropdown, but instead of a list of menu items, its just
|
6
|
-
# a rendered block
|
6
|
+
# a rendered block. The popover is triggered by a button or link.
|
7
|
+
#
|
8
|
+
# Dropdowns, and popovers in general, use tippy.js to position content
|
9
|
+
# rather than pure CSS for accessibility. The layout of pure CSS was too
|
10
|
+
# tricky to get right and we felt the dependency tradeoff was worthwhile.
|
11
|
+
#
|
12
|
+
# Tippy.js options can be passed in via the `options` attribute or, more
|
13
|
+
# conveniently by the typed options listed below.
|
7
14
|
|
8
15
|
PositionTypes = Types::Coercible::Symbol.enum(
|
9
16
|
:top,
|
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
data/lib/protos/swap/off.rb
CHANGED
data/lib/protos/swap/on.rb
CHANGED
data/lib/protos/swap.rb
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
module Protos
|
4
4
|
class Swap < Component
|
5
|
+
# DOCS: The swap component is a checkbox that can be toggled on and off to
|
6
|
+
# display different content.
|
7
|
+
# https://daisyui.com/components/swap/
|
8
|
+
|
5
9
|
def template
|
6
10
|
label(**attrs) do
|
7
11
|
input(type: :checkbox, class: css[:input])
|
data/lib/protos/table/body.rb
CHANGED