ruby_ui 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/generators/ruby_ui/component_generator.rb +130 -0
- data/lib/generators/ruby_ui/install/install_generator.rb +90 -0
- data/lib/generators/ruby_ui/javascript_utils.rb +36 -0
- data/lib/ruby_ui/accordion/accordion.rb +17 -0
- data/lib/ruby_ui/accordion/accordion_content.rb +21 -0
- data/lib/ruby_ui/accordion/accordion_default_content.rb +17 -0
- data/lib/ruby_ui/accordion/accordion_default_trigger.rb +19 -0
- data/lib/ruby_ui/accordion/accordion_icon.rb +38 -0
- data/lib/ruby_ui/accordion/accordion_item.rb +28 -0
- data/lib/ruby_ui/accordion/accordion_trigger.rb +17 -0
- data/lib/ruby_ui/alert/alert.rb +36 -0
- data/lib/ruby_ui/alert/alert_description.rb +17 -0
- data/lib/ruby_ui/alert/alert_title.rb +17 -0
- data/lib/ruby_ui/alert_dialog/alert_dialog.rb +26 -0
- data/lib/ruby_ui/alert_dialog/alert_dialog_action.rb +17 -0
- data/lib/ruby_ui/alert_dialog/alert_dialog_cancel.rb +21 -0
- data/lib/ruby_ui/alert_dialog/alert_dialog_content.rb +45 -0
- data/lib/ruby_ui/alert_dialog/alert_dialog_description.rb +17 -0
- data/lib/ruby_ui/alert_dialog/alert_dialog_footer.rb +17 -0
- data/lib/ruby_ui/alert_dialog/alert_dialog_header.rb +17 -0
- data/lib/ruby_ui/alert_dialog/alert_dialog_title.rb +17 -0
- data/lib/ruby_ui/alert_dialog/alert_dialog_trigger.rb +18 -0
- data/lib/ruby_ui/aspect_ratio/aspect_ratio.rb +33 -0
- data/lib/ruby_ui/avatar/avatar.rb +31 -0
- data/lib/ruby_ui/avatar/avatar_fallback.rb +17 -0
- data/lib/ruby_ui/avatar/avatar_image.rb +26 -0
- data/lib/ruby_ui/badge/badge.rb +60 -0
- data/lib/ruby_ui/base.rb +22 -0
- data/lib/ruby_ui/button/button.rb +97 -0
- data/lib/ruby_ui/calendar/calendar.rb +39 -0
- data/lib/ruby_ui/calendar/calendar_body.rb +19 -0
- data/lib/ruby_ui/calendar/calendar_days.rb +104 -0
- data/lib/ruby_ui/calendar/calendar_header.rb +17 -0
- data/lib/ruby_ui/calendar/calendar_next.rb +43 -0
- data/lib/ruby_ui/calendar/calendar_prev.rb +43 -0
- data/lib/ruby_ui/calendar/calendar_title.rb +27 -0
- data/lib/ruby_ui/calendar/calendar_weekdays.rb +33 -0
- data/lib/ruby_ui/card/card.rb +17 -0
- data/lib/ruby_ui/card/card_content.rb +17 -0
- data/lib/ruby_ui/card/card_description.rb +17 -0
- data/lib/ruby_ui/card/card_footer.rb +17 -0
- data/lib/ruby_ui/card/card_header.rb +17 -0
- data/lib/ruby_ui/card/card_title.rb +17 -0
- data/lib/ruby_ui/chart/chart.rb +23 -0
- data/lib/ruby_ui/checkbox/checkbox.rb +23 -0
- data/lib/ruby_ui/checkbox/checkbox_group.rb +20 -0
- data/lib/ruby_ui/clipboard/clipboard.rb +42 -0
- data/lib/ruby_ui/clipboard/clipboard_popover.rb +40 -0
- data/lib/ruby_ui/clipboard/clipboard_source.rb +19 -0
- data/lib/ruby_ui/clipboard/clipboard_trigger.rb +20 -0
- data/lib/ruby_ui/codeblock/codeblock.rb +102 -0
- data/lib/ruby_ui/collapsible/collapsible.rb +25 -0
- data/lib/ruby_ui/collapsible/collapsible_content.rb +18 -0
- data/lib/ruby_ui/collapsible/collapsible_trigger.rb +19 -0
- data/lib/ruby_ui/combobox/combobox.rb +24 -0
- data/lib/ruby_ui/combobox/combobox_content.rb +31 -0
- data/lib/ruby_ui/combobox/combobox_empty.rb +21 -0
- data/lib/ruby_ui/combobox/combobox_group.rb +38 -0
- data/lib/ruby_ui/combobox/combobox_input.rb +22 -0
- data/lib/ruby_ui/combobox/combobox_item.rb +53 -0
- data/lib/ruby_ui/combobox/combobox_list.rb +27 -0
- data/lib/ruby_ui/combobox/combobox_search_input.rb +56 -0
- data/lib/ruby_ui/combobox/combobox_separator.rb +15 -0
- data/lib/ruby_ui/combobox/combobox_trigger.rb +52 -0
- data/lib/ruby_ui/combobox/combobox_value.rb +27 -0
- data/lib/ruby_ui/command/command.rb +9 -0
- data/lib/ruby_ui/command/command_dialog.rb +17 -0
- data/lib/ruby_ui/command/command_dialog_content.rb +48 -0
- data/lib/ruby_ui/command/command_dialog_trigger.rb +29 -0
- data/lib/ruby_ui/command/command_empty.rb +19 -0
- data/lib/ruby_ui/command/command_group.rb +40 -0
- data/lib/ruby_ui/command/command_input.rb +56 -0
- data/lib/ruby_ui/command/command_item.rb +32 -0
- data/lib/ruby_ui/command/command_list.rb +17 -0
- data/lib/ruby_ui/context_menu/context_menu.rb +26 -0
- data/lib/ruby_ui/context_menu/context_menu_content.rb +25 -0
- data/lib/ruby_ui/context_menu/context_menu_item.rb +66 -0
- data/lib/ruby_ui/context_menu/context_menu_label.rb +24 -0
- data/lib/ruby_ui/context_menu/context_menu_separator.rb +19 -0
- data/lib/ruby_ui/context_menu/context_menu_trigger.rb +20 -0
- data/lib/ruby_ui/dialog/dialog.rb +25 -0
- data/lib/ruby_ui/dialog/dialog_content.rb +78 -0
- data/lib/ruby_ui/dialog/dialog_description.rb +17 -0
- data/lib/ruby_ui/dialog/dialog_footer.rb +17 -0
- data/lib/ruby_ui/dialog/dialog_header.rb +17 -0
- data/lib/ruby_ui/dialog/dialog_middle.rb +17 -0
- data/lib/ruby_ui/dialog/dialog_title.rb +17 -0
- data/lib/ruby_ui/dialog/dialog_trigger.rb +20 -0
- data/lib/ruby_ui/dropdown_menu/dropdown_menu.rb +26 -0
- data/lib/ruby_ui/dropdown_menu/dropdown_menu_content.rb +22 -0
- data/lib/ruby_ui/dropdown_menu/dropdown_menu_item.rb +28 -0
- data/lib/ruby_ui/dropdown_menu/dropdown_menu_label.rb +17 -0
- data/lib/ruby_ui/dropdown_menu/dropdown_menu_separator.rb +19 -0
- data/lib/ruby_ui/dropdown_menu/dropdown_menu_trigger.rb +18 -0
- data/lib/ruby_ui/form/form.rb +15 -0
- data/lib/ruby_ui/form/form_field.rb +20 -0
- data/lib/ruby_ui/form/form_field_error.rb +20 -0
- data/lib/ruby_ui/form/form_field_hint.rb +15 -0
- data/lib/ruby_ui/form/form_field_label.rb +15 -0
- data/lib/ruby_ui/hover_card/hover_card.rb +27 -0
- data/lib/ruby_ui/hover_card/hover_card_content.rb +22 -0
- data/lib/ruby_ui/hover_card/hover_card_trigger.rb +20 -0
- data/lib/ruby_ui/input/input.rb +26 -0
- data/lib/ruby_ui/link/link.rb +97 -0
- data/lib/ruby_ui/masked_input/masked_input.rb +15 -0
- data/lib/ruby_ui/pagination/pagination.rb +19 -0
- data/lib/ruby_ui/pagination/pagination_content.rb +17 -0
- data/lib/ruby_ui/pagination/pagination_ellipsis.rb +42 -0
- data/lib/ruby_ui/pagination/pagination_item.rb +28 -0
- data/lib/ruby_ui/popover/popover.rb +26 -0
- data/lib/ruby_ui/popover/popover_content.rb +27 -0
- data/lib/ruby_ui/popover/popover_trigger.rb +20 -0
- data/lib/ruby_ui/radio_button/radio_button.rb +22 -0
- data/lib/ruby_ui/select/select.rb +23 -0
- data/lib/ruby_ui/select/select_content.rb +32 -0
- data/lib/ruby_ui/select/select_group.rb +15 -0
- data/lib/ruby_ui/select/select_input.rb +22 -0
- data/lib/ruby_ui/select/select_item.rb +52 -0
- data/lib/ruby_ui/select/select_label.rb +17 -0
- data/lib/ruby_ui/select/select_trigger.rb +54 -0
- data/lib/ruby_ui/select/select_value.rb +27 -0
- data/lib/ruby_ui/sheet/sheet.rb +17 -0
- data/lib/ruby_ui/sheet/sheet_content.rb +77 -0
- data/lib/ruby_ui/sheet/sheet_description.rb +17 -0
- data/lib/ruby_ui/sheet/sheet_footer.rb +17 -0
- data/lib/ruby_ui/sheet/sheet_header.rb +17 -0
- data/lib/ruby_ui/sheet/sheet_middle.rb +17 -0
- data/lib/ruby_ui/sheet/sheet_title.rb +17 -0
- data/lib/ruby_ui/sheet/sheet_trigger.rb +17 -0
- data/lib/ruby_ui/shortcut_key/shortcut_key.rb +17 -0
- data/lib/ruby_ui/table/table.rb +19 -0
- data/lib/ruby_ui/table/table_body.rb +17 -0
- data/lib/ruby_ui/table/table_caption.rb +17 -0
- data/lib/ruby_ui/table/table_cell.rb +17 -0
- data/lib/ruby_ui/table/table_footer.rb +17 -0
- data/lib/ruby_ui/table/table_head.rb +17 -0
- data/lib/ruby_ui/table/table_header.rb +17 -0
- data/lib/ruby_ui/table/table_row.rb +17 -0
- data/lib/ruby_ui/tabs/tabs.rb +25 -0
- data/lib/ruby_ui/tabs/tabs_content.rb +26 -0
- data/lib/ruby_ui/tabs/tabs_list.rb +17 -0
- data/lib/ruby_ui/tabs/tabs_trigger.rb +28 -0
- data/lib/ruby_ui/textarea/textarea.rb +26 -0
- data/lib/ruby_ui/theme_toggle/theme_toggle.rb +41 -0
- data/lib/ruby_ui/tooltip/tooltip.rb +26 -0
- data/lib/ruby_ui/tooltip/tooltip_content.rb +26 -0
- data/lib/ruby_ui/tooltip/tooltip_trigger.rb +19 -0
- data/lib/ruby_ui/typography/heading.rb +60 -0
- data/lib/ruby_ui/typography/inline_code.rb +17 -0
- data/lib/ruby_ui/typography/inline_link.rb +22 -0
- data/lib/ruby_ui/typography/text.rb +53 -0
- data/lib/ruby_ui/typography/typography_blockquote.rb +17 -0
- data/lib/ruby_ui.rb +5 -0
- metadata +280 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class TableCell < Base
|
5
|
+
def view_template(&)
|
6
|
+
td(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_attrs
|
12
|
+
{
|
13
|
+
class: "p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]"
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class TableFooter < Base
|
5
|
+
def view_template(&)
|
6
|
+
tfoot(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_attrs
|
12
|
+
{
|
13
|
+
class: "border-t bg-muted bg-opacity-50 font-medium[& amp;>tr]:last:border-b-0"
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class TableHead < Base
|
5
|
+
def view_template(&)
|
6
|
+
th(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_attrs
|
12
|
+
{
|
13
|
+
class: "h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]"
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class TableRow < Base
|
5
|
+
def view_template(&)
|
6
|
+
tr(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_attrs
|
12
|
+
{
|
13
|
+
class: "border-b transition-colors hover:bg-muted hover:bg-opacity-50 data-[state=selected]:bg-muted"
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class Tabs < Base
|
5
|
+
def initialize(default: nil, **attrs)
|
6
|
+
@default = default
|
7
|
+
super(**attrs)
|
8
|
+
end
|
9
|
+
|
10
|
+
def view_template(&)
|
11
|
+
div(**attrs, &)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def default_attrs
|
17
|
+
{
|
18
|
+
data: {
|
19
|
+
controller: "ruby-ui--tabs",
|
20
|
+
ruby_ui__tabs_active_value: @default
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class TabsContent < Base
|
5
|
+
def initialize(value:, **attrs)
|
6
|
+
@value = value
|
7
|
+
super(**attrs)
|
8
|
+
end
|
9
|
+
|
10
|
+
def view_template(&)
|
11
|
+
div(**attrs, &)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def default_attrs
|
17
|
+
{
|
18
|
+
data: {
|
19
|
+
ruby_ui__tabs_target: :content,
|
20
|
+
value: @value
|
21
|
+
},
|
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"
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class TabsList < Base
|
5
|
+
def view_template(&)
|
6
|
+
div(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_attrs
|
12
|
+
{
|
13
|
+
class: "inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground"
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class TabsTrigger < Base
|
5
|
+
def initialize(value:, **attrs)
|
6
|
+
@value = value
|
7
|
+
super(**attrs)
|
8
|
+
end
|
9
|
+
|
10
|
+
def view_template(&)
|
11
|
+
button(**attrs, &)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def default_attrs
|
17
|
+
{
|
18
|
+
type: :button,
|
19
|
+
data: {
|
20
|
+
ruby_ui__tabs_target: "trigger",
|
21
|
+
action: "click->ruby-ui--tabs#show",
|
22
|
+
value: @value
|
23
|
+
},
|
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"
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class Textarea < Base
|
5
|
+
def initialize(rows: 4, **attrs)
|
6
|
+
@rows = rows
|
7
|
+
super(**attrs)
|
8
|
+
end
|
9
|
+
|
10
|
+
def view_template(&)
|
11
|
+
textarea(rows: @rows, **attrs, &)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def default_attrs
|
17
|
+
{
|
18
|
+
data: {
|
19
|
+
ruby_ui__form_field_target: "input",
|
20
|
+
action: "input->ruby-ui--form-field#onInput invalid->ruby-ui--form-field#onInvalid"
|
21
|
+
},
|
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
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class ThemeToggle < Base
|
5
|
+
def view_template(&)
|
6
|
+
div(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
def light_mode(**user_attrs, &)
|
10
|
+
light_attrs = mix(default_light_attrs, user_attrs)
|
11
|
+
div(**light_attrs, &)
|
12
|
+
end
|
13
|
+
|
14
|
+
def dark_mode(**user_attrs, &)
|
15
|
+
dark_attrs = mix(default_dark_attrs, user_attrs)
|
16
|
+
div(**dark_attrs, &)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def default_attrs
|
22
|
+
{
|
23
|
+
data: {controller: "ruby-ui--theme-toggle"}
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def default_light_attrs
|
28
|
+
{
|
29
|
+
class: "dark:hidden",
|
30
|
+
data: {action: "click->ruby-ui--theme-toggle#setDarkTheme"}
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def default_dark_attrs
|
35
|
+
{
|
36
|
+
class: "hidden dark:inline-block",
|
37
|
+
data: {action: "click->ruby-ui--theme-toggle#setLightTheme"}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class Tooltip < Base
|
5
|
+
def initialize(placement: "top", **attrs)
|
6
|
+
@placement = placement
|
7
|
+
super(**attrs)
|
8
|
+
end
|
9
|
+
|
10
|
+
def view_template(&)
|
11
|
+
div(**attrs, &)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def default_attrs
|
17
|
+
{
|
18
|
+
data: {
|
19
|
+
controller: "ruby-ui--tooltip",
|
20
|
+
ruby_ui__tooltip_placement_value: @placement
|
21
|
+
},
|
22
|
+
class: "group"
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class TooltipContent < Base
|
5
|
+
def initialize(**attrs)
|
6
|
+
@id = "tooltip#{SecureRandom.hex(4)}"
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def view_template(&)
|
11
|
+
div(**attrs, &)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def default_attrs
|
17
|
+
{
|
18
|
+
id: @id,
|
19
|
+
data: {
|
20
|
+
ruby_ui__tooltip_target: "content"
|
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-[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
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class TooltipTrigger < Base
|
5
|
+
def view_template(&)
|
6
|
+
div(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_attrs
|
12
|
+
{
|
13
|
+
data: {ruby_ui__tooltip_target: "trigger"},
|
14
|
+
variant: :outline,
|
15
|
+
class: "peer"
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -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,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class InlineCode < Base
|
5
|
+
def view_template(&)
|
6
|
+
code(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_attrs
|
12
|
+
{
|
13
|
+
class: "relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold"
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyUI
|
4
|
+
class InlineLink < Base
|
5
|
+
def initialize(href:, **attrs)
|
6
|
+
super(**attrs)
|
7
|
+
@href = href
|
8
|
+
end
|
9
|
+
|
10
|
+
def view_template(&)
|
11
|
+
a(href: @href, **attrs, &)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def default_attrs
|
17
|
+
{
|
18
|
+
class: "text-primary font-medium hover:underline underline-offset-4 cursor-pointer"
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
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
|