protos 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +56 -60
  3. data/examples/list.rb +1 -1
  4. data/examples/navbar.rb +1 -1
  5. data/lib/protos/accordion/item.rb +4 -2
  6. data/lib/protos/accordion.rb +5 -4
  7. data/lib/protos/alert/actions.rb +1 -1
  8. data/lib/protos/alert/icon.rb +1 -1
  9. data/lib/protos/alert.rb +1 -1
  10. data/lib/protos/avatar.rb +1 -1
  11. data/lib/protos/breadcrumbs/crumb.rb +1 -1
  12. data/lib/protos/breadcrumbs.rb +1 -1
  13. data/lib/protos/card/actions.rb +1 -1
  14. data/lib/protos/card/body.rb +1 -1
  15. data/lib/protos/card/image.rb +1 -1
  16. data/lib/protos/card/title.rb +1 -1
  17. data/lib/protos/card.rb +1 -1
  18. data/lib/protos/carousel/actions.rb +1 -1
  19. data/lib/protos/carousel/item.rb +1 -1
  20. data/lib/protos/carousel.rb +1 -1
  21. data/lib/protos/chat_bubble/content.rb +1 -1
  22. data/lib/protos/chat_bubble/footer.rb +1 -1
  23. data/lib/protos/chat_bubble/header.rb +1 -1
  24. data/lib/protos/chat_bubble/image.rb +1 -1
  25. data/lib/protos/chat_bubble.rb +1 -1
  26. data/lib/protos/collapse/content.rb +1 -1
  27. data/lib/protos/collapse/title.rb +10 -2
  28. data/lib/protos/collapse.rb +12 -4
  29. data/lib/protos/command/dialog.rb +1 -1
  30. data/lib/protos/command/empty.rb +1 -1
  31. data/lib/protos/command/group.rb +1 -1
  32. data/lib/protos/command/input.rb +3 -2
  33. data/lib/protos/command/item.rb +1 -1
  34. data/lib/protos/command/list.rb +1 -1
  35. data/lib/protos/command/title.rb +1 -1
  36. data/lib/protos/command/trigger.rb +1 -1
  37. data/lib/protos/command.rb +1 -1
  38. data/lib/protos/drawer/content.rb +1 -1
  39. data/lib/protos/drawer/side.rb +1 -1
  40. data/lib/protos/drawer/trigger.rb +1 -1
  41. data/lib/protos/drawer.rb +2 -2
  42. data/lib/protos/dropdown/item.rb +1 -1
  43. data/lib/protos/dropdown/menu.rb +1 -1
  44. data/lib/protos/hero/content.rb +1 -1
  45. data/lib/protos/hero/overlay.rb +1 -1
  46. data/lib/protos/hero.rb +1 -1
  47. data/lib/protos/list/item.rb +1 -1
  48. data/lib/protos/list.rb +1 -1
  49. data/lib/protos/modal/close_button.rb +1 -1
  50. data/lib/protos/modal/dialog.rb +1 -1
  51. data/lib/protos/modal/trigger.rb +1 -1
  52. data/lib/protos/modal.rb +1 -1
  53. data/lib/protos/popover/content.rb +1 -1
  54. data/lib/protos/popover/trigger.rb +1 -1
  55. data/lib/protos/popover.rb +1 -1
  56. data/lib/protos/stats/actions.rb +1 -1
  57. data/lib/protos/stats/description.rb +1 -1
  58. data/lib/protos/stats/figure.rb +1 -1
  59. data/lib/protos/stats/stat.rb +1 -1
  60. data/lib/protos/stats/title.rb +1 -1
  61. data/lib/protos/stats/value.rb +1 -1
  62. data/lib/protos/stats.rb +1 -1
  63. data/lib/protos/swap/off.rb +1 -1
  64. data/lib/protos/swap/on.rb +1 -1
  65. data/lib/protos/swap.rb +3 -4
  66. data/lib/protos/table/body.rb +1 -1
  67. data/lib/protos/table/caption.rb +1 -1
  68. data/lib/protos/table/cell.rb +1 -1
  69. data/lib/protos/table/footer.rb +1 -1
  70. data/lib/protos/table/head.rb +1 -1
  71. data/lib/protos/table/header.rb +1 -1
  72. data/lib/protos/table/row.rb +1 -1
  73. data/lib/protos/table.rb +1 -1
  74. data/lib/protos/tabs/tab.rb +3 -2
  75. data/lib/protos/tabs.rb +1 -1
  76. data/lib/protos/theme.rb +10 -1
  77. data/lib/protos/timeline/center.rb +1 -1
  78. data/lib/protos/timeline/item.rb +1 -1
  79. data/lib/protos/timeline/left.rb +1 -1
  80. data/lib/protos/timeline/right.rb +1 -1
  81. data/lib/protos/timeline.rb +1 -1
  82. data/lib/protos/toast/close_button.rb +1 -1
  83. data/lib/protos/toast.rb +1 -1
  84. data/lib/protos/token_list.rb +1 -17
  85. data/lib/protos/typography/heading.rb +1 -1
  86. data/lib/protos/typography/inline_link.rb +1 -1
  87. data/lib/protos/typography/paragraph.rb +1 -1
  88. data/lib/protos/version.rb +1 -1
  89. data/protos.gemspec +1 -1
  90. metadata +4 -4
@@ -7,7 +7,7 @@ module Protos
7
7
  # Protos::Popover::Content component as the main functionality for
8
8
  # dropdowns comes from there.
9
9
 
10
- def template(&block)
10
+ def view_template(&block)
11
11
  template_tag(**template_attrs) do
12
12
  ul(**attrs, &block)
13
13
  end
@@ -6,7 +6,7 @@ module Protos
6
6
  # DOCS: The content of a hero. This would be centered within the main
7
7
  # component container.
8
8
 
9
- def template(&block)
9
+ def view_template(&block)
10
10
  div(**attrs, &block)
11
11
  end
12
12
 
@@ -7,7 +7,7 @@ module Protos
7
7
  # their opacity through the opacity of the overlay. This can be useful to
8
8
  # make text readable on noisy images.
9
9
 
10
- def template(&block)
10
+ def view_template(&block)
11
11
  div(**attrs, &block)
12
12
  end
13
13
 
data/lib/protos/hero.rb CHANGED
@@ -6,7 +6,7 @@ module Protos
6
6
  # optionally layout an image for a responsive layout.
7
7
  # https://daisyui.com/components/hero/
8
8
 
9
- def template(&block)
9
+ def view_template(&block)
10
10
  div(**attrs, &block)
11
11
  end
12
12
 
@@ -7,7 +7,7 @@ module Protos
7
7
  # work for list items, including border radius. E.g. only the first and
8
8
  # last items will have border radius on the top and bottom.
9
9
 
10
- def template(&block)
10
+ def view_template(&block)
11
11
  li(**attrs, &block)
12
12
  end
13
13
 
data/lib/protos/list.rb CHANGED
@@ -7,7 +7,7 @@ module Protos
7
7
 
8
8
  option :ordered, Types::Bool, default: -> { false }, reader: false
9
9
 
10
- def template(&block)
10
+ def view_template(&block)
11
11
  send(element, **attrs, &block)
12
12
  end
13
13
 
@@ -5,7 +5,7 @@ module Protos
5
5
  class CloseButton < Component
6
6
  # DOCS: A close button for a modal
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  form(method: :dialog, class: css[:form]) do
10
10
  button(
11
11
  **attrs,
@@ -6,7 +6,7 @@ module Protos
6
6
  # DOCS: A modal dialog. This is the place for the main content of the
7
7
  # modal that will be displayed when the trigger is clicked.
8
8
 
9
- def template(&block)
9
+ def view_template(&block)
10
10
  dialog(**attrs) do
11
11
  div(class: css[:modal], &block)
12
12
  end
@@ -5,7 +5,7 @@ module Protos
5
5
  class Trigger < Component
6
6
  # DOCS: A trigger is a button that opens a modal
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  button(**attrs, &block)
10
10
  end
11
11
 
data/lib/protos/modal.rb CHANGED
@@ -5,7 +5,7 @@ module Protos
5
5
  # DOCS: A modal component that can be triggered by a button or a link and
6
6
  # will open a fullscreen modal, usually with a close button.
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  div(**attrs, class: css[:container], &block)
10
10
  end
11
11
 
@@ -8,7 +8,7 @@ module Protos
8
8
  # This means content in here will not be available in system tests that
9
9
  # use rack_test.
10
10
 
11
- def template(&block)
11
+ def view_template(&block)
12
12
  template_tag(**template_attrs) do
13
13
  div(**attrs, &block)
14
14
  end
@@ -6,7 +6,7 @@ module Protos
6
6
  # DOCS: The trigger of a popover. This is the element that you would hover
7
7
  # or click on to show the popover.
8
8
 
9
- def template(&block)
9
+ def view_template(&block)
10
10
  div(**attrs, &block)
11
11
  end
12
12
 
@@ -80,7 +80,7 @@ module Protos
80
80
  reader: false,
81
81
  type: TriggerTypes | Types::Array.of(TriggerTypes)
82
82
 
83
- def template(&block)
83
+ def view_template(&block)
84
84
  div(**attrs, &block)
85
85
  end
86
86
 
@@ -5,7 +5,7 @@ module Protos
5
5
  class Actions < Component
6
6
  # DOCS: A container for the actions (e.g. buttons) for a group of stats
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  div(**attrs, &block)
10
10
  end
11
11
 
@@ -5,7 +5,7 @@ module Protos
5
5
  class Description < Component
6
6
  # DOCS: A description for a group of stats
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  div(**attrs, &block)
10
10
  end
11
11
 
@@ -5,7 +5,7 @@ module Protos
5
5
  class Figure < Component
6
6
  # DOCS: A figure for a single stat
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  div(**attrs, &block)
10
10
  end
11
11
 
@@ -5,7 +5,7 @@ module Protos
5
5
  class Stat < Component
6
6
  # DOCS: A single stat container
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  div(**attrs, &block)
10
10
  end
11
11
 
@@ -5,7 +5,7 @@ module Protos
5
5
  class Title < Component
6
6
  # DOCS: A title for a group of stats
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  div(**attrs, &block)
10
10
  end
11
11
 
@@ -5,7 +5,7 @@ module Protos
5
5
  class Value < Component
6
6
  # DOCS: A value for a single stat
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  div(**attrs, &block)
10
10
  end
11
11
 
data/lib/protos/stats.rb CHANGED
@@ -5,7 +5,7 @@ module Protos
5
5
  # DOCS: Stats component that contains a collection of stats
6
6
  # https://daisyui.com/components/stat/
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  div(**attrs, &block)
10
10
  end
11
11
 
@@ -5,7 +5,7 @@ module Protos
5
5
  class Off < Component
6
6
  # DOCS: The off state for a swap component. This is the default state.
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  div(**attrs, &block)
10
10
  end
11
11
 
@@ -5,7 +5,7 @@ module Protos
5
5
  class On < Component
6
6
  # DOCS: The on state for a swap component. This is the active state.
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  div(**attrs, &block)
10
10
  end
11
11
 
data/lib/protos/swap.rb CHANGED
@@ -6,9 +6,9 @@ module Protos
6
6
  # display different content.
7
7
  # https://daisyui.com/components/swap/
8
8
 
9
- def template
9
+ def view_template
10
10
  label(**attrs) do
11
- input(type: :checkbox, class: css[:input])
11
+ input(type: :checkbox, class: css[:input], autocomplete: :off)
12
12
  yield if block_given?
13
13
  end
14
14
  end
@@ -25,8 +25,7 @@ module Protos
25
25
 
26
26
  def theme
27
27
  {
28
- container: tokens("swap"),
29
- input: tokens("hidden")
28
+ container: tokens("swap")
30
29
  }
31
30
  end
32
31
  end
@@ -5,7 +5,7 @@ module Protos
5
5
  class Body < Component
6
6
  # DOCS: The body of a table
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  tbody(**attrs, &block)
10
10
  end
11
11
  end
@@ -5,7 +5,7 @@ module Protos
5
5
  class Caption < Component
6
6
  # DOCS: The caption of a table
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  caption(**attrs, &block)
10
10
  end
11
11
 
@@ -11,7 +11,7 @@ module Protos
11
11
  :left
12
12
  }
13
13
 
14
- def template(&block)
14
+ def view_template(&block)
15
15
  td(**attrs, &block)
16
16
  end
17
17
 
@@ -5,7 +5,7 @@ module Protos
5
5
  class Footer < Component
6
6
  # DOCS: The footer of a table
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  tfoot(**attrs, &block)
10
10
  end
11
11
  end
@@ -11,7 +11,7 @@ module Protos
11
11
  :left
12
12
  }
13
13
 
14
- def template(&block)
14
+ def view_template(&block)
15
15
  th(**attrs, &block)
16
16
  end
17
17
 
@@ -6,7 +6,7 @@ module Protos
6
6
  # DOCS: The header of a table that contains many Protos::Table::Head
7
7
  # components
8
8
 
9
- def template(&block)
9
+ def view_template(&block)
10
10
  thead(**attrs, &block)
11
11
  end
12
12
  end
@@ -5,7 +5,7 @@ module Protos
5
5
  class Row < Component
6
6
  # DOCS: The row of a table
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  tr(**attrs, &block)
10
10
  end
11
11
  end
data/lib/protos/table.rb CHANGED
@@ -18,7 +18,7 @@ module Protos
18
18
  :lg
19
19
  )
20
20
 
21
- def template(&block)
21
+ def view_template(&block)
22
22
  div(**attrs) do
23
23
  table(class: css[:table], &block)
24
24
  end
@@ -10,13 +10,14 @@ module Protos
10
10
  option :active, default: -> { false }
11
11
  option :disabled, default: -> { false }
12
12
 
13
- def template(&block)
13
+ def view_template(&block)
14
14
  input(
15
15
  type: :radio,
16
16
  class: css[:input],
17
17
  name: id,
18
18
  role: :tab,
19
- aria_label: label
19
+ aria_label: label,
20
+ autocomplete: :off
20
21
  )
21
22
  div(**attrs, &block)
22
23
  end
data/lib/protos/tabs.rb CHANGED
@@ -24,7 +24,7 @@ module Protos
24
24
  :lg
25
25
  )
26
26
 
27
- def template(&block)
27
+ def view_template(&block)
28
28
  div(**attrs, &block)
29
29
  end
30
30
 
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)
@@ -6,7 +6,7 @@ module Protos
6
6
  # DOCS: The center of a timeline. This would usually be an icon or
7
7
  # something small that shows a point on the timeline.
8
8
 
9
- def template(&block)
9
+ def view_template(&block)
10
10
  div(**attrs, &block)
11
11
  end
12
12
 
@@ -7,7 +7,7 @@ module Protos
7
7
  # right and depending on its position in the list, an hr at the beginning
8
8
  # or end.
9
9
 
10
- def template(&block)
10
+ def view_template(&block)
11
11
  li(**attrs, &block)
12
12
  end
13
13
  end
@@ -6,7 +6,7 @@ module Protos
6
6
  # DOCS: Content on the left (on daisyui "start") side of a timeline.
7
7
  # We chose not to use start/end because of the keywork conflict with ruby.
8
8
 
9
- def template(&block)
9
+ def view_template(&block)
10
10
  div(**attrs, &block)
11
11
  end
12
12
 
@@ -6,7 +6,7 @@ module Protos
6
6
  # DOCS: Content on the right (on daisyui "end") side of a timeline.
7
7
  # We chose not to use start/end because of the keywork conflict with ruby.
8
8
 
9
- def template(&block)
9
+ def view_template(&block)
10
10
  div(**attrs, &block)
11
11
  end
12
12
 
@@ -7,7 +7,7 @@ module Protos
7
7
 
8
8
  option :vertical, type: Types::Bool, default: -> { false }
9
9
 
10
- def template(&block)
10
+ def view_template(&block)
11
11
  ul(**attrs, &block)
12
12
  end
13
13
 
@@ -5,7 +5,7 @@ module Protos
5
5
  class CloseButton < Component
6
6
  # DOCS: A close button for a toast
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  form(method: :dialog, class: css[:form]) do
10
10
  button(
11
11
  autofocus: true,
data/lib/protos/toast.rb CHANGED
@@ -23,7 +23,7 @@ module Protos
23
23
  default: -> { :bottom_end },
24
24
  reader: false
25
25
 
26
- def template(&block)
26
+ def view_template(&block)
27
27
  dialog(**attrs, &block)
28
28
  end
29
29
 
@@ -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
@@ -12,7 +12,7 @@ module Protos
12
12
  option :size, type: SizeTypes, default: -> { "md" }, reader: false
13
13
  option :level, type: LevelTypes, default: -> { 1 }, reader: false
14
14
 
15
- def template(&block)
15
+ def view_template(&block)
16
16
  send(element, **attrs, &block)
17
17
  end
18
18
 
@@ -5,7 +5,7 @@ module Protos
5
5
  class InlineLink < Component
6
6
  # DOCS: A link that is styled to be inline with text
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  a(**attrs, &block)
10
10
  end
11
11
 
@@ -5,7 +5,7 @@ module Protos
5
5
  class Paragraph < Component
6
6
  # DOCS: A paragraph of text
7
7
 
8
- def template(&block)
8
+ def view_template(&block)
9
9
  p(**attrs, &block)
10
10
  end
11
11
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Protos
4
- VERSION = "0.2.2"
4
+ VERSION = "0.3.0"
5
5
  end
data/protos.gemspec CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency "dry-core", "~> 1.0"
38
38
  spec.add_dependency "dry-initializer", "~> 3.1"
39
39
  spec.add_dependency "dry-types", "~> 1.7"
40
- spec.add_dependency "phlex", "~> 1.9"
40
+ spec.add_dependency "phlex", "~> 1.10"
41
41
  spec.add_dependency "tailwind_merge", "~> 0.10"
42
42
 
43
43
  # For more information and examples about making a new gem, check out our
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.3.0
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-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-core
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.9'
61
+ version: '1.10'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.9'
68
+ version: '1.10'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: tailwind_merge
71
71
  requirement: !ruby/object:Gem::Requirement