ruby_ui 1.0.0.pre.alpha.4 → 1.0.0.rc1
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/LICENSE.txt +21 -0
- data/README.md +85 -0
- data/lib/generators/ruby_ui/component_generator.rb +94 -0
- data/lib/generators/ruby_ui/dependencies.yml +74 -0
- data/lib/generators/ruby_ui/install/install_generator.rb +89 -0
- data/lib/generators/ruby_ui/install/templates/ruby_ui.rb.erb +18 -0
- data/lib/generators/ruby_ui/install/templates/tailwind.css.erb +156 -0
- data/lib/generators/ruby_ui/javascript_utils.rb +57 -0
- data/lib/{rbui → ruby_ui}/accordion/accordion.rb +1 -1
- data/lib/{rbui → ruby_ui}/accordion/accordion_content.rb +2 -2
- data/lib/ruby_ui/accordion/accordion_controller.js +97 -0
- data/lib/{rbui → ruby_ui}/accordion/accordion_default_content.rb +1 -1
- data/lib/{rbui → ruby_ui}/accordion/accordion_default_trigger.rb +3 -3
- data/lib/{rbui → ruby_ui}/accordion/accordion_icon.rb +2 -2
- data/lib/{rbui → ruby_ui}/accordion/accordion_item.rb +4 -4
- data/lib/{rbui → ruby_ui}/accordion/accordion_trigger.rb +3 -2
- data/lib/{rbui → ruby_ui}/alert/alert.rb +3 -3
- data/lib/{rbui → ruby_ui}/alert/alert_description.rb +1 -1
- data/lib/{rbui → ruby_ui}/alert/alert_title.rb +1 -1
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog.rb +3 -3
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_action.rb +2 -2
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_cancel.rb +3 -3
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_content.rb +5 -5
- data/lib/ruby_ui/alert_dialog/alert_dialog_controller.js +31 -0
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_description.rb +1 -1
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_footer.rb +2 -2
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_header.rb +2 -2
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_title.rb +1 -1
- data/lib/{rbui → ruby_ui}/alert_dialog/alert_dialog_trigger.rb +2 -2
- data/lib/{rbui → ruby_ui}/aspect_ratio/aspect_ratio.rb +1 -1
- data/lib/{rbui → ruby_ui}/avatar/avatar.rb +2 -2
- data/lib/{rbui → ruby_ui}/avatar/avatar_fallback.rb +1 -1
- data/lib/{rbui → ruby_ui}/avatar/avatar_image.rb +1 -1
- data/lib/{rbui → ruby_ui}/badge/badge.rb +2 -2
- data/lib/{rbui → ruby_ui}/base.rb +1 -8
- data/lib/ruby_ui/breadcrumb/breadcrumb.rb +17 -0
- data/lib/ruby_ui/breadcrumb/breadcrumb_ellipsis.rb +39 -0
- data/lib/{rbui/typography/typography_list_item.rb → ruby_ui/breadcrumb/breadcrumb_item.rb} +3 -3
- data/lib/ruby_ui/breadcrumb/breadcrumb_link.rb +22 -0
- data/lib/ruby_ui/breadcrumb/breadcrumb_list.rb +17 -0
- data/lib/ruby_ui/breadcrumb/breadcrumb_page.rb +19 -0
- data/lib/ruby_ui/breadcrumb/breadcrumb_separator.rb +38 -0
- data/lib/{rbui → ruby_ui}/button/button.rb +13 -13
- data/lib/ruby_ui/calendar/calendar.rb +39 -0
- data/lib/{rbui → ruby_ui}/calendar/calendar_body.rb +2 -2
- data/lib/ruby_ui/calendar/calendar_controller.js +249 -0
- data/lib/{rbui → ruby_ui}/calendar/calendar_days.rb +14 -14
- data/lib/{rbui → ruby_ui}/calendar/calendar_header.rb +1 -1
- data/lib/ruby_ui/calendar/calendar_input_controller.js +8 -0
- data/lib/{rbui → ruby_ui}/calendar/calendar_next.rb +2 -2
- data/lib/{rbui → ruby_ui}/calendar/calendar_prev.rb +2 -2
- data/lib/{rbui → ruby_ui}/calendar/calendar_title.rb +2 -2
- data/lib/{rbui → ruby_ui}/calendar/calendar_weekdays.rb +2 -2
- data/lib/{rbui → ruby_ui}/card/card.rb +1 -1
- data/lib/{rbui → ruby_ui}/card/card_content.rb +1 -1
- data/lib/{rbui → ruby_ui}/card/card_description.rb +1 -1
- data/lib/{rbui → ruby_ui}/card/card_footer.rb +1 -1
- data/lib/{rbui → ruby_ui}/card/card_header.rb +1 -1
- data/lib/{rbui → ruby_ui}/card/card_title.rb +1 -1
- data/lib/ruby_ui/carousel/carousel.rb +44 -0
- data/lib/ruby_ui/carousel/carousel_content.rb +23 -0
- data/lib/ruby_ui/carousel/carousel_controller.js +60 -0
- data/lib/ruby_ui/carousel/carousel_item.rb +23 -0
- data/lib/ruby_ui/carousel/carousel_next.rb +48 -0
- data/lib/ruby_ui/carousel/carousel_previous.rb +49 -0
- data/lib/{rbui → ruby_ui}/chart/chart.rb +3 -3
- data/lib/ruby_ui/chart/chart_controller.js +103 -0
- data/lib/{rbui → ruby_ui}/checkbox/checkbox.rb +4 -4
- data/lib/{rbui → ruby_ui}/checkbox/checkbox_group.rb +2 -2
- data/lib/ruby_ui/checkbox/checkbox_group_controller.js +21 -0
- data/lib/{rbui → ruby_ui}/clipboard/clipboard.rb +6 -6
- data/lib/ruby_ui/clipboard/clipboard_controller.js +54 -0
- data/lib/{rbui → ruby_ui}/clipboard/clipboard_popover.rb +2 -2
- data/lib/{rbui → ruby_ui}/clipboard/clipboard_source.rb +2 -2
- data/lib/{rbui → ruby_ui}/clipboard/clipboard_trigger.rb +3 -3
- data/lib/{rbui → ruby_ui}/codeblock/codeblock.rb +7 -10
- data/lib/{rbui → ruby_ui}/collapsible/collapsible.rb +3 -3
- data/lib/{rbui → ruby_ui}/collapsible/collapsible_content.rb +2 -2
- data/lib/ruby_ui/collapsible/collapsible_controller.js +47 -0
- data/lib/{rbui → ruby_ui}/collapsible/collapsible_trigger.rb +2 -2
- data/lib/ruby_ui/combobox/combobox.rb +26 -0
- data/lib/ruby_ui/combobox/combobox_checkbox.rb +25 -0
- data/lib/ruby_ui/combobox/combobox_controller.js +176 -0
- data/lib/{rbui/combobox/combobox_empty.rb → ruby_ui/combobox/combobox_empty_state.rb} +3 -3
- data/lib/ruby_ui/combobox/combobox_item.rb +25 -0
- data/lib/ruby_ui/combobox/combobox_list.rb +18 -0
- data/lib/ruby_ui/combobox/combobox_list_group.rb +20 -0
- data/lib/ruby_ui/combobox/combobox_popover.rb +30 -0
- data/lib/ruby_ui/combobox/combobox_radio.rb +26 -0
- data/lib/{rbui → ruby_ui}/combobox/combobox_search_input.rb +22 -25
- data/lib/ruby_ui/combobox/combobox_toggle_all_checkbox.rb +25 -0
- data/lib/{rbui → ruby_ui}/combobox/combobox_trigger.rb +26 -21
- data/lib/{rbui → ruby_ui}/command/command.rb +1 -1
- data/lib/ruby_ui/command/command_controller.js +136 -0
- data/lib/{rbui → ruby_ui}/command/command_dialog.rb +2 -2
- data/lib/{rbui → ruby_ui}/command/command_dialog_content.rb +6 -6
- data/lib/{rbui → ruby_ui}/command/command_dialog_trigger.rb +3 -3
- data/lib/{rbui → ruby_ui}/command/command_empty.rb +2 -2
- data/lib/{rbui → ruby_ui}/command/command_group.rb +2 -2
- data/lib/{rbui → ruby_ui}/command/command_input.rb +3 -3
- data/lib/{rbui → ruby_ui}/command/command_item.rb +2 -2
- data/lib/{rbui → ruby_ui}/command/command_list.rb +1 -1
- data/lib/{rbui → ruby_ui}/context_menu/context_menu.rb +2 -2
- data/lib/{rbui → ruby_ui}/context_menu/context_menu_content.rb +2 -2
- data/lib/ruby_ui/context_menu/context_menu_controller.js +144 -0
- data/lib/{rbui → ruby_ui}/context_menu/context_menu_item.rb +3 -3
- data/lib/{rbui → ruby_ui}/context_menu/context_menu_label.rb +2 -2
- data/lib/{rbui → ruby_ui}/context_menu/context_menu_separator.rb +1 -1
- data/lib/{rbui → ruby_ui}/context_menu/context_menu_trigger.rb +3 -3
- data/lib/{rbui → ruby_ui}/dialog/dialog.rb +3 -3
- data/lib/{rbui → ruby_ui}/dialog/dialog_content.rb +9 -9
- data/lib/ruby_ui/dialog/dialog_controller.js +32 -0
- data/lib/{rbui → ruby_ui}/dialog/dialog_description.rb +1 -1
- data/lib/{rbui → ruby_ui}/dialog/dialog_footer.rb +2 -2
- data/lib/{rbui → ruby_ui}/dialog/dialog_header.rb +2 -2
- data/lib/{rbui → ruby_ui}/dialog/dialog_middle.rb +1 -1
- data/lib/{rbui → ruby_ui}/dialog/dialog_title.rb +1 -1
- data/lib/{rbui → ruby_ui}/dialog/dialog_trigger.rb +2 -2
- data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu.rb +4 -4
- data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_content.rb +2 -2
- data/lib/ruby_ui/dropdown_menu/dropdown_menu_controller.js +120 -0
- data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_item.rb +3 -3
- data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_label.rb +1 -1
- data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_separator.rb +1 -1
- data/lib/{rbui → ruby_ui}/dropdown_menu/dropdown_menu_trigger.rb +2 -2
- data/lib/{rbui → ruby_ui}/form/form.rb +1 -1
- data/lib/{rbui → ruby_ui}/form/form_field.rb +2 -2
- data/lib/ruby_ui/form/form_field_controller.js +61 -0
- data/lib/{rbui → ruby_ui}/form/form_field_error.rb +2 -2
- data/lib/{rbui → ruby_ui}/form/form_field_hint.rb +1 -1
- data/lib/{rbui → ruby_ui}/form/form_field_label.rb +1 -1
- data/lib/{rbui → ruby_ui}/hover_card/hover_card.rb +3 -3
- data/lib/{rbui → ruby_ui}/hover_card/hover_card_content.rb +2 -2
- data/lib/ruby_ui/hover_card/hover_card_controller.js +144 -0
- data/lib/{rbui → ruby_ui}/hover_card/hover_card_trigger.rb +2 -2
- data/lib/{rbui → ruby_ui}/input/input.rb +3 -3
- data/lib/{rbui → ruby_ui}/link/link.rb +13 -13
- data/lib/ruby_ui/masked_input/masked_input.rb +15 -0
- data/lib/ruby_ui/masked_input/masked_input_controller.js +9 -0
- data/lib/{rbui → ruby_ui}/pagination/pagination.rb +1 -1
- data/lib/{rbui → ruby_ui}/pagination/pagination_content.rb +1 -1
- data/lib/{rbui → ruby_ui}/pagination/pagination_ellipsis.rb +1 -1
- data/lib/{rbui → ruby_ui}/pagination/pagination_item.rb +4 -4
- data/lib/{rbui → ruby_ui}/popover/popover.rb +4 -4
- data/lib/{rbui → ruby_ui}/popover/popover_content.rb +2 -2
- data/lib/ruby_ui/popover/popover_controller.js +107 -0
- data/lib/{rbui → ruby_ui}/popover/popover_trigger.rb +2 -2
- data/lib/ruby_ui/progress/progress.rb +37 -0
- data/lib/ruby_ui/radio_button/radio_button.rb +25 -0
- data/lib/{rbui → ruby_ui}/select/select.rb +5 -5
- data/lib/{rbui → ruby_ui}/select/select_content.rb +3 -3
- data/lib/ruby_ui/select/select_controller.js +171 -0
- data/lib/{rbui → ruby_ui}/select/select_group.rb +1 -1
- data/lib/{rbui → ruby_ui}/select/select_input.rb +4 -4
- data/lib/{rbui → ruby_ui}/select/select_item.rb +4 -4
- data/lib/ruby_ui/select/select_item_controller.js +11 -0
- data/lib/{rbui → ruby_ui}/select/select_label.rb +1 -1
- data/lib/{rbui → ruby_ui}/select/select_trigger.rb +3 -3
- data/lib/{rbui → ruby_ui}/select/select_value.rb +3 -3
- data/lib/ruby_ui/separator/separator.rb +38 -0
- data/lib/{rbui → ruby_ui}/sheet/sheet.rb +2 -2
- data/lib/{rbui → ruby_ui}/sheet/sheet_content.rb +8 -8
- data/lib/ruby_ui/sheet/sheet_content_controller.js +7 -0
- data/lib/ruby_ui/sheet/sheet_controller.js +9 -0
- data/lib/{rbui → ruby_ui}/sheet/sheet_description.rb +1 -1
- data/lib/{rbui → ruby_ui}/sheet/sheet_footer.rb +1 -1
- data/lib/{rbui → ruby_ui}/sheet/sheet_header.rb +1 -1
- data/lib/{rbui → ruby_ui}/sheet/sheet_middle.rb +1 -1
- data/lib/{rbui → ruby_ui}/sheet/sheet_title.rb +1 -1
- data/lib/{rbui → ruby_ui}/sheet/sheet_trigger.rb +2 -2
- data/lib/{rbui → ruby_ui}/shortcut_key/shortcut_key.rb +1 -1
- data/lib/ruby_ui/skeleton/skeleton.rb +17 -0
- data/lib/ruby_ui/switch/switch.rb +24 -0
- data/lib/{rbui → ruby_ui}/table/table.rb +1 -1
- data/lib/{rbui → ruby_ui}/table/table_body.rb +1 -1
- data/lib/{rbui → ruby_ui}/table/table_caption.rb +1 -1
- data/lib/{rbui → ruby_ui}/table/table_cell.rb +1 -1
- data/lib/{rbui → ruby_ui}/table/table_footer.rb +1 -1
- data/lib/{rbui → ruby_ui}/table/table_head.rb +1 -1
- data/lib/{rbui → ruby_ui}/table/table_header.rb +1 -1
- data/lib/{rbui → ruby_ui}/table/table_row.rb +1 -1
- data/lib/{rbui → ruby_ui}/tabs/tabs.rb +3 -3
- data/lib/{rbui → ruby_ui}/tabs/tabs_content.rb +2 -2
- data/lib/ruby_ui/tabs/tabs_controller.js +45 -0
- data/lib/{rbui → ruby_ui}/tabs/tabs_list.rb +1 -1
- data/lib/{rbui → ruby_ui}/tabs/tabs_trigger.rb +3 -3
- data/lib/{rbui → ruby_ui}/textarea/textarea.rb +3 -3
- data/lib/{rbui → ruby_ui}/theme_toggle/theme_toggle.rb +4 -4
- data/lib/ruby_ui/theme_toggle/theme_toggle_controller.js +30 -0
- data/lib/{rbui → ruby_ui}/tooltip/tooltip.rb +3 -3
- data/lib/{rbui → ruby_ui}/tooltip/tooltip_content.rb +3 -3
- data/lib/ruby_ui/tooltip/tooltip_controller.js +37 -0
- data/lib/{rbui → ruby_ui}/tooltip/tooltip_trigger.rb +2 -2
- data/lib/ruby_ui/typography/heading.rb +60 -0
- data/lib/{rbui/typography/typography_inline_code.rb → ruby_ui/typography/inline_code.rb} +2 -2
- data/lib/{rbui/typography/typography_inline_link.rb → ruby_ui/typography/inline_link.rb} +2 -2
- data/lib/ruby_ui/typography/text.rb +53 -0
- data/lib/{rbui → ruby_ui}/typography/typography_blockquote.rb +1 -1
- data/lib/ruby_ui.rb +5 -1
- metadata +208 -173
- data/lib/generators/rbui/base_generator.rb +0 -17
- data/lib/generators/rbui/component_generator.rb +0 -137
- data/lib/generators/rbui/install/install_generator.rb +0 -194
- data/lib/rbui/calendar/calendar.rb +0 -39
- data/lib/rbui/combobox/combobox.rb +0 -24
- data/lib/rbui/combobox/combobox_content.rb +0 -31
- data/lib/rbui/combobox/combobox_group.rb +0 -38
- data/lib/rbui/combobox/combobox_input.rb +0 -22
- data/lib/rbui/combobox/combobox_item.rb +0 -53
- data/lib/rbui/combobox/combobox_list.rb +0 -29
- data/lib/rbui/combobox/combobox_separator.rb +0 -15
- data/lib/rbui/combobox/combobox_value.rb +0 -27
- data/lib/rbui/radio_button/radio_button.rb +0 -22
- data/lib/rbui/railtie.rb +0 -52
- data/lib/rbui/typography/typography_h1.rb +0 -17
- data/lib/rbui/typography/typography_h2.rb +0 -17
- data/lib/rbui/typography/typography_h3.rb +0 -17
- data/lib/rbui/typography/typography_h4.rb +0 -17
- data/lib/rbui/typography/typography_large.rb +0 -17
- data/lib/rbui/typography/typography_lead.rb +0 -17
- data/lib/rbui/typography/typography_list.rb +0 -47
- data/lib/rbui/typography/typography_muted.rb +0 -17
- data/lib/rbui/typography/typography_p.rb +0 -17
- data/lib/rbui/typography/typography_small.rb +0 -17
- data/lib/rbui/version.rb +0 -5
- data/lib/rbui.rb +0 -57
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module RubyUI
|
4
4
|
class SheetTrigger < Base
|
5
5
|
def view_template(&)
|
6
6
|
div(**attrs, &)
|
@@ -10,7 +10,7 @@ module RBUI
|
|
10
10
|
|
11
11
|
def default_attrs
|
12
12
|
{
|
13
|
-
data: {action: "click->
|
13
|
+
data: {action: "click->ruby-ui--sheet#open"}
|
14
14
|
}
|
15
15
|
end
|
16
16
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class Switch < Base
|
5
|
+
def initialize(include_hidden: true, checked_value: "1", unchecked_value: "0", **attrs)
|
6
|
+
@include_hidden = include_hidden
|
7
|
+
@checked_value = checked_value
|
8
|
+
@unchecked_value = unchecked_value
|
9
|
+
super(**attrs)
|
10
|
+
end
|
11
|
+
|
12
|
+
def view_template
|
13
|
+
label(
|
14
|
+
role: "switch",
|
15
|
+
class: "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50 bg-input has-[:checked]:bg-primary"
|
16
|
+
) do
|
17
|
+
input(type: "hidden", name: attrs[:name], value: @unchecked_value) if @include_hidden
|
18
|
+
input(**attrs.merge(type: "checkbox", class: "hidden peer", value: @checked_value))
|
19
|
+
|
20
|
+
span(class: "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform translate-x-0 peer-checked:translate-x-5 ")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module RubyUI
|
4
4
|
class Tabs < Base
|
5
5
|
def initialize(default: nil, **attrs)
|
6
6
|
@default = default
|
@@ -16,8 +16,8 @@ module RBUI
|
|
16
16
|
def default_attrs
|
17
17
|
{
|
18
18
|
data: {
|
19
|
-
controller: "
|
20
|
-
|
19
|
+
controller: "ruby-ui--tabs",
|
20
|
+
ruby_ui__tabs_active_value: @default
|
21
21
|
}
|
22
22
|
}
|
23
23
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module RubyUI
|
4
4
|
class TabsContent < Base
|
5
5
|
def initialize(value:, **attrs)
|
6
6
|
@value = value
|
@@ -16,7 +16,7 @@ module RBUI
|
|
16
16
|
def default_attrs
|
17
17
|
{
|
18
18
|
data: {
|
19
|
-
|
19
|
+
ruby_ui__tabs_target: :content,
|
20
20
|
value: @value
|
21
21
|
},
|
22
22
|
class: "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 hidden"
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
2
|
+
|
3
|
+
// Connects to data-controller="ruby-ui--tabs"
|
4
|
+
export default class extends Controller {
|
5
|
+
static targets = ["trigger", "content"];
|
6
|
+
static values = { active: String };
|
7
|
+
|
8
|
+
connect() {
|
9
|
+
if (!this.hasActiveValue && this.triggerTargets.length > 0) {
|
10
|
+
this.activeValue = this.triggerTargets[0].dataset.value;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
show(e) {
|
15
|
+
this.activeValue = e.currentTarget.dataset.value;
|
16
|
+
}
|
17
|
+
|
18
|
+
activeValueChanged(currentValue, previousValue) {
|
19
|
+
if (currentValue == "" || currentValue == previousValue) return;
|
20
|
+
|
21
|
+
this.contentTargets.forEach((el) => {
|
22
|
+
el.classList.add("hidden");
|
23
|
+
});
|
24
|
+
|
25
|
+
this.triggerTargets.forEach((el) => {
|
26
|
+
el.dataset.state = "inactive";
|
27
|
+
});
|
28
|
+
|
29
|
+
this.activeContentTarget() &&
|
30
|
+
this.activeContentTarget().classList.remove("hidden");
|
31
|
+
this.activeTriggerTarget().dataset.state = "active";
|
32
|
+
}
|
33
|
+
|
34
|
+
activeTriggerTarget() {
|
35
|
+
return this.triggerTargets.find(
|
36
|
+
(el) => el.dataset.value == this.activeValue,
|
37
|
+
);
|
38
|
+
}
|
39
|
+
|
40
|
+
activeContentTarget() {
|
41
|
+
return this.contentTargets.find(
|
42
|
+
(el) => el.dataset.value == this.activeValue,
|
43
|
+
);
|
44
|
+
}
|
45
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module RubyUI
|
4
4
|
class TabsTrigger < Base
|
5
5
|
def initialize(value:, **attrs)
|
6
6
|
@value = value
|
@@ -17,8 +17,8 @@ module RBUI
|
|
17
17
|
{
|
18
18
|
type: :button,
|
19
19
|
data: {
|
20
|
-
|
21
|
-
action: "click->
|
20
|
+
ruby_ui__tabs_target: "trigger",
|
21
|
+
action: "click->ruby-ui--tabs#show",
|
22
22
|
value: @value
|
23
23
|
},
|
24
24
|
class: "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module RubyUI
|
4
4
|
class Textarea < Base
|
5
5
|
def initialize(rows: 4, **attrs)
|
6
6
|
@rows = rows
|
@@ -16,8 +16,8 @@ module RBUI
|
|
16
16
|
def default_attrs
|
17
17
|
{
|
18
18
|
data: {
|
19
|
-
|
20
|
-
action: "input->
|
19
|
+
ruby_ui__form_field_target: "input",
|
20
|
+
action: "input->ruby-ui--form-field#onInput invalid->ruby-ui--form-field#onInvalid"
|
21
21
|
},
|
22
22
|
class: "flex w-full rounded-md border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 border-border focus-visible:ring-ring placeholder:text-muted-foreground"
|
23
23
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module RubyUI
|
4
4
|
class ThemeToggle < Base
|
5
5
|
def view_template(&)
|
6
6
|
div(**attrs, &)
|
@@ -20,21 +20,21 @@ module RBUI
|
|
20
20
|
|
21
21
|
def default_attrs
|
22
22
|
{
|
23
|
-
data: {controller: "
|
23
|
+
data: {controller: "ruby-ui--theme-toggle"}
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
27
27
|
def default_light_attrs
|
28
28
|
{
|
29
29
|
class: "dark:hidden",
|
30
|
-
data: {action: "click->
|
30
|
+
data: {action: "click->ruby-ui--theme-toggle#setDarkTheme"}
|
31
31
|
}
|
32
32
|
end
|
33
33
|
|
34
34
|
def default_dark_attrs
|
35
35
|
{
|
36
36
|
class: "hidden dark:inline-block",
|
37
|
-
data: {action: "click->
|
37
|
+
data: {action: "click->ruby-ui--theme-toggle#setLightTheme"}
|
38
38
|
}
|
39
39
|
end
|
40
40
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
initialize() {
|
5
|
+
this.setTheme()
|
6
|
+
}
|
7
|
+
|
8
|
+
setTheme() {
|
9
|
+
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
|
10
|
+
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
11
|
+
document.documentElement.classList.add('dark')
|
12
|
+
document.documentElement.classList.remove('light')
|
13
|
+
} else {
|
14
|
+
document.documentElement.classList.remove('dark')
|
15
|
+
document.documentElement.classList.add('light')
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
setLightTheme() {
|
20
|
+
// Whenever the user explicitly chooses light mode
|
21
|
+
localStorage.theme = 'light'
|
22
|
+
this.setTheme()
|
23
|
+
}
|
24
|
+
|
25
|
+
setDarkTheme() {
|
26
|
+
// Whenever the user explicitly chooses dark mode
|
27
|
+
localStorage.theme = 'dark'
|
28
|
+
this.setTheme()
|
29
|
+
}
|
30
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module RubyUI
|
4
4
|
class Tooltip < Base
|
5
5
|
def initialize(placement: "top", **attrs)
|
6
6
|
@placement = placement
|
@@ -16,8 +16,8 @@ module RBUI
|
|
16
16
|
def default_attrs
|
17
17
|
{
|
18
18
|
data: {
|
19
|
-
controller: "
|
20
|
-
|
19
|
+
controller: "ruby-ui--tooltip",
|
20
|
+
ruby_ui__tooltip_placement_value: @placement
|
21
21
|
},
|
22
22
|
class: "group"
|
23
23
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module RubyUI
|
4
4
|
class TooltipContent < Base
|
5
5
|
def initialize(**attrs)
|
6
6
|
@id = "tooltip#{SecureRandom.hex(4)}"
|
@@ -17,9 +17,9 @@ module RBUI
|
|
17
17
|
{
|
18
18
|
id: @id,
|
19
19
|
data: {
|
20
|
-
|
20
|
+
ruby_ui__tooltip_target: "content"
|
21
21
|
},
|
22
|
-
class: "invisible peer-hover:visible peer-focus:visible w-max absolute top-0 left-0 z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md peer-focus:zoom-in-95 animate-out fade-out-0 zoom-out-95 peer-hover:animate-in peer-focus:animate-in peer-hover:fade-in-0 peer-focus:fade-in-0 peer-hover:zoom-in-95 group-data-[
|
22
|
+
class: "invisible peer-hover:visible peer-focus:visible w-max absolute top-0 left-0 z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md peer-focus:zoom-in-95 animate-out fade-out-0 zoom-out-95 peer-hover:animate-in peer-focus:animate-in peer-hover:fade-in-0 peer-focus:fade-in-0 peer-hover:zoom-in-95 group-data-[ruby-ui--tooltip-placement-value=bottom]:slide-in-from-top-2 group-data-[ruby-ui--tooltip-placement-value=left]:slide-in-from-right-2 group-data-[ruby-ui--tooltip-placement-value=right]:slide-in-from-left-2 group-data-[ruby-ui--tooltip-placement-value=top]:slide-in-from-bottom-2 delay-500"
|
23
23
|
}
|
24
24
|
end
|
25
25
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
2
|
+
import { computePosition, autoUpdate, offset } from "@floating-ui/dom";
|
3
|
+
|
4
|
+
export default class extends Controller {
|
5
|
+
static targets = ["trigger", "content"];
|
6
|
+
static values = { placement: String }
|
7
|
+
|
8
|
+
constructor(...args) {
|
9
|
+
super(...args);
|
10
|
+
this.cleanup;
|
11
|
+
}
|
12
|
+
|
13
|
+
connect() {
|
14
|
+
this.setFloatingElement();
|
15
|
+
|
16
|
+
const tooltipId = this.contentTarget.getAttribute("id");
|
17
|
+
this.triggerTarget.setAttribute("aria-describedby", tooltipId);
|
18
|
+
|
19
|
+
}
|
20
|
+
|
21
|
+
disconnect() {
|
22
|
+
this.cleanup();
|
23
|
+
}
|
24
|
+
|
25
|
+
setFloatingElement() {
|
26
|
+
console.log(this.placementValue);
|
27
|
+
|
28
|
+
this.cleanup = autoUpdate(this.triggerTarget, this.contentTarget, () => {
|
29
|
+
computePosition(this.triggerTarget, this.contentTarget, { placement: this.placementValue, middleware: [offset(4)] }).then(({ x, y }) => {
|
30
|
+
Object.assign(this.contentTarget.style, {
|
31
|
+
left: `${x}px`,
|
32
|
+
top: `${y}px`,
|
33
|
+
});
|
34
|
+
});
|
35
|
+
});
|
36
|
+
}
|
37
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module RubyUI
|
4
4
|
class TooltipTrigger < Base
|
5
5
|
def view_template(&)
|
6
6
|
div(**attrs, &)
|
@@ -10,7 +10,7 @@ module RBUI
|
|
10
10
|
|
11
11
|
def default_attrs
|
12
12
|
{
|
13
|
-
data: {
|
13
|
+
data: {ruby_ui__tooltip_target: "trigger"},
|
14
14
|
variant: :outline,
|
15
15
|
class: "peer"
|
16
16
|
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class Heading < Base
|
5
|
+
def initialize(level: nil, as: nil, size: nil, **attrs)
|
6
|
+
@level = level
|
7
|
+
@as = as
|
8
|
+
@size = size
|
9
|
+
super(**attrs)
|
10
|
+
end
|
11
|
+
|
12
|
+
def view_template(&)
|
13
|
+
tag = determine_tag
|
14
|
+
public_send(tag, **attrs, &)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def determine_tag
|
20
|
+
return @as if @as
|
21
|
+
return "h#{@level}" if @level
|
22
|
+
"h1"
|
23
|
+
end
|
24
|
+
|
25
|
+
def default_attrs
|
26
|
+
{
|
27
|
+
class: class_names
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def class_names
|
32
|
+
base_classes = "scroll-m-20 font-bold tracking-tight"
|
33
|
+
size_class = size_to_class[(@size || level_to_size[@level&.to_s] || "6").to_s]
|
34
|
+
"#{base_classes} #{size_class}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def size_to_class
|
38
|
+
{
|
39
|
+
"1" => "text-xs",
|
40
|
+
"2" => "text-sm",
|
41
|
+
"3" => "text-base",
|
42
|
+
"4" => "text-lg",
|
43
|
+
"5" => "text-xl",
|
44
|
+
"6" => "text-2xl",
|
45
|
+
"7" => "text-3xl lg:text-4xl",
|
46
|
+
"8" => "text-4xl",
|
47
|
+
"9" => "text-5xl"
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def level_to_size
|
52
|
+
{
|
53
|
+
"1" => "7",
|
54
|
+
"2" => "6",
|
55
|
+
"3" => "5",
|
56
|
+
"4" => "4"
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class Text < Base
|
5
|
+
def initialize(as: "p", size: "3", weight: "regular", **attrs)
|
6
|
+
@as = as
|
7
|
+
@size = size
|
8
|
+
@weight = weight
|
9
|
+
super(**attrs)
|
10
|
+
end
|
11
|
+
|
12
|
+
def view_template(&)
|
13
|
+
public_send(@as, **attrs, &)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def default_attrs
|
19
|
+
{
|
20
|
+
class: class_names
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def class_names
|
25
|
+
"#{size_to_class[@size]} #{weight_to_class[@weight]}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def size_to_class
|
29
|
+
{
|
30
|
+
"1" => "text-xs", "xs" => "text-xs",
|
31
|
+
"2" => "text-sm", "sm" => "text-sm",
|
32
|
+
"3" => "text-base", "base" => "text-base",
|
33
|
+
"4" => "text-lg", "lg" => "text-lg",
|
34
|
+
"5" => "text-xl", "xl" => "text-xl",
|
35
|
+
"6" => "text-2xl", "2xl" => "text-2xl",
|
36
|
+
"7" => "text-3xl", "3xl" => "text-3xl",
|
37
|
+
"8" => "text-4xl", "4xl" => "text-4xl",
|
38
|
+
"9" => "text-5xl", "5xl" => "text-5xl"
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def weight_to_class
|
43
|
+
{
|
44
|
+
"muted" => "text-muted-foreground",
|
45
|
+
"light" => "font-light",
|
46
|
+
"regular" => "font-normal",
|
47
|
+
"medium" => "font-medium",
|
48
|
+
"semibold" => "font-semibold",
|
49
|
+
"bold" => "font-bold"
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/ruby_ui.rb
CHANGED