protos 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +13 -0
- data/lib/protos/alert/actions.rb +1 -1
- data/lib/protos/chat_bubble.rb +8 -8
- data/lib/protos/combobox.rb +9 -9
- data/lib/protos/command/list.rb +6 -0
- data/lib/protos/command.rb +1 -1
- data/lib/protos/dropdown/menu.rb +4 -2
- data/lib/protos/dropdown/trigger.rb +1 -4
- data/lib/protos/dropdown.rb +5 -38
- data/lib/protos/popover/content.rb +7 -3
- data/lib/protos/popover/trigger.rb +10 -1
- data/lib/protos/popover.rb +77 -17
- data/lib/protos/stats.rb +24 -0
- data/lib/protos/swap.rb +3 -2
- data/lib/protos/table.rb +29 -1
- data/lib/protos/tabs/tab.rb +2 -2
- data/lib/protos/tabs.rb +6 -6
- data/lib/protos/theme.rb +20 -16
- data/lib/protos/toast/close_button.rb +10 -0
- data/lib/protos/toast.rb +30 -9
- data/lib/protos/token_list.rb +32 -7
- data/lib/protos/version.rb +1 -1
- data/lib/protos.rb +10 -7
- data/protos.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5001f5f332c249597cb0f0c40cb8ff83429d7843db7c2f3f6cfc3b3ad6e9b50
|
4
|
+
data.tar.gz: 4e0426a89a66cd600cafe5411b02f6b3c5088dcc12bf64148d238bc542878459
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eab1e457a004e0501c698f22a3c1aefb389a28a7970f864762320d4a4628e3b502d4a70080f05cdafc112d4dedd3d8a79637428ecef2194ccdf98d93111f2312
|
7
|
+
data.tar.gz: 3b1325007d6ad4c99bc478213aebf31bc03463308f591de7051d5542a95f1d9fd76d176d8e2a6d1396887b7f997e8bb19f14bde22d8544036144d2633317b98b
|
data/CHANGELOG.md
CHANGED
@@ -3,3 +3,9 @@
|
|
3
3
|
## [0.1.0] - 2024-03-01
|
4
4
|
|
5
5
|
- Initial release
|
6
|
+
|
7
|
+
## [0.2.0] - 2024-03-06
|
8
|
+
|
9
|
+
- Chose to move away from daisyUI dropdown defaults as they have problems
|
10
|
+
displaying properly in too many situations
|
11
|
+
- Opted for using a protos-stimulus controller that uses tippy.js
|
data/README.md
CHANGED
@@ -4,6 +4,19 @@ A UI component library for [Phlex](https://www.phlex.fun/) using
|
|
4
4
|
[tailwindcss](https://tailwindcss.com/) and
|
5
5
|
[daisyUI](https://daisyui.com/).
|
6
6
|
|
7
|
+
You can see a full list of the components at
|
8
|
+
[https://protos.inhouse.work/](https://protos.inhouse.work/).
|
9
|
+
|
10
|
+
- Tailwindcss classes are merged using
|
11
|
+
[tailwind\_merge](https://github.com/gjtorikian/tailwind_merge).
|
12
|
+
- Uses [tippy.js](https://atomiks.github.io/tippyjs/v6/getting-started/) for
|
13
|
+
dropdowns, combobox, and popovers
|
14
|
+
|
15
|
+
Other Phlex based UI libraries worth checking out:
|
16
|
+
|
17
|
+
- [PhlexUI](https://phlexui.com/)
|
18
|
+
- [ZestUI](https://zestui.com/)
|
19
|
+
|
7
20
|
This library avoids re-making Protos components for extremely simple daisyui
|
8
21
|
components such as:
|
9
22
|
|
data/lib/protos/alert/actions.rb
CHANGED
data/lib/protos/chat_bubble.rb
CHANGED
@@ -14,20 +14,20 @@ module Protos
|
|
14
14
|
div(**attrs, &block)
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def header(...)
|
22
|
-
Header.new(...)
|
17
|
+
def content(...)
|
18
|
+
Content.new(...)
|
23
19
|
end
|
24
20
|
|
25
21
|
def footer(...)
|
26
22
|
Footer.new(...)
|
27
23
|
end
|
28
24
|
|
29
|
-
def
|
30
|
-
|
25
|
+
def header(...)
|
26
|
+
Header.new(...)
|
27
|
+
end
|
28
|
+
|
29
|
+
def image(...)
|
30
|
+
Image.new(...)
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
data/lib/protos/combobox.rb
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Protos
|
4
|
-
class Combobox <
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
4
|
+
class Combobox < Popover
|
5
|
+
option :trigger,
|
6
|
+
default: -> { :click },
|
7
|
+
reader: false,
|
8
|
+
type: TriggerTypes | Types::Array.of(TriggerTypes)
|
12
9
|
|
13
10
|
def trigger(...)
|
14
11
|
Popover::Trigger.new(...)
|
@@ -46,7 +43,10 @@ module Protos
|
|
46
43
|
|
47
44
|
def default_attrs
|
48
45
|
{
|
49
|
-
data: {
|
46
|
+
data: {
|
47
|
+
controller: "protos--popover",
|
48
|
+
"protos--popover-options-value": JSON.generate(options)
|
49
|
+
}
|
50
50
|
}
|
51
51
|
end
|
52
52
|
end
|
data/lib/protos/command/list.rb
CHANGED
data/lib/protos/command.rb
CHANGED
data/lib/protos/dropdown/menu.rb
CHANGED
data/lib/protos/dropdown.rb
CHANGED
@@ -1,25 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Protos
|
4
|
-
class Dropdown <
|
5
|
-
PositionTypes = Types::Coercible::Symbol.enum(
|
6
|
-
:top,
|
7
|
-
:bottom,
|
8
|
-
:left,
|
9
|
-
:right,
|
10
|
-
:start,
|
11
|
-
:end
|
12
|
-
)
|
13
|
-
|
4
|
+
class Dropdown < Popover
|
14
5
|
option :position,
|
15
6
|
type: PositionTypes,
|
16
7
|
default: -> { :bottom },
|
17
8
|
reader: false
|
18
|
-
option :
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
9
|
+
option :trigger,
|
10
|
+
default: -> { :click },
|
11
|
+
reader: false,
|
12
|
+
type: TriggerTypes | Types::Array.of(TriggerTypes)
|
23
13
|
|
24
14
|
def item(...)
|
25
15
|
Item.new(...)
|
@@ -32,28 +22,5 @@ module Protos
|
|
32
22
|
def trigger(...)
|
33
23
|
Trigger.new(...)
|
34
24
|
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def position
|
39
|
-
{
|
40
|
-
bottom: "dropdown-bottom",
|
41
|
-
top: "dropdown-top",
|
42
|
-
left: "dropdown-left",
|
43
|
-
right: "dropdown-right",
|
44
|
-
end: "dropdown-end",
|
45
|
-
start: "dropdown-start"
|
46
|
-
}.fetch(@position)
|
47
|
-
end
|
48
|
-
|
49
|
-
def theme
|
50
|
-
{
|
51
|
-
container: tokens(
|
52
|
-
"dropdown",
|
53
|
-
position,
|
54
|
-
hover: "dropdown-hover"
|
55
|
-
)
|
56
|
-
}
|
57
|
-
end
|
58
25
|
end
|
59
26
|
end
|
@@ -4,14 +4,18 @@ module Protos
|
|
4
4
|
class Popover
|
5
5
|
class Content < Component
|
6
6
|
def template(&block)
|
7
|
-
|
7
|
+
template_tag(**template_attrs) do
|
8
|
+
div(**attrs, &block)
|
9
|
+
end
|
8
10
|
end
|
9
11
|
|
10
12
|
private
|
11
13
|
|
12
|
-
def
|
14
|
+
def template_attrs
|
13
15
|
{
|
14
|
-
|
16
|
+
data: {
|
17
|
+
"protos--popover-target": "template"
|
18
|
+
}
|
15
19
|
}
|
16
20
|
end
|
17
21
|
end
|
@@ -4,7 +4,16 @@ module Protos
|
|
4
4
|
class Popover
|
5
5
|
class Trigger < Component
|
6
6
|
def template(&block)
|
7
|
-
|
7
|
+
div(**attrs, &block)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def default_attrs
|
13
|
+
{
|
14
|
+
data: { "protos--popover-target": "trigger" },
|
15
|
+
tabindex: 0
|
16
|
+
}
|
8
17
|
end
|
9
18
|
end
|
10
19
|
end
|
data/lib/protos/popover.rb
CHANGED
@@ -7,21 +7,74 @@ module Protos
|
|
7
7
|
|
8
8
|
PositionTypes = Types::Coercible::Symbol.enum(
|
9
9
|
:top,
|
10
|
+
:top_start,
|
11
|
+
:top_end,
|
12
|
+
:right,
|
13
|
+
:right_start,
|
14
|
+
:right_end,
|
10
15
|
:bottom,
|
16
|
+
:bottom_start,
|
17
|
+
:bottom_end,
|
11
18
|
:left,
|
12
|
-
:
|
13
|
-
:
|
14
|
-
|
19
|
+
:left_start,
|
20
|
+
:left_end
|
21
|
+
)
|
22
|
+
|
23
|
+
AnimationTypes = Types::Coercible::Symbol.enum(
|
24
|
+
:fade,
|
25
|
+
:shift_away,
|
26
|
+
:shift_away_subtle,
|
27
|
+
:shift_away_extreme,
|
28
|
+
:shift_towards,
|
29
|
+
:shift_towards_subtle,
|
30
|
+
:shift_towards_extreme,
|
31
|
+
:scale,
|
32
|
+
:scale_subtle,
|
33
|
+
:scale_extreme,
|
34
|
+
:perspective,
|
35
|
+
:perspective_subtle,
|
36
|
+
:perspective_extreme
|
37
|
+
)
|
38
|
+
|
39
|
+
TriggerTypes = Types::Coercible::Symbol.enum(
|
40
|
+
:focus,
|
41
|
+
:mouseenter,
|
42
|
+
:click,
|
43
|
+
:focusin,
|
44
|
+
:manual
|
15
45
|
)
|
16
46
|
|
17
47
|
option :position,
|
18
48
|
type: PositionTypes,
|
19
|
-
default: -> { :
|
49
|
+
default: -> { :top },
|
50
|
+
reader: false
|
51
|
+
option :animation,
|
52
|
+
type: AnimationTypes,
|
53
|
+
default: -> { :fade },
|
20
54
|
reader: false
|
21
|
-
option :
|
55
|
+
option :duration,
|
56
|
+
type: Types::Integer | Types::Array.of(Types::Integer),
|
57
|
+
default: -> { [300, 250] },
|
58
|
+
reader: false
|
59
|
+
option :hide_on_click,
|
60
|
+
type: Types::Bool | Types.Value(:toggle),
|
61
|
+
default: -> { true },
|
62
|
+
reader: false
|
63
|
+
option :z_index,
|
64
|
+
type: Types::Integer,
|
65
|
+
default: -> { 9999 },
|
66
|
+
reader: false
|
67
|
+
option :options,
|
68
|
+
default: -> { {} },
|
69
|
+
reader: false,
|
70
|
+
type: Types::Hash
|
71
|
+
option :trigger,
|
72
|
+
default: -> { %i[mouseenter focus] },
|
73
|
+
reader: false,
|
74
|
+
type: TriggerTypes | Types::Array.of(TriggerTypes)
|
22
75
|
|
23
76
|
def template(&block)
|
24
|
-
|
77
|
+
div(**attrs, &block)
|
25
78
|
end
|
26
79
|
|
27
80
|
def content(...)
|
@@ -34,20 +87,27 @@ module Protos
|
|
34
87
|
|
35
88
|
private
|
36
89
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
90
|
+
def dasherize(string)
|
91
|
+
string.to_s.tr("_", "-")
|
92
|
+
end
|
93
|
+
|
94
|
+
def options
|
95
|
+
opts = {}
|
96
|
+
opts[:animation] = dasherize(@animation)
|
97
|
+
opts[:placement] = dasherize(@position)
|
98
|
+
opts[:duration] = @duration
|
99
|
+
opts[:hideOnClick] = @hide_on_click
|
100
|
+
opts[:zIndex] = @z_index
|
101
|
+
opts[:trigger] = Array(@trigger).flatten.map(&:to_s).join(" ")
|
102
|
+
opts.merge(@options)
|
46
103
|
end
|
47
104
|
|
48
|
-
def
|
105
|
+
def default_attrs
|
49
106
|
{
|
50
|
-
|
107
|
+
data: {
|
108
|
+
controller: "protos--popover",
|
109
|
+
"protos--popover-options-value": JSON.generate(options)
|
110
|
+
}
|
51
111
|
}
|
52
112
|
end
|
53
113
|
end
|
data/lib/protos/stats.rb
CHANGED
@@ -6,6 +6,30 @@ module Protos
|
|
6
6
|
div(**attrs, &block)
|
7
7
|
end
|
8
8
|
|
9
|
+
def actions(...)
|
10
|
+
Actions.new(...)
|
11
|
+
end
|
12
|
+
|
13
|
+
def description(...)
|
14
|
+
Description.new(...)
|
15
|
+
end
|
16
|
+
|
17
|
+
def figure(...)
|
18
|
+
Figure.new(...)
|
19
|
+
end
|
20
|
+
|
21
|
+
def stat(...)
|
22
|
+
Stat.new(...)
|
23
|
+
end
|
24
|
+
|
25
|
+
def title(...)
|
26
|
+
Title.new(...)
|
27
|
+
end
|
28
|
+
|
29
|
+
def value(...)
|
30
|
+
Value.new(...)
|
31
|
+
end
|
32
|
+
|
9
33
|
private
|
10
34
|
|
11
35
|
def theme
|
data/lib/protos/swap.rb
CHANGED
@@ -4,7 +4,7 @@ module Protos
|
|
4
4
|
class Swap < Component
|
5
5
|
def template
|
6
6
|
label(**attrs) do
|
7
|
-
input(type: :checkbox)
|
7
|
+
input(type: :checkbox, class: css[:input])
|
8
8
|
yield if block_given?
|
9
9
|
end
|
10
10
|
end
|
@@ -21,7 +21,8 @@ module Protos
|
|
21
21
|
|
22
22
|
def theme
|
23
23
|
{
|
24
|
-
container: tokens("swap")
|
24
|
+
container: tokens("swap"),
|
25
|
+
input: tokens("hidden")
|
25
26
|
}
|
26
27
|
end
|
27
28
|
end
|
data/lib/protos/table.rb
CHANGED
@@ -2,6 +2,19 @@
|
|
2
2
|
|
3
3
|
module Protos
|
4
4
|
class Table < Component
|
5
|
+
option :pin_rows, default: -> { false }, type: Types::Bool
|
6
|
+
option :pin_columns, default: -> { false }, type: Types::Bool
|
7
|
+
option :striped, default: -> { false }, type: Types::Bool
|
8
|
+
option :size,
|
9
|
+
default: -> { :md },
|
10
|
+
reader: false,
|
11
|
+
type: Types::Coercible::Symbol.enum(
|
12
|
+
:xs,
|
13
|
+
:sm,
|
14
|
+
:md,
|
15
|
+
:lg
|
16
|
+
)
|
17
|
+
|
5
18
|
def template(&block)
|
6
19
|
div(**attrs) do
|
7
20
|
table(class: css[:table], &block)
|
@@ -38,10 +51,25 @@ module Protos
|
|
38
51
|
|
39
52
|
private
|
40
53
|
|
54
|
+
def size
|
55
|
+
{
|
56
|
+
xs: "table-xs",
|
57
|
+
sm: "table-sm",
|
58
|
+
md: "table-md",
|
59
|
+
lg: "table-lg"
|
60
|
+
}.fetch(@size)
|
61
|
+
end
|
62
|
+
|
41
63
|
def theme
|
42
64
|
{
|
43
65
|
container: tokens("w-full", "overflow-x-auto"),
|
44
|
-
table: tokens(
|
66
|
+
table: tokens(
|
67
|
+
"table",
|
68
|
+
size,
|
69
|
+
pin_rows: "table-pin-rows",
|
70
|
+
pin_columns: "table-pin-columns",
|
71
|
+
striped: "table-striped"
|
72
|
+
)
|
45
73
|
}
|
46
74
|
end
|
47
75
|
end
|
data/lib/protos/tabs/tab.rb
CHANGED
data/lib/protos/tabs.rb
CHANGED
@@ -3,23 +3,23 @@
|
|
3
3
|
module Protos
|
4
4
|
class Tabs < Component
|
5
5
|
option :type,
|
6
|
+
default: -> { :default },
|
7
|
+
reader: false,
|
6
8
|
type: Types::Coercible::Symbol.enum(
|
7
9
|
:default,
|
8
10
|
:boxed,
|
9
11
|
:bordered,
|
10
12
|
:lifted
|
11
|
-
)
|
12
|
-
default: -> { :default },
|
13
|
-
reader: false
|
13
|
+
)
|
14
14
|
option :size,
|
15
|
+
default: -> { :md },
|
16
|
+
reader: false,
|
15
17
|
type: Types::Coercible::Symbol.enum(
|
16
18
|
:xs,
|
17
19
|
:sm,
|
18
20
|
:md,
|
19
21
|
:lg
|
20
|
-
)
|
21
|
-
default: -> { :md },
|
22
|
-
reader: false
|
22
|
+
)
|
23
23
|
|
24
24
|
def template(&block)
|
25
25
|
div(**attrs, &block)
|
data/lib/protos/theme.rb
CHANGED
@@ -15,27 +15,35 @@ module Protos
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def add(key, value)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
TokenList.new
|
19
|
+
.add(@theme.fetch(key, ""))
|
20
|
+
.add(value)
|
21
|
+
.to_s
|
22
|
+
.tap do |tokens|
|
23
|
+
@theme[key] = tokens
|
24
|
+
end
|
23
25
|
end
|
24
26
|
|
25
27
|
def remove(key, value)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
TokenList.new
|
29
|
+
.add(@theme.fetch(key, ""))
|
30
|
+
.remove(value)
|
31
|
+
.to_s
|
32
|
+
.tap do |tokens|
|
33
|
+
@theme[key] = tokens
|
34
|
+
end
|
31
35
|
end
|
32
36
|
|
33
37
|
def set(key, value)
|
34
38
|
if value.is_a?(Hash)
|
35
39
|
@theme[key] = value
|
36
40
|
else
|
37
|
-
|
38
|
-
|
41
|
+
TokenList
|
42
|
+
.parse(value)
|
43
|
+
.to_s
|
44
|
+
.tap do |tokens|
|
45
|
+
@theme[key] = tokens
|
46
|
+
end
|
39
47
|
end
|
40
48
|
end
|
41
49
|
|
@@ -61,10 +69,6 @@ module Protos
|
|
61
69
|
|
62
70
|
private
|
63
71
|
|
64
|
-
def parse(value)
|
65
|
-
TokenList.parse(value)
|
66
|
-
end
|
67
|
-
|
68
72
|
def negation?(key)
|
69
73
|
key.to_s.start_with?("!")
|
70
74
|
end
|
@@ -13,6 +13,16 @@ module Protos
|
|
13
13
|
)
|
14
14
|
end
|
15
15
|
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def theme
|
20
|
+
{
|
21
|
+
# NOTE: Added this because I'm noticing the form having a margin
|
22
|
+
# with a default setup. Not sure if this is really needed.
|
23
|
+
form: tokens("m-0")
|
24
|
+
}
|
25
|
+
end
|
16
26
|
end
|
17
27
|
end
|
18
28
|
end
|
data/lib/protos/toast.rb
CHANGED
@@ -3,15 +3,21 @@
|
|
3
3
|
module Protos
|
4
4
|
class Toast < Component
|
5
5
|
Positions = Types::Symbol.enum(
|
6
|
-
:
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
6
|
+
:top_start,
|
7
|
+
:top_center,
|
8
|
+
:top_end,
|
9
|
+
:middle_start,
|
10
|
+
:middle_center,
|
11
|
+
:middle_end,
|
12
|
+
:bottom_start,
|
13
|
+
:bottom_center,
|
14
|
+
:bottom_end
|
12
15
|
)
|
13
16
|
|
14
|
-
option :position,
|
17
|
+
option :position,
|
18
|
+
type: Positions,
|
19
|
+
default: -> { :bottom_end },
|
20
|
+
reader: false
|
15
21
|
|
16
22
|
def template(&block)
|
17
23
|
dialog(**attrs, &block)
|
@@ -29,12 +35,27 @@ module Protos
|
|
29
35
|
}
|
30
36
|
end
|
31
37
|
|
38
|
+
def position
|
39
|
+
{
|
40
|
+
top_start: "toast-start toast-top",
|
41
|
+
top_center: "toast-center toast-top",
|
42
|
+
top_end: "toast-end toast-top",
|
43
|
+
middle_start: "toast-start toast-middle",
|
44
|
+
middle_center: "toast-center toast-middle",
|
45
|
+
middle_end: "toast-end toast-middle",
|
46
|
+
bottom_start: "toast-start toast-bottom",
|
47
|
+
bottom_center: "toast-center toast-bottom",
|
48
|
+
bottom_end: "toast-end toast-bottom"
|
49
|
+
}.fetch(@position)
|
50
|
+
end
|
51
|
+
|
32
52
|
def theme
|
33
53
|
{
|
34
54
|
container: tokens(
|
35
55
|
"toast",
|
36
|
-
|
37
|
-
"[&:not([open])]:hidden"
|
56
|
+
position,
|
57
|
+
"[&:not([open])]:hidden",
|
58
|
+
"bg-transparent"
|
38
59
|
)
|
39
60
|
}
|
40
61
|
end
|
data/lib/protos/token_list.rb
CHANGED
@@ -6,36 +6,61 @@ module Protos
|
|
6
6
|
case input
|
7
7
|
when String then new(input.split)
|
8
8
|
when Array then new(input)
|
9
|
+
when TokenList then input
|
9
10
|
else raise ArgumentError, "Invalid input: #{input.inspect}"
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
13
14
|
attr_reader :tokens
|
14
15
|
|
15
|
-
def initialize(tokens)
|
16
|
+
def initialize(tokens = [])
|
16
17
|
@tokens = Set.new(tokens)
|
17
18
|
end
|
18
19
|
|
19
20
|
def to_s
|
20
|
-
@tokens.to_a.join(" ")
|
21
|
+
merge(@tokens.to_a.join(" "))
|
21
22
|
end
|
22
23
|
|
23
24
|
def -(other)
|
24
|
-
other = TokenList.parse(other)
|
25
|
+
other = TokenList.parse(other)
|
25
26
|
self.class.new(@tokens - other.tokens)
|
26
27
|
end
|
27
28
|
|
28
29
|
def +(other)
|
29
|
-
other = TokenList.parse(other)
|
30
|
+
other = TokenList.parse(other)
|
30
31
|
self.class.new(@tokens + other.tokens)
|
31
32
|
end
|
32
33
|
|
33
34
|
def remove(token)
|
34
|
-
|
35
|
+
tap do
|
36
|
+
self.class.parse(token).tokens.each do |token|
|
37
|
+
@tokens.delete(token)
|
38
|
+
end
|
39
|
+
end
|
35
40
|
end
|
36
41
|
|
37
|
-
def add(
|
38
|
-
|
42
|
+
def add(input)
|
43
|
+
tap do
|
44
|
+
self.class.parse(input).tokens.each do |token|
|
45
|
+
@tokens.add(token)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def merge(tokens)
|
53
|
+
TailwindMerge::Merger.new(
|
54
|
+
config: {
|
55
|
+
theme: {
|
56
|
+
# Not currently working in the gem.
|
57
|
+
# "spacing" => %w[xs sm md lg xl],
|
58
|
+
# "padding" => %w[xs sm md lg xl],
|
59
|
+
# "margin" => %w[xs sm md lg xl]
|
60
|
+
}
|
61
|
+
}
|
62
|
+
)
|
63
|
+
.merge(tokens)
|
39
64
|
end
|
40
65
|
end
|
41
66
|
end
|
data/lib/protos/version.rb
CHANGED
data/lib/protos.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "json"
|
3
4
|
require "dry-types"
|
4
5
|
require "dry-initializer"
|
5
6
|
require "phlex"
|
7
|
+
require "tailwind_merge"
|
6
8
|
|
7
9
|
module Protos
|
8
10
|
class Error < StandardError; end
|
@@ -50,8 +52,6 @@ module Protos
|
|
50
52
|
require_relative "protos/collapse/title"
|
51
53
|
require_relative "protos/collapse/content"
|
52
54
|
|
53
|
-
require_relative "protos/combobox"
|
54
|
-
|
55
55
|
require_relative "protos/command"
|
56
56
|
require_relative "protos/command/input"
|
57
57
|
require_relative "protos/command/dialog"
|
@@ -67,11 +67,6 @@ module Protos
|
|
67
67
|
require_relative "protos/drawer/trigger"
|
68
68
|
require_relative "protos/drawer/content"
|
69
69
|
|
70
|
-
require_relative "protos/dropdown"
|
71
|
-
require_relative "protos/dropdown/item"
|
72
|
-
require_relative "protos/dropdown/menu"
|
73
|
-
require_relative "protos/dropdown/trigger"
|
74
|
-
|
75
70
|
require_relative "protos/hero"
|
76
71
|
require_relative "protos/hero/content"
|
77
72
|
require_relative "protos/hero/overlay"
|
@@ -125,5 +120,13 @@ module Protos
|
|
125
120
|
require_relative "protos/typography/heading"
|
126
121
|
require_relative "protos/typography/paragraph"
|
127
122
|
require_relative "protos/typography/inline_link"
|
123
|
+
|
124
|
+
# Dependent
|
125
|
+
require_relative "protos/dropdown"
|
126
|
+
require_relative "protos/dropdown/item"
|
127
|
+
require_relative "protos/dropdown/menu"
|
128
|
+
require_relative "protos/dropdown/trigger"
|
129
|
+
|
130
|
+
require_relative "protos/combobox"
|
128
131
|
end
|
129
132
|
end
|
data/protos.gemspec
CHANGED
@@ -38,6 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_dependency "dry-initializer", "~> 3.1"
|
39
39
|
spec.add_dependency "dry-types", "~> 1.7"
|
40
40
|
spec.add_dependency "phlex", "~> 1.9"
|
41
|
+
spec.add_dependency "tailwind_merge", "~> 0.10"
|
41
42
|
|
42
43
|
# For more information and examples about making a new gem, check out our
|
43
44
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nolan J Tait
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-core
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.9'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: tailwind_merge
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.10'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.10'
|
69
83
|
description: A UI component library built with phlex and daisyui
|
70
84
|
email:
|
71
85
|
- nolanjtait@gmail.com
|