protos 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -1
- data/README.md +34 -22
- data/examples/list.rb +2 -2
- data/examples/navbar.rb +3 -8
- data/lib/protos/accordion/item.rb +4 -2
- data/lib/protos/accordion.rb +10 -11
- data/lib/protos/alert.rb +3 -0
- data/lib/protos/avatar.rb +10 -10
- data/lib/protos/badge.rb +62 -0
- data/lib/protos/breadcrumbs.rb +2 -0
- data/lib/protos/card.rb +12 -7
- data/lib/protos/carousel.rb +13 -10
- data/lib/protos/chat_bubble/content.rb +12 -12
- data/lib/protos/chat_bubble.rb +11 -6
- data/lib/protos/collapse/title.rb +3 -3
- data/lib/protos/collapse.rb +10 -7
- data/lib/protos/combobox.rb +3 -3
- data/lib/protos/command/input.rb +4 -4
- data/lib/protos/command.rb +16 -2
- data/lib/protos/component.rb +1 -1
- data/lib/protos/drawer.rb +7 -3
- data/lib/protos/dropdown.rb +10 -6
- data/lib/protos/hero.rb +3 -0
- data/lib/protos/list.rb +2 -0
- data/lib/protos/modal/close_button.rb +8 -0
- data/lib/protos/modal/dialog.rb +4 -6
- data/lib/protos/modal.rb +6 -1
- data/lib/protos/popover.rb +24 -21
- data/lib/protos/stats.rb +7 -0
- data/lib/protos/steps.rb +5 -3
- data/lib/protos/swap.rb +3 -0
- data/lib/protos/table/caption.rb +3 -3
- data/lib/protos/table/cell.rb +3 -3
- data/lib/protos/table/head.rb +3 -3
- data/lib/protos/table.rb +21 -13
- data/lib/protos/tabs/tab.rb +4 -4
- data/lib/protos/tabs.rb +18 -16
- data/lib/protos/theme.rb +8 -7
- data/lib/protos/timeline.rb +8 -3
- data/lib/protos/toast.rb +5 -3
- data/lib/protos/typography/paragraph.rb +3 -3
- data/lib/protos/typography.rb +4 -0
- data/lib/protos/version.rb +1 -1
- data/lib/protos.rb +37 -121
- metadata +4 -7
- data/lib/protos/command/dialog.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7486060db2b247fab3e5d5caa33c6f8d35631772e267ae248d8929b71038fbb
|
4
|
+
data.tar.gz: ef414faf4cc381245bc9e7b609124858b4a1d1280dfcf5e21a139641d6877f0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37c65c3a6be4bfc15fb70e31988a4624c56426e607796de03ae8be9b47be9f016ad27ee4fc508ec57442f6cb0ae8d5d2e27bad40b8b8178c61488935fcafbf9c
|
7
|
+
data.tar.gz: 56354393cb9425b3455bcf4baa568a7f23805a226a3b0de75264f505dc9c5f2deee503d77e4b3fd0d7e3ecdef6253daebc5262ba0cb5b7591b6582fec3f96adb
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,23 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
- Changes passing an `input_id` to accordions. Replaced with the more accurate
|
4
|
+
`input_name` (optional) parameter. There was no point in having different
|
5
|
+
name attributes for the different radio buttons
|
6
|
+
- Updates modal component to use newer modal controller from protos-stimulus
|
7
|
+
that uses `@stimulus-components/dialog`
|
8
|
+
- Adds the ability for `css` helper to take multiple values, including inline
|
9
|
+
values instead of theme keys.
|
10
|
+
- Adds new `Protos::Badge` component
|
11
|
+
- Removes deprecated tokens to prepare for phlex 2.0
|
12
|
+
- Removes `dry-initializer` undefined constant to improve performance
|
13
|
+
- Adds autoloading constants instead of hard requires
|
14
|
+
|
3
15
|
## [0.6.0] - 2024-09-04
|
4
16
|
|
5
17
|
- Changes how merging attributes works to only mix on certain attributes,
|
6
18
|
overriding on all others. This is opposite to how attributes used to be merged
|
7
19
|
by default. This is a fix for attributes like `value` where you actually need
|
8
20
|
to override them.
|
9
|
-
- Adds tests for all Rails components
|
10
21
|
- Adds a separate tested `Mix` class for handling attribute merging
|
11
22
|
|
12
23
|
## [0.5.0] - 2024-08-27
|
data/README.md
CHANGED
@@ -88,9 +88,10 @@ class Navbar
|
|
88
88
|
end
|
89
89
|
```
|
90
90
|
|
91
|
-
Eventually everyone makes a kind of ad-hoc system for specifying styles.
|
92
|
-
|
93
|
-
|
91
|
+
Eventually everyone makes a kind of ad-hoc system for specifying styles.
|
92
|
+
|
93
|
+
It gets more complicated when you have attributes like a data-controller. How do
|
94
|
+
you give a good experience letting people using your components to add their own
|
94
95
|
controllers while your component depends on one already?
|
95
96
|
|
96
97
|
This library is an attempt to make this kind of developer experience while
|
@@ -136,7 +137,7 @@ class List < Protos::Component
|
|
136
137
|
|
137
138
|
def theme
|
138
139
|
{
|
139
|
-
list: "space-y-4", # We can use
|
140
|
+
list: ["space-y-4"], # We can use arrays
|
140
141
|
item: "font-bold text-2xl" # Or just plain old strings
|
141
142
|
}
|
142
143
|
end
|
@@ -218,13 +219,25 @@ class List < Protos::Component
|
|
218
219
|
|
219
220
|
def custom_theme
|
220
221
|
{
|
221
|
-
list:
|
222
|
-
item:
|
222
|
+
list: "space-y-4",
|
223
|
+
item: ["font-bold", "text-2xl"]
|
223
224
|
}
|
224
225
|
end
|
225
226
|
end
|
226
227
|
```
|
227
228
|
|
229
|
+
Slots can also take multiple arguments, and even inline styles:
|
230
|
+
|
231
|
+
```ruby
|
232
|
+
class ListItem < Protos::Component
|
233
|
+
def view_template
|
234
|
+
li(class: css[:item, :primary_item, "text-sm"])
|
235
|
+
end
|
236
|
+
end
|
237
|
+
```
|
238
|
+
|
239
|
+
This combines the styles together, removing any duplicates.
|
240
|
+
|
228
241
|
### Attrs and default attrs
|
229
242
|
|
230
243
|
By convention, all components spread in an `attrs` hash on their outermost
|
@@ -257,8 +270,8 @@ class List < Protos::Component
|
|
257
270
|
|
258
271
|
def theme
|
259
272
|
{
|
260
|
-
container:
|
261
|
-
item:
|
273
|
+
container: "space-y-4",
|
274
|
+
item: "font-bold"
|
262
275
|
}
|
263
276
|
end
|
264
277
|
end
|
@@ -488,7 +501,7 @@ module Components
|
|
488
501
|
|
489
502
|
def theme
|
490
503
|
super.merge({
|
491
|
-
input:
|
504
|
+
input: ["block", "bg-red-500"]
|
492
505
|
})
|
493
506
|
end
|
494
507
|
end
|
@@ -561,11 +574,11 @@ module Ui
|
|
561
574
|
|
562
575
|
def theme
|
563
576
|
{
|
564
|
-
container:
|
565
|
-
header:
|
566
|
-
list:
|
567
|
-
actions:
|
568
|
-
item:
|
577
|
+
container: "space-y-xs",
|
578
|
+
header: "flex justify-between items-end gap-sm",
|
579
|
+
list: "divide-y border w-full",
|
580
|
+
actions: "space-x-xs",
|
581
|
+
item: "p-sm"
|
569
582
|
}
|
570
583
|
end
|
571
584
|
end
|
@@ -676,10 +689,10 @@ module Ui
|
|
676
689
|
|
677
690
|
def theme
|
678
691
|
{
|
679
|
-
container:
|
680
|
-
header:
|
681
|
-
table:
|
682
|
-
caption:
|
692
|
+
container: "space-y-sm",
|
693
|
+
header: "flex justify-between items-end gap-sm",
|
694
|
+
table: "border",
|
695
|
+
caption: "text-muted"
|
683
696
|
}
|
684
697
|
end
|
685
698
|
end
|
@@ -714,12 +727,11 @@ render Ui::Table.new(title: "A table", collection:) do |table|
|
|
714
727
|
end
|
715
728
|
```
|
716
729
|
|
717
|
-
##
|
730
|
+
## Missing components
|
718
731
|
|
719
|
-
This library
|
720
|
-
components
|
732
|
+
This library tries to avoid re-making Protos components for extremely simple
|
733
|
+
DaisyUI components. Here is a list that we don't yet have components for:
|
721
734
|
|
722
|
-
- Badge
|
723
735
|
- Buttons
|
724
736
|
- Checkbox
|
725
737
|
- File input
|
data/examples/list.rb
CHANGED
data/examples/navbar.rb
CHANGED
@@ -20,14 +20,9 @@ class Navbar < Protos::Component
|
|
20
20
|
|
21
21
|
def theme
|
22
22
|
{
|
23
|
-
container:
|
24
|
-
|
25
|
-
|
26
|
-
"items-center",
|
27
|
-
"gap-sm"
|
28
|
-
),
|
29
|
-
heading: tokens("text-2xl", "font-bold"),
|
30
|
-
subtitle: tokens("text-base")
|
23
|
+
container: "flex justify-between items-center gap-sm",
|
24
|
+
heading: "text-2xl font-bold",
|
25
|
+
subtitle: "text-base"
|
31
26
|
}
|
32
27
|
end
|
33
28
|
end
|
@@ -5,13 +5,15 @@ module Protos
|
|
5
5
|
class Item < Component
|
6
6
|
# DOCS: An accorion is just a collapse with radio buttons.
|
7
7
|
|
8
|
-
option :
|
8
|
+
option :input_name,
|
9
|
+
type: Types::String | Types::Integer | Types::Nil,
|
10
|
+
reader: false
|
9
11
|
|
10
12
|
def view_template(&block)
|
11
13
|
li(**attrs) do
|
12
14
|
render Collapse.new(
|
13
15
|
theme: collapse_theme,
|
14
|
-
|
16
|
+
input_name: @input_name,
|
15
17
|
input_type: :radio,
|
16
18
|
&block
|
17
19
|
)
|
data/lib/protos/accordion.rb
CHANGED
@@ -7,30 +7,29 @@ module Protos
|
|
7
7
|
# to be open at the same time, use the collapse component.
|
8
8
|
# https://daisyui.com/components/accordion/
|
9
9
|
|
10
|
+
autoload :Item, "protos/accordion/item"
|
11
|
+
|
12
|
+
option :input_name,
|
13
|
+
default: -> { "accordion-#{SecureRandom.hex(4)}" },
|
14
|
+
reader: false,
|
15
|
+
type: Types::String
|
16
|
+
|
10
17
|
def view_template(&)
|
11
18
|
ul(**attrs, &)
|
12
19
|
end
|
13
20
|
|
14
|
-
def item(*,
|
15
|
-
|
16
|
-
|
17
|
-
render Item.new(*, input_id: current_input_id, **, &)
|
21
|
+
def item(*, **, &)
|
22
|
+
render Item.new(*, input_name: @input_name, **, &)
|
18
23
|
end
|
19
24
|
|
20
25
|
def content(...) = render Collapse::Content.new(...)
|
21
26
|
|
22
27
|
def title(*, **, &)
|
23
|
-
render Collapse::Title.new(*, input_id:
|
28
|
+
render Collapse::Title.new(*, input_id: @input_name, **, &)
|
24
29
|
end
|
25
30
|
|
26
31
|
private
|
27
32
|
|
28
|
-
attr_reader :current_input_id
|
29
|
-
|
30
|
-
def current_input_id=(value)
|
31
|
-
@current_input_id = value || "collapse-#{SecureRandom.hex(4)}"
|
32
|
-
end
|
33
|
-
|
34
33
|
def theme
|
35
34
|
{
|
36
35
|
container: "join join-vertical"
|
data/lib/protos/alert.rb
CHANGED
@@ -6,6 +6,9 @@ module Protos
|
|
6
6
|
# be used in combination with Protos::Toast to have popup notifications.
|
7
7
|
# https://daisyui.com/components/alert/
|
8
8
|
|
9
|
+
autoload :Actions, "protos/alert/actions"
|
10
|
+
autoload :Icon, "protos/alert/icon"
|
11
|
+
|
9
12
|
Styles = Types::Coercible::Symbol.enum(
|
10
13
|
:info,
|
11
14
|
:success,
|
data/lib/protos/avatar.rb
CHANGED
@@ -64,13 +64,13 @@ module Protos
|
|
64
64
|
|
65
65
|
option :placeholder, type: Types::Bool, default: -> { false }
|
66
66
|
option :indicator,
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
type: Indicators,
|
68
|
+
default: -> { :none },
|
69
|
+
reader: false
|
70
70
|
option :shape,
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
type: MaskShapes,
|
72
|
+
default: -> { :none },
|
73
|
+
reader: false
|
74
74
|
|
75
75
|
def view_template(&block)
|
76
76
|
div(**attrs) do
|
@@ -90,12 +90,12 @@ module Protos
|
|
90
90
|
|
91
91
|
def theme
|
92
92
|
{
|
93
|
-
container:
|
93
|
+
container: [
|
94
94
|
"avatar",
|
95
95
|
indicator,
|
96
|
-
placeholder
|
97
|
-
|
98
|
-
figure:
|
96
|
+
("placeholder" if placeholder)
|
97
|
+
],
|
98
|
+
figure: shape
|
99
99
|
}
|
100
100
|
end
|
101
101
|
end
|
data/lib/protos/badge.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Protos
|
4
|
+
class Badge < Component
|
5
|
+
Badges = Types::Coercible::Symbol.enum(
|
6
|
+
:default,
|
7
|
+
:neutral,
|
8
|
+
:success,
|
9
|
+
:primary,
|
10
|
+
:secondary,
|
11
|
+
:info,
|
12
|
+
:error,
|
13
|
+
:warning,
|
14
|
+
:ghost
|
15
|
+
)
|
16
|
+
|
17
|
+
Sizes = Types::Coercible::Symbol.enum(:default, :xs, :sm, :md, :lg)
|
18
|
+
|
19
|
+
option :type, type: Badges, default: -> { :default }
|
20
|
+
option :outline, default: -> { false }
|
21
|
+
option :size, type: Sizes, default: -> { :default }
|
22
|
+
|
23
|
+
def view_template(&)
|
24
|
+
span(**attrs, &)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def badge_style
|
30
|
+
{
|
31
|
+
neutral: "badge-neutral",
|
32
|
+
success: "badge-success",
|
33
|
+
primary: "badge-primary",
|
34
|
+
secondary: "badge-secondary",
|
35
|
+
info: "badge-info",
|
36
|
+
error: "badge-error",
|
37
|
+
warning: "badge-warning",
|
38
|
+
ghost: "badge-ghost"
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def badge_size
|
43
|
+
{
|
44
|
+
xs: "badge-xs",
|
45
|
+
sm: "badge-sm",
|
46
|
+
md: "badge-md",
|
47
|
+
lg: "badge-lg"
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def theme
|
52
|
+
{
|
53
|
+
container: [
|
54
|
+
"badge",
|
55
|
+
badge_style[type],
|
56
|
+
badge_size[size],
|
57
|
+
("badge-outline" if outline)
|
58
|
+
].compact
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/protos/breadcrumbs.rb
CHANGED
data/lib/protos/card.rb
CHANGED
@@ -5,6 +5,11 @@ module Protos
|
|
5
5
|
# DOCS: A card component
|
6
6
|
# https://daisyui.com/components/card/
|
7
7
|
|
8
|
+
autoload :Body, "protos/card/body"
|
9
|
+
autoload :Title, "protos/card/title"
|
10
|
+
autoload :Actions, "protos/card/actions"
|
11
|
+
autoload :Image, "protos/card/image"
|
12
|
+
|
8
13
|
ImageDisplays = Types::Coercible::Symbol.enum(:default, :overlay, :side)
|
9
14
|
|
10
15
|
IMAGE_DISPLAYS = {
|
@@ -16,9 +21,9 @@ module Protos
|
|
16
21
|
option :border, type: Types::Bool, default: -> { true }, reader: :private
|
17
22
|
option :compact, type: Types::Bool, default: -> { false }, reader: :private
|
18
23
|
option :image_display,
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
ImageDisplays,
|
25
|
+
default: -> { :default },
|
26
|
+
reader: false
|
22
27
|
|
23
28
|
def view_template(&)
|
24
29
|
article(**attrs, &)
|
@@ -40,12 +45,12 @@ module Protos
|
|
40
45
|
|
41
46
|
def theme
|
42
47
|
{
|
43
|
-
container:
|
48
|
+
container: [
|
44
49
|
"card",
|
45
50
|
image_display,
|
46
|
-
|
47
|
-
|
48
|
-
|
51
|
+
("card-bordered" if border),
|
52
|
+
("card-compact" if compact)
|
53
|
+
]
|
49
54
|
}
|
50
55
|
end
|
51
56
|
end
|
data/lib/protos/carousel.rb
CHANGED
@@ -6,6 +6,9 @@ module Protos
|
|
6
6
|
# through in a mobile friendly manner.
|
7
7
|
# https://daisyui.com/components/carousel/
|
8
8
|
|
9
|
+
autoload :Item, "protos/carousel/item"
|
10
|
+
autoload :Actions, "protos/carousel/actions"
|
11
|
+
|
9
12
|
SNAP_POINTS = {
|
10
13
|
none: "",
|
11
14
|
center: "carousel-center",
|
@@ -14,13 +17,13 @@ module Protos
|
|
14
17
|
|
15
18
|
option :vertical, type: Types::Bool, default: -> { false }
|
16
19
|
option :snap_to,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
default: -> { :none },
|
21
|
+
reader: false,
|
22
|
+
type: Types::Coercible::Symbol.enum(
|
23
|
+
:none,
|
24
|
+
:center,
|
25
|
+
:end
|
26
|
+
)
|
24
27
|
|
25
28
|
def view_template(&)
|
26
29
|
div(**attrs, &)
|
@@ -38,11 +41,11 @@ module Protos
|
|
38
41
|
|
39
42
|
def theme
|
40
43
|
{
|
41
|
-
container:
|
44
|
+
container: [
|
42
45
|
"carousel",
|
43
46
|
snap_to,
|
44
|
-
|
45
|
-
|
47
|
+
("carousel-vertical" if vertical)
|
48
|
+
]
|
46
49
|
}
|
47
50
|
end
|
48
51
|
end
|
@@ -18,18 +18,18 @@ module Protos
|
|
18
18
|
}.freeze
|
19
19
|
|
20
20
|
option :type,
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
21
|
+
default: -> { :none },
|
22
|
+
reader: false,
|
23
|
+
type: Types::Coercible::Symbol.enum(
|
24
|
+
:none,
|
25
|
+
:primary,
|
26
|
+
:secondary,
|
27
|
+
:accent,
|
28
|
+
:info,
|
29
|
+
:success,
|
30
|
+
:warning,
|
31
|
+
:error
|
32
|
+
)
|
33
33
|
|
34
34
|
def view_template(&)
|
35
35
|
div(**attrs, &)
|
data/lib/protos/chat_bubble.rb
CHANGED
@@ -7,18 +7,23 @@ module Protos
|
|
7
7
|
# in a larger chat history.
|
8
8
|
# https://daisyui.com/components/chat/
|
9
9
|
|
10
|
+
autoload :Content, "protos/chat_bubble/content"
|
11
|
+
autoload :Image, "protos/chat_bubble/image"
|
12
|
+
autoload :Header, "protos/chat_bubble/header"
|
13
|
+
autoload :Footer, "protos/chat_bubble/footer"
|
14
|
+
|
10
15
|
ALIGNMENTS = {
|
11
16
|
start: "chat-start",
|
12
17
|
end: "chat-end"
|
13
18
|
}.freeze
|
14
19
|
|
15
20
|
option :align,
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
default: -> { :start },
|
22
|
+
reader: false,
|
23
|
+
type: Types::Coercible::Symbol.enum(
|
24
|
+
:start,
|
25
|
+
:end
|
26
|
+
)
|
22
27
|
|
23
28
|
def view_template(&)
|
24
29
|
div(**attrs, &)
|
@@ -7,9 +7,9 @@ module Protos
|
|
7
7
|
# visible and is used to toggle the collapse.
|
8
8
|
|
9
9
|
option :input_id,
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
type: Types::String | Types::Integer | Types::Nil,
|
11
|
+
reader: false,
|
12
|
+
default: -> { }
|
13
13
|
|
14
14
|
def view_template(&)
|
15
15
|
if @input_id
|
data/lib/protos/collapse.rb
CHANGED
@@ -6,19 +6,22 @@ module Protos
|
|
6
6
|
# is visible at all times, and the content is only visible when expanded.
|
7
7
|
# https://daisyui.com/components/collapse/
|
8
8
|
|
9
|
+
autoload :Title, "protos/collapse/title"
|
10
|
+
autoload :Content, "protos/collapse/content"
|
11
|
+
|
9
12
|
option :input_type, default: -> { :checkbox }, reader: false
|
10
|
-
option :
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
option :input_name,
|
14
|
+
reader: false,
|
15
|
+
default: -> { "collapse-#{SecureRandom.hex(4)}" },
|
16
|
+
type: Types::String | Types::Integer
|
14
17
|
|
15
18
|
def view_template
|
16
19
|
div(**attrs) do
|
17
20
|
if @input_type
|
18
21
|
input(
|
19
22
|
type: @input_type,
|
20
|
-
id: @
|
21
|
-
name: @
|
23
|
+
id: @input_name,
|
24
|
+
name: @input_name,
|
22
25
|
autocomplete: :off,
|
23
26
|
# form: "" prevents the radio button from being submitted if its
|
24
27
|
# within a form
|
@@ -29,7 +32,7 @@ module Protos
|
|
29
32
|
end
|
30
33
|
end
|
31
34
|
|
32
|
-
def title(*, **, &) = render Title.new(*, input_id: @
|
35
|
+
def title(*, **, &) = render Title.new(*, input_id: @input_name, **, &)
|
33
36
|
|
34
37
|
def content(...) = render Content.new(...)
|
35
38
|
|
data/lib/protos/combobox.rb
CHANGED
@@ -7,9 +7,9 @@ module Protos
|
|
7
7
|
# Comboboxes use popovers and command to create the list of options.
|
8
8
|
|
9
9
|
option :trigger,
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
default: -> { :click },
|
11
|
+
reader: false,
|
12
|
+
type: Popover::Triggers | Types::Array.of(Popover::Triggers)
|
13
13
|
|
14
14
|
def trigger(...) = render Popover::Trigger.new(...)
|
15
15
|
|
data/lib/protos/command/input.rb
CHANGED
@@ -6,10 +6,10 @@ module Protos
|
|
6
6
|
# DOCS: The search input for the command palette
|
7
7
|
|
8
8
|
option :placeholder,
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
reader: :private,
|
10
|
+
default: -> {
|
11
|
+
"Type a command or search..."
|
12
|
+
}
|
13
13
|
|
14
14
|
def view_template(&block)
|
15
15
|
li(**attrs) do
|
data/lib/protos/command.rb
CHANGED
@@ -6,6 +6,15 @@ 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
|
+
autoload :Input, "protos/command/input"
|
10
|
+
autoload :Dialog, "protos/command/dialog"
|
11
|
+
autoload :Group, "protos/command/group"
|
12
|
+
autoload :List, "protos/command/list"
|
13
|
+
autoload :Trigger, "protos/command/trigger"
|
14
|
+
autoload :Title, "protos/command/title"
|
15
|
+
autoload :Item, "protos/command/item"
|
16
|
+
autoload :Empty, "protos/command/empty"
|
17
|
+
|
9
18
|
def view_template(&)
|
10
19
|
div(**attrs, &)
|
11
20
|
end
|
@@ -16,7 +25,9 @@ module Protos
|
|
16
25
|
|
17
26
|
def trigger(...) = render Command::Trigger.new(...)
|
18
27
|
|
19
|
-
def dialog(...) = render
|
28
|
+
def dialog(...) = render Modal::Dialog.new(...)
|
29
|
+
|
30
|
+
def close_button(...) = render Modal::CloseButton.new(...)
|
20
31
|
|
21
32
|
def title(...) = render Command::Title.new(...)
|
22
33
|
|
@@ -30,7 +41,10 @@ module Protos
|
|
30
41
|
|
31
42
|
def default_attrs
|
32
43
|
{
|
33
|
-
data: {
|
44
|
+
data: {
|
45
|
+
controller: "protos--modal",
|
46
|
+
action: "click->protos--modal#backdropClose"
|
47
|
+
}
|
34
48
|
}
|
35
49
|
end
|
36
50
|
end
|
data/lib/protos/component.rb
CHANGED
@@ -10,7 +10,7 @@ module Protos
|
|
10
10
|
# make configuring each class much easier. It also enables gathering up all
|
11
11
|
# undefined options and adding them to the html_options hash.
|
12
12
|
|
13
|
-
extend Dry::Initializer
|
13
|
+
extend Dry::Initializer[undefined: false]
|
14
14
|
extend Dry::Core::ClassAttributes
|
15
15
|
|
16
16
|
# Define methods for css and attrs. Each is expected to return a hash
|
data/lib/protos/drawer.rb
CHANGED
@@ -7,10 +7,14 @@ module Protos
|
|
7
7
|
# trigger is clicked.
|
8
8
|
# https://daisyui.com/components/drawer/
|
9
9
|
|
10
|
+
autoload :Side, "protos/drawer/side"
|
11
|
+
autoload :Trigger, "protos/drawer/trigger"
|
12
|
+
autoload :Content, "protos/drawer/content"
|
13
|
+
|
10
14
|
option :id,
|
11
|
-
|
12
|
-
|
13
|
-
|
15
|
+
reader: false,
|
16
|
+
type: Types::Coercible::String,
|
17
|
+
default: -> { "drawer-#{SecureRandom.hex(4)}" }
|
14
18
|
|
15
19
|
def view_template
|
16
20
|
div(**attrs) do
|