ui_components 0.1.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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +4 -0
- data/app/assets/javascripts/ui_components/controllers/clipboard_controller.js +22 -0
- data/app/components/documentation/body/example_preview_component.rb +24 -0
- data/app/components/documentation/body_component.html.erb +26 -0
- data/app/components/documentation/body_component.rb +41 -0
- data/app/components/documentation_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/action/button_component.rb +83 -0
- data/app/components/ui_components/daisy_ui/action/dropdown/anchor_component.rb +35 -0
- data/app/components/ui_components/daisy_ui/action/dropdown/card_component.rb +41 -0
- data/app/components/ui_components/daisy_ui/action/dropdown/card_item_component.rb +29 -0
- data/app/components/ui_components/daisy_ui/action/dropdown/list_item_component.rb +30 -0
- data/app/components/ui_components/daisy_ui/action/dropdown/menu_component.rb +40 -0
- data/app/components/ui_components/daisy_ui/action/dropdown_component.rb +79 -0
- data/app/components/ui_components/daisy_ui/action/modal/anchor_component.rb +43 -0
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/action/item_component.rb +33 -0
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/action_component.rb +42 -0
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/body_component.rb +31 -0
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/close_component.rb +33 -0
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/title_component.rb +31 -0
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box_component.rb +54 -0
- data/app/components/ui_components/daisy_ui/action/modal/dialog_component.rb +58 -0
- data/app/components/ui_components/daisy_ui/action/modal_component.rb +33 -0
- data/app/components/ui_components/daisy_ui/action/swap/off_component.rb +27 -0
- data/app/components/ui_components/daisy_ui/action/swap/on_component.rb +27 -0
- data/app/components/ui_components/daisy_ui/action/swap_component.rb +59 -0
- data/app/components/ui_components/daisy_ui/base_component.rb +41 -0
- data/app/components/ui_components/daisy_ui/data_display/accordion/anchor_component.rb +27 -0
- data/app/components/ui_components/daisy_ui/data_display/accordion/body_component.rb +27 -0
- data/app/components/ui_components/daisy_ui/data_display/accordion/item_component.rb +69 -0
- data/app/components/ui_components/daisy_ui/data_display/accordion_component.rb +32 -0
- data/app/components/ui_components/daisy_ui/data_display/avatar/box_component.rb +61 -0
- data/app/components/ui_components/daisy_ui/data_display/avatar/item_component.rb +62 -0
- data/app/components/ui_components/daisy_ui/data_display/avatar_component.rb +21 -0
- data/app/components/ui_components/daisy_ui/data_display/badge_component.rb +58 -0
- data/app/controllers/ui_components/daisy_ui/action_components_controller.rb +15 -0
- data/app/controllers/ui_components/daisy_ui/application_controller.rb +9 -0
- data/app/controllers/ui_components/daisy_ui/data_display_components_controller.rb +13 -0
- data/app/controllers/ui_components/daisy_ui/home_controller.rb +9 -0
- data/app/helpers/action/button_helper.rb +18 -0
- data/app/helpers/action/dropdown_helper.rb +19 -0
- data/app/helpers/data_display/badge_helper.rb +26 -0
- data/app/views/ui_components/daisy_ui/action_components/button.html.erb +114 -0
- data/app/views/ui_components/daisy_ui/action_components/dropdown.html.erb +117 -0
- data/app/views/ui_components/daisy_ui/action_components/modal.html.erb +73 -0
- data/app/views/ui_components/daisy_ui/action_components/swap.html.erb +97 -0
- data/app/views/ui_components/daisy_ui/data_display_components/accordion.html.erb +205 -0
- data/app/views/ui_components/daisy_ui/data_display_components/avatar.html.erb +261 -0
- data/app/views/ui_components/daisy_ui/data_display_components/badge.html.erb +150 -0
- data/app/views/ui_components/daisy_ui/home/index.html.erb +20 -0
- data/config/routes.rb +22 -0
- data/lib/tasks/ui_components_tasks.rake +55 -0
- data/lib/ui_components/config/daisy_ui_class_names.rb +33 -0
- data/lib/ui_components/config/tailwind_class_names.rb +44 -0
- data/lib/ui_components/config.rb +52 -0
- data/lib/ui_components/engine.rb +12 -0
- data/lib/ui_components/version.rb +5 -0
- data/lib/ui_components.rb +9 -0
- data/sig/ui_components.rbs +4 -0
- metadata +155 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Accordion
|
7
|
+
class ItemComponent < BaseComponent
|
8
|
+
ICONS = %w[arrow plus]
|
9
|
+
|
10
|
+
CSS_CLASSES_DEFAULT = %w[collapse bg-base-100 border border-base-300].freeze
|
11
|
+
CSS_CLASSES_VARIANTS = (ICONS.map { |key| "collapse-#{key}" }).freeze
|
12
|
+
CSS_CLASSES = (
|
13
|
+
CSS_CLASSES_DEFAULT +
|
14
|
+
CSS_CLASSES_VARIANTS +
|
15
|
+
AnchorComponent::CSS_CLASSES +
|
16
|
+
BodyComponent::CSS_CLASSES
|
17
|
+
).freeze
|
18
|
+
|
19
|
+
erb_template <<-ERB
|
20
|
+
<%= tag.div(**set_options) do %>
|
21
|
+
<%= tag.input(**set_input_options) %>
|
22
|
+
<%= anchor %>
|
23
|
+
<%= body %>
|
24
|
+
<% end %>
|
25
|
+
ERB
|
26
|
+
|
27
|
+
renders_one :anchor, AnchorComponent
|
28
|
+
renders_one :body, BodyComponent
|
29
|
+
|
30
|
+
def initialize(
|
31
|
+
opener:,
|
32
|
+
toggle:,
|
33
|
+
opened: false,
|
34
|
+
icon: nil,
|
35
|
+
**args
|
36
|
+
)
|
37
|
+
@opener = opener
|
38
|
+
@toggle = toggle
|
39
|
+
@opened = opened
|
40
|
+
@icon = icon
|
41
|
+
|
42
|
+
super(**args)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def set_input_options
|
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
|
55
|
+
TailwindMerge::Merger.new.merge([
|
56
|
+
*CSS_CLASSES_DEFAULT,
|
57
|
+
icon_class,
|
58
|
+
@css_class
|
59
|
+
])
|
60
|
+
end
|
61
|
+
|
62
|
+
def icon_class
|
63
|
+
"collapse-#{@icon}" if ICONS.include?(@icon)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
class AccordionComponent < BaseComponent
|
7
|
+
CSS_CLASSES = Accordion::ItemComponent::CSS_CLASSES
|
8
|
+
|
9
|
+
erb_template <<-ERB
|
10
|
+
<%= tag.div(**set_options) do %>
|
11
|
+
<% items.each do |item| %>
|
12
|
+
<%= item %>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
15
|
+
ERB
|
16
|
+
|
17
|
+
renders_many :items, ->(**args) { Accordion::ItemComponent.new(**args.merge(opener: @opener, toggle: @toggle)) }
|
18
|
+
|
19
|
+
def initialize(
|
20
|
+
opener: "my_accordion",
|
21
|
+
toggle: false,
|
22
|
+
**args
|
23
|
+
)
|
24
|
+
@opener = opener
|
25
|
+
@toggle = toggle
|
26
|
+
|
27
|
+
super(**args)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Avatar
|
7
|
+
class BoxComponent < BaseComponent
|
8
|
+
MASKS = %w[squircle hexagon triangle]
|
9
|
+
|
10
|
+
CSS_CLASSES_DEFAULT = %w[avatar w-24].freeze
|
11
|
+
CSS_CLASSES_VARIANTS = (
|
12
|
+
%w[mask bg-neutral text-neutral-content ring-primary ring-offset-base-100 ring ring-offset-2] +
|
13
|
+
MASKS.map { |key| "mask-#{key}" }
|
14
|
+
).freeze
|
15
|
+
CSS_CLASSES = (CSS_CLASSES_DEFAULT + CSS_CLASSES_VARIANTS).freeze
|
16
|
+
|
17
|
+
erb_template <<-ERB
|
18
|
+
<%= tag.div(**set_options) { content } %>
|
19
|
+
ERB
|
20
|
+
|
21
|
+
def initialize(
|
22
|
+
placeholder: false,
|
23
|
+
with_ring: false,
|
24
|
+
mask: nil,
|
25
|
+
**args
|
26
|
+
)
|
27
|
+
@placeholder = placeholder
|
28
|
+
@with_ring = with_ring
|
29
|
+
@mask = mask
|
30
|
+
|
31
|
+
super(**args)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def class_string
|
37
|
+
TailwindMerge::Merger.new.merge([
|
38
|
+
*CSS_CLASSES_DEFAULT,
|
39
|
+
placeholder_class,
|
40
|
+
ring_class,
|
41
|
+
mask_class,
|
42
|
+
@css_class
|
43
|
+
])
|
44
|
+
end
|
45
|
+
|
46
|
+
def placeholder_class
|
47
|
+
"bg-neutral text-neutral-content" if @placeholder
|
48
|
+
end
|
49
|
+
|
50
|
+
def ring_class
|
51
|
+
"ring-primary ring-offset-base-100 ring ring-offset-2" if @with_ring
|
52
|
+
end
|
53
|
+
|
54
|
+
def mask_class
|
55
|
+
"mask mask-#{@mask}" if MASKS.include?(@mask)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
module Avatar
|
7
|
+
class ItemComponent < BaseComponent
|
8
|
+
STATUSES = %w[online offline]
|
9
|
+
|
10
|
+
CSS_CLASSES_DEFAULT = %w[avatar].freeze
|
11
|
+
CSS_CLASSES_VARIANTS = (
|
12
|
+
%w[avatar-placeholder] +
|
13
|
+
STATUSES.map { |key| "avatar-#{key}" }
|
14
|
+
).freeze
|
15
|
+
CSS_CLASSES = (
|
16
|
+
CSS_CLASSES_DEFAULT +
|
17
|
+
CSS_CLASSES_VARIANTS +
|
18
|
+
BoxComponent::CSS_CLASSES
|
19
|
+
).freeze
|
20
|
+
|
21
|
+
erb_template <<-ERB
|
22
|
+
<%= tag.div(**set_options) do %>
|
23
|
+
<%= box %>
|
24
|
+
<% end %>
|
25
|
+
ERB
|
26
|
+
|
27
|
+
renders_one :box, ->(**args) { BoxComponent.new(**args.merge(placeholder: @placeholder)) }
|
28
|
+
|
29
|
+
def initialize(
|
30
|
+
placeholder: false,
|
31
|
+
status: nil,
|
32
|
+
**args
|
33
|
+
)
|
34
|
+
@placeholder = placeholder
|
35
|
+
@status = status
|
36
|
+
|
37
|
+
super(**args)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def class_string
|
43
|
+
TailwindMerge::Merger.new.merge([
|
44
|
+
*CSS_CLASSES_DEFAULT,
|
45
|
+
placeholder_class,
|
46
|
+
status_class,
|
47
|
+
@css_class
|
48
|
+
])
|
49
|
+
end
|
50
|
+
|
51
|
+
def placeholder_class
|
52
|
+
"avatar-placeholder" if @placeholder
|
53
|
+
end
|
54
|
+
|
55
|
+
def status_class
|
56
|
+
"avatar-#{@status}" if STATUSES.include?(@status)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
class AvatarComponent < BaseComponent
|
7
|
+
CSS_CLASSES = Avatar::ItemComponent::CSS_CLASSES
|
8
|
+
|
9
|
+
erb_template <<-ERB
|
10
|
+
<%= tag.div(**set_options) do %>
|
11
|
+
<% items.each do |item| %>
|
12
|
+
<%= item %>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
15
|
+
ERB
|
16
|
+
|
17
|
+
renders_many :items, Avatar::ItemComponent
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module DataDisplay
|
6
|
+
class BadgeComponent < BaseComponent
|
7
|
+
CSS_CLASSES_DEFAULT = %w[badge].freeze
|
8
|
+
CSS_CLASSES_VARIANTS = (
|
9
|
+
SIZES.map { |key| "badge-#{key}" } +
|
10
|
+
COLORS.map { |key| "badge-#{key}" } +
|
11
|
+
KINDS.map { |key| "badge-#{key}" }
|
12
|
+
).freeze
|
13
|
+
CSS_CLASSES = (CSS_CLASSES_DEFAULT + CSS_CLASSES_VARIANTS).freeze
|
14
|
+
|
15
|
+
erb_template <<-ERB
|
16
|
+
<%= tag.div(**set_options) { content } %>
|
17
|
+
ERB
|
18
|
+
|
19
|
+
def initialize(
|
20
|
+
size: nil,
|
21
|
+
color: nil,
|
22
|
+
kind: nil,
|
23
|
+
**args
|
24
|
+
)
|
25
|
+
@size = size.to_s
|
26
|
+
@color = color.to_s
|
27
|
+
@kind = kind.to_s
|
28
|
+
|
29
|
+
super(**args)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def class_string
|
35
|
+
TailwindMerge::Merger.new.merge([
|
36
|
+
*CSS_CLASSES_DEFAULT,
|
37
|
+
size_class,
|
38
|
+
color_class,
|
39
|
+
kind_class,
|
40
|
+
@css_class
|
41
|
+
])
|
42
|
+
end
|
43
|
+
|
44
|
+
def size_class
|
45
|
+
"badge-#{@size}" if SIZES.include?(@size)
|
46
|
+
end
|
47
|
+
|
48
|
+
def color_class
|
49
|
+
"badge-#{@color}" if COLORS.include?(@color)
|
50
|
+
end
|
51
|
+
|
52
|
+
def kind_class
|
53
|
+
"badge-#{@kind}" if KINDS.include?(@kind)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Action
|
4
|
+
module ButtonHelper
|
5
|
+
def action_button_handle_component_params(kind_key:, color_key:)
|
6
|
+
params = { kind: "#{kind_key}", color: "#{color_key}" }
|
7
|
+
|
8
|
+
params.delete(:color) if color_key == "default"
|
9
|
+
|
10
|
+
params.compact_blank.filter_map { |k, v| "#{k}: #{v.inspect}" }.join(", ")
|
11
|
+
end
|
12
|
+
|
13
|
+
def action_button_skip_kind(kind_key:, color_key:)
|
14
|
+
kind_key == "disabled" && color_key != "default" ||
|
15
|
+
kind_key == "link" && %w[primary secondary].include?(color_key)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Action
|
4
|
+
module DropdownHelper
|
5
|
+
def action_dropdown_handle_component_title(axis_key:, align_key:)
|
6
|
+
"# Dropdown #{axis_key} #{"(default)" if axis_key == "bottom"} /
|
7
|
+
aligns to #{align_key} #{"(default)" if align_key == "start"} of button horizontally"
|
8
|
+
end
|
9
|
+
|
10
|
+
def action_dropdown_handle_component_params(axis_key:, align_key:)
|
11
|
+
params = { axis: "#{axis_key}", align: "#{align_key}" }
|
12
|
+
|
13
|
+
params.delete(:axis) if axis_key == "bottom"
|
14
|
+
params.delete(:align) if align_key == "start"
|
15
|
+
|
16
|
+
params.filter_map { |k, v| "#{k}: #{v.inspect}" }.join(", ")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DataDisplay
|
4
|
+
module BadgeHelper
|
5
|
+
def data_display_badge_handle_component_params(kind_key:, color_key:)
|
6
|
+
params = { kind: "#{kind_key}", color: "#{color_key}" }
|
7
|
+
|
8
|
+
params.delete(:color) if kind_key == "ghost" && color_key == "primary"
|
9
|
+
|
10
|
+
params.compact_blank.filter_map { |k, v| "#{k}: #{v.inspect}" }.join(", ")
|
11
|
+
end
|
12
|
+
|
13
|
+
def data_display_badge_skip_kind(kind_key:, color_key:)
|
14
|
+
kind_key == "ghost" && color_key != "primary"
|
15
|
+
end
|
16
|
+
|
17
|
+
def data_display_badge_icons
|
18
|
+
{
|
19
|
+
"info" => '<svg class="size-[1em]" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="currentColor"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/></svg>',
|
20
|
+
"success" => '<svg class="size-[1em]" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="currentColor"><path d="M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q65 0 123 19t107 53l-58 59q-38-24-81-37.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160q133 0 226.5-93.5T800-480q0-18-2-36t-6-35l65-65q11 32 17 66t6 70q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm-56-216L254-466l56-56 114 114 400-401 56 56-456 457Z"/></svg>',
|
21
|
+
"warning" => '<svg class="size-[1em]" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="currentColor"><path d="m40-120 440-760 440 760H40Zm138-80h604L480-720 178-200Zm302-40q17 0 28.5-11.5T520-280q0-17-11.5-28.5T480-320q-17 0-28.5 11.5T440-280q0 17 11.5 28.5T480-240Zm-40-120h80v-200h-80v200Zm40-100Z"/></svg>',
|
22
|
+
"error" => '<svg class="size-[1em]" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="currentColor"><path d="M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q54 0 104-17.5t92-50.5L228-676q-33 42-50.5 92T160-480q0 134 93 227t227 93Zm252-124q33-42 50.5-92T800-480q0-134-93-227t-227-93q-54 0-104 17.5T284-732l448 448Z"/></svg>'
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
<% component = UiComponents::DaisyUi::Action::ButtonComponent %>
|
2
|
+
|
3
|
+
<div class="grid grid-cols gap-16 p-2 mt-6 mb-36">
|
4
|
+
<div class="mb-2">
|
5
|
+
<h1 class="font-bold mb-2"># Actions > Button</h1>
|
6
|
+
<ul class="bg-base-100 rounded-box shadow-md p-2">
|
7
|
+
<%= link_to "Home", daisy_ui_path, class: "link link-primary m-2" %>
|
8
|
+
<%= link_to "Dropdown >", daisy_ui_dropdown_path, class: "link link-primary m-2" %>
|
9
|
+
</ul>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<%= render DocumentationComponent.new do |document| %>
|
13
|
+
<%= document.with_header { "# Button" } %>
|
14
|
+
<%= document.with_body do |body| %>
|
15
|
+
<%= body.with_preview_example(
|
16
|
+
source: <<~ERB
|
17
|
+
<$= render #{component}.new do $>
|
18
|
+
Default
|
19
|
+
<$ end $>
|
20
|
+
ERB
|
21
|
+
) %>
|
22
|
+
<% end %>
|
23
|
+
<% end %>
|
24
|
+
|
25
|
+
<% sizes = { 'xs' => 'Xsmall', 'sm' => 'Small', 'md' => 'Medium', 'lg' => 'Large', 'xl' => 'Xlarge' } %>
|
26
|
+
|
27
|
+
<%= render DocumentationComponent.new do |document| %>
|
28
|
+
<%= document.with_header { "# Button sizes" } %>
|
29
|
+
<%= document.with_body do |body| %>
|
30
|
+
<% sizes.each do |key, value| %>
|
31
|
+
<%= body.with_preview_example(
|
32
|
+
source: <<~ERB
|
33
|
+
<$= render #{component}.new#{"(size: \"#{key}\")" if key != "md"} do $>
|
34
|
+
#{value}
|
35
|
+
<$ end $>
|
36
|
+
ERB
|
37
|
+
) %>
|
38
|
+
<% end %>
|
39
|
+
<% end %>
|
40
|
+
<% end %>
|
41
|
+
|
42
|
+
<% colors = { 'default' => 'Default', 'primary' => 'Primary', 'secondary' => 'Secondary', 'accent' => 'Accent', 'info' => 'Info', 'success' => 'Success', 'warning' => 'Warning', 'error' => 'Error' } %>
|
43
|
+
|
44
|
+
<%= render DocumentationComponent.new do |document| %>
|
45
|
+
<%= document.with_header { "# Button colors" } %>
|
46
|
+
<%= document.with_body do |body| %>
|
47
|
+
<% colors.each do |key, value| %>
|
48
|
+
<%= body.with_preview_example(
|
49
|
+
source: <<~ERB
|
50
|
+
<$= render #{component}.new#{"(color: \"#{key}\")" if key != "default"} do $>
|
51
|
+
#{value}
|
52
|
+
<$ end $>
|
53
|
+
ERB
|
54
|
+
) %>
|
55
|
+
<% end %>
|
56
|
+
<% end %>
|
57
|
+
<% end %>
|
58
|
+
|
59
|
+
<% kinds = { 'soft' => 'Soft', 'outline' => 'Outline', 'dash' => 'Dash', 'active' => 'Active', 'disabled' => 'Disabled', 'ghost' => 'Ghost', 'link' => 'Link' } %>
|
60
|
+
|
61
|
+
<% kinds.each do |kind_key, kind_value| %>
|
62
|
+
<%= render DocumentationComponent.new do |document| %>
|
63
|
+
<%= document.with_header { "# #{kind_value} buttons" } %>
|
64
|
+
<%= document.with_body do |body| %>
|
65
|
+
<% colors.each do |color_key, value| %>
|
66
|
+
|
67
|
+
<% next if action_button_skip_kind(kind_key:, color_key:) %>
|
68
|
+
|
69
|
+
<%= body.with_preview_example(
|
70
|
+
source: <<~ERB
|
71
|
+
<$= render #{component}.new(#{action_button_handle_component_params(kind_key:, color_key:)}) do $>
|
72
|
+
#{value}
|
73
|
+
<$ end $>
|
74
|
+
ERB
|
75
|
+
) %>
|
76
|
+
<% end %>
|
77
|
+
<% end %>
|
78
|
+
<% end %>
|
79
|
+
<% end %>
|
80
|
+
|
81
|
+
<% wide_sizes = { 'wide' => 'Wide', 'block' => 'Block' } %>
|
82
|
+
|
83
|
+
<%= render DocumentationComponent.new do |document| %>
|
84
|
+
<%= document.with_header { "# Wide buttons" } %>
|
85
|
+
<%= document.with_body do |body| %>
|
86
|
+
<% wide_sizes.each do |key, value| %>
|
87
|
+
<%= body.with_preview_example(
|
88
|
+
source: <<~ERB
|
89
|
+
<$= render #{component}.new(wide_size: "#{key}") do $>
|
90
|
+
#{value}
|
91
|
+
<$ end $>
|
92
|
+
ERB
|
93
|
+
) %>
|
94
|
+
<% end %>
|
95
|
+
<% end %>
|
96
|
+
<% end %>
|
97
|
+
|
98
|
+
<% shapes = { 'square' => 'Square', 'circle' => 'Circle' } %>
|
99
|
+
|
100
|
+
<%= render DocumentationComponent.new do |document| %>
|
101
|
+
<%= document.with_header { "# Shape buttons" } %>
|
102
|
+
<%= document.with_body do |body| %>
|
103
|
+
<% shapes.each do |key, value| %>
|
104
|
+
<%= body.with_preview_example(
|
105
|
+
source: <<~ERB
|
106
|
+
<$= render #{component}.new(shape: "#{key}") do $>
|
107
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="18px" viewBox="0 -960 960 960" width="18px" fill="currentColor"><path d="M720-120H280v-520l280-280 50 50q7 7 11.5 19t4.5 23v14l-44 174h258q32 0 56 24t24 56v80q0 7-2 15t-4 15L794-168q-9 20-30 34t-44 14Zm-360-80h360l120-280v-80H480l54-220-174 174v406Zm0-406v406-406Zm-80-34v80H160v360h120v80H80v-520h200Z"/></svg>
|
108
|
+
<$ end $>
|
109
|
+
ERB
|
110
|
+
) %>
|
111
|
+
<% end %>
|
112
|
+
<% end %>
|
113
|
+
<% end %>
|
114
|
+
</div>
|
@@ -0,0 +1,117 @@
|
|
1
|
+
<% component = UiComponents::DaisyUi::Action::DropdownComponent %>
|
2
|
+
|
3
|
+
<div class="grid grid-cols gap-16 p-2 mt-6 mb-36">
|
4
|
+
<div class="mb-2">
|
5
|
+
<h1 class="font-bold mb-2"># Actions > Dropdown</h1>
|
6
|
+
<ul class="bg-base-100 rounded-box shadow-md p-2">
|
7
|
+
<%= link_to "< Button", daisy_ui_button_path, class: "link link-primary m-2" %>
|
8
|
+
<%= link_to "Home", daisy_ui_path, class: "link link-primary m-2" %>
|
9
|
+
<%= link_to "Modal >", daisy_ui_modal_path, class: "link link-primary m-2" %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<%= render DocumentationComponent.new do |document| %>
|
14
|
+
<%= document.with_header { "# Dropdown" } %>
|
15
|
+
<%= document.with_body(preview_options: { css_class: "text-center" }) do |body| %>
|
16
|
+
<%= body.with_preview_example(
|
17
|
+
source: <<~ERB
|
18
|
+
<$= render #{component}.new do |dropdown| $>
|
19
|
+
<$= dropdown.with_anchor { "Click" } $>
|
20
|
+
<$= dropdown.with_menu do |menu| $>
|
21
|
+
<$= menu.with_item { "Item 1" } $>
|
22
|
+
<$= menu.with_item { "Item 2" } $>
|
23
|
+
<$ end $>
|
24
|
+
<$ end $>
|
25
|
+
ERB
|
26
|
+
) %>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
<% aligns = %w[start center end] %>
|
31
|
+
<% axes = %w[top right bottom left] %>
|
32
|
+
|
33
|
+
<% axes.each do |axis_key| %>
|
34
|
+
<% aligns.each do |align_key| %>
|
35
|
+
<%= render DocumentationComponent.new do |document| %>
|
36
|
+
<%= document.with_header { action_dropdown_handle_component_title(axis_key:, align_key:) } %>
|
37
|
+
<%= document.with_body(preview_options: { css_class: "text-center" }) do |body| %>
|
38
|
+
<% component_params = action_dropdown_handle_component_params(axis_key:, align_key:) %>
|
39
|
+
|
40
|
+
<%= body.with_preview_example(
|
41
|
+
source: <<~ERB
|
42
|
+
<$= render #{component}.new#{"(#{component_params})" if component_params.present?} do |dropdown| $>
|
43
|
+
<$= dropdown.with_anchor { "Click" } $>
|
44
|
+
<$= dropdown.with_menu do |menu| $>
|
45
|
+
<$= menu.with_item { "Item 1" } $>
|
46
|
+
<$= menu.with_item { "Item 2" } $>
|
47
|
+
<$ end $>
|
48
|
+
<$ end $>
|
49
|
+
ERB
|
50
|
+
) %>
|
51
|
+
<% end %>
|
52
|
+
<% end %>
|
53
|
+
<% end %>
|
54
|
+
<% end %>
|
55
|
+
|
56
|
+
<% events = %w[hover opened] %>
|
57
|
+
|
58
|
+
<% events.each do |key| %>
|
59
|
+
<%= render DocumentationComponent.new do |document| %>
|
60
|
+
<%= document.with_header { "# Dropdown - #{key}" } %>
|
61
|
+
<%= document.with_body(preview_options: { css_class: "text-center" }) do |body| %>
|
62
|
+
<%= body.with_preview_example(
|
63
|
+
source: <<~ERB
|
64
|
+
<$= render #{component}.new(#{key}: true) do |dropdown| $>
|
65
|
+
<$= dropdown.with_anchor { "Click" } $>
|
66
|
+
<$= dropdown.with_menu do |menu| $>
|
67
|
+
<$= menu.with_item { "Item 1" } $>
|
68
|
+
<$= menu.with_item { "Item 2" } $>
|
69
|
+
<$ end $>
|
70
|
+
<$ end $>
|
71
|
+
ERB
|
72
|
+
) %>
|
73
|
+
<% end %>
|
74
|
+
<% end %>
|
75
|
+
<% end %>
|
76
|
+
|
77
|
+
<%= render DocumentationComponent.new do |document| %>
|
78
|
+
<%= document.with_header { "# Card as dropdown" } %>
|
79
|
+
<%= document.with_body(preview_options: { css_class: "text-center" }) do |body| %>
|
80
|
+
<%= body.with_preview_example(
|
81
|
+
source: <<~ERB
|
82
|
+
<$= render #{component}.new do |dropdown| $>
|
83
|
+
<$= dropdown.with_anchor(css_class: "m-1") { "Click" } $>
|
84
|
+
<$= dropdown.with_card do |card| $>
|
85
|
+
<$= card.with_item do $>
|
86
|
+
<p>This is a card. You can use any element as a dropdown.</p>
|
87
|
+
<$ end $>
|
88
|
+
<$ end $>
|
89
|
+
<$ end $>
|
90
|
+
ERB
|
91
|
+
) %>
|
92
|
+
<% end %>
|
93
|
+
<% end %>
|
94
|
+
|
95
|
+
<%= render DocumentationComponent.new do |document| %>
|
96
|
+
<%= document.with_header { "# Helper dropdown" } %>
|
97
|
+
<%= document.with_body(preview_options: { css_class: "text-center" }) do |body| %>
|
98
|
+
<%= body.with_preview_example(
|
99
|
+
source: <<~ERB
|
100
|
+
A normal text and a helper dropdown
|
101
|
+
<$= render #{component}.new do |dropdown| $>
|
102
|
+
<$= dropdown.with_anchor(css_class: "btn-circle btn-ghost btn-xs text-info") do $>
|
103
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="currentColor"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/></svg>
|
104
|
+
<$ end $>
|
105
|
+
|
106
|
+
<$= dropdown.with_card do |card| $>
|
107
|
+
<$= card.with_item(options: { tabindex: "0" }) do $>
|
108
|
+
<h2 class="card-title">You needed more info?</h2>
|
109
|
+
<p>This is a card. You can use any element as a dropdown.</p>
|
110
|
+
<$ end $>
|
111
|
+
<$ end $>
|
112
|
+
<$ end $>
|
113
|
+
ERB
|
114
|
+
) %>
|
115
|
+
<% end %>
|
116
|
+
<% end %>
|
117
|
+
</div>
|