protos 0.6.0 → 1.0.0

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -1
  3. data/README.md +62 -81
  4. data/examples/list.rb +2 -2
  5. data/examples/navbar.rb +3 -8
  6. data/lib/protos/accordion/item.rb +4 -2
  7. data/lib/protos/accordion.rb +10 -11
  8. data/lib/protos/alert.rb +4 -4
  9. data/lib/protos/avatar.rb +12 -20
  10. data/lib/protos/badge.rb +58 -0
  11. data/lib/protos/breadcrumbs.rb +2 -0
  12. data/lib/protos/card.rb +37 -19
  13. data/lib/protos/carousel.rb +15 -10
  14. data/lib/protos/chat_bubble/content.rb +9 -17
  15. data/lib/protos/chat_bubble.rb +13 -6
  16. data/lib/protos/collapse/title.rb +3 -3
  17. data/lib/protos/collapse.rb +32 -11
  18. data/lib/protos/combobox.rb +3 -3
  19. data/lib/protos/command/input.rb +4 -4
  20. data/lib/protos/command.rb +16 -2
  21. data/lib/protos/component.rb +12 -36
  22. data/lib/protos/diff/item.rb +34 -0
  23. data/lib/protos/diff/resizer.rb +19 -0
  24. data/lib/protos/diff.rb +30 -0
  25. data/lib/protos/drawer.rb +7 -3
  26. data/lib/protos/dropdown/menu.rb +2 -5
  27. data/lib/protos/dropdown.rb +10 -6
  28. data/lib/protos/hero.rb +3 -0
  29. data/lib/protos/list/item.rb +7 -3
  30. data/lib/protos/list.rb +3 -1
  31. data/lib/protos/menu/item.rb +23 -0
  32. data/lib/protos/menu.rb +56 -0
  33. data/lib/protos/mix.rb +3 -5
  34. data/lib/protos/modal/close_button.rb +8 -0
  35. data/lib/protos/modal/dialog.rb +4 -6
  36. data/lib/protos/modal.rb +6 -1
  37. data/lib/protos/popover/content.rb +1 -1
  38. data/lib/protos/popover.rb +24 -21
  39. data/lib/protos/stats.rb +7 -0
  40. data/lib/protos/status.rb +46 -0
  41. data/lib/protos/steps/step.rb +1 -12
  42. data/lib/protos/steps.rb +5 -3
  43. data/lib/protos/swap.rb +3 -0
  44. data/lib/protos/table/caption.rb +5 -3
  45. data/lib/protos/table/cell.rb +3 -3
  46. data/lib/protos/table/head.rb +3 -3
  47. data/lib/protos/table.rb +23 -13
  48. data/lib/protos/tabs/tab.rb +4 -4
  49. data/lib/protos/tabs.rb +30 -22
  50. data/lib/protos/tailwind_merge.rb +65 -0
  51. data/lib/protos/theme.rb +32 -30
  52. data/lib/protos/timeline.rb +8 -3
  53. data/lib/protos/toast.rb +5 -3
  54. data/lib/protos/types.rb +11 -0
  55. data/lib/protos/typography/paragraph.rb +3 -3
  56. data/lib/protos/typography.rb +4 -0
  57. data/lib/protos/version.rb +1 -1
  58. data/lib/protos.rb +41 -121
  59. data/protos.gemspec +4 -5
  60. metadata +19 -29
  61. data/lib/protos/command/dialog.rb +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0796561a80e75fb39f8b35ec75257104adc90b21227ef1525876576d10415269'
4
- data.tar.gz: 394a8ee190d1d2647476db45d2d9b9edb156bc42a3935898d6f1deca35261326
3
+ metadata.gz: 660af240890f0f3089840c5e672be261d68e37a3c027483e62a12c37420df46a
4
+ data.tar.gz: 83b4736dcb8a891f65782bbab576442dbba9a787100a3ed2e7e3c8488e2f9c85
5
5
  SHA512:
6
- metadata.gz: 59e2288d2ae8adfc3b352838dda25c776edddf48d99b310181629e78f09831552be23e36adedaca7bf3601678cb08950500f4b72f2ed609324ccd72ddd32a92d
7
- data.tar.gz: e0e4beda7e4cbff4e3b669899b65df2ec7c37fe388e75b561418ce1cc65abd4cb1cfecabd743f964bf0dee98de1c4ccdbf9f7e76f77078f294a8bfb0a4272802
6
+ metadata.gz: b07d86baa8de3458eb2a5c337335d8a0569f9eff4196f886d9cdcce604bd7d56ce59c4e6c59de85c361e438c64db5fece61f4a67a532d4f03599e47f200802f0
7
+ data.tar.gz: a9db0f4770430e2a9191c0075d69b3fd66e7b42b75300c4ef2d129cde5f9e8b0cc5e034be2fad031070c6a1b1e9f99fc01893d257eb7ca5e68ff748db1ee4f9c
data/CHANGELOG.md CHANGED
@@ -1,12 +1,41 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.0.0] - 2025-03-01
4
+
5
+ - Adds `Protos::Status` component
6
+ - Adds `Protos::Diff` component
7
+ - Adds `Protos::Menu` component
8
+ - Adds `state` and `icon` options to `Protos::Collapse`
9
+ - Changes `dash` option to `dashed` on `Protos::Card`
10
+ - Adds `dashed` and `soft` to `Protos::Badge`
11
+ - Adds `xl` size to `Protos::Badge`
12
+ - Updates to Phlex `v2`
13
+ - Updates to new DaisyUI `v5.0` styles
14
+ - Performance improvements to `Protos::Theme`
15
+ - Removes redefining `default_attrs` and `theme` methods. Didn't want the
16
+ overhead of this completely unused feature. This removes `dry-core` as
17
+ a dependency
18
+
19
+ ## [0.7.0] - 2025-01-13
20
+
21
+ - Changes passing an `input_id` to accordions. Replaced with the more accurate
22
+ `input_name` (optional) parameter. There was no point in having different
23
+ name attributes for the different radio buttons
24
+ - Updates modal component to use newer modal controller from protos-stimulus
25
+ that uses `@stimulus-components/dialog`
26
+ - Adds the ability for `css` helper to take multiple values, including inline
27
+ values instead of theme keys.
28
+ - Adds new `Protos::Badge` component
29
+ - Removes deprecated tokens to prepare for phlex 2.0
30
+ - Removes `dry-initializer` undefined constant to improve performance
31
+ - Adds autoloading constants instead of hard requires
32
+
3
33
  ## [0.6.0] - 2024-09-04
4
34
 
5
35
  - Changes how merging attributes works to only mix on certain attributes,
6
36
  overriding on all others. This is opposite to how attributes used to be merged
7
37
  by default. This is a fix for attributes like `value` where you actually need
8
38
  to override them.
9
- - Adds tests for all Rails components
10
39
  - Adds a separate tested `Mix` class for handling attribute merging
11
40
 
12
41
  ## [0.5.0] - 2024-08-27
data/README.md CHANGED
@@ -11,14 +11,12 @@ You can see a full list of the components at
11
11
  [tailwind\_merge](https://github.com/gjtorikian/tailwind_merge).
12
12
  - Uses [tippy.js](https://atomiks.github.io/tippyjs/v6/getting-started/) for
13
13
  dropdowns, combobox, and popovers
14
- - All components avoid using
15
- [`Phlex::DeferredRender`](https://www.phlex.fun/#slots)
16
- so you can reorder components exactly how you like them.
17
14
 
18
15
  Other Phlex based UI libraries worth checking out:
19
16
 
20
17
  - [PhlexUI](https://phlexui.com/)
21
18
  - [ZestUI](https://zestui.com/)
19
+ - [Nitro Kit](https://github.com/mikker/nitro_kit)
22
20
 
23
21
  Thinking of making your next static site using Phlex? Check out
24
22
  [staticky](https://github.com/nolantait/staticky). The protos docs were
@@ -88,9 +86,10 @@ class Navbar
88
86
  end
89
87
  ```
90
88
 
91
- Eventually everyone makes a kind of ad-hoc system for specifying styles. It gets
92
- more complicated when you have attributes like a data-controller. How do you
93
- give a good experience letting people using your components to add their own
89
+ Eventually everyone makes a kind of ad-hoc system for specifying styles.
90
+
91
+ It gets more complicated when you have attributes like a data-controller. How do
92
+ you give a good experience letting people using your components to add their own
94
93
  controllers while your component depends on one already?
95
94
 
96
95
  This library is an attempt to make this kind of developer experience while
@@ -136,7 +135,7 @@ class List < Protos::Component
136
135
 
137
136
  def theme
138
137
  {
139
- list: "space-y-4", # We can use `#tokens` from phlex (recommended)
138
+ list: ["space-y-4"], # We can use arrays
140
139
  item: "font-bold text-2xl" # Or just plain old strings
141
140
  }
142
141
  end
@@ -205,26 +204,18 @@ The new `css[:item]` slot would be:
205
204
  <li class="font-bold">Item 1</li>
206
205
  ```
207
206
 
208
- If you want to change the method we define our default theme under you can
209
- override the `theme_method` on the class:
207
+ Slots can also take multiple arguments, and even inline styles:
210
208
 
211
209
  ```ruby
212
- class List < Protos::Component
213
- theme_method :custom_theme
214
-
215
- # ...
216
-
217
- private
218
-
219
- def custom_theme
220
- {
221
- list: tokens("space-y-4"),
222
- item: tokens("font-bold", "text-2xl")
223
- }
210
+ class ListItem < Protos::Component
211
+ def view_template
212
+ li(class: css[:item, :primary_item, "text-sm"])
224
213
  end
225
214
  end
226
215
  ```
227
216
 
217
+ This combines the styles together, removing any duplicates.
218
+
228
219
  ### Attrs and default attrs
229
220
 
230
221
  By convention, all components spread in an `attrs` hash on their outermost
@@ -257,8 +248,8 @@ class List < Protos::Component
257
248
 
258
249
  def theme
259
250
  {
260
- container: tokens("space-y-4"),
261
- item: tokens("font-bold")
251
+ container: "space-y-4",
252
+ item: "font-bold"
262
253
  }
263
254
  end
264
255
  end
@@ -289,23 +280,6 @@ That would output both controllers to the DOM element:
289
280
  This makes it very convenient to add functionality to basic components without
290
281
  overriding their core behavior or having to modify/override their class.
291
282
 
292
- If we wanted to, just like for our theme we can change the method from
293
- `default_attrs` by defining the `default_attrs_method` on the class:
294
-
295
- ```ruby
296
- class List < Protos::Component
297
- default_attrs_method :custom_attrs
298
-
299
- private
300
-
301
- def custom_attrs
302
- {
303
- data: { controller: "list" }
304
- }
305
- end
306
- end
307
- ```
308
-
309
283
  ### Params and options
310
284
 
311
285
  Components extend
@@ -488,7 +462,7 @@ module Components
488
462
 
489
463
  def theme
490
464
  super.merge({
491
- input: tokens("block", "bg-red-500")
465
+ input: ["block", "bg-red-500"]
492
466
  })
493
467
  end
494
468
  end
@@ -510,16 +484,24 @@ module Components
510
484
  end
511
485
  ```
512
486
 
513
- You could use `Proto::List` to create your own list and even use
514
- `Phlex::DeferredRender` to make the API more convenient.
487
+ You could use `Proto::List` to create your own list and even use some kind of
488
+ [`DeferredRender`](https://www.phlex.fun/miscellaneous/v2-upgrade.html#removed-deferredrender)
489
+ to make the API more convenient.
515
490
 
516
491
  Let's create a list component with headers and actions:
517
492
 
518
493
  ```ruby
494
+ module DeferredRender
495
+ def before_template(&)
496
+ vanish(&)
497
+ super
498
+ end
499
+ end
500
+
519
501
  module Ui
520
502
  class List < Protos::Component
521
503
  include Protos::Typography
522
- include Phlex::DeferredRender
504
+ include DeferredRender
523
505
 
524
506
  option :title, default: -> {}
525
507
  option :ordered, default: -> { false }
@@ -561,11 +543,11 @@ module Ui
561
543
 
562
544
  def theme
563
545
  {
564
- container: tokens("space-y-xs"),
565
- header: tokens("flex", "justify-between", "items-end", "gap-sm"),
566
- list: tokens("divide-y", "border", "w-full"),
567
- actions: tokens("space-x-xs"),
568
- item: tokens("p-sm")
546
+ container: "space-y-xs",
547
+ header: "flex justify-between items-end gap-sm",
548
+ list: "divide-y border w-full",
549
+ actions: "space-x-xs",
550
+ item: "p-sm"
569
551
  }
570
552
  end
571
553
  end
@@ -590,8 +572,7 @@ Or here is another example of a table:
590
572
  module Ui
591
573
  class Table < ApplicationComponent
592
574
  include Protos::Typography
593
- include Phlex::DeferredRender
594
- include Actionable
575
+ include DeferredRender
595
576
 
596
577
  class Column
597
578
  attr_reader :title
@@ -609,6 +590,7 @@ module Ui
609
590
  option :title, default: -> {}
610
591
  option :collection, default: -> { [] }, reader: false
611
592
  option :columns, default: -> { [] }, reader: false
593
+ option :actions, default: -> { [] }, reader: false
612
594
 
613
595
  def template
614
596
  article(**attrs) do
@@ -676,10 +658,10 @@ module Ui
676
658
 
677
659
  def theme
678
660
  {
679
- container: tokens("space-y-sm"),
680
- header: tokens("flex", "justify-between", "items-end", "gap-sm"),
681
- table: tokens("border"),
682
- caption: tokens("text-muted")
661
+ container: "space-y-sm",
662
+ header: "flex justify-between items-end gap-sm",
663
+ table: "border",
664
+ caption: "text-muted"
683
665
  }
684
666
  end
685
667
  end
@@ -714,32 +696,31 @@ render Ui::Table.new(title: "A table", collection:) do |table|
714
696
  end
715
697
  ```
716
698
 
717
- ## No unnecessary components
718
-
719
- This library avoids re-making Protos components for extremely simple daisyui
720
- components such as:
721
-
722
- - Badge
723
- - Buttons
724
- - Checkbox
725
- - File input
726
- - Indicator
727
- - Join
728
- - Kbd
729
- - Link
730
- - Loading
731
- - Mask
732
- - Progress
733
- - Radial progress
734
- - Radio
735
- - Range
736
- - Select
737
- - Skeleton
738
- - Stack
739
- - Text input
740
- - Textarea
741
- - Toggle
742
- - Tooltip
699
+ ## Missing components
700
+
701
+ Here is a list that we don't yet have components for:
702
+
703
+ - [] Buttons
704
+ - [] Calendar
705
+ - [] Checkbox
706
+ - [] File input
707
+ - [] Indicator
708
+ - [] Join
709
+ - [] Kbd
710
+ - [] Link
711
+ - [] Loading
712
+ - [] Mask
713
+ - [] Progress
714
+ - [] Radial progress
715
+ - [] Radio
716
+ - [] Range
717
+ - [] Select
718
+ - [] Skeleton
719
+ - [] Stack
720
+ - [] Text input
721
+ - [] Textarea
722
+ - [] Toggle
723
+ - [] Tooltip
743
724
 
744
725
  ## Development
745
726
 
data/examples/list.rb CHANGED
@@ -20,8 +20,8 @@ class List < Protos::Component
20
20
 
21
21
  def theme
22
22
  {
23
- container: tokens("space-y-4"),
24
- item: tokens("font-bold")
23
+ container: "space-y-4",
24
+ item: "font-bold"
25
25
  }
26
26
  end
27
27
  end
data/examples/navbar.rb CHANGED
@@ -20,14 +20,9 @@ class Navbar < Protos::Component
20
20
 
21
21
  def theme
22
22
  {
23
- container: tokens(
24
- "flex",
25
- "justify-between",
26
- "items-center",
27
- "gap-sm"
28
- ),
29
- heading: tokens("text-2xl", "font-bold"),
30
- subtitle: tokens("text-base")
23
+ container: "flex justify-between items-center gap-sm",
24
+ heading: "text-2xl font-bold",
25
+ subtitle: "text-base"
31
26
  }
32
27
  end
33
28
  end
@@ -5,13 +5,15 @@ module Protos
5
5
  class Item < Component
6
6
  # DOCS: An accorion is just a collapse with radio buttons.
7
7
 
8
- option :input_id, type: Types::String | Types::Integer
8
+ option :input_name,
9
+ type: Types::String | Types::Integer | Types::Nil,
10
+ reader: false
9
11
 
10
12
  def view_template(&block)
11
13
  li(**attrs) do
12
14
  render Collapse.new(
13
15
  theme: collapse_theme,
14
- input_id: @input_id.to_s,
16
+ input_name: @input_name,
15
17
  input_type: :radio,
16
18
  &block
17
19
  )
@@ -7,30 +7,29 @@ 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
+ autoload :Item, "protos/accordion/item"
11
+
12
+ option :input_name,
13
+ default: -> { "accordion-#{SecureRandom.hex(4)}" },
14
+ reader: false,
15
+ type: Types::String
16
+
10
17
  def view_template(&)
11
18
  ul(**attrs, &)
12
19
  end
13
20
 
14
- def item(*, input_id: nil, **, &)
15
- self.current_input_id = input_id
16
-
17
- render Item.new(*, input_id: current_input_id, **, &)
21
+ def item(*, **, &)
22
+ render Item.new(*, input_name: @input_name, **, &)
18
23
  end
19
24
 
20
25
  def content(...) = render Collapse::Content.new(...)
21
26
 
22
27
  def title(*, **, &)
23
- render Collapse::Title.new(*, input_id: current_input_id, **, &)
28
+ render Collapse::Title.new(*, input_id: @input_name, **, &)
24
29
  end
25
30
 
26
31
  private
27
32
 
28
- attr_reader :current_input_id
29
-
30
- def current_input_id=(value)
31
- @current_input_id = value || "collapse-#{SecureRandom.hex(4)}"
32
- end
33
-
34
33
  def theme
35
34
  {
36
35
  container: "join join-vertical"
data/lib/protos/alert.rb CHANGED
@@ -6,6 +6,9 @@ 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
+ autoload :Actions, "protos/alert/actions"
10
+ autoload :Icon, "protos/alert/icon"
11
+
9
12
  Styles = Types::Coercible::Symbol.enum(
10
13
  :info,
11
14
  :success,
@@ -34,10 +37,7 @@ module Protos
34
37
 
35
38
  def theme
36
39
  {
37
- container: %W[
38
- alert
39
- #{style}
40
- ]
40
+ container: ["alert", style]
41
41
  }
42
42
  end
43
43
 
data/lib/protos/avatar.rb CHANGED
@@ -17,10 +17,6 @@ module Protos
17
17
  :diamond,
18
18
  :square,
19
19
  :circle,
20
- :parallelogram,
21
- :parallelogram2,
22
- :parallelogram3,
23
- :parallelogram4,
24
20
  :star,
25
21
  :star2,
26
22
  :triangle,
@@ -42,10 +38,6 @@ module Protos
42
38
  diamond: "mask mask-diamond",
43
39
  square: "mask mask-square",
44
40
  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
41
  star: "mask mask-star",
50
42
  star2: "mask mask-star-2",
51
43
  triangle: "mask mask-triangle",
@@ -58,19 +50,19 @@ module Protos
58
50
 
59
51
  INDICATORS = {
60
52
  none: "",
61
- online: "online",
62
- offline: "offline"
53
+ online: "avatar-online",
54
+ offline: "avatar-offline"
63
55
  }.freeze
64
56
 
65
57
  option :placeholder, type: Types::Bool, default: -> { false }
66
58
  option :indicator,
67
- type: Indicators,
68
- default: -> { :none },
69
- reader: false
59
+ type: Indicators,
60
+ default: -> { :none },
61
+ reader: false
70
62
  option :shape,
71
- type: MaskShapes,
72
- default: -> { :none },
73
- reader: false
63
+ type: MaskShapes,
64
+ default: -> { :none },
65
+ reader: false
74
66
 
75
67
  def view_template(&block)
76
68
  div(**attrs) do
@@ -90,12 +82,12 @@ module Protos
90
82
 
91
83
  def theme
92
84
  {
93
- container: tokens(
85
+ container: [
94
86
  "avatar",
95
87
  indicator,
96
- placeholder: "placeholder"
97
- ),
98
- figure: tokens(shape)
88
+ ("placeholder" if placeholder)
89
+ ],
90
+ figure: shape
99
91
  }
100
92
  end
101
93
  end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Badge < Component
5
+ Styles = Types::Coercible::Symbol.enum(
6
+ *Types::Styles.values,
7
+ :ghost
8
+ )
9
+
10
+ Sizes = Types::Coercible::Symbol.enum(:default, :xs, :sm, :md, :lg, :xl)
11
+
12
+ STYLES = {
13
+ default: "",
14
+ neutral: "badge-neutral",
15
+ success: "badge-success",
16
+ primary: "badge-primary",
17
+ secondary: "badge-secondary",
18
+ info: "badge-info",
19
+ error: "badge-error",
20
+ warning: "badge-warning",
21
+ ghost: "badge-ghost"
22
+ }.freeze
23
+
24
+ SIZES = {
25
+ default: "badge-md",
26
+ xs: "badge-xs",
27
+ sm: "badge-sm",
28
+ md: "badge-md",
29
+ lg: "badge-lg",
30
+ xl: "badge-xl"
31
+ }.freeze
32
+
33
+ option :type, type: Styles, default: -> { :default }
34
+ option :outline, default: -> { false }
35
+ option :dashed, default: -> { false }
36
+ option :soft, default: -> { false }
37
+ option :size, type: Sizes, default: -> { :default }
38
+
39
+ def view_template(&)
40
+ span(**attrs, &)
41
+ end
42
+
43
+ private
44
+
45
+ def theme
46
+ {
47
+ container: [
48
+ "badge",
49
+ STYLES.fetch(type),
50
+ SIZES.fetch(size),
51
+ ("badge-outline" if outline),
52
+ ("badge-dashed" if dashed),
53
+ ("badge-soft" if soft)
54
+ ].compact
55
+ }
56
+ end
57
+ end
58
+ end
@@ -5,6 +5,8 @@ module Protos
5
5
  # DOCS: A list of breadcrumbs (e.g links) for navigation
6
6
  # https://daisyui.com/components/breadcrumbs/
7
7
 
8
+ autoload :Crumb, "protos/breadcrumbs/crumb"
9
+
8
10
  def view_template(&block)
9
11
  nav(**attrs) do
10
12
  ul(class: css[:list], &block)
data/lib/protos/card.rb CHANGED
@@ -5,20 +5,40 @@ module Protos
5
5
  # DOCS: A card component
6
6
  # https://daisyui.com/components/card/
7
7
 
8
- ImageDisplays = Types::Coercible::Symbol.enum(:default, :overlay, :side)
8
+ autoload :Body, "protos/card/body"
9
+ autoload :Title, "protos/card/title"
10
+ autoload :Actions, "protos/card/actions"
11
+ autoload :Image, "protos/card/image"
9
12
 
10
- IMAGE_DISPLAYS = {
11
- default: "",
12
- overlay: "image-full",
13
- side: "card-side"
13
+ Sizes = Types::Coercible::Symbol.enum(
14
+ :default,
15
+ :xs,
16
+ :sm,
17
+ :md,
18
+ :lg,
19
+ :xl
20
+ )
21
+
22
+ SIZES = {
23
+ default: "card-md",
24
+ xs: "card-xs",
25
+ sm: "card-sm",
26
+ md: "card-md",
27
+ lg: "card-lg",
28
+ xl: "card-xl"
14
29
  }.freeze
15
30
 
31
+ option :size, type: Sizes, default: -> { :default }, reader: :private
32
+ option :image_side,
33
+ type: Types::Bool,
34
+ default: -> { false },
35
+ reader: :private
36
+ option :image_full,
37
+ type: Types::Bool,
38
+ default: -> { false },
39
+ reader: :private
16
40
  option :border, type: Types::Bool, default: -> { true }, reader: :private
17
- option :compact, type: Types::Bool, default: -> { false }, reader: :private
18
- option :image_display,
19
- ImageDisplays,
20
- default: -> { :default },
21
- reader: false
41
+ option :dashed, type: Types::Bool, default: -> { false }, reader: :private
22
42
 
23
43
  def view_template(&)
24
44
  article(**attrs, &)
@@ -34,18 +54,16 @@ module Protos
34
54
 
35
55
  private
36
56
 
37
- def image_display
38
- IMAGE_DISPLAYS.fetch(@image_display)
39
- end
40
-
41
57
  def theme
42
58
  {
43
- container: tokens(
59
+ container: [
44
60
  "card",
45
- image_display,
46
- border: "card-bordered",
47
- compact: "card-compact"
48
- )
61
+ SIZES[size],
62
+ ("card-bordered" if border),
63
+ ("card-dash" if dashed),
64
+ ("image-full" if image_full),
65
+ ("card-side" if image_side)
66
+ ]
49
67
  }
50
68
  end
51
69
  end
@@ -6,6 +6,15 @@ module Protos
6
6
  # through in a mobile friendly manner.
7
7
  # https://daisyui.com/components/carousel/
8
8
 
9
+ autoload :Item, "protos/carousel/item"
10
+ autoload :Actions, "protos/carousel/actions"
11
+
12
+ Positions = Types::Coercible::Symbol.enum(
13
+ :none,
14
+ :center,
15
+ :end
16
+ )
17
+
9
18
  SNAP_POINTS = {
10
19
  none: "",
11
20
  center: "carousel-center",
@@ -14,13 +23,9 @@ module Protos
14
23
 
15
24
  option :vertical, type: Types::Bool, default: -> { false }
16
25
  option :snap_to,
17
- default: -> { :none },
18
- reader: false,
19
- type: Types::Coercible::Symbol.enum(
20
- :none,
21
- :center,
22
- :end
23
- )
26
+ default: -> { :none },
27
+ reader: false,
28
+ type: Positions
24
29
 
25
30
  def view_template(&)
26
31
  div(**attrs, &)
@@ -38,11 +43,11 @@ module Protos
38
43
 
39
44
  def theme
40
45
  {
41
- container: tokens(
46
+ container: [
42
47
  "carousel",
43
48
  snap_to,
44
- vertical: "carousel-vertical"
45
- )
49
+ ("carousel-vertical" if vertical)
50
+ ]
46
51
  }
47
52
  end
48
53
  end