protos 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6771e623cc76042636663c199b9dd48e3b9d8ed5011d180f7e9e1fa50728fc65
4
- data.tar.gz: 3dcd91f89719b72fbd9f23725add23ef09d0588196f8647ed7597baeed48b5de
3
+ metadata.gz: 939a00cb6d422dc749d734683f4eceedf4c1857f21ab770dae704a99e06cdf8a
4
+ data.tar.gz: 60525463c5531256d9cac2139791b112c477b746a8ed2a643d29856fe548517a
5
5
  SHA512:
6
- metadata.gz: 843780d369c551ee4e407037a6fa842343d36f9582d73823573af5bb06ee243424d85416737d9c6e80f433ab0147be41caf7af93b1c5db64765f479886157340
7
- data.tar.gz: 37fb34135c07d53fc0d9e7af1c814f91130ed0a6891fb00db2059090fe7ec8787cebc004b41186a9cf09c936a151c9c2ef503333a25169cee91b1a3ca67f5864
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
- input(type: :radio, name: id, id:)
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
@@ -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, default: -> { SecureRandom.uuid }
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
- div(**attrs, &block)
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
@@ -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
- def template(&block)
10
- div(**attrs, &block)
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)
@@ -24,7 +24,7 @@ module Protos
24
24
  end
25
25
 
26
26
  def to_s
27
- merge(@tokens.to_a.join(" "))
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Protos
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
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.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-10 00:00:00.000000000 Z
11
+ date: 2024-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-core