protos 0.2.0 → 0.2.2

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.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +262 -70
  3. data/examples/list.rb +34 -0
  4. data/lib/protos/accordion/item.rb +6 -4
  5. data/lib/protos/accordion.rb +5 -0
  6. data/lib/protos/alert/actions.rb +2 -0
  7. data/lib/protos/alert/icon.rb +3 -0
  8. data/lib/protos/alert.rb +4 -0
  9. data/lib/protos/attributes.rb +8 -0
  10. data/lib/protos/avatar.rb +3 -0
  11. data/lib/protos/breadcrumbs/crumb.rb +2 -0
  12. data/lib/protos/breadcrumbs.rb +3 -0
  13. data/lib/protos/card/actions.rb +2 -0
  14. data/lib/protos/card/body.rb +2 -0
  15. data/lib/protos/card/image.rb +4 -0
  16. data/lib/protos/card/title.rb +2 -0
  17. data/lib/protos/card.rb +3 -0
  18. data/lib/protos/carousel/actions.rb +2 -0
  19. data/lib/protos/carousel/item.rb +2 -0
  20. data/lib/protos/carousel.rb +4 -0
  21. data/lib/protos/chat_bubble/content.rb +3 -0
  22. data/lib/protos/chat_bubble/footer.rb +2 -0
  23. data/lib/protos/chat_bubble/header.rb +3 -0
  24. data/lib/protos/chat_bubble/image.rb +3 -0
  25. data/lib/protos/chat_bubble.rb +5 -0
  26. data/lib/protos/collapse/content.rb +3 -0
  27. data/lib/protos/collapse/title.rb +3 -0
  28. data/lib/protos/collapse.rb +4 -0
  29. data/lib/protos/combobox.rb +5 -1
  30. data/lib/protos/command/dialog.rb +9 -1
  31. data/lib/protos/command/empty.rb +3 -0
  32. data/lib/protos/command/group.rb +4 -0
  33. data/lib/protos/command/input.rb +2 -0
  34. data/lib/protos/command/item.rb +2 -0
  35. data/lib/protos/command/list.rb +8 -0
  36. data/lib/protos/command/title.rb +3 -0
  37. data/lib/protos/command/trigger.rb +2 -0
  38. data/lib/protos/command.rb +5 -1
  39. data/lib/protos/component.rb +21 -9
  40. data/lib/protos/drawer/content.rb +3 -0
  41. data/lib/protos/drawer/side.rb +8 -1
  42. data/lib/protos/drawer/trigger.rb +3 -0
  43. data/lib/protos/drawer.rb +6 -1
  44. data/lib/protos/dropdown/item.rb +2 -0
  45. data/lib/protos/dropdown/menu.rb +4 -0
  46. data/lib/protos/dropdown/trigger.rb +2 -0
  47. data/lib/protos/dropdown.rb +8 -0
  48. data/lib/protos/engine.rb +3 -0
  49. data/lib/protos/hero/content.rb +3 -0
  50. data/lib/protos/hero/overlay.rb +4 -0
  51. data/lib/protos/hero.rb +4 -0
  52. data/lib/protos/list/item.rb +4 -0
  53. data/lib/protos/list.rb +3 -0
  54. data/lib/protos/modal/close_button.rb +2 -0
  55. data/lib/protos/modal/dialog.rb +9 -1
  56. data/lib/protos/modal/trigger.rb +2 -0
  57. data/lib/protos/modal.rb +3 -0
  58. data/lib/protos/popover/content.rb +5 -0
  59. data/lib/protos/popover/trigger.rb +3 -0
  60. data/lib/protos/popover.rb +8 -1
  61. data/lib/protos/stats/actions.rb +2 -0
  62. data/lib/protos/stats/description.rb +2 -0
  63. data/lib/protos/stats/figure.rb +2 -0
  64. data/lib/protos/stats/stat.rb +2 -0
  65. data/lib/protos/stats/title.rb +2 -0
  66. data/lib/protos/stats/value.rb +2 -0
  67. data/lib/protos/stats.rb +3 -0
  68. data/lib/protos/swap/off.rb +2 -0
  69. data/lib/protos/swap/on.rb +2 -0
  70. data/lib/protos/swap.rb +7 -2
  71. data/lib/protos/table/body.rb +2 -0
  72. data/lib/protos/table/caption.rb +2 -0
  73. data/lib/protos/table/cell.rb +2 -0
  74. data/lib/protos/table/footer.rb +2 -0
  75. data/lib/protos/table/head.rb +2 -0
  76. data/lib/protos/table/header.rb +3 -0
  77. data/lib/protos/table/row.rb +2 -0
  78. data/lib/protos/table.rb +32 -1
  79. data/lib/protos/tabs/tab.rb +2 -0
  80. data/lib/protos/tabs.rb +3 -0
  81. data/lib/protos/theme.rb +5 -0
  82. data/lib/protos/timeline/center.rb +3 -0
  83. data/lib/protos/timeline/item.rb +4 -0
  84. data/lib/protos/timeline/left.rb +3 -0
  85. data/lib/protos/timeline/right.rb +3 -0
  86. data/lib/protos/timeline.rb +3 -0
  87. data/lib/protos/toast/close_button.rb +2 -0
  88. data/lib/protos/toast.rb +32 -8
  89. data/lib/protos/token_list.rb +7 -1
  90. data/lib/protos/typography/heading.rb +3 -0
  91. data/lib/protos/typography/inline_link.rb +2 -0
  92. data/lib/protos/typography/paragraph.rb +2 -0
  93. data/lib/protos/typography.rb +3 -0
  94. data/lib/protos/version.rb +1 -1
  95. metadata +3 -2
data/lib/protos/swap.rb CHANGED
@@ -2,9 +2,13 @@
2
2
 
3
3
  module Protos
4
4
  class Swap < Component
5
+ # DOCS: The swap component is a checkbox that can be toggled on and off to
6
+ # display different content.
7
+ # https://daisyui.com/components/swap/
8
+
5
9
  def template
6
10
  label(**attrs) do
7
- input(type: :checkbox)
11
+ input(type: :checkbox, class: css[:input])
8
12
  yield if block_given?
9
13
  end
10
14
  end
@@ -21,7 +25,8 @@ module Protos
21
25
 
22
26
  def theme
23
27
  {
24
- container: tokens("swap")
28
+ container: tokens("swap"),
29
+ input: tokens("hidden")
25
30
  }
26
31
  end
27
32
  end
@@ -3,6 +3,8 @@
3
3
  module Protos
4
4
  class Table
5
5
  class Body < Component
6
+ # DOCS: The body of a table
7
+
6
8
  def template(&block)
7
9
  tbody(**attrs, &block)
8
10
  end
@@ -3,6 +3,8 @@
3
3
  module Protos
4
4
  class Table
5
5
  class Caption < Component
6
+ # DOCS: The caption of a table
7
+
6
8
  def template(&block)
7
9
  caption(**attrs, &block)
8
10
  end
@@ -3,6 +3,8 @@
3
3
  module Protos
4
4
  class Table
5
5
  class Cell < Component
6
+ # DOCS: A single cell in a table
7
+
6
8
  option :align,
7
9
  type: Types::Coercible::Symbol.enum(:left, :center, :right),
8
10
  default: -> {
@@ -3,6 +3,8 @@
3
3
  module Protos
4
4
  class Table
5
5
  class Footer < Component
6
+ # DOCS: The footer of a table
7
+
6
8
  def template(&block)
7
9
  tfoot(**attrs, &block)
8
10
  end
@@ -3,6 +3,8 @@
3
3
  module Protos
4
4
  class Table
5
5
  class Head < Component
6
+ # DOCS: The head of a table
7
+
6
8
  option :align,
7
9
  type: Types::Coercible::Symbol.enum(:left, :center, :right),
8
10
  default: -> {
@@ -3,6 +3,9 @@
3
3
  module Protos
4
4
  class Table
5
5
  class Header < Component
6
+ # DOCS: The header of a table that contains many Protos::Table::Head
7
+ # components
8
+
6
9
  def template(&block)
7
10
  thead(**attrs, &block)
8
11
  end
@@ -3,6 +3,8 @@
3
3
  module Protos
4
4
  class Table
5
5
  class Row < Component
6
+ # DOCS: The row of a table
7
+
6
8
  def template(&block)
7
9
  tr(**attrs, &block)
8
10
  end
data/lib/protos/table.rb CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  module Protos
4
4
  class Table < Component
5
+ # DOCS: A table component
6
+ # https://daisyui.com/components/table/
7
+
8
+ option :pin_rows, default: -> { false }, type: Types::Bool
9
+ option :pin_columns, default: -> { false }, type: Types::Bool
10
+ option :striped, default: -> { false }, type: Types::Bool
11
+ option :size,
12
+ default: -> { :md },
13
+ reader: false,
14
+ type: Types::Coercible::Symbol.enum(
15
+ :xs,
16
+ :sm,
17
+ :md,
18
+ :lg
19
+ )
20
+
5
21
  def template(&block)
6
22
  div(**attrs) do
7
23
  table(class: css[:table], &block)
@@ -38,10 +54,25 @@ module Protos
38
54
 
39
55
  private
40
56
 
57
+ def size
58
+ {
59
+ xs: "table-xs",
60
+ sm: "table-sm",
61
+ md: "table-md",
62
+ lg: "table-lg"
63
+ }.fetch(@size)
64
+ end
65
+
41
66
  def theme
42
67
  {
43
68
  container: tokens("w-full", "overflow-x-auto"),
44
- table: tokens("table")
69
+ table: tokens(
70
+ "table",
71
+ size,
72
+ pin_rows: "table-pin-rows",
73
+ pin_columns: "table-pin-columns",
74
+ striped: "table-striped"
75
+ )
45
76
  }
46
77
  end
47
78
  end
@@ -3,6 +3,8 @@
3
3
  module Protos
4
4
  class Tabs
5
5
  class Tab < Component
6
+ # DOCS: A single tab in a tabs component
7
+
6
8
  param :id
7
9
  option :label
8
10
  option :active, default: -> { false }
data/lib/protos/tabs.rb CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  module Protos
4
4
  class Tabs < Component
5
+ # DOCS: A component that contains many Protos::Tab components
6
+ # https://daisyui.com/components/tab/
7
+
5
8
  option :type,
6
9
  default: -> { :default },
7
10
  reader: false,
data/lib/protos/theme.rb CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  module Protos
4
4
  class Theme
5
+ # DOCS: A class that holds data for a theme. This class is used to safely
6
+ # merge in user supplied css classes into a default theme.
7
+ # This is the object that is returned by `css` and used to set slots for
8
+ # a component style.
9
+
5
10
  def initialize(theme = {}, **kwargs)
6
11
  @theme = theme.merge(kwargs)
7
12
  end
@@ -3,6 +3,9 @@
3
3
  module Protos
4
4
  class Timeline
5
5
  class Center < Component
6
+ # DOCS: The center of a timeline. This would usually be an icon or
7
+ # something small that shows a point on the timeline.
8
+
6
9
  def template(&block)
7
10
  div(**attrs, &block)
8
11
  end
@@ -3,6 +3,10 @@
3
3
  module Protos
4
4
  class Timeline
5
5
  class Item < Component
6
+ # DOCS: The item of a timeline. Usually containing a center, left and
7
+ # right and depending on its position in the list, an hr at the beginning
8
+ # or end.
9
+
6
10
  def template(&block)
7
11
  li(**attrs, &block)
8
12
  end
@@ -3,6 +3,9 @@
3
3
  module Protos
4
4
  class Timeline
5
5
  class Left < Component
6
+ # DOCS: Content on the left (on daisyui "start") side of a timeline.
7
+ # We chose not to use start/end because of the keywork conflict with ruby.
8
+
6
9
  def template(&block)
7
10
  div(**attrs, &block)
8
11
  end
@@ -3,6 +3,9 @@
3
3
  module Protos
4
4
  class Timeline
5
5
  class Right < Component
6
+ # DOCS: Content on the right (on daisyui "end") side of a timeline.
7
+ # We chose not to use start/end because of the keywork conflict with ruby.
8
+
6
9
  def template(&block)
7
10
  div(**attrs, &block)
8
11
  end
@@ -2,6 +2,9 @@
2
2
 
3
3
  module Protos
4
4
  class Timeline < Component
5
+ # DOCS: A timeline component
6
+ # https://daisyui.com/components/timeline/
7
+
5
8
  option :vertical, type: Types::Bool, default: -> { false }
6
9
 
7
10
  def template(&block)
@@ -3,6 +3,8 @@
3
3
  module Protos
4
4
  class Toast
5
5
  class CloseButton < Component
6
+ # DOCS: A close button for a toast
7
+
6
8
  def template(&block)
7
9
  form(method: :dialog, class: css[:form]) do
8
10
  button(
data/lib/protos/toast.rb CHANGED
@@ -2,16 +2,26 @@
2
2
 
3
3
  module Protos
4
4
  class Toast < Component
5
+ # DOCS: A toast component that can be used to display messages to the user
6
+ # that popup at a fixed position on the screen.
7
+ # https://daisyui.com/components/toast/
8
+
5
9
  Positions = Types::Symbol.enum(
6
- :start,
7
- :center,
8
- :end,
9
- :top,
10
- :middle,
11
- :bottom
10
+ :top_start,
11
+ :top_center,
12
+ :top_end,
13
+ :middle_start,
14
+ :middle_center,
15
+ :middle_end,
16
+ :bottom_start,
17
+ :bottom_center,
18
+ :bottom_end
12
19
  )
13
20
 
14
- option :position, type: Positions, default: -> { :end }
21
+ option :position,
22
+ type: Positions,
23
+ default: -> { :bottom_end },
24
+ reader: false
15
25
 
16
26
  def template(&block)
17
27
  dialog(**attrs, &block)
@@ -29,11 +39,25 @@ module Protos
29
39
  }
30
40
  end
31
41
 
42
+ def position
43
+ {
44
+ top_start: "toast-start toast-top",
45
+ top_center: "toast-center toast-top",
46
+ top_end: "toast-end toast-top",
47
+ middle_start: "toast-start toast-middle",
48
+ middle_center: "toast-center toast-middle",
49
+ middle_end: "toast-end toast-middle",
50
+ bottom_start: "toast-start toast-bottom",
51
+ bottom_center: "toast-center toast-bottom",
52
+ bottom_end: "toast-end toast-bottom"
53
+ }.fetch(@position)
54
+ end
55
+
32
56
  def theme
33
57
  {
34
58
  container: tokens(
35
59
  "toast",
36
- "toast-end",
60
+ position,
37
61
  "[&:not([open])]:hidden",
38
62
  "bg-transparent"
39
63
  )
@@ -2,12 +2,18 @@
2
2
 
3
3
  module Protos
4
4
  class TokenList
5
+ # DOCS: A list of utility tokens that can handle parsing and merging sets of
6
+ # tokens together safely. It uses TailwindMerge to merge the tokens together
7
+ # while accounting for their conflicts.
8
+
5
9
  def self.parse(input)
6
10
  case input
7
11
  when String then new(input.split)
8
12
  when Array then new(input)
9
13
  when TokenList then input
10
- else raise ArgumentError, "Invalid input: #{input.inspect}"
14
+ when NilClass then new
15
+ else raise ArgumentError,
16
+ "Invalid input for #{self.class.name}: #{input.inspect}"
11
17
  end
12
18
  end
13
19
 
@@ -3,6 +3,9 @@
3
3
  module Protos
4
4
  module Typography
5
5
  class Heading < Protos::Component
6
+ # DOCS: A heading component that encapsulates all heading levels by their
7
+ # size and level.
8
+
6
9
  SizeTypes = Types::Coercible::Symbol.enum(:xs, :sm, :md, :lg, :xl)
7
10
  LevelTypes = Types::Integer.enum(1, 2, 3, 4, 5, 6)
8
11
 
@@ -3,6 +3,8 @@
3
3
  module Protos
4
4
  module Typography
5
5
  class InlineLink < Component
6
+ # DOCS: A link that is styled to be inline with text
7
+
6
8
  def template(&block)
7
9
  a(**attrs, &block)
8
10
  end
@@ -3,6 +3,8 @@
3
3
  module Protos
4
4
  module Typography
5
5
  class Paragraph < Component
6
+ # DOCS: A paragraph of text
7
+
6
8
  def template(&block)
7
9
  p(**attrs, &block)
8
10
  end
@@ -2,6 +2,9 @@
2
2
 
3
3
  module Protos
4
4
  module Typography
5
+ # DOCS: The core typography module that can be mixedin to override the
6
+ # default elements with custom elements.
7
+
5
8
  def h1(**options, &block)
6
9
  render(Heading.new(level: 1, size: :xl, **options), &block)
7
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Protos
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.2"
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.0
4
+ version: 0.2.2
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-07 00:00:00.000000000 Z
11
+ date: 2024-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-core
@@ -93,6 +93,7 @@ files:
93
93
  - LICENSE.txt
94
94
  - README.md
95
95
  - Rakefile
96
+ - examples/list.rb
96
97
  - examples/navbar.rb
97
98
  - lib/protos.rb
98
99
  - lib/protos/accordion.rb