ui_components 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +18 -11
- data/app/assets/javascripts/ui_components/controllers/countdown_controller.js +55 -0
- data/app/components/documentation/body/example_preview_component.rb +1 -1
- data/app/components/documentation/body_component.html.erb +1 -1
- data/app/components/documentation/body_component.rb +4 -4
- data/app/components/ui_components/daisy_ui/action/button_component.rb +13 -13
- data/app/components/ui_components/daisy_ui/action/dropdown/anchor_component.rb +1 -11
- data/app/components/ui_components/daisy_ui/action/dropdown/card/item_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/action/dropdown/card_component.rb +4 -14
- data/app/components/ui_components/daisy_ui/action/dropdown/menu/item_component.rb +32 -0
- data/app/components/ui_components/daisy_ui/action/dropdown/menu_component.rb +2 -12
- data/app/components/ui_components/daisy_ui/action/dropdown_component.rb +12 -12
- data/app/components/ui_components/daisy_ui/action/modal/anchor_component.rb +1 -11
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/action/item_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/action_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/body_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/close_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/title_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/modal/dialog_component.rb +2 -12
- data/app/components/ui_components/daisy_ui/action/swap/off_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/swap/on_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/swap_component.rb +6 -6
- data/app/components/ui_components/daisy_ui/base_component.rb +24 -3
- data/app/components/ui_components/daisy_ui/data_display/accordion/item/anchor_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/accordion/item/body_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/accordion/item_component.rb +15 -15
- data/app/components/ui_components/daisy_ui/data_display/avatar/item/box_component.rb +63 -0
- data/app/components/ui_components/daisy_ui/data_display/avatar/item_component.rb +8 -8
- data/app/components/ui_components/daisy_ui/data_display/badge_component.rb +7 -7
- data/app/components/ui_components/daisy_ui/data_display/card/body/action_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/card/body/context_component.rb +17 -0
- data/app/components/ui_components/daisy_ui/data_display/card/body/title_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/card/body_component.rb +34 -0
- data/app/components/ui_components/daisy_ui/data_display/card/figure_component.rb +15 -0
- data/app/components/ui_components/daisy_ui/data_display/card_component.rb +83 -0
- data/app/components/ui_components/daisy_ui/data_display/carousel/indicator_component.rb +18 -0
- data/app/components/ui_components/daisy_ui/data_display/carousel/item/passer_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/carousel/item_component.rb +26 -0
- data/app/components/ui_components/daisy_ui/data_display/carousel_component.rb +63 -0
- data/app/components/ui_components/daisy_ui/data_display/chat/bubble_component.rb +42 -0
- data/app/components/ui_components/daisy_ui/data_display/chat/footer_component.rb +18 -0
- data/app/components/ui_components/daisy_ui/data_display/chat/header_component.rb +18 -0
- data/app/components/ui_components/daisy_ui/data_display/chat_component.rb +58 -0
- data/app/components/ui_components/daisy_ui/data_display/countdown/item_component.rb +49 -0
- data/app/components/ui_components/daisy_ui/data_display/countdown_component.rb +37 -0
- data/app/components/ui_components/daisy_ui/data_display/{accordion/anchor_component.rb → diff/item1_component.rb} +5 -8
- data/app/components/ui_components/daisy_ui/data_display/{accordion/body_component.rb → diff/item2_component.rb} +6 -8
- data/app/components/ui_components/daisy_ui/data_display/diff/resizer_component.rb +25 -0
- data/app/components/ui_components/daisy_ui/data_display/diff_component.rb +35 -0
- data/app/components/ui_components/daisy_ui/data_display/kbd_component.rb +40 -0
- data/app/components/ui_components/daisy_ui/data_display/list/item_component.rb +40 -0
- data/app/components/ui_components/daisy_ui/data_display/list_component.rb +22 -0
- data/app/components/ui_components/daisy_ui/data_display/stat/item/action_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/stat/item/description_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/stat/item/figure_component.rb +24 -0
- data/app/components/ui_components/daisy_ui/data_display/stat/item/title_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/stat/item/value_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/stat/item_component.rb +39 -0
- data/app/components/ui_components/daisy_ui/data_display/stat_component.rb +50 -0
- data/app/components/ui_components/daisy_ui/data_display/status_component.rb +59 -0
- data/app/components/ui_components/daisy_ui/data_display/table/item/body_component.rb +23 -0
- data/app/components/ui_components/daisy_ui/data_display/table/item/foot_component.rb +23 -0
- data/app/components/ui_components/daisy_ui/data_display/table/item/head_component.rb +23 -0
- data/app/components/ui_components/daisy_ui/data_display/table/item/row/data_component.rb +19 -0
- data/app/components/ui_components/daisy_ui/data_display/table/item/row/header_component.rb +19 -0
- data/app/components/ui_components/daisy_ui/data_display/table/item/row_component.rb +32 -0
- data/app/components/ui_components/daisy_ui/data_display/table/item_component.rb +29 -0
- data/app/components/ui_components/daisy_ui/data_display/table_component.rb +72 -0
- data/app/components/ui_components/daisy_ui/data_display/timeline/item/item_end_component.rb +44 -0
- data/app/components/ui_components/daisy_ui/data_display/timeline/item/item_middle_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/timeline/item/item_start_component.rb +44 -0
- data/app/components/ui_components/daisy_ui/data_display/timeline/item/line_component.rb +17 -0
- data/app/components/ui_components/daisy_ui/data_display/timeline/item_component.rb +40 -0
- data/app/components/ui_components/daisy_ui/data_display/timeline_component.rb +50 -0
- data/app/controllers/ui_components/daisy_ui/data_display_components_controller.rb +22 -0
- data/app/helpers/data_display/carousel_helper.rb +13 -0
- data/app/views/ui_components/daisy_ui/action_components/button.html.erb +35 -33
- data/app/views/ui_components/daisy_ui/action_components/dropdown.html.erb +38 -25
- data/app/views/ui_components/daisy_ui/action_components/modal.html.erb +31 -18
- data/app/views/ui_components/daisy_ui/action_components/swap.html.erb +31 -17
- data/app/views/ui_components/daisy_ui/data_display_components/accordion.html.erb +59 -105
- data/app/views/ui_components/daisy_ui/data_display_components/avatar.html.erb +40 -27
- data/app/views/ui_components/daisy_ui/data_display_components/badge.html.erb +45 -42
- data/app/views/ui_components/daisy_ui/data_display_components/card.html.erb +302 -0
- data/app/views/ui_components/daisy_ui/data_display_components/carousel.html.erb +303 -0
- data/app/views/ui_components/daisy_ui/data_display_components/chat.html.erb +190 -0
- data/app/views/ui_components/daisy_ui/data_display_components/countdown.html.erb +211 -0
- data/app/views/ui_components/daisy_ui/data_display_components/diff.html.erb +69 -0
- data/app/views/ui_components/daisy_ui/data_display_components/kbd.html.erb +157 -0
- data/app/views/ui_components/daisy_ui/data_display_components/list.html.erb +247 -0
- data/app/views/ui_components/daisy_ui/data_display_components/stat.html.erb +208 -0
- data/app/views/ui_components/daisy_ui/data_display_components/status.html.erb +93 -0
- data/app/views/ui_components/daisy_ui/data_display_components/table.html.erb +358 -0
- data/app/views/ui_components/daisy_ui/data_display_components/timeline.html.erb +431 -0
- data/app/views/ui_components/daisy_ui/home/index.html.erb +11 -0
- data/config/routes.rb +13 -2
- data/lib/tasks/ui_components_tasks.rake +0 -3
- data/lib/ui_components/config/daisy_ui_class_names.rb +3 -2
- data/lib/ui_components/config/tailwind_class_names.rb +27 -4
- data/lib/ui_components/version.rb +1 -1
- metadata +65 -7
- data/app/components/ui_components/daisy_ui/action/dropdown/card_item_component.rb +0 -29
- data/app/components/ui_components/daisy_ui/action/dropdown/list_item_component.rb +0 -30
- data/app/components/ui_components/daisy_ui/data_display/avatar/box_component.rb +0 -61
@@ -15,6 +15,8 @@ module UiComponents
|
|
15
15
|
CSS_CLASSES_VARIANTS = %w[].freeze
|
16
16
|
CSS_CLASSES = (CSS_CLASSES_DEFAULT + CSS_CLASSES_VARIANTS).freeze
|
17
17
|
|
18
|
+
attr_accessor :slot_order
|
19
|
+
|
18
20
|
def initialize(
|
19
21
|
css_class: nil,
|
20
22
|
css_style: nil,
|
@@ -23,18 +25,37 @@ module UiComponents
|
|
23
25
|
@css_class = css_class.to_s
|
24
26
|
@css_style = css_style.to_s
|
25
27
|
@options = options
|
28
|
+
|
29
|
+
@slot_order = []
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.tracks_slot_order(slots)
|
33
|
+
slots.each do |slot|
|
34
|
+
singularized = slot.to_s.singularize
|
35
|
+
alias_method "original_with_#{singularized}", "with_#{singularized}"
|
36
|
+
|
37
|
+
define_method "with_#{singularized}" do |*args, **kwargs, &block|
|
38
|
+
@slot_order << slot unless @slot_order.include?(slot)
|
39
|
+
|
40
|
+
send("original_with_#{singularized}", *args, **kwargs, &block)
|
41
|
+
end
|
42
|
+
end
|
26
43
|
end
|
27
44
|
|
28
45
|
private
|
29
46
|
|
30
47
|
def set_options
|
31
|
-
@options.merge!(class:
|
48
|
+
@options.merge!(class: css_class_string)
|
32
49
|
@options.merge!(style: @css_style) if @css_style.present?
|
50
|
+
other_options if respond_to?(:other_options, true)
|
33
51
|
@options.compact_blank!
|
34
52
|
end
|
35
53
|
|
36
|
-
def
|
37
|
-
|
54
|
+
def css_class_string
|
55
|
+
TailwindMerge::Merger.new.merge([
|
56
|
+
*self.class::CSS_CLASSES_DEFAULT,
|
57
|
+
@css_class
|
58
|
+
])
|
38
59
|
end
|
39
60
|
end
|
40
61
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Accordion
|
7
|
+
module Item
|
8
|
+
class AnchorComponent < BaseComponent
|
9
|
+
CSS_CLASSES_DEFAULT = %w[collapse-title].freeze
|
10
|
+
CSS_CLASSES = CSS_CLASSES_DEFAULT
|
11
|
+
|
12
|
+
erb_template <<-ERB
|
13
|
+
<%= tag.div(**set_options) { content } %>
|
14
|
+
ERB
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Accordion
|
7
|
+
module Item
|
8
|
+
class BodyComponent < BaseComponent
|
9
|
+
CSS_CLASSES_DEFAULT = %w[collapse-content].freeze
|
10
|
+
CSS_CLASSES = CSS_CLASSES_DEFAULT
|
11
|
+
|
12
|
+
erb_template <<-ERB
|
13
|
+
<%= tag.div(**set_options) { content } %>
|
14
|
+
ERB
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -5,15 +5,15 @@ module UiComponents
|
|
5
5
|
module DataDisplay
|
6
6
|
module Accordion
|
7
7
|
class ItemComponent < BaseComponent
|
8
|
-
ICONS = %w[arrow plus]
|
8
|
+
ICONS = %w[arrow plus].freeze
|
9
9
|
|
10
10
|
CSS_CLASSES_DEFAULT = %w[collapse bg-base-100 border border-base-300].freeze
|
11
11
|
CSS_CLASSES_VARIANTS = (ICONS.map { |key| "collapse-#{key}" }).freeze
|
12
12
|
CSS_CLASSES = (
|
13
13
|
CSS_CLASSES_DEFAULT +
|
14
14
|
CSS_CLASSES_VARIANTS +
|
15
|
-
AnchorComponent::CSS_CLASSES +
|
16
|
-
BodyComponent::CSS_CLASSES
|
15
|
+
Item::AnchorComponent::CSS_CLASSES +
|
16
|
+
Item::BodyComponent::CSS_CLASSES
|
17
17
|
).freeze
|
18
18
|
|
19
19
|
erb_template <<-ERB
|
@@ -24,8 +24,8 @@ module UiComponents
|
|
24
24
|
<% end %>
|
25
25
|
ERB
|
26
26
|
|
27
|
-
renders_one :anchor, AnchorComponent
|
28
|
-
renders_one :body, BodyComponent
|
27
|
+
renders_one :anchor, Item::AnchorComponent
|
28
|
+
renders_one :body, Item::BodyComponent
|
29
29
|
|
30
30
|
def initialize(
|
31
31
|
opener:,
|
@@ -44,24 +44,24 @@ module UiComponents
|
|
44
44
|
|
45
45
|
private
|
46
46
|
|
47
|
-
def
|
48
|
-
options = { type: (@toggle ? "checkbox" : "radio") }
|
49
|
-
options.merge!(name: @opener)
|
50
|
-
options.merge!(checked: "checked") if @opened
|
51
|
-
options.compact_blank!
|
52
|
-
end
|
53
|
-
|
54
|
-
def class_string
|
47
|
+
def css_class_string
|
55
48
|
TailwindMerge::Merger.new.merge([
|
56
49
|
*CSS_CLASSES_DEFAULT,
|
57
|
-
|
50
|
+
icon_css_class,
|
58
51
|
@css_class
|
59
52
|
])
|
60
53
|
end
|
61
54
|
|
62
|
-
def
|
55
|
+
def icon_css_class
|
63
56
|
"collapse-#{@icon}" if ICONS.include?(@icon)
|
64
57
|
end
|
58
|
+
|
59
|
+
def set_input_options
|
60
|
+
options = { type: (@toggle ? "checkbox" : "radio") }
|
61
|
+
options.merge!(name: @opener)
|
62
|
+
options.merge!(checked: "checked") if @opened
|
63
|
+
options.compact_blank!
|
64
|
+
end
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Avatar
|
7
|
+
module Item
|
8
|
+
class BoxComponent < BaseComponent
|
9
|
+
MASKS = %w[squircle hexagon triangle].freeze
|
10
|
+
|
11
|
+
CSS_CLASSES_DEFAULT = %w[w-24].freeze
|
12
|
+
CSS_CLASSES_VARIANTS = (
|
13
|
+
%w[mask bg-neutral text-neutral-content ring-primary ring-offset-base-100 ring ring-offset-2] +
|
14
|
+
MASKS.map { |key| "mask-#{key}" }
|
15
|
+
).freeze
|
16
|
+
CSS_CLASSES = (CSS_CLASSES_DEFAULT + CSS_CLASSES_VARIANTS).freeze
|
17
|
+
|
18
|
+
erb_template <<-ERB
|
19
|
+
<%= tag.div(**set_options) { content } %>
|
20
|
+
ERB
|
21
|
+
|
22
|
+
def initialize(
|
23
|
+
placeholder: false,
|
24
|
+
with_ring: false,
|
25
|
+
mask: nil,
|
26
|
+
**args
|
27
|
+
)
|
28
|
+
@placeholder = placeholder
|
29
|
+
@with_ring = with_ring
|
30
|
+
@mask = mask
|
31
|
+
|
32
|
+
super(**args)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def css_class_string
|
38
|
+
TailwindMerge::Merger.new.merge([
|
39
|
+
*CSS_CLASSES_DEFAULT,
|
40
|
+
placeholder_css_class,
|
41
|
+
ring_css_class,
|
42
|
+
mask_css_class,
|
43
|
+
@css_class
|
44
|
+
])
|
45
|
+
end
|
46
|
+
|
47
|
+
def placeholder_css_class
|
48
|
+
"bg-neutral text-neutral-content" if @placeholder
|
49
|
+
end
|
50
|
+
|
51
|
+
def ring_css_class
|
52
|
+
"ring-primary ring-offset-base-100 ring ring-offset-2" if @with_ring
|
53
|
+
end
|
54
|
+
|
55
|
+
def mask_css_class
|
56
|
+
"mask mask-#{@mask}" if MASKS.include?(@mask)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -5,7 +5,7 @@ module UiComponents
|
|
5
5
|
module DataDisplay
|
6
6
|
module Avatar
|
7
7
|
class ItemComponent < BaseComponent
|
8
|
-
STATUSES = %w[online offline]
|
8
|
+
STATUSES = %w[online offline].freeze
|
9
9
|
|
10
10
|
CSS_CLASSES_DEFAULT = %w[avatar].freeze
|
11
11
|
CSS_CLASSES_VARIANTS = (
|
@@ -15,7 +15,7 @@ module UiComponents
|
|
15
15
|
CSS_CLASSES = (
|
16
16
|
CSS_CLASSES_DEFAULT +
|
17
17
|
CSS_CLASSES_VARIANTS +
|
18
|
-
BoxComponent::CSS_CLASSES
|
18
|
+
Item::BoxComponent::CSS_CLASSES
|
19
19
|
).freeze
|
20
20
|
|
21
21
|
erb_template <<-ERB
|
@@ -24,7 +24,7 @@ module UiComponents
|
|
24
24
|
<% end %>
|
25
25
|
ERB
|
26
26
|
|
27
|
-
renders_one :box, ->(**args) { BoxComponent.new(**args.merge(placeholder: @placeholder)) }
|
27
|
+
renders_one :box, ->(**args) { Item::BoxComponent.new(**args.merge(placeholder: @placeholder)) }
|
28
28
|
|
29
29
|
def initialize(
|
30
30
|
placeholder: false,
|
@@ -39,20 +39,20 @@ module UiComponents
|
|
39
39
|
|
40
40
|
private
|
41
41
|
|
42
|
-
def
|
42
|
+
def css_class_string
|
43
43
|
TailwindMerge::Merger.new.merge([
|
44
44
|
*CSS_CLASSES_DEFAULT,
|
45
|
-
|
46
|
-
|
45
|
+
placeholder_css_class,
|
46
|
+
status_css_class,
|
47
47
|
@css_class
|
48
48
|
])
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
51
|
+
def placeholder_css_class
|
52
52
|
"avatar-placeholder" if @placeholder
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
55
|
+
def status_css_class
|
56
56
|
"avatar-#{@status}" if STATUSES.include?(@status)
|
57
57
|
end
|
58
58
|
end
|
@@ -31,25 +31,25 @@ module UiComponents
|
|
31
31
|
|
32
32
|
private
|
33
33
|
|
34
|
-
def
|
34
|
+
def css_class_string
|
35
35
|
TailwindMerge::Merger.new.merge([
|
36
36
|
*CSS_CLASSES_DEFAULT,
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
size_css_class,
|
38
|
+
color_css_class,
|
39
|
+
kind_css_class,
|
40
40
|
@css_class
|
41
41
|
])
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
44
|
+
def size_css_class
|
45
45
|
"badge-#{@size}" if SIZES.include?(@size)
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
48
|
+
def color_css_class
|
49
49
|
"badge-#{@color}" if COLORS.include?(@color)
|
50
50
|
end
|
51
51
|
|
52
|
-
def
|
52
|
+
def kind_css_class
|
53
53
|
"badge-#{@kind}" if KINDS.include?(@kind)
|
54
54
|
end
|
55
55
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Card
|
7
|
+
module Body
|
8
|
+
class ActionComponent < BaseComponent
|
9
|
+
CSS_CLASSES_DEFAULT = %w[card-actions justify-end].freeze
|
10
|
+
CSS_CLASSES = CSS_CLASSES_DEFAULT
|
11
|
+
|
12
|
+
erb_template <<-ERB
|
13
|
+
<%= tag.div(**set_options) { content } %>
|
14
|
+
ERB
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Card
|
7
|
+
module Body
|
8
|
+
class ContextComponent < BaseComponent
|
9
|
+
erb_template <<-ERB
|
10
|
+
<%= content %>
|
11
|
+
ERB
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Card
|
7
|
+
module Body
|
8
|
+
class TitleComponent < BaseComponent
|
9
|
+
CSS_CLASSES_DEFAULT = %w[card-title].freeze
|
10
|
+
CSS_CLASSES = CSS_CLASSES_DEFAULT
|
11
|
+
|
12
|
+
erb_template <<-ERB
|
13
|
+
<%= tag.h2(**set_options) { content } %>
|
14
|
+
ERB
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Card
|
7
|
+
class BodyComponent < BaseComponent
|
8
|
+
CSS_CLASSES_DEFAULT = %w[card-body].freeze
|
9
|
+
CSS_CLASSES = (
|
10
|
+
CSS_CLASSES_DEFAULT +
|
11
|
+
Body::TitleComponent::CSS_CLASSES +
|
12
|
+
Body::ActionComponent::CSS_CLASSES
|
13
|
+
).freeze
|
14
|
+
|
15
|
+
erb_template <<-ERB
|
16
|
+
<%= tag.div(**set_options) do %>
|
17
|
+
<% content.present? %>
|
18
|
+
|
19
|
+
<% slot_order.each do |slot| %>
|
20
|
+
<%= send(slot) if send(slot).present? %>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
23
|
+
ERB
|
24
|
+
|
25
|
+
renders_one :title, Body::TitleComponent
|
26
|
+
renders_one :context, Body::ContextComponent
|
27
|
+
renders_one :action, Body::ActionComponent
|
28
|
+
|
29
|
+
tracks_slot_order registered_slots.keys
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Card
|
7
|
+
class FigureComponent < BaseComponent
|
8
|
+
erb_template <<-ERB
|
9
|
+
<%= tag.figure(**set_options) { content } %>
|
10
|
+
ERB
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
class CardComponent < BaseComponent
|
7
|
+
SIZES = %w[xs sm md lg xl].freeze
|
8
|
+
BORDER_KINDS = %w[border dash].freeze
|
9
|
+
|
10
|
+
CSS_CLASSES_DEFAULT = %w[card w-96 bg-base-100 shadow-sm].freeze
|
11
|
+
CSS_CLASSES_VARIANTS = (
|
12
|
+
%w[card-side image-full] +
|
13
|
+
SIZES.map { |key| "card-#{key}" } +
|
14
|
+
BORDER_KINDS.map { |key| "card-#{key}" }
|
15
|
+
).freeze
|
16
|
+
CSS_CLASSES = (
|
17
|
+
CSS_CLASSES_DEFAULT +
|
18
|
+
CSS_CLASSES_VARIANTS +
|
19
|
+
Card::BodyComponent::CSS_CLASSES
|
20
|
+
).freeze
|
21
|
+
|
22
|
+
erb_template <<-ERB
|
23
|
+
<%= tag.div(**set_options) do %>
|
24
|
+
<% content.present? %>
|
25
|
+
|
26
|
+
<% slot_order.each do |slot| %>
|
27
|
+
<%= send(slot) if send(slot).present? %>
|
28
|
+
<% end %>
|
29
|
+
<% end %>
|
30
|
+
ERB
|
31
|
+
|
32
|
+
renders_one :figure, Card::FigureComponent
|
33
|
+
renders_one :body, Card::BodyComponent
|
34
|
+
|
35
|
+
tracks_slot_order registered_slots.keys
|
36
|
+
|
37
|
+
def initialize(
|
38
|
+
size: nil,
|
39
|
+
side: false,
|
40
|
+
border_kind: nil,
|
41
|
+
image_full: nil,
|
42
|
+
**args
|
43
|
+
)
|
44
|
+
@size = size
|
45
|
+
@side = side
|
46
|
+
@border_kind = border_kind
|
47
|
+
@image_full = image_full
|
48
|
+
|
49
|
+
super(**args)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def css_class_string
|
55
|
+
TailwindMerge::Merger.new.merge([
|
56
|
+
*CSS_CLASSES_DEFAULT,
|
57
|
+
size_css_class,
|
58
|
+
side_css_class,
|
59
|
+
border_kind_css_class,
|
60
|
+
image_full_css_class,
|
61
|
+
@css_class
|
62
|
+
])
|
63
|
+
end
|
64
|
+
|
65
|
+
def size_css_class
|
66
|
+
"card-#{@size}" if SIZES.include?(@size)
|
67
|
+
end
|
68
|
+
|
69
|
+
def side_css_class
|
70
|
+
"card-side" if @side
|
71
|
+
end
|
72
|
+
|
73
|
+
def border_kind_css_class
|
74
|
+
"card-#{@border_kind}" if BORDER_KINDS.include?(@border_kind)
|
75
|
+
end
|
76
|
+
|
77
|
+
def image_full_css_class
|
78
|
+
"image-full" if @image_full
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Carousel
|
7
|
+
class IndicatorComponent < BaseComponent
|
8
|
+
CSS_CLASSES_DEFAULT = %w[flex w-full justify-center gap-2 py-2].freeze
|
9
|
+
CSS_CLASSES = CSS_CLASSES_DEFAULT
|
10
|
+
|
11
|
+
erb_template <<-ERB
|
12
|
+
<%= tag.dev(**set_options) { content } %>
|
13
|
+
ERB
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Carousel
|
7
|
+
module Item
|
8
|
+
class PasserComponent < BaseComponent
|
9
|
+
CSS_CLASSES_DEFAULT = %w[absolute left-5 right-5 top-1/2 flex -translate-y-1/2 transform justify-between].freeze
|
10
|
+
CSS_CLASSES = CSS_CLASSES_DEFAULT
|
11
|
+
|
12
|
+
erb_template <<-ERB
|
13
|
+
<%= tag.dev(**set_options) { content } %>
|
14
|
+
ERB
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Carousel
|
7
|
+
class ItemComponent < BaseComponent
|
8
|
+
CSS_CLASSES_DEFAULT = %w[carousel-item].freeze
|
9
|
+
CSS_CLASSES = (
|
10
|
+
CSS_CLASSES_DEFAULT +
|
11
|
+
Item::PasserComponent::CSS_CLASSES
|
12
|
+
).freeze
|
13
|
+
|
14
|
+
erb_template <<-ERB
|
15
|
+
<%= tag.dev(**set_options) do %>
|
16
|
+
<%= content %>
|
17
|
+
<%= passer %>
|
18
|
+
<% end %>
|
19
|
+
ERB
|
20
|
+
|
21
|
+
renders_one :passer, Item::PasserComponent
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
class CarouselComponent < BaseComponent
|
7
|
+
CSS_CLASSES_DEFAULT = %w[carousel].freeze
|
8
|
+
CSS_CLASSES_VARIANTS = (
|
9
|
+
%w[carousel-horizontal carousel-vertical] +
|
10
|
+
ALIGNS.map { |key| "carousel-#{key}" }
|
11
|
+
).freeze
|
12
|
+
CSS_CLASSES = (
|
13
|
+
CSS_CLASSES_DEFAULT +
|
14
|
+
CSS_CLASSES_VARIANTS +
|
15
|
+
Carousel::ItemComponent::CSS_CLASSES +
|
16
|
+
Carousel::IndicatorComponent::CSS_CLASSES
|
17
|
+
).freeze
|
18
|
+
|
19
|
+
erb_template <<-ERB
|
20
|
+
<%= tag.div(**set_options) do %>
|
21
|
+
<% items.each do |item| %>
|
22
|
+
<%= item %>
|
23
|
+
<% end %>
|
24
|
+
<% end %>
|
25
|
+
<%= indicator %>
|
26
|
+
ERB
|
27
|
+
|
28
|
+
renders_many :items, Carousel::ItemComponent
|
29
|
+
renders_one :indicator, Carousel::IndicatorComponent
|
30
|
+
|
31
|
+
def initialize(
|
32
|
+
align: nil,
|
33
|
+
vertical: false,
|
34
|
+
**args
|
35
|
+
)
|
36
|
+
@align = align
|
37
|
+
@vertical = vertical
|
38
|
+
|
39
|
+
super(**args)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def css_class_string
|
45
|
+
TailwindMerge::Merger.new.merge([
|
46
|
+
*CSS_CLASSES_DEFAULT,
|
47
|
+
align_css_class,
|
48
|
+
vertical_css_class,
|
49
|
+
@css_class
|
50
|
+
])
|
51
|
+
end
|
52
|
+
|
53
|
+
def align_css_class
|
54
|
+
"carousel-#{@align}" if ALIGNS.include?(@align)
|
55
|
+
end
|
56
|
+
|
57
|
+
def vertical_css_class
|
58
|
+
"carousel-vertical" if @vertical
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Chat
|
7
|
+
class BubbleComponent < BaseComponent
|
8
|
+
CSS_CLASSES_DEFAULT = %w[chat-bubble].freeze
|
9
|
+
CSS_CLASSES_VARIANTS = (COLORS.map { |key| "chat-bubble-#{key}" }).freeze
|
10
|
+
CSS_CLASSES = (CSS_CLASSES_DEFAULT + CSS_CLASSES_VARIANTS).freeze
|
11
|
+
|
12
|
+
erb_template <<-ERB
|
13
|
+
<%= tag.div(**set_options) { content } %>
|
14
|
+
ERB
|
15
|
+
|
16
|
+
def initialize(
|
17
|
+
color: nil,
|
18
|
+
**args
|
19
|
+
)
|
20
|
+
@color = color
|
21
|
+
|
22
|
+
super(**args)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def css_class_string
|
28
|
+
TailwindMerge::Merger.new.merge([
|
29
|
+
*CSS_CLASSES_DEFAULT,
|
30
|
+
color_css_class,
|
31
|
+
@css_class
|
32
|
+
])
|
33
|
+
end
|
34
|
+
|
35
|
+
def color_css_class
|
36
|
+
"chat-bubble-#{@color}" if COLORS.include?(@color)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|