protos 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -1
- data/README.md +2 -1
- data/TODO.md +18 -0
- data/lib/protos/accordion/item.rb +2 -2
- data/lib/protos/accordion.rb +3 -9
- data/lib/protos/alert/actions.rb +1 -1
- data/lib/protos/alert/icon.rb +1 -1
- data/lib/protos/alert.rb +15 -13
- data/lib/protos/attributes.rb +3 -0
- data/lib/protos/avatar.rb +60 -32
- data/lib/protos/breadcrumbs.rb +1 -1
- data/lib/protos/card/actions.rb +1 -1
- data/lib/protos/card/body.rb +1 -1
- data/lib/protos/card/title.rb +1 -1
- data/lib/protos/card.rb +9 -7
- data/lib/protos/carousel/actions.rb +10 -10
- data/lib/protos/carousel/item.rb +1 -1
- data/lib/protos/carousel.rb +7 -5
- data/lib/protos/chat_bubble/content.rb +17 -12
- data/lib/protos/chat_bubble/footer.rb +1 -1
- data/lib/protos/chat_bubble/header.rb +1 -1
- data/lib/protos/chat_bubble/image.rb +1 -1
- data/lib/protos/chat_bubble.rb +10 -5
- data/lib/protos/collapse/content.rb +1 -1
- data/lib/protos/collapse/title.rb +1 -1
- data/lib/protos/collapse.rb +5 -1
- data/lib/protos/combobox.rb +1 -1
- data/lib/protos/command/dialog.rb +8 -8
- data/lib/protos/command/empty.rb +1 -1
- data/lib/protos/command/input.rb +12 -12
- data/lib/protos/command/list.rb +1 -1
- data/lib/protos/command/title.rb +1 -1
- data/lib/protos/drawer/content.rb +1 -1
- data/lib/protos/drawer/side.rb +6 -6
- data/lib/protos/drawer/trigger.rb +1 -1
- data/lib/protos/drawer.rb +2 -2
- data/lib/protos/dropdown/menu.rb +7 -7
- data/lib/protos/dropdown.rb +2 -2
- data/lib/protos/hero/content.rb +1 -1
- data/lib/protos/hero/overlay.rb +1 -1
- data/lib/protos/hero.rb +1 -1
- data/lib/protos/list/item.rb +4 -4
- data/lib/protos/list.rb +1 -4
- data/lib/protos/modal/close_button.rb +1 -4
- data/lib/protos/modal/dialog.rb +17 -12
- data/lib/protos/popover.rb +6 -6
- data/lib/protos/stats/actions.rb +1 -1
- data/lib/protos/stats/description.rb +1 -1
- data/lib/protos/stats/figure.rb +1 -1
- data/lib/protos/stats/stat.rb +1 -1
- data/lib/protos/stats/title.rb +1 -1
- data/lib/protos/stats/value.rb +1 -1
- data/lib/protos/stats.rb +1 -1
- data/lib/protos/steps/step.rb +49 -0
- data/lib/protos/steps.rb +27 -0
- data/lib/protos/swap/off.rb +1 -1
- data/lib/protos/swap/on.rb +1 -1
- data/lib/protos/swap.rb +1 -1
- data/lib/protos/table/caption.rb +15 -1
- data/lib/protos/table/cell.rb +13 -8
- data/lib/protos/table/head.rb +11 -18
- data/lib/protos/table.rb +9 -7
- data/lib/protos/tabs/tab.rb +1 -1
- data/lib/protos/tabs.rb +13 -7
- data/lib/protos/timeline/center.rb +1 -1
- data/lib/protos/timeline/left.rb +1 -1
- data/lib/protos/timeline/right.rb +1 -1
- data/lib/protos/toast/close_button.rb +1 -1
- data/lib/protos/toast.rb +19 -17
- data/lib/protos/token_list.rb +7 -1
- data/lib/protos/types.rb +0 -25
- data/lib/protos/typography/heading.rb +15 -13
- data/lib/protos/typography/inline_link.rb +6 -6
- data/lib/protos/typography/paragraph.rb +3 -3
- data/lib/protos/version.rb +1 -1
- data/lib/protos.rb +3 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e18641b7b93b0f94886468a48ed3c3263bb5edd72dbaeabfc03e346598f0d409
|
4
|
+
data.tar.gz: 207f45d2b30525c4ed65f83943c2c4eb0617a72dacabc7238a9f3cd4309ad96d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 844cc78e0e2972c8e726a46af3ed08e420c3581d93c79f04b266019f10a38f2441b4ec1a76ec787b16592698cc80c742d1d87d8cc793ac0259bd5baa0acbc893
|
7
|
+
data.tar.gz: 7b0c9022724175b60e5d1f53efb75237f944889e07fee18c8ff99165b1ae8b87843e9d0fb7ad3f8358788af565938e240141d386f29f31ac372efb71a95c40b0
|
data/CHANGELOG.md
CHANGED
@@ -15,8 +15,17 @@
|
|
15
15
|
- Updates to phlex v0.10 by changing all `template` methods to `view_template`
|
16
16
|
- Improvements to README
|
17
17
|
|
18
|
-
## [0.4.0] -
|
18
|
+
## [0.4.0] - 2024-04-09
|
19
19
|
|
20
20
|
- Phlex discord didn't like all the calls to `render`
|
21
21
|
- Apparently `render` is called differently within ERB
|
22
22
|
- Suggested to change all calls to immediately render, would improve ergonomics
|
23
|
+
|
24
|
+
## [0.4.2] - 2024-04-30
|
25
|
+
|
26
|
+
- Adds ability to pass arrays of tokens to themes
|
27
|
+
- Removes unnecessary calls to `tokens`, preferring arrays of strings for
|
28
|
+
performance
|
29
|
+
- Improvements to performance with constant hash lookups and early returns on
|
30
|
+
`mix`
|
31
|
+
- Adds steps component
|
data/README.md
CHANGED
@@ -668,7 +668,8 @@ You can run the benchmarks using the raketasks, e.g:
|
|
668
668
|
|
669
669
|
There are also tasks for profiling and exploring memory consumption.
|
670
670
|
|
671
|
-
You can find the latest benchmarks in `benchmarks/`.
|
671
|
+
You can find the latest benchmarks in `benchmarks/`. These were run on a new
|
672
|
+
Macbook M3 Pro chip.
|
672
673
|
|
673
674
|
Currently this library is 30x slower than plain Phlex components. This is due to
|
674
675
|
the overhead of themes, attributes and other quality of life improvements.
|
data/TODO.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# UI Components
|
2
|
+
|
3
|
+
- [ ] Empty state
|
4
|
+
- [ ] Steps
|
5
|
+
- [ ] Avatar group
|
6
|
+
- [ ] Calendar
|
7
|
+
- [ ] [Descriptions](https://ant.design/components/descriptions)
|
8
|
+
- [ ] Image (progressive loading, fault tollerant)
|
9
|
+
|
10
|
+
# Form inputs
|
11
|
+
|
12
|
+
- [ ] [Cascader](https://ant.design/components/cascader)
|
13
|
+
- [ ] Rating
|
14
|
+
- [ ] Select (multiselect, combobox, etc)
|
15
|
+
- [ ] Time picker
|
16
|
+
- [ ] [Transfer](https://ant.design/components/transfer)
|
17
|
+
- [ ] Upload
|
18
|
+
|
@@ -21,14 +21,14 @@ module Protos
|
|
21
21
|
private
|
22
22
|
|
23
23
|
def collapse_theme
|
24
|
-
{ "!container":
|
24
|
+
{ "!container": "bg-base-100" }.tap do |theme|
|
25
25
|
theme[:container!] = css[:collapse] if css[:collapse]
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
def theme
|
30
30
|
{
|
31
|
-
container:
|
31
|
+
container: "join-item"
|
32
32
|
}
|
33
33
|
end
|
34
34
|
end
|
data/lib/protos/accordion.rb
CHANGED
@@ -7,8 +7,7 @@ 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
|
-
option :id,
|
11
|
-
default: -> { "collapse-#{SecureRandom.hex(4)}" }
|
10
|
+
option :id, default: -> { "collapse-#{SecureRandom.hex(4)}" }
|
12
11
|
|
13
12
|
def view_template(&)
|
14
13
|
ul(**attrs, &)
|
@@ -18,18 +17,13 @@ module Protos
|
|
18
17
|
|
19
18
|
def content(...) = render Collapse::Content.new(...)
|
20
19
|
|
21
|
-
def title(*, **, &)
|
22
|
-
render Collapse::Title.new(*, id:, **, &)
|
23
|
-
end
|
20
|
+
def title(*, **, &) = render Collapse::Title.new(*, id:, **, &)
|
24
21
|
|
25
22
|
private
|
26
23
|
|
27
24
|
def theme
|
28
25
|
{
|
29
|
-
container:
|
30
|
-
"join",
|
31
|
-
"join-vertical"
|
32
|
-
)
|
26
|
+
container: "join join-vertical"
|
33
27
|
}
|
34
28
|
end
|
35
29
|
end
|
data/lib/protos/alert/actions.rb
CHANGED
data/lib/protos/alert/icon.rb
CHANGED
data/lib/protos/alert.rb
CHANGED
@@ -6,14 +6,21 @@ 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
|
-
|
9
|
+
Styles = Types::Coercible::Symbol.enum(
|
10
10
|
:info,
|
11
11
|
:success,
|
12
12
|
:warning,
|
13
13
|
:error
|
14
14
|
)
|
15
15
|
|
16
|
-
|
16
|
+
STYLES = {
|
17
|
+
info: "alert-info",
|
18
|
+
error: "alert-error",
|
19
|
+
warning: "alert-warning",
|
20
|
+
success: "alert-success"
|
21
|
+
}.freeze
|
22
|
+
|
23
|
+
option :type, type: Styles, default: -> { :info }, reader: false
|
17
24
|
|
18
25
|
def view_template(&)
|
19
26
|
div(**attrs, &)
|
@@ -27,20 +34,15 @@ module Protos
|
|
27
34
|
|
28
35
|
def theme
|
29
36
|
{
|
30
|
-
container:
|
31
|
-
|
32
|
-
|
33
|
-
|
37
|
+
container: %W[
|
38
|
+
alert
|
39
|
+
#{style}
|
40
|
+
]
|
34
41
|
}
|
35
42
|
end
|
36
43
|
|
37
|
-
def
|
38
|
-
|
39
|
-
info: "alert-info",
|
40
|
-
error: "alert-error",
|
41
|
-
warning: "alert-warning",
|
42
|
-
success: "alert-success"
|
43
|
-
}.fetch(type)
|
44
|
+
def style
|
45
|
+
STYLES.fetch(@type)
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
data/lib/protos/attributes.rb
CHANGED
@@ -36,6 +36,9 @@ module Protos
|
|
36
36
|
def mix(hash, *hashes)
|
37
37
|
hashes.each_with_object(hash) do |hash, result|
|
38
38
|
result.merge!(hash) do |_key, a, b| # rubocop:disable Metrics/ParameterLists
|
39
|
+
next a unless b
|
40
|
+
next a if a == b
|
41
|
+
|
39
42
|
case [a, b]
|
40
43
|
in String, String then "#{a} #{b}"
|
41
44
|
in Array, Array then a + b
|
data/lib/protos/avatar.rb
CHANGED
@@ -5,15 +5,70 @@ module Protos
|
|
5
5
|
# DOCS: The avatar component is used to represent a user or entity.
|
6
6
|
# https://daisyui.com/components/avatar/
|
7
7
|
|
8
|
-
|
8
|
+
Indicators = Types::Coercible::Symbol.enum(:none, :online, :offline)
|
9
|
+
MaskShapes = Types::Coercible::Symbol.enum(
|
10
|
+
:none,
|
11
|
+
:squircle,
|
12
|
+
:heart,
|
13
|
+
:hexagon,
|
14
|
+
:hexagon2,
|
15
|
+
:decagon,
|
16
|
+
:pentagon,
|
17
|
+
:diamond,
|
18
|
+
:square,
|
19
|
+
:circle,
|
20
|
+
:parallelogram,
|
21
|
+
:parallelogram2,
|
22
|
+
:parallelogram3,
|
23
|
+
:parallelogram4,
|
24
|
+
:star,
|
25
|
+
:star2,
|
26
|
+
:triangle,
|
27
|
+
:triangle2,
|
28
|
+
:triangle3,
|
29
|
+
:triangle4,
|
30
|
+
:half1,
|
31
|
+
:half2
|
32
|
+
)
|
33
|
+
|
34
|
+
SHAPES = {
|
35
|
+
none: "",
|
36
|
+
squircle: "mask mask-squircle",
|
37
|
+
heart: "mask mask-heart",
|
38
|
+
hexagon: "mask mask-hexagon",
|
39
|
+
hexagon2: "mask mask-hexagon-2",
|
40
|
+
decagon: "mask mask-decagon",
|
41
|
+
pentagon: "mask mask-pentagon",
|
42
|
+
diamond: "mask mask-diamond",
|
43
|
+
square: "mask mask-square",
|
44
|
+
circle: "mask mask-circle",
|
45
|
+
parallelogram: "mask mask-parallelogram",
|
46
|
+
parallelogram2: "mask mask-parallelogram-2",
|
47
|
+
parallelogram3: "mask mask-parallelogram-3",
|
48
|
+
parallelogram4: "mask mask-parallelogram-4",
|
49
|
+
star: "mask mask-star",
|
50
|
+
star2: "mask mask-star-2",
|
51
|
+
triangle: "mask mask-triangle",
|
52
|
+
triangle2: "mask mask-triangle-2",
|
53
|
+
triangle3: "mask mask-triangle-3",
|
54
|
+
triangle4: "mask mask-triangle-4",
|
55
|
+
half1: "mask mask-half-1",
|
56
|
+
half2: "mask mask-half-2"
|
57
|
+
}.freeze
|
58
|
+
|
59
|
+
INDICATORS = {
|
60
|
+
none: "",
|
61
|
+
online: "online",
|
62
|
+
offline: "offline"
|
63
|
+
}.freeze
|
9
64
|
|
10
65
|
option :placeholder, type: Types::Bool, default: -> { false }
|
11
66
|
option :indicator,
|
12
|
-
type:
|
67
|
+
type: Indicators,
|
13
68
|
default: -> { :none },
|
14
69
|
reader: false
|
15
70
|
option :shape,
|
16
|
-
type:
|
71
|
+
type: MaskShapes,
|
17
72
|
default: -> { :none },
|
18
73
|
reader: false
|
19
74
|
|
@@ -26,38 +81,11 @@ module Protos
|
|
26
81
|
private
|
27
82
|
|
28
83
|
def indicator
|
29
|
-
|
30
|
-
none: "",
|
31
|
-
online: "online",
|
32
|
-
offline: "offline"
|
33
|
-
}.fetch(@indicator)
|
84
|
+
INDICATORS.fetch(@indicator)
|
34
85
|
end
|
35
86
|
|
36
87
|
def shape
|
37
|
-
|
38
|
-
none: "",
|
39
|
-
squircle: "mask mask-squircle",
|
40
|
-
heart: "mask mask-heart",
|
41
|
-
hexagon: "mask mask-hexagon",
|
42
|
-
hexagon2: "mask mask-hexagon-2",
|
43
|
-
decagon: "mask mask-decagon",
|
44
|
-
pentagon: "mask mask-pentagon",
|
45
|
-
diamond: "mask mask-diamond",
|
46
|
-
square: "mask mask-square",
|
47
|
-
circle: "mask mask-circle",
|
48
|
-
parallelogram: "mask mask-parallelogram",
|
49
|
-
parallelogram2: "mask mask-parallelogram-2",
|
50
|
-
parallelogram3: "mask mask-parallelogram-3",
|
51
|
-
parallelogram4: "mask mask-parallelogram-4",
|
52
|
-
star: "mask mask-star",
|
53
|
-
star2: "mask mask-star-2",
|
54
|
-
triangle: "mask mask-triangle",
|
55
|
-
triangle2: "mask mask-triangle-2",
|
56
|
-
triangle3: "mask mask-triangle-3",
|
57
|
-
triangle4: "mask mask-triangle-4",
|
58
|
-
half1: "mask mask-half-1",
|
59
|
-
half2: "mask mask-half-2"
|
60
|
-
}.fetch(@shape)
|
88
|
+
SHAPES.fetch(@shape)
|
61
89
|
end
|
62
90
|
|
63
91
|
def theme
|
data/lib/protos/breadcrumbs.rb
CHANGED
data/lib/protos/card/actions.rb
CHANGED
data/lib/protos/card/body.rb
CHANGED
data/lib/protos/card/title.rb
CHANGED
data/lib/protos/card.rb
CHANGED
@@ -5,12 +5,18 @@ module Protos
|
|
5
5
|
# DOCS: A card component
|
6
6
|
# https://daisyui.com/components/card/
|
7
7
|
|
8
|
-
|
8
|
+
ImageDisplays = Types::Coercible::Symbol.enum(:default, :overlay, :side)
|
9
|
+
|
10
|
+
IMAGE_DISPLAYS = {
|
11
|
+
default: "",
|
12
|
+
overlay: "image-full",
|
13
|
+
side: "card-side"
|
14
|
+
}.freeze
|
9
15
|
|
10
16
|
option :border, type: Types::Bool, default: -> { true }, reader: :private
|
11
17
|
option :compact, type: Types::Bool, default: -> { false }, reader: :private
|
12
18
|
option :image_display,
|
13
|
-
|
19
|
+
ImageDisplays,
|
14
20
|
default: -> { :default },
|
15
21
|
reader: false
|
16
22
|
|
@@ -29,11 +35,7 @@ module Protos
|
|
29
35
|
private
|
30
36
|
|
31
37
|
def image_display
|
32
|
-
|
33
|
-
default: "",
|
34
|
-
overlay: "image-full",
|
35
|
-
side: "card-side"
|
36
|
-
}.fetch(@image_display)
|
38
|
+
IMAGE_DISPLAYS.fetch(@image_display)
|
37
39
|
end
|
38
40
|
|
39
41
|
def theme
|
@@ -13,16 +13,16 @@ module Protos
|
|
13
13
|
|
14
14
|
def theme
|
15
15
|
{
|
16
|
-
container:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
container: %w[
|
17
|
+
absolute
|
18
|
+
flex
|
19
|
+
justify-between
|
20
|
+
transform
|
21
|
+
-translate-y-1/2
|
22
|
+
left-sm
|
23
|
+
right-sm
|
24
|
+
top-1/2
|
25
|
+
]
|
26
26
|
}
|
27
27
|
end
|
28
28
|
end
|
data/lib/protos/carousel/item.rb
CHANGED
data/lib/protos/carousel.rb
CHANGED
@@ -6,6 +6,12 @@ module Protos
|
|
6
6
|
# through in a mobile friendly manner.
|
7
7
|
# https://daisyui.com/components/carousel/
|
8
8
|
|
9
|
+
SNAP_POINTS = {
|
10
|
+
none: "",
|
11
|
+
center: "carousel-center",
|
12
|
+
end: "carousel-end"
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
option :vertical, type: Types::Bool, default: -> { false }
|
10
16
|
option :snap_to,
|
11
17
|
default: -> { :none },
|
@@ -27,11 +33,7 @@ module Protos
|
|
27
33
|
private
|
28
34
|
|
29
35
|
def snap_to
|
30
|
-
|
31
|
-
none: "",
|
32
|
-
center: "carousel-center",
|
33
|
-
end: "carousel-end"
|
34
|
-
}.fetch(@snap_to)
|
36
|
+
SNAP_POINTS.fetch(@snap_to)
|
35
37
|
end
|
36
38
|
|
37
39
|
def theme
|
@@ -6,6 +6,17 @@ module Protos
|
|
6
6
|
# DOCS: The main content of a chat bubble. This would normally be the text
|
7
7
|
# content of the message. It will be colored according to the type.
|
8
8
|
|
9
|
+
STYLES = {
|
10
|
+
none: "",
|
11
|
+
primary: "chat-bubble-primary",
|
12
|
+
secondary: "chat-bubble-secondary",
|
13
|
+
accent: "chat-bubble-accent",
|
14
|
+
info: "chat-bubble-info",
|
15
|
+
success: "chat-bubble-success",
|
16
|
+
warning: "chat-bubble-warning",
|
17
|
+
error: "chat-bubble-error"
|
18
|
+
}.freeze
|
19
|
+
|
9
20
|
option :type,
|
10
21
|
default: -> { :none },
|
11
22
|
reader: false,
|
@@ -26,22 +37,16 @@ module Protos
|
|
26
37
|
|
27
38
|
private
|
28
39
|
|
29
|
-
def
|
30
|
-
|
31
|
-
none: "",
|
32
|
-
primary: "chat-bubble-primary",
|
33
|
-
secondary: "chat-bubble-secondary",
|
34
|
-
accent: "chat-bubble-accent",
|
35
|
-
info: "chat-bubble-info",
|
36
|
-
success: "chat-bubble-success",
|
37
|
-
warning: "chat-bubble-warning",
|
38
|
-
error: "chat-bubble-error"
|
39
|
-
}.fetch(@type)
|
40
|
+
def style
|
41
|
+
STYLES.fetch(@type)
|
40
42
|
end
|
41
43
|
|
42
44
|
def theme
|
43
45
|
{
|
44
|
-
container:
|
46
|
+
container: %W[
|
47
|
+
chat-bubble
|
48
|
+
#{style}
|
49
|
+
]
|
45
50
|
}
|
46
51
|
end
|
47
52
|
end
|
data/lib/protos/chat_bubble.rb
CHANGED
@@ -7,6 +7,11 @@ module Protos
|
|
7
7
|
# in a larger chat history.
|
8
8
|
# https://daisyui.com/components/chat/
|
9
9
|
|
10
|
+
ALIGNMENTS = {
|
11
|
+
start: "chat-start",
|
12
|
+
end: "chat-end"
|
13
|
+
}.freeze
|
14
|
+
|
10
15
|
option :align,
|
11
16
|
default: -> { :start },
|
12
17
|
reader: false,
|
@@ -30,15 +35,15 @@ module Protos
|
|
30
35
|
private
|
31
36
|
|
32
37
|
def align
|
33
|
-
|
34
|
-
start: "chat-start",
|
35
|
-
end: "chat-end"
|
36
|
-
}.fetch(@align)
|
38
|
+
ALIGNMENTS.fetch(@align)
|
37
39
|
end
|
38
40
|
|
39
41
|
def theme
|
40
42
|
{
|
41
|
-
container:
|
43
|
+
container: %W[
|
44
|
+
chat
|
45
|
+
#{align}
|
46
|
+
]
|
42
47
|
}
|
43
48
|
end
|
44
49
|
end
|
data/lib/protos/collapse.rb
CHANGED
data/lib/protos/combobox.rb
CHANGED
@@ -25,14 +25,14 @@ module Protos
|
|
25
25
|
|
26
26
|
def theme
|
27
27
|
{
|
28
|
-
container:
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
modal:
|
35
|
-
form:
|
28
|
+
container: %w[
|
29
|
+
modal
|
30
|
+
modal-bottom
|
31
|
+
backdrop-blur-sm
|
32
|
+
sm:modal-middle
|
33
|
+
],
|
34
|
+
modal: "modal-box p-0",
|
35
|
+
form: "modal-backdrop"
|
36
36
|
}
|
37
37
|
end
|
38
38
|
end
|