rbui 0.0.0 → 1.0.0.pre.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbui/accordion/accordion.rb +17 -0
- data/lib/rbui/accordion/accordion_content.rb +21 -0
- data/lib/rbui/accordion/accordion_default_content.rb +17 -0
- data/lib/rbui/accordion/accordion_default_trigger.rb +19 -0
- data/lib/rbui/accordion/accordion_icon.rb +38 -0
- data/lib/rbui/accordion/accordion_item.rb +28 -0
- data/lib/rbui/accordion/accordion_trigger.rb +16 -0
- data/lib/rbui/alert/alert.rb +36 -0
- data/lib/rbui/alert/alert_description.rb +17 -0
- data/lib/rbui/alert/alert_title.rb +17 -0
- data/lib/rbui/alert_dialog/alert_dialog.rb +26 -0
- data/lib/rbui/alert_dialog/alert_dialog_action.rb +17 -0
- data/lib/rbui/alert_dialog/alert_dialog_cancel.rb +21 -0
- data/lib/rbui/alert_dialog/alert_dialog_content.rb +45 -0
- data/lib/rbui/alert_dialog/alert_dialog_description.rb +17 -0
- data/lib/rbui/alert_dialog/alert_dialog_footer.rb +17 -0
- data/lib/rbui/alert_dialog/alert_dialog_header.rb +17 -0
- data/lib/rbui/alert_dialog/alert_dialog_title.rb +17 -0
- data/lib/rbui/alert_dialog/alert_dialog_trigger.rb +18 -0
- data/lib/rbui/aspect_ratio/aspect_ratio.rb +33 -0
- data/lib/rbui/avatar/avatar.rb +31 -0
- data/lib/rbui/avatar/avatar_fallback.rb +17 -0
- data/lib/rbui/avatar/avatar_image.rb +26 -0
- data/lib/rbui/badge/badge.rb +60 -0
- data/lib/rbui/base.rb +27 -0
- data/lib/rbui/button/button.rb +97 -0
- data/lib/rbui/calendar/calendar.rb +39 -0
- data/lib/rbui/calendar/calendar_body.rb +19 -0
- data/lib/rbui/calendar/calendar_days.rb +104 -0
- data/lib/rbui/calendar/calendar_header.rb +17 -0
- data/lib/rbui/calendar/calendar_next.rb +43 -0
- data/lib/rbui/calendar/calendar_prev.rb +43 -0
- data/lib/rbui/calendar/calendar_title.rb +27 -0
- data/lib/rbui/calendar/calendar_weekdays.rb +33 -0
- data/lib/rbui/card/card.rb +17 -0
- data/lib/rbui/card/card_content.rb +17 -0
- data/lib/rbui/card/card_description.rb +17 -0
- data/lib/rbui/card/card_footer.rb +17 -0
- data/lib/rbui/card/card_header.rb +17 -0
- data/lib/rbui/card/card_title.rb +17 -0
- data/lib/rbui/chart/chart.rb +23 -0
- data/lib/rbui/checkbox/checkbox.rb +23 -0
- data/lib/rbui/checkbox/checkbox_group.rb +20 -0
- data/lib/rbui/clipboard/clipboard.rb +42 -0
- data/lib/rbui/clipboard/clipboard_popover.rb +40 -0
- data/lib/rbui/clipboard/clipboard_source.rb +19 -0
- data/lib/rbui/clipboard/clipboard_trigger.rb +20 -0
- data/lib/rbui/codeblock/codeblock.rb +105 -0
- data/lib/rbui/collapsible/collapsible.rb +25 -0
- data/lib/rbui/collapsible/collapsible_content.rb +18 -0
- data/lib/rbui/collapsible/collapsible_trigger.rb +19 -0
- data/lib/rbui/combobox/combobox.rb +24 -0
- data/lib/rbui/combobox/combobox_content.rb +31 -0
- data/lib/rbui/combobox/combobox_empty.rb +21 -0
- data/lib/rbui/combobox/combobox_group.rb +38 -0
- data/lib/rbui/combobox/combobox_input.rb +22 -0
- data/lib/rbui/combobox/combobox_item.rb +53 -0
- data/lib/rbui/combobox/combobox_list.rb +29 -0
- data/lib/rbui/combobox/combobox_search_input.rb +56 -0
- data/lib/rbui/combobox/combobox_separator.rb +15 -0
- data/lib/rbui/combobox/combobox_trigger.rb +52 -0
- data/lib/rbui/combobox/combobox_value.rb +27 -0
- data/lib/rbui/command/command.rb +9 -0
- data/lib/rbui/command/command_dialog.rb +17 -0
- data/lib/rbui/command/command_dialog_content.rb +48 -0
- data/lib/rbui/command/command_dialog_trigger.rb +29 -0
- data/lib/rbui/command/command_empty.rb +19 -0
- data/lib/rbui/command/command_group.rb +40 -0
- data/lib/rbui/command/command_input.rb +56 -0
- data/lib/rbui/command/command_item.rb +32 -0
- data/lib/rbui/command/command_list.rb +17 -0
- data/lib/rbui/context_menu/context_menu.rb +26 -0
- data/lib/rbui/context_menu/context_menu_content.rb +25 -0
- data/lib/rbui/context_menu/context_menu_item.rb +66 -0
- data/lib/rbui/context_menu/context_menu_label.rb +24 -0
- data/lib/rbui/context_menu/context_menu_separator.rb +19 -0
- data/lib/rbui/context_menu/context_menu_trigger.rb +20 -0
- data/lib/rbui/dialog/dialog.rb +25 -0
- data/lib/rbui/dialog/dialog_content.rb +78 -0
- data/lib/rbui/dialog/dialog_description.rb +17 -0
- data/lib/rbui/dialog/dialog_footer.rb +17 -0
- data/lib/rbui/dialog/dialog_header.rb +17 -0
- data/lib/rbui/dialog/dialog_middle.rb +17 -0
- data/lib/rbui/dialog/dialog_title.rb +17 -0
- data/lib/rbui/dialog/dialog_trigger.rb +20 -0
- data/lib/rbui/dropdown_menu/dropdown_menu.rb +26 -0
- data/lib/rbui/dropdown_menu/dropdown_menu_content.rb +22 -0
- data/lib/rbui/dropdown_menu/dropdown_menu_item.rb +28 -0
- data/lib/rbui/dropdown_menu/dropdown_menu_label.rb +17 -0
- data/lib/rbui/dropdown_menu/dropdown_menu_separator.rb +19 -0
- data/lib/rbui/dropdown_menu/dropdown_menu_trigger.rb +18 -0
- data/lib/rbui/form/form.rb +15 -0
- data/lib/rbui/form/form_field.rb +20 -0
- data/lib/rbui/form/form_field_error.rb +20 -0
- data/lib/rbui/form/form_field_hint.rb +15 -0
- data/lib/rbui/form/form_field_label.rb +15 -0
- data/lib/rbui/hover_card/hover_card.rb +27 -0
- data/lib/rbui/hover_card/hover_card_content.rb +22 -0
- data/lib/rbui/hover_card/hover_card_trigger.rb +20 -0
- data/lib/rbui/input/input.rb +26 -0
- data/lib/rbui/link/link.rb +97 -0
- data/lib/rbui/pagination/pagination.rb +19 -0
- data/lib/rbui/pagination/pagination_content.rb +17 -0
- data/lib/rbui/pagination/pagination_ellipsis.rb +42 -0
- data/lib/rbui/pagination/pagination_item.rb +28 -0
- data/lib/rbui/popover/popover.rb +25 -0
- data/lib/rbui/popover/popover_content.rb +22 -0
- data/lib/rbui/popover/popover_trigger.rb +20 -0
- data/lib/rbui/radio_button/radio_button.rb +22 -0
- data/lib/rbui/select/select.rb +23 -0
- data/lib/rbui/select/select_content.rb +32 -0
- data/lib/rbui/select/select_group.rb +15 -0
- data/lib/rbui/select/select_input.rb +22 -0
- data/lib/rbui/select/select_item.rb +52 -0
- data/lib/rbui/select/select_label.rb +17 -0
- data/lib/rbui/select/select_trigger.rb +54 -0
- data/lib/rbui/select/select_value.rb +27 -0
- data/lib/rbui/sheet/sheet.rb +17 -0
- data/lib/rbui/sheet/sheet_content.rb +77 -0
- data/lib/rbui/sheet/sheet_description.rb +17 -0
- data/lib/rbui/sheet/sheet_footer.rb +17 -0
- data/lib/rbui/sheet/sheet_header.rb +17 -0
- data/lib/rbui/sheet/sheet_middle.rb +17 -0
- data/lib/rbui/sheet/sheet_title.rb +17 -0
- data/lib/rbui/sheet/sheet_trigger.rb +17 -0
- data/lib/rbui/shortcut_key/shortcut_key.rb +17 -0
- data/lib/rbui/table/table.rb +19 -0
- data/lib/rbui/table/table_body.rb +17 -0
- data/lib/rbui/table/table_caption.rb +17 -0
- data/lib/rbui/table/table_cell.rb +17 -0
- data/lib/rbui/table/table_footer.rb +17 -0
- data/lib/rbui/table/table_head.rb +17 -0
- data/lib/rbui/table/table_header.rb +17 -0
- data/lib/rbui/table/table_row.rb +17 -0
- data/lib/rbui/tabs/tabs.rb +25 -0
- data/lib/rbui/tabs/tabs_content.rb +26 -0
- data/lib/rbui/tabs/tabs_list.rb +17 -0
- data/lib/rbui/tabs/tabs_trigger.rb +28 -0
- data/lib/rbui/theme_toggle/theme_toggle.rb +41 -0
- data/lib/rbui/tooltip/tooltip.rb +26 -0
- data/lib/rbui/tooltip/tooltip_content.rb +26 -0
- data/lib/rbui/tooltip/tooltip_trigger.rb +19 -0
- data/lib/rbui/typography/typography_blockquote.rb +17 -0
- data/lib/rbui/typography/typography_h1.rb +17 -0
- data/lib/rbui/typography/typography_h2.rb +17 -0
- data/lib/rbui/typography/typography_h3.rb +17 -0
- data/lib/rbui/typography/typography_h4.rb +17 -0
- data/lib/rbui/typography/typography_inline_code.rb +17 -0
- data/lib/rbui/typography/typography_inline_link.rb +22 -0
- data/lib/rbui/typography/typography_large.rb +17 -0
- data/lib/rbui/typography/typography_lead.rb +17 -0
- data/lib/rbui/typography/typography_list.rb +47 -0
- data/lib/rbui/typography/typography_list_item.rb +17 -0
- data/lib/rbui/typography/typography_muted.rb +17 -0
- data/lib/rbui/typography/typography_p.rb +17 -0
- data/lib/rbui/typography/typography_small.rb +17 -0
- data/lib/rbui/version.rb +5 -0
- data/lib/rbui.rb +42 -3
- metadata +254 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 794cdf4660f12d1e59c2c2d9f6652bc08142b19679b716b7455ef528ffe8de9a
|
4
|
+
data.tar.gz: cb8a388fc16a758575396ec1716a758614a341c70683ff5a83c4ff01d13e8360
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fac186cab781c5331efa8a88f510711f1b73455535e42b841e0d798b8548f66cd95498a6bfdf8ebf95570ef063ae611a6eae04c9915e14cfb17d4478b4b947fd
|
7
|
+
data.tar.gz: 43083c45bf22547efab83489001106102f82fce9ab07d61f4cd2f6047c3bcc0cc412360517367eb5ccfd7c5a19fa07b11dd36fde080df2149f6e8934c1ca6852
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class AccordionContent < Base
|
5
|
+
def view_template(&)
|
6
|
+
div(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_attrs
|
12
|
+
{
|
13
|
+
data: {
|
14
|
+
rbui__accordion_target: "content"
|
15
|
+
},
|
16
|
+
class: "overflow-y-hidden",
|
17
|
+
style: "height: 0px;"
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class AccordionDefaultTrigger < Base
|
5
|
+
def view_template(&block)
|
6
|
+
div(class: "flex items-center justify-between w-full") do
|
7
|
+
p(&block)
|
8
|
+
RBUI.AccordionIcon
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def default_attrs
|
13
|
+
{
|
14
|
+
data: {action: "click->rbui--accordion#toggle"},
|
15
|
+
class: "w-full flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline"
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class AccordionIcon < Base
|
5
|
+
def view_template(&block)
|
6
|
+
span(**attrs) do
|
7
|
+
if block
|
8
|
+
block.call
|
9
|
+
else
|
10
|
+
icon
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def icon
|
16
|
+
svg(
|
17
|
+
xmlns: "http://www.w3.org/2000/svg",
|
18
|
+
viewbox: "0 0 20 20",
|
19
|
+
fill: "currentColor",
|
20
|
+
class: "w-4 h-4"
|
21
|
+
) do |s|
|
22
|
+
s.path(
|
23
|
+
fill_rule: "evenodd",
|
24
|
+
d:
|
25
|
+
"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",
|
26
|
+
clip_rule: "evenodd"
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_attrs
|
32
|
+
{
|
33
|
+
class: "opacity-50",
|
34
|
+
data: {rbui__accordion_target: "icon"}
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class AccordionItem < Base
|
5
|
+
def initialize(open: false, rotate_icon: 180, **attrs)
|
6
|
+
@open = open
|
7
|
+
@rotate_icon = rotate_icon
|
8
|
+
super(**attrs)
|
9
|
+
end
|
10
|
+
|
11
|
+
def view_template(&)
|
12
|
+
div(**attrs, &)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def default_attrs
|
18
|
+
{
|
19
|
+
data: {
|
20
|
+
controller: "rbui--accordion",
|
21
|
+
rbui__accordion_open_value: @open,
|
22
|
+
rbui__accordion_rotate_icon_value: @rotate_icon
|
23
|
+
},
|
24
|
+
class: "border-b"
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class AccordionTrigger < Base
|
5
|
+
def view_template(&)
|
6
|
+
button(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
def default_attrs
|
10
|
+
{
|
11
|
+
data: {action: "click->rbui--accordion#toggle"},
|
12
|
+
class: "w-full flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline"
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class Alert < Base
|
5
|
+
def initialize(variant: nil, **attrs)
|
6
|
+
@variant = variant
|
7
|
+
super(**attrs) # must be called after variant is set
|
8
|
+
end
|
9
|
+
|
10
|
+
def view_template(&)
|
11
|
+
div(**attrs, &)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def colors
|
17
|
+
case @variant
|
18
|
+
when nil
|
19
|
+
"ring-border bg-muted/20 text-foreground [&>svg]:opacity-80"
|
20
|
+
when :warning
|
21
|
+
"ring-warning/20 bg-warning/5 text-warning [&>svg]:text-warning/80"
|
22
|
+
when :success
|
23
|
+
"ring-success/20 bg-success/5 text-success [&>svg]:text-success/80"
|
24
|
+
when :destructive
|
25
|
+
"ring-destructive/20 bg-destructive/5 text-destructive [&>svg]:text-destructive/80"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def default_attrs
|
30
|
+
base_classes = "backdrop-blur relative w-full ring-1 ring-inset rounded-lg px-4 py-4 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg~*]:pl-8"
|
31
|
+
{
|
32
|
+
class: tokens(base_classes, colors)
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class AlertDialog < Base
|
5
|
+
def initialize(open: false, **attrs)
|
6
|
+
@open = open
|
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: "rbui--alert-dialog",
|
20
|
+
rbui__alert_dialog_open_value: @open.to_s
|
21
|
+
},
|
22
|
+
class: "inline-block"
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class AlertDialogCancel < Base
|
5
|
+
def view_template(&)
|
6
|
+
render RBUI::Button.new(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_attrs
|
12
|
+
{
|
13
|
+
variant: :outline,
|
14
|
+
data: {
|
15
|
+
action: "click->rbui--alert-dialog#dismiss"
|
16
|
+
},
|
17
|
+
class: "mt-2 sm:mt-0"
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class AlertDialogContent < Base
|
5
|
+
def view_template(&block)
|
6
|
+
template_tag(**attrs) do
|
7
|
+
div(data: {controller: "rbui--alert-dialog"}) do
|
8
|
+
background
|
9
|
+
container(&block)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def background
|
15
|
+
div(
|
16
|
+
data_state: "open",
|
17
|
+
class:
|
18
|
+
"fixed inset-0 z-50 bg-black/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
19
|
+
style: "pointer-events:auto",
|
20
|
+
data_aria_hidden: "true",
|
21
|
+
aria_hidden: "true"
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def container(&)
|
26
|
+
div(
|
27
|
+
role: "alertdialog",
|
28
|
+
data_state: "open",
|
29
|
+
class: "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full",
|
30
|
+
style: "pointer-events:auto",
|
31
|
+
&
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def default_attrs
|
38
|
+
{
|
39
|
+
data: {
|
40
|
+
rbui__alert_dialog_target: "content"
|
41
|
+
}
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class AlertDialogFooter < Base
|
5
|
+
def view_template(&)
|
6
|
+
div(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_attrs
|
12
|
+
{
|
13
|
+
class: "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2"
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class AlertDialogHeader < Base
|
5
|
+
def view_template(&)
|
6
|
+
div(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_attrs
|
12
|
+
{
|
13
|
+
class: "flex flex-col space-y-2 text-center sm:text-left"
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class AlertDialogTrigger < Base
|
5
|
+
def view_template(&)
|
6
|
+
div(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_attrs
|
12
|
+
{
|
13
|
+
data: {action: "click->rbui--alert-dialog#open"},
|
14
|
+
class: "inline-block"
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class AspectRatio < Base
|
5
|
+
def initialize(aspect_ratio: "16/9", **attrs)
|
6
|
+
raise "aspect_ratio must be in the format of a string with a slash in the middle (eg. '16/9', '1/1')" unless aspect_ratio.is_a?(String) && aspect_ratio.include?("/")
|
7
|
+
|
8
|
+
@aspect_ratio = aspect_ratio
|
9
|
+
super(**attrs)
|
10
|
+
end
|
11
|
+
|
12
|
+
def view_template(&block)
|
13
|
+
div(
|
14
|
+
class: "relative w-full",
|
15
|
+
style: "padding-bottom: #{padding_bottom}%;"
|
16
|
+
) do
|
17
|
+
div(**attrs, &block)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def padding_bottom
|
24
|
+
@aspect_ratio.split("/").map(&:to_i).reverse.reduce(&:fdiv) * 100
|
25
|
+
end
|
26
|
+
|
27
|
+
def default_attrs
|
28
|
+
{
|
29
|
+
class: "bg-muted absolute inset-0 [&>img]:object-cover [&>img]:absolute [&>img]:h-full [&>img]:w-full [&>img]:inset-0 [&>img]:text-transparent"
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class Avatar < Base
|
5
|
+
SIZES = {
|
6
|
+
xs: "h-4 w-4 text-[0.5rem]",
|
7
|
+
sm: "h-6 w-6 text-xs",
|
8
|
+
md: "h-10 w-10 text-base",
|
9
|
+
lg: "h-14 w-14 text-xl",
|
10
|
+
xl: "h-20 w-20 text-3xl"
|
11
|
+
}
|
12
|
+
|
13
|
+
def initialize(size: :md, **attrs)
|
14
|
+
@size = size
|
15
|
+
@size_classes = SIZES[@size]
|
16
|
+
super(**attrs)
|
17
|
+
end
|
18
|
+
|
19
|
+
def view_template(&)
|
20
|
+
span(**attrs, &)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def default_attrs
|
26
|
+
{
|
27
|
+
class: tokens("relative flex shrink-0 overflow-hidden rounded-full", @size_classes)
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class AvatarFallback < Base
|
5
|
+
def view_template(&)
|
6
|
+
span(**attrs, &)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_attrs
|
12
|
+
{
|
13
|
+
class: "flex h-full w-full items-center justify-center rounded-full bg-muted"
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class AvatarImage < Base
|
5
|
+
def initialize(src:, alt: "", **attrs)
|
6
|
+
@src = src
|
7
|
+
@alt = alt
|
8
|
+
super(**attrs)
|
9
|
+
end
|
10
|
+
|
11
|
+
def view_template
|
12
|
+
img(**attrs)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def default_attrs
|
18
|
+
{
|
19
|
+
loading: "lazy",
|
20
|
+
class: "aspect-square h-full w-full",
|
21
|
+
alt: @alt,
|
22
|
+
src: @src
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBUI
|
4
|
+
class Badge < Base
|
5
|
+
SIZES = {
|
6
|
+
sm: "px-1.5 py-0.5 text-xs",
|
7
|
+
md: "px-2 py-1 text-xs",
|
8
|
+
lg: "px-3 py-1 text-sm"
|
9
|
+
}
|
10
|
+
|
11
|
+
COLORS = {
|
12
|
+
primary: "text-primary bg-primary/5 ring-primary/20",
|
13
|
+
secondary: "text-secondary bg-secondary/10 ring-secondary/20",
|
14
|
+
outline: "text-foreground bg-background ring-border",
|
15
|
+
destructive: "text-destructive bg-destructive/10 ring-destructive/20",
|
16
|
+
success: "text-success bg-success/10 ring-success/20",
|
17
|
+
warning: "text-warning bg-warning/10 ring-warning/20",
|
18
|
+
slate: "text-slate-500 bg-slate-500/10 ring-slate-500/20",
|
19
|
+
gray: "text-gray-500 bg-gray-500/10 ring-gray-500/20",
|
20
|
+
zinc: "text-zinc-500 bg-zinc-500/10 ring-zinc-500/20",
|
21
|
+
neutral: "text-neutral-500 bg-neutral-500/10 ring-neutral-500/20",
|
22
|
+
stone: "text-stone-500 bg-stone-500/10 ring-stone-500/20",
|
23
|
+
red: "text-red-500 bg-red-500/10 ring-red-500/20",
|
24
|
+
orange: "text-orange-500 bg-orange-500/10 ring-orange-500/20",
|
25
|
+
amber: "text-amber-500 bg-amber-500/10 ring-amber-500/20",
|
26
|
+
yellow: "text-yellow-500 bg-yellow-500/10 ring-yellow-500/20",
|
27
|
+
lime: "text-lime-500 bg-lime-500/10 ring-lime-500/20",
|
28
|
+
green: "text-green-500 bg-green-500/10 ring-green-500/20",
|
29
|
+
emerald: "text-emerald-500 bg-emerald-500/10 ring-emerald-500/20",
|
30
|
+
teal: "text-teal-500 bg-teal-500/10 ring-teal-500/20",
|
31
|
+
cyan: "text-cyan-500 bg-cyan-500/10 ring-cyan-500/20",
|
32
|
+
sky: "text-sky-500 bg-sky-500/10 ring-sky-500/20",
|
33
|
+
blue: "text-blue-500 bg-blue-500/10 ring-blue-500/20",
|
34
|
+
indigo: "text-indigo-500 bg-indigo-500/10 ring-indigo-500/20",
|
35
|
+
violet: "text-violet-500 bg-violet-500/10 ring-violet-500/20",
|
36
|
+
purple: "text-purple-500 bg-purple-500/10 ring-purple-500/20",
|
37
|
+
fuchsia: "text-fuchsia-500 bg-fuchsia-500/10 ring-fuchsia-500/20",
|
38
|
+
pink: "text-pink-500 bg-pink-500/10 ring-pink-500/20",
|
39
|
+
rose: "text-rose-500 bg-rose-500/10 ring-rose-500/20"
|
40
|
+
}
|
41
|
+
|
42
|
+
def initialize(variant: :primary, size: :md, **args)
|
43
|
+
@variant = variant
|
44
|
+
@size = size
|
45
|
+
super(**args)
|
46
|
+
end
|
47
|
+
|
48
|
+
def view_template(&)
|
49
|
+
span(**attrs, &)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def default_attrs
|
55
|
+
{
|
56
|
+
class: tokens("inline-flex items-center rounded-md font-medium ring-1 ring-inset", SIZES[@size], COLORS[@variant])
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/rbui/base.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "tailwind_merge"
|
4
|
+
|
5
|
+
module RBUI
|
6
|
+
class Base < Phlex::HTML
|
7
|
+
attr_reader :attrs
|
8
|
+
|
9
|
+
def initialize(**user_attrs)
|
10
|
+
@attrs = mix(default_attrs, user_attrs)
|
11
|
+
@attrs[:class] = ::TailwindMerge::Merger.new.merge(@attrs[:class]) if @attrs[:class]
|
12
|
+
end
|
13
|
+
|
14
|
+
if defined?(Rails) && Rails.env.development?
|
15
|
+
def before_template
|
16
|
+
comment { "Before #{self.class.name}" }
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def default_attrs
|
24
|
+
{}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|