better_ui 0.9.0 → 0.9.1
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/lib/better_ui/version.rb +1 -1
- data/spec/components/previews/better_ui/action_messages_component_preview/all_styles.html.erb +17 -0
- data/spec/components/previews/better_ui/action_messages_component_preview/all_variants.html.erb +19 -0
- data/spec/components/previews/better_ui/action_messages_component_preview/auto_dismiss.html.erb +51 -0
- data/spec/components/previews/better_ui/action_messages_component_preview/dismissible.html.erb +19 -0
- data/spec/components/previews/better_ui/action_messages_component_preview/with_title.html.erb +17 -0
- data/spec/components/previews/better_ui/action_messages_component_preview.rb +224 -0
- data/spec/components/previews/better_ui/avatar_component_preview/all_shapes.html.erb +26 -0
- data/spec/components/previews/better_ui/avatar_component_preview/all_sizes.html.erb +24 -0
- data/spec/components/previews/better_ui/avatar_component_preview/all_variants.html.erb +12 -0
- data/spec/components/previews/better_ui/avatar_component_preview/with_initials.html.erb +22 -0
- data/spec/components/previews/better_ui/avatar_component_preview/with_status.html.erb +26 -0
- data/spec/components/previews/better_ui/avatar_component_preview.rb +73 -0
- data/spec/components/previews/better_ui/badge_component_preview/all_sizes.html.erb +29 -0
- data/spec/components/previews/better_ui/badge_component_preview/all_styles.html.erb +26 -0
- data/spec/components/previews/better_ui/badge_component_preview/all_variants.html.erb +14 -0
- data/spec/components/previews/better_ui/badge_component_preview/counter_badges.html.erb +39 -0
- data/spec/components/previews/better_ui/badge_component_preview/dot_badges.html.erb +28 -0
- data/spec/components/previews/better_ui/badge_component_preview.rb +69 -0
- data/spec/components/previews/better_ui/breadcrumb/breadcrumb_component_preview/all_separators.html.erb +47 -0
- data/spec/components/previews/better_ui/breadcrumb/breadcrumb_component_preview/default.html.erb +23 -0
- data/spec/components/previews/better_ui/breadcrumb/breadcrumb_component_preview/with_icons.html.erb +43 -0
- data/spec/components/previews/better_ui/breadcrumb/breadcrumb_component_preview.rb +38 -0
- data/spec/components/previews/better_ui/button_component_preview/all_sizes.html.erb +25 -0
- data/spec/components/previews/better_ui/button_component_preview/all_variants.html.erb +14 -0
- data/spec/components/previews/better_ui/button_component_preview/as_links.html.erb +18 -0
- data/spec/components/previews/better_ui/button_component_preview/auto_loading_submit.html.erb +112 -0
- data/spec/components/previews/better_ui/button_component_preview/external_links.html.erb +61 -0
- data/spec/components/previews/better_ui/button_component_preview/form_integration.html.erb +102 -0
- data/spec/components/previews/better_ui/button_component_preview/interactive.html.erb +149 -0
- data/spec/components/previews/better_ui/button_component_preview/link_states.html.erb +36 -0
- data/spec/components/previews/better_ui/button_component_preview/loading_states.html.erb +62 -0
- data/spec/components/previews/better_ui/button_component_preview/turbo_method_links.html.erb +98 -0
- data/spec/components/previews/better_ui/button_component_preview/with_icons.html.erb +123 -0
- data/spec/components/previews/better_ui/button_component_preview.rb +155 -0
- data/spec/components/previews/better_ui/card_component_preview/all_sizes.html.erb +10 -0
- data/spec/components/previews/better_ui/card_component_preview/all_styles.html.erb +22 -0
- data/spec/components/previews/better_ui/card_component_preview/all_variants.html.erb +10 -0
- data/spec/components/previews/better_ui/card_component_preview.rb +269 -0
- data/spec/components/previews/better_ui/container_component_preview/all_sizes.html.erb +13 -0
- data/spec/components/previews/better_ui/container_component_preview.rb +59 -0
- data/spec/components/previews/better_ui/dialog/alert_component_preview/all_variants.html.erb +17 -0
- data/spec/components/previews/better_ui/dialog/alert_component_preview/custom_button_label.html.erb +14 -0
- data/spec/components/previews/better_ui/dialog/alert_component_preview/default.html.erb +13 -0
- data/spec/components/previews/better_ui/dialog/alert_component_preview/playground.html.erb +16 -0
- data/spec/components/previews/better_ui/dialog/alert_component_preview/without_icon.html.erb +14 -0
- data/spec/components/previews/better_ui/dialog/alert_component_preview.rb +57 -0
- data/spec/components/previews/better_ui/dialog/confirm_component_preview/all_variants.html.erb +17 -0
- data/spec/components/previews/better_ui/dialog/confirm_component_preview/custom_labels.html.erb +15 -0
- data/spec/components/previews/better_ui/dialog/confirm_component_preview/danger_confirm.html.erb +15 -0
- data/spec/components/previews/better_ui/dialog/confirm_component_preview/default.html.erb +13 -0
- data/spec/components/previews/better_ui/dialog/confirm_component_preview/playground.html.erb +17 -0
- data/spec/components/previews/better_ui/dialog/confirm_component_preview.rb +60 -0
- data/spec/components/previews/better_ui/dialog/dialog_component_preview/all_sizes.html.erb +32 -0
- data/spec/components/previews/better_ui/dialog/dialog_component_preview/default.html.erb +34 -0
- data/spec/components/previews/better_ui/dialog/dialog_component_preview/no_close_button.html.erb +28 -0
- data/spec/components/previews/better_ui/dialog/dialog_component_preview/playground.html.erb +39 -0
- data/spec/components/previews/better_ui/dialog/dialog_component_preview/with_all_slots.html.erb +52 -0
- data/spec/components/previews/better_ui/dialog/dialog_component_preview.rb +51 -0
- data/spec/components/previews/better_ui/divider_component_preview/all_styles.html.erb +58 -0
- data/spec/components/previews/better_ui/divider_component_preview/with_labels.html.erb +67 -0
- data/spec/components/previews/better_ui/divider_component_preview.rb +62 -0
- data/spec/components/previews/better_ui/drawer/header_component_preview.rb +169 -0
- data/spec/components/previews/better_ui/drawer/layout_component_preview/complete_layout.html.erb +87 -0
- data/spec/components/previews/better_ui/drawer/layout_component_preview/dark_theme.html.erb +36 -0
- data/spec/components/previews/better_ui/drawer/layout_component_preview/dashboard_example.html.erb +188 -0
- data/spec/components/previews/better_ui/drawer/layout_component_preview/default.html.erb +22 -0
- data/spec/components/previews/better_ui/drawer/layout_component_preview/primary_theme.html.erb +36 -0
- data/spec/components/previews/better_ui/drawer/layout_component_preview/right_sidebar.html.erb +44 -0
- data/spec/components/previews/better_ui/drawer/layout_component_preview/with_header_only.html.erb +20 -0
- data/spec/components/previews/better_ui/drawer/layout_component_preview/with_sidebar_only.html.erb +21 -0
- data/spec/components/previews/better_ui/drawer/layout_component_preview.rb +91 -0
- data/spec/components/previews/better_ui/drawer/nav_group_component_preview/complete_navigation.html.erb +55 -0
- data/spec/components/previews/better_ui/drawer/nav_group_component_preview.rb +163 -0
- data/spec/components/previews/better_ui/drawer/nav_item_component_preview.rb +104 -0
- data/spec/components/previews/better_ui/drawer/sidebar_component_preview.rb +212 -0
- data/spec/components/previews/better_ui/dropdown/dropdown_component_preview/all_sizes.html.erb +19 -0
- data/spec/components/previews/better_ui/dropdown/dropdown_component_preview/default.html.erb +12 -0
- data/spec/components/previews/better_ui/dropdown/dropdown_component_preview/disabled_items.html.erb +14 -0
- data/spec/components/previews/better_ui/dropdown/dropdown_component_preview/placement_options.html.erb +16 -0
- data/spec/components/previews/better_ui/dropdown/dropdown_component_preview/playground.html.erb +35 -0
- data/spec/components/previews/better_ui/dropdown/dropdown_component_preview/with_dividers_and_headers.html.erb +18 -0
- data/spec/components/previews/better_ui/dropdown/dropdown_component_preview/with_icons.html.erb +34 -0
- data/spec/components/previews/better_ui/dropdown/dropdown_component_preview.rb +59 -0
- data/spec/components/previews/better_ui/fa_icon_component_preview/all_sizes.html.erb +17 -0
- data/spec/components/previews/better_ui/fa_icon_component_preview/all_styles.html.erb +19 -0
- data/spec/components/previews/better_ui/fa_icon_component_preview/all_variants.html.erb +26 -0
- data/spec/components/previews/better_ui/fa_icon_component_preview/animations.html.erb +26 -0
- data/spec/components/previews/better_ui/fa_icon_component_preview/transformations.html.erb +88 -0
- data/spec/components/previews/better_ui/fa_icon_component_preview.rb +85 -0
- data/spec/components/previews/better_ui/forms/checkbox_component_preview/all_sizes.html.erb +12 -0
- data/spec/components/previews/better_ui/forms/checkbox_component_preview/all_variants.html.erb +12 -0
- data/spec/components/previews/better_ui/forms/checkbox_component_preview/form_integration.html.erb +32 -0
- data/spec/components/previews/better_ui/forms/checkbox_component_preview.rb +143 -0
- data/spec/components/previews/better_ui/forms/checkbox_group_component_preview/all_variants.html.erb +14 -0
- data/spec/components/previews/better_ui/forms/checkbox_group_component_preview/form_integration.html.erb +47 -0
- data/spec/components/previews/better_ui/forms/checkbox_group_component_preview/orientations.html.erb +34 -0
- data/spec/components/previews/better_ui/forms/checkbox_group_component_preview.rb +150 -0
- data/spec/components/previews/better_ui/forms/number_input_component_preview/all_sizes.html.erb +14 -0
- data/spec/components/previews/better_ui/forms/number_input_component_preview/form_integration.html.erb +45 -0
- data/spec/components/previews/better_ui/forms/number_input_component_preview.rb +211 -0
- data/spec/components/previews/better_ui/forms/password_input_component_preview/all_sizes.html.erb +12 -0
- data/spec/components/previews/better_ui/forms/password_input_component_preview/confirm_password_example.html.erb +29 -0
- data/spec/components/previews/better_ui/forms/password_input_component_preview/form_integration.html.erb +34 -0
- data/spec/components/previews/better_ui/forms/password_input_component_preview.rb +181 -0
- data/spec/components/previews/better_ui/forms/select_component_preview/all_sizes.html.erb +13 -0
- data/spec/components/previews/better_ui/forms/select_component_preview/all_states.html.erb +64 -0
- data/spec/components/previews/better_ui/forms/select_component_preview.rb +167 -0
- data/spec/components/previews/better_ui/forms/text_input_component_preview/all_sizes.html.erb +12 -0
- data/spec/components/previews/better_ui/forms/text_input_component_preview/all_types.html.erb +12 -0
- data/spec/components/previews/better_ui/forms/text_input_component_preview/form_integration.html.erb +33 -0
- data/spec/components/previews/better_ui/forms/text_input_component_preview.rb +247 -0
- data/spec/components/previews/better_ui/forms/textarea_component_preview/all_resize_variants.html.erb +13 -0
- data/spec/components/previews/better_ui/forms/textarea_component_preview/all_sizes.html.erb +12 -0
- data/spec/components/previews/better_ui/forms/textarea_component_preview/form_integration.html.erb +36 -0
- data/spec/components/previews/better_ui/forms/textarea_component_preview.rb +239 -0
- data/spec/components/previews/better_ui/heading_component_preview/all_alignments.html.erb +12 -0
- data/spec/components/previews/better_ui/heading_component_preview/all_levels.html.erb +7 -0
- data/spec/components/previews/better_ui/heading_component_preview/all_variants.html.erb +14 -0
- data/spec/components/previews/better_ui/heading_component_preview.rb +113 -0
- data/spec/components/previews/better_ui/link_component_preview/all_sizes.html.erb +25 -0
- data/spec/components/previews/better_ui/link_component_preview/all_styles.html.erb +14 -0
- data/spec/components/previews/better_ui/link_component_preview/all_variants.html.erb +14 -0
- data/spec/components/previews/better_ui/link_component_preview/with_icons.html.erb +66 -0
- data/spec/components/previews/better_ui/link_component_preview.rb +66 -0
- data/spec/components/previews/better_ui/progress_component_preview/all_sizes.html.erb +15 -0
- data/spec/components/previews/better_ui/progress_component_preview/all_variants.html.erb +11 -0
- data/spec/components/previews/better_ui/progress_component_preview.rb +64 -0
- data/spec/components/previews/better_ui/spinner_component_preview/all_sizes.html.erb +17 -0
- data/spec/components/previews/better_ui/spinner_component_preview/all_variants.html.erb +11 -0
- data/spec/components/previews/better_ui/spinner_component_preview.rb +44 -0
- data/spec/components/previews/better_ui/table/table_component_preview/all_sizes.html.erb +28 -0
- data/spec/components/previews/better_ui/table/table_component_preview/all_variants.html.erb +34 -0
- data/spec/components/previews/better_ui/table/table_component_preview/bordered.html.erb +33 -0
- data/spec/components/previews/better_ui/table/table_component_preview/collection_mode.html.erb +31 -0
- data/spec/components/previews/better_ui/table/table_component_preview/default.html.erb +33 -0
- data/spec/components/previews/better_ui/table/table_component_preview/empty_state.html.erb +36 -0
- data/spec/components/previews/better_ui/table/table_component_preview/highlighted.html.erb +64 -0
- data/spec/components/previews/better_ui/table/table_component_preview/hoverable.html.erb +27 -0
- data/spec/components/previews/better_ui/table/table_component_preview/inside_card.html.erb +173 -0
- data/spec/components/previews/better_ui/table/table_component_preview/sortable.html.erb +44 -0
- data/spec/components/previews/better_ui/table/table_component_preview/striped.html.erb +31 -0
- data/spec/components/previews/better_ui/table/table_component_preview/with_footer.html.erb +40 -0
- data/spec/components/previews/better_ui/table/table_component_preview.rb +79 -0
- data/spec/components/previews/better_ui/tabs/container_component_preview/alignments.html.erb +24 -0
- data/spec/components/previews/better_ui/tabs/container_component_preview/all_sizes.html.erb +24 -0
- data/spec/components/previews/better_ui/tabs/container_component_preview/all_variants.html.erb +24 -0
- data/spec/components/previews/better_ui/tabs/container_component_preview/bordered_style.html.erb +30 -0
- data/spec/components/previews/better_ui/tabs/container_component_preview/default.html.erb +30 -0
- data/spec/components/previews/better_ui/tabs/container_component_preview/disabled_tab.html.erb +65 -0
- data/spec/components/previews/better_ui/tabs/container_component_preview/pills_style.html.erb +34 -0
- data/spec/components/previews/better_ui/tabs/container_component_preview/turbo_mode.html.erb +40 -0
- data/spec/components/previews/better_ui/tabs/container_component_preview/vertical_left.html.erb +38 -0
- data/spec/components/previews/better_ui/tabs/container_component_preview/vertical_right.html.erb +30 -0
- data/spec/components/previews/better_ui/tabs/container_component_preview/with_icons_and_badges.html.erb +71 -0
- data/spec/components/previews/better_ui/tabs/container_component_preview.rb +130 -0
- data/spec/components/previews/better_ui/tag_component_preview/all_styles.html.erb +14 -0
- data/spec/components/previews/better_ui/tag_component_preview/all_variants.html.erb +14 -0
- data/spec/components/previews/better_ui/tag_component_preview/as_links.html.erb +14 -0
- data/spec/components/previews/better_ui/tag_component_preview/dismissible.html.erb +34 -0
- data/spec/components/previews/better_ui/tag_component_preview.rb +56 -0
- data/spec/components/previews/better_ui/tooltip_component_preview/all_positions.html.erb +25 -0
- data/spec/components/previews/better_ui/tooltip_component_preview/variants.html.erb +37 -0
- data/spec/components/previews/better_ui/tooltip_component_preview.rb +40 -0
- metadata +164 -1
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module BetterUi
|
|
4
|
+
module Drawer
|
|
5
|
+
# @label Nav Group
|
|
6
|
+
class NavGroupComponentPreview < ViewComponent::Preview
|
|
7
|
+
# @label Default
|
|
8
|
+
def default
|
|
9
|
+
render BetterUi::Drawer::NavGroupComponent.new(title: "Main") do |group|
|
|
10
|
+
group.with_item(label: "Dashboard", href: "#", active: true) do |item|
|
|
11
|
+
item.with_icon { dashboard_icon }
|
|
12
|
+
end
|
|
13
|
+
group.with_item(label: "Projects", href: "#") do |item|
|
|
14
|
+
item.with_icon { projects_icon }
|
|
15
|
+
end
|
|
16
|
+
group.with_item(label: "Team", href: "#") do |item|
|
|
17
|
+
item.with_icon { team_icon }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @label Without Title
|
|
23
|
+
def without_title
|
|
24
|
+
render BetterUi::Drawer::NavGroupComponent.new do |group|
|
|
25
|
+
group.with_item(label: "Dashboard", href: "#", active: true) do |item|
|
|
26
|
+
item.with_icon { dashboard_icon }
|
|
27
|
+
end
|
|
28
|
+
group.with_item(label: "Settings", href: "#") do |item|
|
|
29
|
+
item.with_icon { settings_icon }
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# @label With Badges
|
|
35
|
+
def with_badges
|
|
36
|
+
render BetterUi::Drawer::NavGroupComponent.new(title: "Messages") do |group|
|
|
37
|
+
group.with_item(label: "Inbox", href: "#", active: true) do |item|
|
|
38
|
+
item.with_icon { inbox_icon }
|
|
39
|
+
item.with_badge { "12" }
|
|
40
|
+
end
|
|
41
|
+
group.with_item(label: "Sent", href: "#") do |item|
|
|
42
|
+
item.with_icon { sent_icon }
|
|
43
|
+
end
|
|
44
|
+
group.with_item(label: "Drafts", href: "#") do |item|
|
|
45
|
+
item.with_icon { drafts_icon }
|
|
46
|
+
item.with_badge { "3" }
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# @label Dark Variant
|
|
52
|
+
# @display bg_color #1f2937
|
|
53
|
+
def dark_variant
|
|
54
|
+
render BetterUi::Drawer::NavGroupComponent.new(title: "Main", variant: :dark) do |group|
|
|
55
|
+
group.with_item(label: "Dashboard", href: "#", active: true) do |item|
|
|
56
|
+
item.with_icon { dashboard_icon }
|
|
57
|
+
end
|
|
58
|
+
group.with_item(label: "Projects", href: "#") do |item|
|
|
59
|
+
item.with_icon { projects_icon }
|
|
60
|
+
end
|
|
61
|
+
group.with_item(label: "Team", href: "#") do |item|
|
|
62
|
+
item.with_icon { team_icon }
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# @label Primary Variant
|
|
68
|
+
# @display bg_color #1d4ed8
|
|
69
|
+
def primary_variant
|
|
70
|
+
render BetterUi::Drawer::NavGroupComponent.new(title: "Main", variant: :primary) do |group|
|
|
71
|
+
group.with_item(label: "Dashboard", href: "#", active: true) do |item|
|
|
72
|
+
item.with_icon { dashboard_icon }
|
|
73
|
+
end
|
|
74
|
+
group.with_item(label: "Projects", href: "#") do |item|
|
|
75
|
+
item.with_icon { projects_icon }
|
|
76
|
+
end
|
|
77
|
+
group.with_item(label: "Team", href: "#") do |item|
|
|
78
|
+
item.with_icon { team_icon }
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# @label With HTTP Method
|
|
84
|
+
def with_http_method
|
|
85
|
+
render BetterUi::Drawer::NavGroupComponent.new(title: "Account") do |group|
|
|
86
|
+
group.with_item(label: "Settings", href: "#") do |item|
|
|
87
|
+
item.with_icon { settings_icon }
|
|
88
|
+
end
|
|
89
|
+
group.with_item(label: "Help", href: "#") do |item|
|
|
90
|
+
item.with_icon { help_icon }
|
|
91
|
+
end
|
|
92
|
+
group.with_item(label: "Logout", href: "#", method: :delete) do |item|
|
|
93
|
+
item.with_icon { logout_icon }
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# @label Complete Sidebar Navigation
|
|
99
|
+
def complete_navigation
|
|
100
|
+
render_with_template
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# @label Playground
|
|
104
|
+
# @param title text
|
|
105
|
+
# @param variant select { choices: [light, dark, primary] }
|
|
106
|
+
def playground(title: "Navigation", variant: :light)
|
|
107
|
+
render BetterUi::Drawer::NavGroupComponent.new(
|
|
108
|
+
title: title.present? ? title : nil,
|
|
109
|
+
variant: variant.to_sym
|
|
110
|
+
) do |group|
|
|
111
|
+
group.with_item(label: "Dashboard", href: "#", active: true) do |item|
|
|
112
|
+
item.with_icon { dashboard_icon }
|
|
113
|
+
end
|
|
114
|
+
group.with_item(label: "Projects", href: "#") do |item|
|
|
115
|
+
item.with_icon { projects_icon }
|
|
116
|
+
end
|
|
117
|
+
group.with_item(label: "Messages", href: "#") do |item|
|
|
118
|
+
item.with_icon { inbox_icon }
|
|
119
|
+
item.with_badge { "5" }
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
private
|
|
125
|
+
|
|
126
|
+
def dashboard_icon
|
|
127
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6'></path></svg>".html_safe
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def projects_icon
|
|
131
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10'></path></svg>".html_safe
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def team_icon
|
|
135
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z'></path></svg>".html_safe
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def settings_icon
|
|
139
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z'></path><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M15 12a3 3 0 11-6 0 3 3 0 016 0z'></path></svg>".html_safe
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def help_icon
|
|
143
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z'></path></svg>".html_safe
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def logout_icon
|
|
147
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1'></path></svg>".html_safe
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def inbox_icon
|
|
151
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4'></path></svg>".html_safe
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def sent_icon
|
|
155
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 19l9 2-9-18-9 18 9-2zm0 0v-8'></path></svg>".html_safe
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def drafts_icon
|
|
159
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z'></path></svg>".html_safe
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module BetterUi
|
|
4
|
+
module Drawer
|
|
5
|
+
# @label Nav Item
|
|
6
|
+
class NavItemComponentPreview < ViewComponent::Preview
|
|
7
|
+
# @label Default
|
|
8
|
+
def default
|
|
9
|
+
render BetterUi::Drawer::NavItemComponent.new(label: "Dashboard", href: "#")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# @label With Icon
|
|
13
|
+
def with_icon
|
|
14
|
+
render BetterUi::Drawer::NavItemComponent.new(label: "Dashboard", href: "#") do |item|
|
|
15
|
+
item.with_icon do
|
|
16
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6'></path></svg>".html_safe
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @label Active State
|
|
22
|
+
def active_state
|
|
23
|
+
render BetterUi::Drawer::NavItemComponent.new(label: "Dashboard", href: "#", active: true) do |item|
|
|
24
|
+
item.with_icon do
|
|
25
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6'></path></svg>".html_safe
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @label With Badge
|
|
31
|
+
def with_badge
|
|
32
|
+
render BetterUi::Drawer::NavItemComponent.new(label: "Messages", href: "#") do |item|
|
|
33
|
+
item.with_icon do
|
|
34
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z'></path></svg>".html_safe
|
|
35
|
+
end
|
|
36
|
+
item.with_badge { "5" }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @label With HTTP Method (Delete)
|
|
41
|
+
def with_http_method
|
|
42
|
+
render BetterUi::Drawer::NavItemComponent.new(label: "Logout", href: "#", method: :delete) do |item|
|
|
43
|
+
item.with_icon do
|
|
44
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1'></path></svg>".html_safe
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# @label Dark Variant
|
|
50
|
+
# @display bg_color #1f2937
|
|
51
|
+
def dark_variant
|
|
52
|
+
render BetterUi::Drawer::NavItemComponent.new(label: "Dashboard", href: "#", variant: :dark, active: true) do |item|
|
|
53
|
+
item.with_icon do
|
|
54
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6'></path></svg>".html_safe
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# @label Primary Variant
|
|
60
|
+
# @display bg_color #1d4ed8
|
|
61
|
+
def primary_variant
|
|
62
|
+
render BetterUi::Drawer::NavItemComponent.new(label: "Dashboard", href: "#", variant: :primary, active: true) do |item|
|
|
63
|
+
item.with_icon do
|
|
64
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6'></path></svg>".html_safe
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# @label All Features
|
|
70
|
+
def all_features
|
|
71
|
+
render BetterUi::Drawer::NavItemComponent.new(
|
|
72
|
+
label: "Notifications",
|
|
73
|
+
href: "#",
|
|
74
|
+
active: true
|
|
75
|
+
) do |item|
|
|
76
|
+
item.with_icon do
|
|
77
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9'></path></svg>".html_safe
|
|
78
|
+
end
|
|
79
|
+
item.with_badge { "99+" }
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# @label Playground
|
|
84
|
+
# @param label text
|
|
85
|
+
# @param href text
|
|
86
|
+
# @param active toggle
|
|
87
|
+
# @param variant select { choices: [light, dark, primary] }
|
|
88
|
+
# @param method select { choices: [~, get, post, put, patch, delete] }
|
|
89
|
+
def playground(label: "Dashboard", href: "#", active: false, variant: :light, method: nil)
|
|
90
|
+
render BetterUi::Drawer::NavItemComponent.new(
|
|
91
|
+
label: label,
|
|
92
|
+
href: href,
|
|
93
|
+
active: active,
|
|
94
|
+
variant: variant.to_sym,
|
|
95
|
+
method: method.present? && method != "~" ? method.to_sym : nil
|
|
96
|
+
) do |item|
|
|
97
|
+
item.with_icon do
|
|
98
|
+
"<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6'></path></svg>".html_safe
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module BetterUi
|
|
4
|
+
module Drawer
|
|
5
|
+
# @label Sidebar
|
|
6
|
+
class SidebarComponentPreview < ViewComponent::Preview
|
|
7
|
+
# @label Default
|
|
8
|
+
def default
|
|
9
|
+
render BetterUi::Drawer::SidebarComponent.new do |sidebar|
|
|
10
|
+
sidebar.with_navigation do
|
|
11
|
+
"<nav class='space-y-2'>
|
|
12
|
+
<a href='#' class='block px-4 py-2 rounded-md bg-primary-50 text-primary-700'>Dashboard</a>
|
|
13
|
+
<a href='#' class='block px-4 py-2 rounded-md hover:bg-grayscale-100'>Projects</a>
|
|
14
|
+
<a href='#' class='block px-4 py-2 rounded-md hover:bg-grayscale-100'>Team</a>
|
|
15
|
+
<a href='#' class='block px-4 py-2 rounded-md hover:bg-grayscale-100'>Settings</a>
|
|
16
|
+
</nav>".html_safe
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @label With Header
|
|
22
|
+
def with_header
|
|
23
|
+
render BetterUi::Drawer::SidebarComponent.new do |sidebar|
|
|
24
|
+
sidebar.with_header do
|
|
25
|
+
"<div class='flex items-center'>
|
|
26
|
+
<div class='w-8 h-8 bg-primary-600 rounded-lg flex items-center justify-center text-white font-bold'>B</div>
|
|
27
|
+
<span class='ml-2 font-semibold'>BetterUI</span>
|
|
28
|
+
</div>".html_safe
|
|
29
|
+
end
|
|
30
|
+
sidebar.with_navigation do
|
|
31
|
+
"<nav class='space-y-2'>
|
|
32
|
+
<a href='#' class='block px-4 py-2 rounded-md bg-primary-50 text-primary-700'>Dashboard</a>
|
|
33
|
+
<a href='#' class='block px-4 py-2 rounded-md hover:bg-grayscale-100'>Projects</a>
|
|
34
|
+
<a href='#' class='block px-4 py-2 rounded-md hover:bg-grayscale-100'>Team</a>
|
|
35
|
+
</nav>".html_safe
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @label With Footer
|
|
41
|
+
def with_footer
|
|
42
|
+
render BetterUi::Drawer::SidebarComponent.new do |sidebar|
|
|
43
|
+
sidebar.with_navigation do
|
|
44
|
+
"<nav class='space-y-2'>
|
|
45
|
+
<a href='#' class='block px-4 py-2 rounded-md bg-primary-50 text-primary-700'>Dashboard</a>
|
|
46
|
+
<a href='#' class='block px-4 py-2 rounded-md hover:bg-grayscale-100'>Projects</a>
|
|
47
|
+
</nav>".html_safe
|
|
48
|
+
end
|
|
49
|
+
sidebar.with_footer do
|
|
50
|
+
"<div class='flex items-center'>
|
|
51
|
+
<div class='w-8 h-8 bg-grayscale-300 rounded-full'></div>
|
|
52
|
+
<div class='ml-3'>
|
|
53
|
+
<div class='text-sm font-medium'>John Doe</div>
|
|
54
|
+
<div class='text-xs text-grayscale-500'>john@example.com</div>
|
|
55
|
+
</div>
|
|
56
|
+
</div>".html_safe
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# @label Complete Sidebar
|
|
62
|
+
def complete_sidebar
|
|
63
|
+
render BetterUi::Drawer::SidebarComponent.new do |sidebar|
|
|
64
|
+
sidebar.with_header do
|
|
65
|
+
"<div class='flex items-center'>
|
|
66
|
+
<div class='w-8 h-8 bg-primary-600 rounded-lg flex items-center justify-center text-white font-bold'>B</div>
|
|
67
|
+
<span class='ml-2 font-semibold'>BetterUI</span>
|
|
68
|
+
</div>".html_safe
|
|
69
|
+
end
|
|
70
|
+
sidebar.with_navigation do
|
|
71
|
+
"<nav class='space-y-6'>
|
|
72
|
+
<div>
|
|
73
|
+
<h3 class='px-4 text-xs font-semibold text-grayscale-500 uppercase tracking-wider'>Main</h3>
|
|
74
|
+
<div class='mt-2 space-y-1'>
|
|
75
|
+
<a href='#' class='flex items-center px-4 py-2 rounded-md bg-primary-50 text-primary-700'>
|
|
76
|
+
<svg class='w-5 h-5 mr-3' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6'></path></svg>
|
|
77
|
+
Dashboard
|
|
78
|
+
</a>
|
|
79
|
+
<a href='#' class='flex items-center px-4 py-2 rounded-md hover:bg-grayscale-100'>
|
|
80
|
+
<svg class='w-5 h-5 mr-3' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10'></path></svg>
|
|
81
|
+
Projects
|
|
82
|
+
</a>
|
|
83
|
+
<a href='#' class='flex items-center px-4 py-2 rounded-md hover:bg-grayscale-100'>
|
|
84
|
+
<svg class='w-5 h-5 mr-3' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197m12 5.198H9'></path></svg>
|
|
85
|
+
Team
|
|
86
|
+
</a>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
<div>
|
|
90
|
+
<h3 class='px-4 text-xs font-semibold text-grayscale-500 uppercase tracking-wider'>Settings</h3>
|
|
91
|
+
<div class='mt-2 space-y-1'>
|
|
92
|
+
<a href='#' class='flex items-center px-4 py-2 rounded-md hover:bg-grayscale-100'>
|
|
93
|
+
<svg class='w-5 h-5 mr-3' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z'></path><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M15 12a3 3 0 11-6 0 3 3 0 016 0z'></path></svg>
|
|
94
|
+
Settings
|
|
95
|
+
</a>
|
|
96
|
+
<a href='#' class='flex items-center px-4 py-2 rounded-md hover:bg-grayscale-100'>
|
|
97
|
+
<svg class='w-5 h-5 mr-3' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z'></path></svg>
|
|
98
|
+
Help
|
|
99
|
+
</a>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
</nav>".html_safe
|
|
103
|
+
end
|
|
104
|
+
sidebar.with_footer do
|
|
105
|
+
"<div class='flex items-center'>
|
|
106
|
+
<div class='w-10 h-10 bg-grayscale-300 rounded-full'></div>
|
|
107
|
+
<div class='ml-3'>
|
|
108
|
+
<div class='text-sm font-medium'>John Doe</div>
|
|
109
|
+
<div class='text-xs text-grayscale-500'>john@example.com</div>
|
|
110
|
+
</div>
|
|
111
|
+
<button class='ml-auto p-2 text-grayscale-500 hover:text-grayscale-700'>
|
|
112
|
+
<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1'></path></svg>
|
|
113
|
+
</button>
|
|
114
|
+
</div>".html_safe
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# @label Light Variant
|
|
120
|
+
def light_variant
|
|
121
|
+
render BetterUi::Drawer::SidebarComponent.new(variant: :light) do |sidebar|
|
|
122
|
+
sidebar.with_navigation { "Light Sidebar Navigation" }
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# @label Dark Variant
|
|
127
|
+
# @display bg_color #374151
|
|
128
|
+
def dark_variant
|
|
129
|
+
render BetterUi::Drawer::SidebarComponent.new(variant: :dark) do |sidebar|
|
|
130
|
+
sidebar.with_navigation do
|
|
131
|
+
"<nav class='space-y-2'>
|
|
132
|
+
<a href='#' class='block px-4 py-2 rounded-md bg-white/10 text-white'>Dashboard</a>
|
|
133
|
+
<a href='#' class='block px-4 py-2 rounded-md hover:bg-white/5 text-grayscale-300'>Projects</a>
|
|
134
|
+
<a href='#' class='block px-4 py-2 rounded-md hover:bg-white/5 text-grayscale-300'>Team</a>
|
|
135
|
+
</nav>".html_safe
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# @label Primary Variant
|
|
141
|
+
def primary_variant
|
|
142
|
+
render BetterUi::Drawer::SidebarComponent.new(variant: :primary) do |sidebar|
|
|
143
|
+
sidebar.with_navigation do
|
|
144
|
+
"<nav class='space-y-2'>
|
|
145
|
+
<a href='#' class='block px-4 py-2 rounded-md bg-white/20 text-white'>Dashboard</a>
|
|
146
|
+
<a href='#' class='block px-4 py-2 rounded-md hover:bg-white/10 text-primary-100'>Projects</a>
|
|
147
|
+
<a href='#' class='block px-4 py-2 rounded-md hover:bg-white/10 text-primary-100'>Team</a>
|
|
148
|
+
</nav>".html_safe
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# @label Left Position
|
|
154
|
+
def left_position
|
|
155
|
+
render BetterUi::Drawer::SidebarComponent.new(position: :left) do |sidebar|
|
|
156
|
+
sidebar.with_navigation { "Left-positioned Sidebar (border on right)" }
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# @label Right Position
|
|
161
|
+
def right_position
|
|
162
|
+
render BetterUi::Drawer::SidebarComponent.new(position: :right) do |sidebar|
|
|
163
|
+
sidebar.with_navigation { "Right-positioned Sidebar (border on left)" }
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# @label Small Width (Icon Only)
|
|
168
|
+
def small_width
|
|
169
|
+
render BetterUi::Drawer::SidebarComponent.new(width: :sm) do |sidebar|
|
|
170
|
+
sidebar.with_navigation do
|
|
171
|
+
"<nav class='space-y-2'>
|
|
172
|
+
<a href='#' class='block p-2 rounded-md bg-primary-50 text-primary-700'>
|
|
173
|
+
<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6'></path></svg>
|
|
174
|
+
</a>
|
|
175
|
+
<a href='#' class='block p-2 rounded-md hover:bg-grayscale-100'>
|
|
176
|
+
<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10'></path></svg>
|
|
177
|
+
</a>
|
|
178
|
+
<a href='#' class='block p-2 rounded-md hover:bg-grayscale-100'>
|
|
179
|
+
<svg class='w-5 h-5' fill='none' stroke='currentColor' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z'></path><path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M15 12a3 3 0 11-6 0 3 3 0 016 0z'></path></svg>
|
|
180
|
+
</a>
|
|
181
|
+
</nav>".html_safe
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# @label Large Width
|
|
187
|
+
def large_width
|
|
188
|
+
render BetterUi::Drawer::SidebarComponent.new(width: :lg) do |sidebar|
|
|
189
|
+
sidebar.with_navigation { "Large Width Sidebar (320px)" }
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# @label Playground
|
|
194
|
+
# @param variant select { choices: [light, dark, primary] }
|
|
195
|
+
# @param position select { choices: [left, right] }
|
|
196
|
+
# @param width select { choices: [sm, md, lg] }
|
|
197
|
+
# @param collapsible toggle
|
|
198
|
+
def playground(variant: :light, position: :left, width: :md, collapsible: true)
|
|
199
|
+
render BetterUi::Drawer::SidebarComponent.new(
|
|
200
|
+
variant: variant.to_sym,
|
|
201
|
+
position: position.to_sym,
|
|
202
|
+
width: width.to_sym,
|
|
203
|
+
collapsible: collapsible
|
|
204
|
+
) do |sidebar|
|
|
205
|
+
sidebar.with_header { "Sidebar Header" }
|
|
206
|
+
sidebar.with_navigation { "Sidebar Navigation" }
|
|
207
|
+
sidebar.with_footer { "Sidebar Footer" }
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
end
|
data/spec/components/previews/better_ui/dropdown/dropdown_component_preview/all_sizes.html.erb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<div class="p-8">
|
|
2
|
+
<h3 class="text-lg font-semibold mb-4">Size Variants</h3>
|
|
3
|
+
|
|
4
|
+
<div class="flex gap-8 items-start">
|
|
5
|
+
<% [:sm, :md, :lg].each do |size| %>
|
|
6
|
+
<div>
|
|
7
|
+
<p class="text-sm text-grayscale-500 mb-2"><%= size %></p>
|
|
8
|
+
<%= render BetterUi::Dropdown::DropdownComponent.new(size: size) do |d| %>
|
|
9
|
+
<% d.with_trigger do %>
|
|
10
|
+
<%= render(BetterUi::ButtonComponent.new(variant: :secondary, style: :outline)) do %>Size: <%= size %><% end %>
|
|
11
|
+
<% end %>
|
|
12
|
+
<% d.with_item(href: "#") { "Action One" } %>
|
|
13
|
+
<% d.with_item(href: "#") { "Action Two" } %>
|
|
14
|
+
<% d.with_item(href: "#") { "Action Three" } %>
|
|
15
|
+
<% end %>
|
|
16
|
+
</div>
|
|
17
|
+
<% end %>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<div class="p-8">
|
|
2
|
+
<h3 class="text-lg font-semibold mb-4">Default Dropdown</h3>
|
|
3
|
+
|
|
4
|
+
<%= render BetterUi::Dropdown::DropdownComponent.new do |d| %>
|
|
5
|
+
<% d.with_trigger do %>
|
|
6
|
+
<%= render(BetterUi::ButtonComponent.new(variant: :primary)) do %>Options<% end %>
|
|
7
|
+
<% end %>
|
|
8
|
+
<% d.with_item(href: "#edit") { "Edit" } %>
|
|
9
|
+
<% d.with_item(href: "#duplicate") { "Duplicate" } %>
|
|
10
|
+
<% d.with_item(href: "#archive") { "Archive" } %>
|
|
11
|
+
<% end %>
|
|
12
|
+
</div>
|
data/spec/components/previews/better_ui/dropdown/dropdown_component_preview/disabled_items.html.erb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<div class="p-8">
|
|
2
|
+
<h3 class="text-lg font-semibold mb-4">Disabled Items</h3>
|
|
3
|
+
|
|
4
|
+
<%= render BetterUi::Dropdown::DropdownComponent.new do |d| %>
|
|
5
|
+
<% d.with_trigger do %>
|
|
6
|
+
<%= render(BetterUi::ButtonComponent.new(variant: :primary)) do %>Actions<% end %>
|
|
7
|
+
<% end %>
|
|
8
|
+
<% d.with_item(href: "#edit") { "Edit" } %>
|
|
9
|
+
<% d.with_item(href: "#duplicate", disabled: true) { "Duplicate (disabled)" } %>
|
|
10
|
+
<% d.with_item(href: "#archive") { "Archive" } %>
|
|
11
|
+
<% d.with_divider %>
|
|
12
|
+
<% d.with_item(href: "#delete", variant: :danger, disabled: true) { "Delete (disabled)" } %>
|
|
13
|
+
<% end %>
|
|
14
|
+
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<div class="p-8">
|
|
2
|
+
<h3 class="text-lg font-semibold mb-4">Placement Options</h3>
|
|
3
|
+
|
|
4
|
+
<div class="flex flex-wrap gap-8 items-center justify-center" style="min-height: 300px;">
|
|
5
|
+
<% [:bottom_start, :bottom_end, :top_start, :top_end].each do |placement| %>
|
|
6
|
+
<%= render BetterUi::Dropdown::DropdownComponent.new(placement: placement) do |d| %>
|
|
7
|
+
<% d.with_trigger do %>
|
|
8
|
+
<%= render(BetterUi::ButtonComponent.new(variant: :info, style: :outline, size: :sm)) do %><%= placement %><% end %>
|
|
9
|
+
<% end %>
|
|
10
|
+
<% d.with_item(href: "#") { "Action One" } %>
|
|
11
|
+
<% d.with_item(href: "#") { "Action Two" } %>
|
|
12
|
+
<% d.with_item(href: "#") { "Action Three" } %>
|
|
13
|
+
<% end %>
|
|
14
|
+
<% end %>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
data/spec/components/previews/better_ui/dropdown/dropdown_component_preview/playground.html.erb
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<div class="p-8 flex items-center justify-center" style="min-height: 300px;">
|
|
2
|
+
<h3 class="text-lg font-semibold mb-4">Playground</h3>
|
|
3
|
+
|
|
4
|
+
<%= render BetterUi::Dropdown::DropdownComponent.new(
|
|
5
|
+
size: @size,
|
|
6
|
+
placement: @placement,
|
|
7
|
+
shadow: @shadow,
|
|
8
|
+
auto_close: @auto_close,
|
|
9
|
+
close_on_item_click: @close_on_item_click
|
|
10
|
+
) do |d| %>
|
|
11
|
+
<% d.with_trigger do %>
|
|
12
|
+
<%= render(BetterUi::ButtonComponent.new(variant: :primary)) do %>Open Dropdown<% end %>
|
|
13
|
+
<% end %>
|
|
14
|
+
<% d.with_header(text: "Actions") %>
|
|
15
|
+
<% d.with_item(href: "#edit") do |item| %>
|
|
16
|
+
<% item.with_icon do %>
|
|
17
|
+
<svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
18
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" />
|
|
19
|
+
</svg>
|
|
20
|
+
<% end %>
|
|
21
|
+
Edit
|
|
22
|
+
<% end %>
|
|
23
|
+
<% d.with_item(href: "#duplicate") { "Duplicate" } %>
|
|
24
|
+
<% d.with_item(href: "#archive", disabled: true) { "Archive (disabled)" } %>
|
|
25
|
+
<% d.with_divider %>
|
|
26
|
+
<% d.with_item(href: "#delete", variant: :danger) do |item| %>
|
|
27
|
+
<% item.with_icon do %>
|
|
28
|
+
<svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
29
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
|
|
30
|
+
</svg>
|
|
31
|
+
<% end %>
|
|
32
|
+
Delete
|
|
33
|
+
<% end %>
|
|
34
|
+
<% end %>
|
|
35
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<div class="p-8">
|
|
2
|
+
<h3 class="text-lg font-semibold mb-4">With Dividers and Section Headers</h3>
|
|
3
|
+
|
|
4
|
+
<%= render BetterUi::Dropdown::DropdownComponent.new(size: :lg) do |d| %>
|
|
5
|
+
<% d.with_trigger do %>
|
|
6
|
+
<%= render(BetterUi::ButtonComponent.new(variant: :secondary, style: :outline)) do %>Account Menu<% end %>
|
|
7
|
+
<% end %>
|
|
8
|
+
<% d.with_header(text: "Account") %>
|
|
9
|
+
<% d.with_item(href: "#profile") { "My Profile" } %>
|
|
10
|
+
<% d.with_item(href: "#settings") { "Settings" } %>
|
|
11
|
+
<% d.with_divider %>
|
|
12
|
+
<% d.with_header(text: "Team") %>
|
|
13
|
+
<% d.with_item(href: "#members") { "Members" } %>
|
|
14
|
+
<% d.with_item(href: "#billing") { "Billing" } %>
|
|
15
|
+
<% d.with_divider %>
|
|
16
|
+
<% d.with_item(href: "#logout", variant: :danger) { "Sign Out" } %>
|
|
17
|
+
<% end %>
|
|
18
|
+
</div>
|
data/spec/components/previews/better_ui/dropdown/dropdown_component_preview/with_icons.html.erb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<div class="p-8">
|
|
2
|
+
<h3 class="text-lg font-semibold mb-4">With Icons</h3>
|
|
3
|
+
|
|
4
|
+
<%= render BetterUi::Dropdown::DropdownComponent.new do |d| %>
|
|
5
|
+
<% d.with_trigger do %>
|
|
6
|
+
<%= render(BetterUi::ButtonComponent.new(variant: :primary)) do %>Actions<% end %>
|
|
7
|
+
<% end %>
|
|
8
|
+
<% d.with_item(href: "#edit") do |item| %>
|
|
9
|
+
<% item.with_icon do %>
|
|
10
|
+
<svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
11
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" />
|
|
12
|
+
</svg>
|
|
13
|
+
<% end %>
|
|
14
|
+
Edit
|
|
15
|
+
<% end %>
|
|
16
|
+
<% d.with_item(href: "#duplicate") do |item| %>
|
|
17
|
+
<% item.with_icon do %>
|
|
18
|
+
<svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
19
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75" />
|
|
20
|
+
</svg>
|
|
21
|
+
<% end %>
|
|
22
|
+
Duplicate
|
|
23
|
+
<% end %>
|
|
24
|
+
<% d.with_divider %>
|
|
25
|
+
<% d.with_item(href: "#delete", variant: :danger) do |item| %>
|
|
26
|
+
<% item.with_icon do %>
|
|
27
|
+
<svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
28
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
|
|
29
|
+
</svg>
|
|
30
|
+
<% end %>
|
|
31
|
+
Delete
|
|
32
|
+
<% end %>
|
|
33
|
+
<% end %>
|
|
34
|
+
</div>
|