protos 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/protos/accordion/item.rb +3 -1
- data/lib/protos/accordion.rb +4 -3
- data/lib/protos/collapse/title.rb +9 -1
- data/lib/protos/collapse.rb +12 -4
- data/lib/protos/theme.rb +10 -1
- data/lib/protos/token_list.rb +1 -17
- data/lib/protos/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 939a00cb6d422dc749d734683f4eceedf4c1857f21ab770dae704a99e06cdf8a
|
4
|
+
data.tar.gz: 60525463c5531256d9cac2139791b112c477b746a8ed2a643d29856fe548517a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '094affdf956f0ff06aba676408ee34d20e6af8ed5ac92afa04576bbc52b83499e491bfd74c3b27c281d20f32fcada8dbad27ec2fbedcb79cb519e9e0a318d2e7'
|
7
|
+
data.tar.gz: 953db1b5c57a9202a3f87e0a3ac8e32ed226f48c85588b7d1041559fd8a0749952c76619cc85eb075717b697623bb1dc045cf0dcc9c23370c1622e67c460d993
|
@@ -10,7 +10,9 @@ module Protos
|
|
10
10
|
def template(&block)
|
11
11
|
li(**attrs) do
|
12
12
|
render collapse_component do
|
13
|
-
|
13
|
+
# form: "" prevents the radio button from being submitted if its
|
14
|
+
# within a form
|
15
|
+
input(type: :radio, name: id, form: "")
|
14
16
|
yield if block
|
15
17
|
end
|
16
18
|
end
|
data/lib/protos/accordion.rb
CHANGED
@@ -7,7 +7,8 @@ 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,
|
10
|
+
option :id,
|
11
|
+
default: -> { "collapse-#{SecureRandom.hex(4)}" }
|
11
12
|
|
12
13
|
def template(&block)
|
13
14
|
ul(**attrs, &block)
|
@@ -17,8 +18,8 @@ module Protos
|
|
17
18
|
Item.new(id:, **kwargs)
|
18
19
|
end
|
19
20
|
|
20
|
-
def title(
|
21
|
-
Collapse::Title.new(
|
21
|
+
def title(*args, **kwargs, &block)
|
22
|
+
Collapse::Title.new(*args, id:, **kwargs, &block)
|
22
23
|
end
|
23
24
|
|
24
25
|
def content(...)
|
@@ -5,9 +5,17 @@ module Protos
|
|
5
5
|
class Title < Component
|
6
6
|
# DOCS: The title of a collapse. This is the content that is always
|
7
7
|
# visible and is used to toggle the collapse.
|
8
|
+
option :id,
|
9
|
+
type: Types::Coercible::String,
|
10
|
+
reader: false,
|
11
|
+
default: -> { "" }
|
8
12
|
|
9
13
|
def template(&block)
|
10
|
-
|
14
|
+
if @id.size.positive?
|
15
|
+
label(for: @id, **attrs, &block)
|
16
|
+
else
|
17
|
+
div(**attrs, &block)
|
18
|
+
end
|
11
19
|
end
|
12
20
|
|
13
21
|
private
|
data/lib/protos/collapse.rb
CHANGED
@@ -6,12 +6,20 @@ 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
|
-
|
10
|
-
|
9
|
+
option :checkbox, default: -> { false }, type: Types::Bool, reader: false
|
10
|
+
option :id,
|
11
|
+
default: -> { "collapse-#{SecureRandom.hex(4)}" },
|
12
|
+
type: Types::String
|
13
|
+
|
14
|
+
def template
|
15
|
+
div(**attrs) do
|
16
|
+
input(type: "checkbox", id:) if @checkbox
|
17
|
+
yield if block_given?
|
18
|
+
end
|
11
19
|
end
|
12
20
|
|
13
|
-
def title(
|
14
|
-
Title.new(
|
21
|
+
def title(*args, **kwargs, &block)
|
22
|
+
Title.new(*args, id:, **kwargs, &block)
|
15
23
|
end
|
16
24
|
|
17
25
|
def content(...)
|
data/lib/protos/theme.rb
CHANGED
@@ -7,12 +7,21 @@ module Protos
|
|
7
7
|
# This is the object that is returned by `css` and used to set slots for
|
8
8
|
# a component style.
|
9
9
|
|
10
|
+
class << self
|
11
|
+
def merger
|
12
|
+
@merger ||= TailwindMerge::Merger.new
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
10
16
|
def initialize(theme = {}, **kwargs)
|
11
17
|
@theme = theme.merge(kwargs)
|
12
18
|
end
|
13
19
|
|
14
20
|
def [](key)
|
15
|
-
@theme[key]
|
21
|
+
value = @theme[key]
|
22
|
+
return value unless value.is_a?(String)
|
23
|
+
|
24
|
+
self.class.merger.merge(value)
|
16
25
|
end
|
17
26
|
|
18
27
|
def key?(key)
|
data/lib/protos/token_list.rb
CHANGED
@@ -24,7 +24,7 @@ module Protos
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def to_s
|
27
|
-
|
27
|
+
@tokens.join(" ")
|
28
28
|
end
|
29
29
|
|
30
30
|
def -(other)
|
@@ -52,21 +52,5 @@ module Protos
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def merge(tokens)
|
59
|
-
TailwindMerge::Merger.new(
|
60
|
-
config: {
|
61
|
-
theme: {
|
62
|
-
# Not currently working in the gem.
|
63
|
-
# "spacing" => %w[xs sm md lg xl],
|
64
|
-
# "padding" => %w[xs sm md lg xl],
|
65
|
-
# "margin" => %w[xs sm md lg xl]
|
66
|
-
}
|
67
|
-
}
|
68
|
-
)
|
69
|
-
.merge(tokens)
|
70
|
-
end
|
71
55
|
end
|
72
56
|
end
|
data/lib/protos/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.3
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-core
|