diff --git a/Gemfile.lock b/Gemfile.lock index b995ebb..a7817a7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,7 @@ PATH remote: . specs: phlex_ui (0.1.10) - activesupport (~> 6.0) + activesupport (>= 6.0) phlex (~> 1.10) rouge (~> 4.2.0) zeitwerk (~> 2.6) diff --git a/lib/.rbnext/.keep b/lib/.rbnext/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/lib/phlex_ui.rb b/lib/phlex_ui.rb index 08d1571..3067747 100644 --- a/lib/phlex_ui.rb +++ b/lib/phlex_ui.rb @@ -9,9 +9,82 @@ loader.inflector.inflect( "phlex_ui" => "PhlexUI" ) + +loader.collapse("#{__dir__}/phlex_ui/accordion") +loader.collapse("#{__dir__}/phlex_ui/alert_dialog") +loader.collapse("#{__dir__}/phlex_ui/alert") +loader.collapse("#{__dir__}/phlex_ui/aspect_ratio") +loader.collapse("#{__dir__}/phlex_ui/avatar") +loader.collapse("#{__dir__}/phlex_ui/badge") +loader.collapse("#{__dir__}/phlex_ui/button") +loader.collapse("#{__dir__}/phlex_ui/calendar") +loader.collapse("#{__dir__}/phlex_ui/card") +loader.collapse("#{__dir__}/phlex_ui/chart") +loader.collapse("#{__dir__}/phlex_ui/checkbox") +loader.collapse("#{__dir__}/phlex_ui/clipboard") +loader.collapse("#{__dir__}/phlex_ui/codeblock") +loader.collapse("#{__dir__}/phlex_ui/collapsible") +loader.collapse("#{__dir__}/phlex_ui/command") +loader.collapse("#{__dir__}/phlex_ui/context_menu") +loader.collapse("#{__dir__}/phlex_ui/dialog") +loader.collapse("#{__dir__}/phlex_ui/dropdown_menu") +loader.collapse("#{__dir__}/phlex_ui/form") +loader.collapse("#{__dir__}/phlex_ui/hint") +loader.collapse("#{__dir__}/phlex_ui/hover_card") +loader.collapse("#{__dir__}/phlex_ui/input_error") +loader.collapse("#{__dir__}/phlex_ui/input") +loader.collapse("#{__dir__}/phlex_ui/link") +loader.collapse("#{__dir__}/phlex_ui/pagination") +loader.collapse("#{__dir__}/phlex_ui/popover") +loader.collapse("#{__dir__}/phlex_ui/select") +loader.collapse("#{__dir__}/phlex_ui/sheet") +loader.collapse("#{__dir__}/phlex_ui/shortcut_key") +loader.collapse("#{__dir__}/phlex_ui/table") +loader.collapse("#{__dir__}/phlex_ui/tabs") +loader.collapse("#{__dir__}/phlex_ui/theme_toggle") +loader.collapse("#{__dir__}/phlex_ui/tooltip") +loader.collapse("#{__dir__}/phlex_ui/typography") + loader.setup # ready! module PhlexUI + extend Phlex::Kit + + autoload :Accordion, "phlex_ui/accordion" + autoload :AlertDialog, "phlex_ui/alert_dialog" + autoload :Alert, "phlex_ui/alert" + autoload :AspectRatio, "phlex_ui/aspect_ratio" + autoload :Avatar, "phlex_ui/avatar" + autoload :Badge, "phlex_ui/badge" + autoload :Button, "phlex_ui/button" + autoload :Calendar, "phlex_ui/calendar" + autoload :Card, "phlex_ui/card" + autoload :Chart, "phlex_ui/chart" + autoload :Checkbox, "phlex_ui/checkbox" + autoload :Clipboard, "phlex_ui/clipboard" + autoload :Codeblock, "phlex_ui/codeblock" + autoload :Collapsible, "phlex_ui/collapsible" + autoload :Command, "phlex_ui/command" + autoload :ContextMenu, "phlex_ui/context_menu" + autoload :Dialog, "phlex_ui/dialog" + autoload :DropdownMenu, "phlex_ui/dropdown_menu" + autoload :Form, "phlex_ui/form" + autoload :Hint, "phlex_ui/hint" + autoload :HoverCard, "phlex_ui/hover_card" + autoload :InputError, "phlex_ui/input_error" + autoload :Input, "phlex_ui/input" + autoload :Label, "phlex_ui/label" + autoload :Link, "phlex_ui/link" + autoload :Pagination, "phlex_ui/pagination" + autoload :Popover, "phlex_ui/popover" + autoload :Select, "phlex_ui/select" + autoload :Sheet, "phlex_ui/sheet" + autoload :ShortcutKey, "phlex_ui/shortcut_key" + autoload :Table, "phlex_ui/table" + autoload :Tabs, "phlex_ui/tabs" + autoload :ThemeToggle, "phlex_ui/theme_toggle" + autoload :Tooltip, "phlex_ui/tooltip" + autoload :Typography, "phlex_ui/typography" end loader.eager_load diff --git a/lib/phlex_ui/accordion/content.rb b/lib/phlex_ui/accordion/accordion_content.rb similarity index 89% rename from lib/phlex_ui/accordion/content.rb rename to lib/phlex_ui/accordion/accordion_content.rb index 7fcb3c1..24875d2 100644 --- a/lib/phlex_ui/accordion/content.rb +++ b/lib/phlex_ui/accordion/accordion_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Accordion::Content < Base + class AccordionContent < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/accordion/default_content.rb b/lib/phlex_ui/accordion/accordion_default_content.rb similarity index 83% rename from lib/phlex_ui/accordion/default_content.rb rename to lib/phlex_ui/accordion/accordion_default_content.rb index cbe0543..f091ed2 100644 --- a/lib/phlex_ui/accordion/default_content.rb +++ b/lib/phlex_ui/accordion/accordion_default_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Accordion::DefaultContent < Base + class AccordionDefaultContent < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/accordion/default_trigger.rb b/lib/phlex_ui/accordion/accordion_default_trigger.rb similarity index 82% rename from lib/phlex_ui/accordion/default_trigger.rb rename to lib/phlex_ui/accordion/accordion_default_trigger.rb index 9c91883..866b694 100644 --- a/lib/phlex_ui/accordion/default_trigger.rb +++ b/lib/phlex_ui/accordion/accordion_default_trigger.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true module PhlexUI - class Accordion::DefaultTrigger < Base + class AccordionDefaultTrigger < Base def view_template(&block) div(class: "flex items-center justify-between w-full") do p(&block) - render ::PhlexUI::Accordion::Icon.new + PhlexUI.AccordionIcon end end diff --git a/lib/phlex_ui/accordion/icon.rb b/lib/phlex_ui/accordion/accordion_icon.rb similarity index 96% rename from lib/phlex_ui/accordion/icon.rb rename to lib/phlex_ui/accordion/accordion_icon.rb index 6ce3656..1479ef1 100644 --- a/lib/phlex_ui/accordion/icon.rb +++ b/lib/phlex_ui/accordion/accordion_icon.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Accordion::Icon < Base + class AccordionIcon < Base def view_template(&block) span(**attrs) do if block diff --git a/lib/phlex_ui/accordion/item.rb b/lib/phlex_ui/accordion/accordion_item.rb similarity index 94% rename from lib/phlex_ui/accordion/item.rb rename to lib/phlex_ui/accordion/accordion_item.rb index b9c06cc..412aa9a 100644 --- a/lib/phlex_ui/accordion/item.rb +++ b/lib/phlex_ui/accordion/accordion_item.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Accordion::Item < Base + class AccordionItem < Base def initialize(open: false, rotate_icon: 180, **attrs) @open = open @rotate_icon = rotate_icon diff --git a/lib/phlex_ui/accordion/trigger.rb b/lib/phlex_ui/accordion/accordion_trigger.rb similarity index 90% rename from lib/phlex_ui/accordion/trigger.rb rename to lib/phlex_ui/accordion/accordion_trigger.rb index 7574a70..147d8e7 100644 --- a/lib/phlex_ui/accordion/trigger.rb +++ b/lib/phlex_ui/accordion/accordion_trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Accordion::Trigger < Base + class AccordionTrigger < Base def view_template(&) button(**attrs, &) end diff --git a/lib/phlex_ui/accordion/builder.rb b/lib/phlex_ui/accordion/builder.rb deleted file mode 100644 index 970c0b9..0000000 --- a/lib/phlex_ui/accordion/builder.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -module PhlexUI - class Accordion::Builder < Base - def view_template(&block) - render PhlexUI::Accordion.new(**attrs) do - block.call - end - end - - def add_item(title, content, open: false) - render Accordion::Item.new(open: open) do - render PhlexUI::Accordion::Trigger.new do - render PhlexUI::Accordion::DefaultTrigger.new { title } - end - render PhlexUI::Accordion::Content.new do - render PhlexUI::Accordion::DefaultContent.new { content } - end - end - end - end -end diff --git a/lib/phlex_ui/alert/description.rb b/lib/phlex_ui/alert/alert_description.rb similarity index 86% rename from lib/phlex_ui/alert/description.rb rename to lib/phlex_ui/alert/alert_description.rb index 6d47bf2..918d22e 100644 --- a/lib/phlex_ui/alert/description.rb +++ b/lib/phlex_ui/alert/alert_description.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Alert::Description < Base + class AlertDescription < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/alert/title.rb b/lib/phlex_ui/alert/alert_title.rb similarity index 89% rename from lib/phlex_ui/alert/title.rb rename to lib/phlex_ui/alert/alert_title.rb index bd03970..b301ec3 100644 --- a/lib/phlex_ui/alert/title.rb +++ b/lib/phlex_ui/alert/alert_title.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Alert::Title < Base + class AlertTitle < Base def view_template(&) h5(**attrs, &) end diff --git a/lib/phlex_ui/alert_dialog/action.rb b/lib/phlex_ui/alert_dialog/alert_dialog_action.rb similarity index 86% rename from lib/phlex_ui/alert_dialog/action.rb rename to lib/phlex_ui/alert_dialog/alert_dialog_action.rb index 8c02e8e..a017ad0 100644 --- a/lib/phlex_ui/alert_dialog/action.rb +++ b/lib/phlex_ui/alert_dialog/alert_dialog_action.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class AlertDialog::Action < Base + class AlertDialogAction < Base def view_template(&) render PhlexUI::Button.new(**attrs, &) end diff --git a/lib/phlex_ui/alert_dialog/cancel.rb b/lib/phlex_ui/alert_dialog/alert_dialog_cancel.rb similarity index 90% rename from lib/phlex_ui/alert_dialog/cancel.rb rename to lib/phlex_ui/alert_dialog/alert_dialog_cancel.rb index d7b9a94..0bec769 100644 --- a/lib/phlex_ui/alert_dialog/cancel.rb +++ b/lib/phlex_ui/alert_dialog/alert_dialog_cancel.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class AlertDialog::Cancel < Base + class AlertDialogCancel < Base def view_template(&) render PhlexUI::Button.new(**attrs, &) end diff --git a/lib/phlex_ui/alert_dialog/content.rb b/lib/phlex_ui/alert_dialog/alert_dialog_content.rb similarity index 97% rename from lib/phlex_ui/alert_dialog/content.rb rename to lib/phlex_ui/alert_dialog/alert_dialog_content.rb index 5d88a0b..4a7ee9e 100644 --- a/lib/phlex_ui/alert_dialog/content.rb +++ b/lib/phlex_ui/alert_dialog/alert_dialog_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class AlertDialog::Content < Base + class AlertDialogContent < Base def view_template(&block) template_tag(**attrs) do div(data: {controller: "dismissable"}) do diff --git a/lib/phlex_ui/alert_dialog/alert_dialog_description.rb b/lib/phlex_ui/alert_dialog/alert_dialog_description.rb new file mode 100644 index 0000000..c249cdf --- /dev/null +++ b/lib/phlex_ui/alert_dialog/alert_dialog_description.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module PhlexUI + class AlertDialogDescription < Base + def view_template(&) + p(**attrs, &) + end + + private + + def default_attrs + { + class: "text-sm text-muted-foreground" + } + end + end +end diff --git a/lib/phlex_ui/alert_dialog/footer.rb b/lib/phlex_ui/alert_dialog/alert_dialog_footer.rb similarity index 87% rename from lib/phlex_ui/alert_dialog/footer.rb rename to lib/phlex_ui/alert_dialog/alert_dialog_footer.rb index 7e19cd0..7456cee 100644 --- a/lib/phlex_ui/alert_dialog/footer.rb +++ b/lib/phlex_ui/alert_dialog/alert_dialog_footer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class AlertDialog::Footer < Base + class AlertDialogFooter < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/alert_dialog/header.rb b/lib/phlex_ui/alert_dialog/alert_dialog_header.rb similarity index 87% rename from lib/phlex_ui/alert_dialog/header.rb rename to lib/phlex_ui/alert_dialog/alert_dialog_header.rb index 3fd056d..d3ce140 100644 --- a/lib/phlex_ui/alert_dialog/header.rb +++ b/lib/phlex_ui/alert_dialog/alert_dialog_header.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class AlertDialog::Header < Base + class AlertDialogHeader < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/alert_dialog/title.rb b/lib/phlex_ui/alert_dialog/alert_dialog_title.rb similarity index 86% rename from lib/phlex_ui/alert_dialog/title.rb rename to lib/phlex_ui/alert_dialog/alert_dialog_title.rb index addb56a..bcf56b3 100644 --- a/lib/phlex_ui/alert_dialog/title.rb +++ b/lib/phlex_ui/alert_dialog/alert_dialog_title.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class AlertDialog::Title < Base + class AlertDialogTitle < Base def view_template(&) h2(**attrs, &) end diff --git a/lib/phlex_ui/alert_dialog/trigger.rb b/lib/phlex_ui/alert_dialog/alert_dialog_trigger.rb similarity index 87% rename from lib/phlex_ui/alert_dialog/trigger.rb rename to lib/phlex_ui/alert_dialog/alert_dialog_trigger.rb index 9aa2dbf..af9cbaf 100644 --- a/lib/phlex_ui/alert_dialog/trigger.rb +++ b/lib/phlex_ui/alert_dialog/alert_dialog_trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class AlertDialog::Trigger < Base + class AlertDialogTrigger < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/alert_dialog/description.rb b/lib/phlex_ui/alert_dialog/description.rb deleted file mode 100644 index 16d63a8..0000000 --- a/lib/phlex_ui/alert_dialog/description.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -module PhlexUI - class AlertDialog::Description < Base - def view_template(&) - p(**attrs, &) - end - - private - - def default_attrs - { - class: "text-sm text-muted-foreground" - } - end - end -end diff --git a/lib/phlex_ui/avatar/fallback.rb b/lib/phlex_ui/avatar/avatar_fallback.rb similarity index 88% rename from lib/phlex_ui/avatar/fallback.rb rename to lib/phlex_ui/avatar/avatar_fallback.rb index e0c1d5d..4441f84 100644 --- a/lib/phlex_ui/avatar/fallback.rb +++ b/lib/phlex_ui/avatar/avatar_fallback.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Avatar::Fallback < Base + class AvatarFallback < Base def view_template(&) span(**attrs, &) end diff --git a/lib/phlex_ui/avatar/image.rb b/lib/phlex_ui/avatar/avatar_image.rb similarity index 92% rename from lib/phlex_ui/avatar/image.rb rename to lib/phlex_ui/avatar/avatar_image.rb index a6878df..30fc340 100644 --- a/lib/phlex_ui/avatar/image.rb +++ b/lib/phlex_ui/avatar/avatar_image.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Avatar::Image < Base + class AvatarImage < Base def initialize(src:, alt: "", **attrs) @src = src @alt = alt diff --git a/lib/phlex_ui/avatar/builder.rb b/lib/phlex_ui/avatar/builder.rb deleted file mode 100644 index eb6387b..0000000 --- a/lib/phlex_ui/avatar/builder.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -module PhlexUI - class Avatar::Builder < Base - def initialize(size: :md, src: nil, alt: nil, initials: nil, **attrs) - @size = size - @src = src - @alt = alt - @initials = initials - super(**attrs) - end - - def view_template - render PhlexUI::Avatar.new(size: @size, **attrs) do - render_image if @src - render_initials if @initials - end - end - - private - - def render_image - render ::PhlexUI::Avatar::Image.new(src: @src, alt: @alt) - end - - def render_initials - render ::PhlexUI::Avatar::Fallback.new { @initials } - end - - def default_attrs - { - class: tokens("relative flex shrink-0 overflow-hidden rounded-full", @size_classes) - } - end - end -end diff --git a/lib/phlex_ui/calendar.rb b/lib/phlex_ui/calendar.rb index 5ea593d..adbb4bb 100644 --- a/lib/phlex_ui/calendar.rb +++ b/lib/phlex_ui/calendar.rb @@ -11,14 +11,14 @@ def initialize(selected_date: nil, input_id: nil, date_format: "yyyy-MM-dd", **a def view_template div(**attrs) do - render PhlexUI::Calendar::Header.new do - render PhlexUI::Calendar::Title.new - render PhlexUI::Calendar::Prev.new - render PhlexUI::Calendar::Next.new + PhlexUI.CalendarHeader do + PhlexUI.CalendarTitle + PhlexUI.CalendarPrev + PhlexUI.CalendarNext end - render PhlexUI::Calendar::Body.new # Where the calendar is rendered (Weekdays and Days) - render PhlexUI::Calendar::Weekdays.new # Template for the weekdays - render PhlexUI::Calendar::Days.new # Template for the days + PhlexUI.CalendarBody # Where the calendar is rendered (Weekdays and Days) + PhlexUI.CalendarWeekdays # Template for the weekdays + PhlexUI.CalendarDays # Template for the days end end diff --git a/lib/phlex_ui/calendar/body.rb b/lib/phlex_ui/calendar/calendar_body.rb similarity index 88% rename from lib/phlex_ui/calendar/body.rb rename to lib/phlex_ui/calendar/calendar_body.rb index 556fe05..3cfe3ed 100644 --- a/lib/phlex_ui/calendar/body.rb +++ b/lib/phlex_ui/calendar/calendar_body.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Calendar::Body < Base + class CalendarBody < Base def view_template table(**attrs) end diff --git a/lib/phlex_ui/calendar/days.rb b/lib/phlex_ui/calendar/calendar_days.rb similarity index 99% rename from lib/phlex_ui/calendar/days.rb rename to lib/phlex_ui/calendar/calendar_days.rb index 6aae1dd..d7ba0c4 100644 --- a/lib/phlex_ui/calendar/days.rb +++ b/lib/phlex_ui/calendar/calendar_days.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Calendar::Days < Base + class CalendarDays < Base BASE_CLASS = "inline-flex items-center justify-center rounded-md text-sm ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-8 w-8 p-0 font-normal aria-selected:opacity-100" def view_template diff --git a/lib/phlex_ui/calendar/header.rb b/lib/phlex_ui/calendar/calendar_header.rb similarity index 88% rename from lib/phlex_ui/calendar/header.rb rename to lib/phlex_ui/calendar/calendar_header.rb index a74b9c9..f9f9695 100644 --- a/lib/phlex_ui/calendar/header.rb +++ b/lib/phlex_ui/calendar/calendar_header.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Calendar::Header < Base + class CalendarHeader < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/calendar/next.rb b/lib/phlex_ui/calendar/calendar_next.rb similarity index 97% rename from lib/phlex_ui/calendar/next.rb rename to lib/phlex_ui/calendar/calendar_next.rb index 74fb25c..1b0b20e 100644 --- a/lib/phlex_ui/calendar/next.rb +++ b/lib/phlex_ui/calendar/calendar_next.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Calendar::Next < Base + class CalendarNext < Base def view_template(&block) button(**attrs) do icon diff --git a/lib/phlex_ui/calendar/prev.rb b/lib/phlex_ui/calendar/calendar_prev.rb similarity index 98% rename from lib/phlex_ui/calendar/prev.rb rename to lib/phlex_ui/calendar/calendar_prev.rb index a761d23..9f04af0 100644 --- a/lib/phlex_ui/calendar/prev.rb +++ b/lib/phlex_ui/calendar/calendar_prev.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Calendar::Prev < Base + class CalendarPrev < Base def view_template(&block) button(**attrs) do icon diff --git a/lib/phlex_ui/calendar/title.rb b/lib/phlex_ui/calendar/calendar_title.rb similarity index 93% rename from lib/phlex_ui/calendar/title.rb rename to lib/phlex_ui/calendar/calendar_title.rb index 31d5563..f62974a 100644 --- a/lib/phlex_ui/calendar/title.rb +++ b/lib/phlex_ui/calendar/calendar_title.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Calendar::Title < Base + class CalendarTitle < Base def initialize(default: "Month Year", **attrs) @default = default super(**attrs) diff --git a/lib/phlex_ui/calendar/weekdays.rb b/lib/phlex_ui/calendar/calendar_weekdays.rb similarity index 95% rename from lib/phlex_ui/calendar/weekdays.rb rename to lib/phlex_ui/calendar/calendar_weekdays.rb index 3f80ec3..fac215b 100644 --- a/lib/phlex_ui/calendar/weekdays.rb +++ b/lib/phlex_ui/calendar/calendar_weekdays.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Calendar::Weekdays < Base + class CalendarWeekdays < Base DAYS = %w[Monday Tuesday Wednesday Thursday Friday Saturday Sunday].freeze def view_template diff --git a/lib/phlex_ui/card/content.rb b/lib/phlex_ui/card/card_content.rb similarity index 87% rename from lib/phlex_ui/card/content.rb rename to lib/phlex_ui/card/card_content.rb index be2d58e..c3a9091 100644 --- a/lib/phlex_ui/card/content.rb +++ b/lib/phlex_ui/card/card_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Card::Content < Base + class CardContent < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/card/description.rb b/lib/phlex_ui/card/card_description.rb similarity index 86% rename from lib/phlex_ui/card/description.rb rename to lib/phlex_ui/card/card_description.rb index d4df680..f6fc773 100644 --- a/lib/phlex_ui/card/description.rb +++ b/lib/phlex_ui/card/card_description.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Card::Description < Base + class CardDescription < Base def view_template(&) p(**attrs, &) end diff --git a/lib/phlex_ui/card/footer.rb b/lib/phlex_ui/card/card_footer.rb similarity index 88% rename from lib/phlex_ui/card/footer.rb rename to lib/phlex_ui/card/card_footer.rb index 186da84..8d28f8b 100644 --- a/lib/phlex_ui/card/footer.rb +++ b/lib/phlex_ui/card/card_footer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Card::Footer < Base + class CardFooter < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/card/header.rb b/lib/phlex_ui/card/card_header.rb similarity index 88% rename from lib/phlex_ui/card/header.rb rename to lib/phlex_ui/card/card_header.rb index 4b58d1c..e239340 100644 --- a/lib/phlex_ui/card/header.rb +++ b/lib/phlex_ui/card/card_header.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Card::Header < Base + class CardHeader < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/card/title.rb b/lib/phlex_ui/card/card_title.rb similarity index 89% rename from lib/phlex_ui/card/title.rb rename to lib/phlex_ui/card/card_title.rb index 9613c3d..33d5172 100644 --- a/lib/phlex_ui/card/title.rb +++ b/lib/phlex_ui/card/card_title.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Card::Title < Base + class CardTitle < Base def view_template(&) h3(**attrs, &) end diff --git a/lib/phlex_ui/clipboard/popover.rb b/lib/phlex_ui/clipboard/clipboard_popover.rb similarity index 96% rename from lib/phlex_ui/clipboard/popover.rb rename to lib/phlex_ui/clipboard/clipboard_popover.rb index e31705e..7af1dbd 100644 --- a/lib/phlex_ui/clipboard/popover.rb +++ b/lib/phlex_ui/clipboard/clipboard_popover.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Clipboard::Popover < Base + class ClipboardPopover < Base def initialize(type:, **attrs) @type = type super(**attrs) diff --git a/lib/phlex_ui/clipboard/source.rb b/lib/phlex_ui/clipboard/clipboard_source.rb similarity index 87% rename from lib/phlex_ui/clipboard/source.rb rename to lib/phlex_ui/clipboard/clipboard_source.rb index 68c4941..accdb11 100644 --- a/lib/phlex_ui/clipboard/source.rb +++ b/lib/phlex_ui/clipboard/clipboard_source.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Clipboard::Source < Base + class ClipboardSource < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/clipboard/trigger.rb b/lib/phlex_ui/clipboard/clipboard_trigger.rb similarity index 89% rename from lib/phlex_ui/clipboard/trigger.rb rename to lib/phlex_ui/clipboard/clipboard_trigger.rb index 98bcefa..ba6c56d 100644 --- a/lib/phlex_ui/clipboard/trigger.rb +++ b/lib/phlex_ui/clipboard/clipboard_trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Clipboard::Trigger < Base + class ClipboardTrigger < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/codeblock.rb b/lib/phlex_ui/codeblock.rb index fd79ee2..af70cf8 100644 --- a/lib/phlex_ui/codeblock.rb +++ b/lib/phlex_ui/codeblock.rb @@ -39,13 +39,13 @@ def default_attrs end def with_clipboard - render PhlexUI::Clipboard.new(success: @clipboard_success, error: @clipboard_error, class: "relative") do - render PhlexUI::Clipboard::Source.new do + PhlexUI.Clipboard(success: @clipboard_success, error: @clipboard_error, class: "relative") do + PhlexUI.ClipboardSource do codeblock end div(class: "absolute top-2 right-2") do - render PhlexUI::Clipboard::Trigger.new do - render PhlexUI::Button.new(variant: :ghost, size: :sm, icon: true, class: "text-white hover:text-white hover:bg-white/20") { clipboard_icon } + PhlexUI.ClipboardTrigger do + PhlexUI.Button(variant: :ghost, size: :sm, icon: true, class: "text-white hover:text-white hover:bg-white/20") { clipboard_icon } end end end diff --git a/lib/phlex_ui/collapsible/content.rb b/lib/phlex_ui/collapsible/collapsible_content.rb similarity index 87% rename from lib/phlex_ui/collapsible/content.rb rename to lib/phlex_ui/collapsible/collapsible_content.rb index 43c8fa0..71b1591 100644 --- a/lib/phlex_ui/collapsible/content.rb +++ b/lib/phlex_ui/collapsible/collapsible_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Collapsible::Content < Base + class CollapsibleContent < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/collapsible/trigger.rb b/lib/phlex_ui/collapsible/collapsible_trigger.rb similarity index 87% rename from lib/phlex_ui/collapsible/trigger.rb rename to lib/phlex_ui/collapsible/collapsible_trigger.rb index 7f810f0..ffddde2 100644 --- a/lib/phlex_ui/collapsible/trigger.rb +++ b/lib/phlex_ui/collapsible/collapsible_trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Collapsible::Trigger < Base + class CollapsibleTrigger < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/command/dialog.rb b/lib/phlex_ui/command/command_dialog.rb similarity index 87% rename from lib/phlex_ui/command/dialog.rb rename to lib/phlex_ui/command/command_dialog.rb index e01a430..f9067be 100644 --- a/lib/phlex_ui/command/dialog.rb +++ b/lib/phlex_ui/command/command_dialog.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Command::Dialog < Base + class CommandDialog < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/command/dialog_content.rb b/lib/phlex_ui/command/command_dialog_content.rb similarity index 97% rename from lib/phlex_ui/command/dialog_content.rb rename to lib/phlex_ui/command/command_dialog_content.rb index 2baf9f8..7f934c8 100644 --- a/lib/phlex_ui/command/dialog_content.rb +++ b/lib/phlex_ui/command/command_dialog_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Command::DialogContent < Base + class CommandDialogContent < Base SIZES = { xs: "max-w-sm", sm: "max-w-md", diff --git a/lib/phlex_ui/command/dialog_trigger.rb b/lib/phlex_ui/command/command_dialog_trigger.rb similarity index 93% rename from lib/phlex_ui/command/dialog_trigger.rb rename to lib/phlex_ui/command/command_dialog_trigger.rb index a0618b7..f8f303c 100644 --- a/lib/phlex_ui/command/dialog_trigger.rb +++ b/lib/phlex_ui/command/command_dialog_trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Command::DialogTrigger < Base + class CommandDialogTrigger < Base DEFAULT_KEYBINDINGS = [ "keydown.ctrl+k@window", "keydown.meta+k@window" diff --git a/lib/phlex_ui/command/empty.rb b/lib/phlex_ui/command/command_empty.rb similarity index 90% rename from lib/phlex_ui/command/empty.rb rename to lib/phlex_ui/command/command_empty.rb index ff85ac9..654a669 100644 --- a/lib/phlex_ui/command/empty.rb +++ b/lib/phlex_ui/command/command_empty.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Command::Empty < Base + class CommandEmpty < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/command/group.rb b/lib/phlex_ui/command/command_group.rb similarity index 96% rename from lib/phlex_ui/command/group.rb rename to lib/phlex_ui/command/command_group.rb index c17b9c2..de5181b 100644 --- a/lib/phlex_ui/command/group.rb +++ b/lib/phlex_ui/command/command_group.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Command::Group < Base + class CommandGroup < Base def initialize(title: nil, **attrs) @title = title super(**attrs) diff --git a/lib/phlex_ui/command/input.rb b/lib/phlex_ui/command/command_input.rb similarity index 98% rename from lib/phlex_ui/command/input.rb rename to lib/phlex_ui/command/command_input.rb index 5f3fc3d..8a79729 100644 --- a/lib/phlex_ui/command/input.rb +++ b/lib/phlex_ui/command/command_input.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Command::Input < Base + class CommandInput < Base def initialize(placeholder: "Type a command or search...", **attrs) @placeholder = placeholder super(**attrs) diff --git a/lib/phlex_ui/command/item.rb b/lib/phlex_ui/command/command_item.rb similarity index 96% rename from lib/phlex_ui/command/item.rb rename to lib/phlex_ui/command/command_item.rb index 0bc3139..3d1697a 100644 --- a/lib/phlex_ui/command/item.rb +++ b/lib/phlex_ui/command/command_item.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Command::Item < Base + class CommandItem < Base def initialize(value:, text: "", href: "#", **attrs) @value = value @text = text diff --git a/lib/phlex_ui/command/list.rb b/lib/phlex_ui/command/command_list.rb similarity index 87% rename from lib/phlex_ui/command/list.rb rename to lib/phlex_ui/command/command_list.rb index b22e592..7192646 100644 --- a/lib/phlex_ui/command/list.rb +++ b/lib/phlex_ui/command/command_list.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Command::List < Base + class CommandList < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/context_menu/content.rb b/lib/phlex_ui/context_menu/context_menu_content.rb similarity index 96% rename from lib/phlex_ui/context_menu/content.rb rename to lib/phlex_ui/context_menu/context_menu_content.rb index 1d4245f..8678351 100644 --- a/lib/phlex_ui/context_menu/content.rb +++ b/lib/phlex_ui/context_menu/context_menu_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class ContextMenu::Content < Base + class ContextMenuContent < Base def view_template(&block) template_tag(data: {popover_target: "content"}) do div(**attrs, &block) diff --git a/lib/phlex_ui/context_menu/item.rb b/lib/phlex_ui/context_menu/context_menu_item.rb similarity index 98% rename from lib/phlex_ui/context_menu/item.rb rename to lib/phlex_ui/context_menu/context_menu_item.rb index 111be8a..4b625b6 100644 --- a/lib/phlex_ui/context_menu/item.rb +++ b/lib/phlex_ui/context_menu/context_menu_item.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class ContextMenu::Item < Base + class ContextMenuItem < Base def initialize(href: "#", checked: false, shortcut: nil, disabled: false, **attrs) @href = href @checked = checked diff --git a/lib/phlex_ui/context_menu/label.rb b/lib/phlex_ui/context_menu/context_menu_label.rb similarity index 91% rename from lib/phlex_ui/context_menu/label.rb rename to lib/phlex_ui/context_menu/context_menu_label.rb index 1a9ce66..972a51a 100644 --- a/lib/phlex_ui/context_menu/label.rb +++ b/lib/phlex_ui/context_menu/context_menu_label.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class ContextMenu::Label < Base + class ContextMenuLabel < Base def initialize(inset: false, **attrs) @inset = inset super(**attrs) diff --git a/lib/phlex_ui/context_menu/separator.rb b/lib/phlex_ui/context_menu/context_menu_separator.rb similarity index 87% rename from lib/phlex_ui/context_menu/separator.rb rename to lib/phlex_ui/context_menu/context_menu_separator.rb index a5e27fb..4855286 100644 --- a/lib/phlex_ui/context_menu/separator.rb +++ b/lib/phlex_ui/context_menu/context_menu_separator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class ContextMenu::Separator < Base + class ContextMenuSeparator < Base def view_template div(**attrs) end diff --git a/lib/phlex_ui/context_menu/trigger.rb b/lib/phlex_ui/context_menu/context_menu_trigger.rb similarity index 89% rename from lib/phlex_ui/context_menu/trigger.rb rename to lib/phlex_ui/context_menu/context_menu_trigger.rb index 0f59c3e..457c7e5 100644 --- a/lib/phlex_ui/context_menu/trigger.rb +++ b/lib/phlex_ui/context_menu/context_menu_trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class ContextMenu::Trigger < Base + class ContextMenuTrigger < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/dialog/content.rb b/lib/phlex_ui/dialog/dialog_content.rb similarity index 98% rename from lib/phlex_ui/dialog/content.rb rename to lib/phlex_ui/dialog/dialog_content.rb index b43f89f..d3a5924 100644 --- a/lib/phlex_ui/dialog/content.rb +++ b/lib/phlex_ui/dialog/dialog_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Dialog::Content < Base + class DialogContent < Base SIZES = { xs: "max-w-sm", sm: "max-w-md", diff --git a/lib/phlex_ui/typography/muted.rb b/lib/phlex_ui/dialog/dialog_description.rb similarity index 86% rename from lib/phlex_ui/typography/muted.rb rename to lib/phlex_ui/dialog/dialog_description.rb index d057bb7..ee5d684 100644 --- a/lib/phlex_ui/typography/muted.rb +++ b/lib/phlex_ui/dialog/dialog_description.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Typography::Muted < Base + class DialogDescription < Base def view_template(&) p(**attrs, &) end diff --git a/lib/phlex_ui/sheet/footer.rb b/lib/phlex_ui/dialog/dialog_footer.rb similarity index 90% rename from lib/phlex_ui/sheet/footer.rb rename to lib/phlex_ui/dialog/dialog_footer.rb index 97cd120..2730206 100644 --- a/lib/phlex_ui/sheet/footer.rb +++ b/lib/phlex_ui/dialog/dialog_footer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Sheet::Footer < Base + class DialogFooter < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/sheet/header.rb b/lib/phlex_ui/dialog/dialog_header.rb similarity index 89% rename from lib/phlex_ui/sheet/header.rb rename to lib/phlex_ui/dialog/dialog_header.rb index 2c748cd..0225465 100644 --- a/lib/phlex_ui/sheet/header.rb +++ b/lib/phlex_ui/dialog/dialog_header.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Sheet::Header < Base + class DialogHeader < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/sheet/middle.rb b/lib/phlex_ui/dialog/dialog_middle.rb similarity index 86% rename from lib/phlex_ui/sheet/middle.rb rename to lib/phlex_ui/dialog/dialog_middle.rb index b169735..09153c8 100644 --- a/lib/phlex_ui/sheet/middle.rb +++ b/lib/phlex_ui/dialog/dialog_middle.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Sheet::Middle < Base + class DialogMiddle < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/sheet/title.rb b/lib/phlex_ui/dialog/dialog_title.rb similarity index 89% rename from lib/phlex_ui/sheet/title.rb rename to lib/phlex_ui/dialog/dialog_title.rb index e056285..764520d 100644 --- a/lib/phlex_ui/sheet/title.rb +++ b/lib/phlex_ui/dialog/dialog_title.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Sheet::Title < Base + class DialogTitle < Base def view_template(&) h3(**attrs, &) end diff --git a/lib/phlex_ui/dialog/trigger.rb b/lib/phlex_ui/dialog/dialog_trigger.rb similarity index 89% rename from lib/phlex_ui/dialog/trigger.rb rename to lib/phlex_ui/dialog/dialog_trigger.rb index 71b6a16..94b31e0 100644 --- a/lib/phlex_ui/dialog/trigger.rb +++ b/lib/phlex_ui/dialog/dialog_trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Dialog::Trigger < Base + class DialogTrigger < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/dropdown_menu/content.rb b/lib/phlex_ui/dropdown_menu/dropdown_menu_content.rb similarity index 95% rename from lib/phlex_ui/dropdown_menu/content.rb rename to lib/phlex_ui/dropdown_menu/dropdown_menu_content.rb index 5e09a15..f5d6edf 100644 --- a/lib/phlex_ui/dropdown_menu/content.rb +++ b/lib/phlex_ui/dropdown_menu/dropdown_menu_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class DropdownMenu::Content < Base + class DropdownMenuContent < Base def view_template(&block) template_tag(data: {popover_target: "content"}) do div(**attrs, &block) diff --git a/lib/phlex_ui/dropdown_menu/item.rb b/lib/phlex_ui/dropdown_menu/dropdown_menu_item.rb similarity index 95% rename from lib/phlex_ui/dropdown_menu/item.rb rename to lib/phlex_ui/dropdown_menu/dropdown_menu_item.rb index ea4a641..66ee455 100644 --- a/lib/phlex_ui/dropdown_menu/item.rb +++ b/lib/phlex_ui/dropdown_menu/dropdown_menu_item.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class DropdownMenu::Item < Base + class DropdownMenuItem < Base def initialize(href: "#", **attrs) @href = href super(**attrs) diff --git a/lib/phlex_ui/dropdown_menu/label.rb b/lib/phlex_ui/dropdown_menu/dropdown_menu_label.rb similarity index 86% rename from lib/phlex_ui/dropdown_menu/label.rb rename to lib/phlex_ui/dropdown_menu/dropdown_menu_label.rb index 6a0ca25..9a46ee4 100644 --- a/lib/phlex_ui/dropdown_menu/label.rb +++ b/lib/phlex_ui/dropdown_menu/dropdown_menu_label.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class DropdownMenu::Label < Base + class DropdownMenuLabel < Base def view_template(&) h3(**attrs, &) end diff --git a/lib/phlex_ui/dropdown_menu/separator.rb b/lib/phlex_ui/dropdown_menu/dropdown_menu_separator.rb similarity index 87% rename from lib/phlex_ui/dropdown_menu/separator.rb rename to lib/phlex_ui/dropdown_menu/dropdown_menu_separator.rb index 0ac22e1..fc12d16 100644 --- a/lib/phlex_ui/dropdown_menu/separator.rb +++ b/lib/phlex_ui/dropdown_menu/dropdown_menu_separator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class DropdownMenu::Separator < Base + class DropdownMenuSeparator < Base def view_template div(**attrs) end diff --git a/lib/phlex_ui/dropdown_menu/trigger.rb b/lib/phlex_ui/dropdown_menu/dropdown_menu_trigger.rb similarity index 86% rename from lib/phlex_ui/dropdown_menu/trigger.rb rename to lib/phlex_ui/dropdown_menu/dropdown_menu_trigger.rb index 9214d41..62b0b98 100644 --- a/lib/phlex_ui/dropdown_menu/trigger.rb +++ b/lib/phlex_ui/dropdown_menu/dropdown_menu_trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class DropdownMenu::Trigger < Base + class DropdownMenuTrigger < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/form/builder.rb b/lib/phlex_ui/form/builder.rb deleted file mode 100644 index 004ec06..0000000 --- a/lib/phlex_ui/form/builder.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -module PhlexUI - class Form::Builder < Base - def view_template(&block) - render PhlexUI::Form.new(**attrs) do - render PhlexUI::Form::Spacer.new do - block.call - end - end - end - - def input(name, label: nil, hint: false, error: nil, **input_attrs) - name = name.to_s - label ||= convert_name_to_label(name) - - render PhlexUI::Form::Item.new do - render PhlexUI::Label.new(for: name) { label } if label - render PhlexUI::Input.new(name: name, id: name, **input_attrs) - render PhlexUI::Hint.new { hint } if hint - end - end - - def button(**button_attrs, &) - render PhlexUI::Button.new(**button_attrs, &) - end - - private - - def convert_name_to_label(name) - name.to_s.split("_").map(&:capitalize).join(" ") - end - - def default_attrs - {} - end - end -end diff --git a/lib/phlex_ui/form/item.rb b/lib/phlex_ui/form/form_item.rb similarity index 88% rename from lib/phlex_ui/form/item.rb rename to lib/phlex_ui/form/form_item.rb index b344473..9d71054 100644 --- a/lib/phlex_ui/form/item.rb +++ b/lib/phlex_ui/form/form_item.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Form::Item < Base + class FormItem < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/form/spacer.rb b/lib/phlex_ui/form/form_spacer.rb similarity index 87% rename from lib/phlex_ui/form/spacer.rb rename to lib/phlex_ui/form/form_spacer.rb index 076240c..608de8e 100644 --- a/lib/phlex_ui/form/spacer.rb +++ b/lib/phlex_ui/form/form_spacer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Form::Spacer < Base + class FormSpacer < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/hover_card/content.rb b/lib/phlex_ui/hover_card/hover_card_content.rb similarity index 95% rename from lib/phlex_ui/hover_card/content.rb rename to lib/phlex_ui/hover_card/hover_card_content.rb index 3931f48..dcffd83 100644 --- a/lib/phlex_ui/hover_card/content.rb +++ b/lib/phlex_ui/hover_card/hover_card_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class HoverCard::Content < Base + class HoverCardContent < Base def view_template(&block) template_tag(data: {popover_target: "content"}) do div(**attrs, &block) diff --git a/lib/phlex_ui/popover/trigger.rb b/lib/phlex_ui/hover_card/hover_card_trigger.rb similarity index 89% rename from lib/phlex_ui/popover/trigger.rb rename to lib/phlex_ui/hover_card/hover_card_trigger.rb index 9e8ce26..6a44c57 100644 --- a/lib/phlex_ui/popover/trigger.rb +++ b/lib/phlex_ui/hover_card/hover_card_trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Popover::Trigger < Base + class HoverCardTrigger < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/pagination/content.rb b/lib/phlex_ui/pagination/pagination_content.rb similarity index 86% rename from lib/phlex_ui/pagination/content.rb rename to lib/phlex_ui/pagination/pagination_content.rb index e425d7d..9e435b9 100644 --- a/lib/phlex_ui/pagination/content.rb +++ b/lib/phlex_ui/pagination/pagination_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Pagination::Content < Base + class PaginationContent < Base def view_template(&) ul(**attrs, &) end diff --git a/lib/phlex_ui/pagination/ellipsis.rb b/lib/phlex_ui/pagination/pagination_ellipsis.rb similarity index 95% rename from lib/phlex_ui/pagination/ellipsis.rb rename to lib/phlex_ui/pagination/pagination_ellipsis.rb index 2ed5457..90ef78d 100644 --- a/lib/phlex_ui/pagination/ellipsis.rb +++ b/lib/phlex_ui/pagination/pagination_ellipsis.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Pagination::Ellipsis < Base + class PaginationEllipsis < Base def view_template(&block) li do span(**attrs) do diff --git a/lib/phlex_ui/pagination/item.rb b/lib/phlex_ui/pagination/pagination_item.rb similarity index 94% rename from lib/phlex_ui/pagination/item.rb rename to lib/phlex_ui/pagination/pagination_item.rb index f2917bb..61f6c9e 100644 --- a/lib/phlex_ui/pagination/item.rb +++ b/lib/phlex_ui/pagination/pagination_item.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Pagination::Item < Base + class PaginationItem < Base def initialize(href: "#", active: false, **attrs) @href = href @active = active diff --git a/lib/phlex_ui/popover/content.rb b/lib/phlex_ui/popover/popover_content.rb similarity index 95% rename from lib/phlex_ui/popover/content.rb rename to lib/phlex_ui/popover/popover_content.rb index 7eb4b95..fb5080b 100644 --- a/lib/phlex_ui/popover/content.rb +++ b/lib/phlex_ui/popover/popover_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Popover::Content < Base + class PopoverContent < Base def view_template(&block) template_tag(data: {popover_target: "content"}) do div(**attrs, &block) diff --git a/lib/phlex_ui/hover_card/trigger.rb b/lib/phlex_ui/popover/popover_trigger.rb similarity index 88% rename from lib/phlex_ui/hover_card/trigger.rb rename to lib/phlex_ui/popover/popover_trigger.rb index d2cfbb9..f573483 100644 --- a/lib/phlex_ui/hover_card/trigger.rb +++ b/lib/phlex_ui/popover/popover_trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class HoverCard::Trigger < Base + class PopoverTrigger < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/select/builder.rb b/lib/phlex_ui/select/builder.rb deleted file mode 100644 index 6ebde29..0000000 --- a/lib/phlex_ui/select/builder.rb +++ /dev/null @@ -1,67 +0,0 @@ -# frozen_string_literal: true - -module PhlexUI - class Select::Builder < Base - def initialize(object, method, collection: [], placeholder: "", value: nil, input_attrs: {}, trigger_attrs: {}, value_attrs: {}, content_attrs: {}, group_attrs: {}, item_attrs: {}, **attrs) - @object = set_object(object) - @method = method - @collection = collection - @placeholder = placeholder - @value = value || @object.send(@method) - @input_attrs = input_attrs - @trigger_attrs = trigger_attrs - @value_attrs = value_attrs - @content_attrs = content_attrs - @group_attrs = group_attrs - @item_attrs = item_attrs - super(**attrs) - end - - def view_template - render PhlexUI::Select.new(**attrs) do - render PhlexUI::Select::Input.new(value: @object.send(@method), id: select_id, name: input_name, type: "hidden", **@input_attrs) - render PhlexUI::Select::Trigger.new(**@trigger_attrs) do - if @value - render PhlexUI::Select::Value.new(id: select_id, **@value_attrs) { @collection.find { |choice| choice[1] == @value }[0] } - else - render PhlexUI::Select::Value.new(placeholder: @placeholder, id: select_id, **@value_attrs) - end - end - render PhlexUI::Select::Content.new(outlet_id: select_id, **@content_attrs) do - render PhlexUI::Select::Group.new(**@group_attrs) do - @collection.each do |choice| - render PhlexUI::Select::Item.new(value: choice[1], selected: @object&.send(@method) == choice[1], **@item_attrs) { choice[0] } - end - end - end - end - end - - private - - def select_id - "#{object_name}_#{@method}" - end - - def input_name - "#{object_name}[#{@method}]" - end - - def object_name - @object.class.name.underscore - end - - def set_object(object) - # if string convert to new instance of object - if object.is_a?(String) - object.classify.constantize.new - else - object - end - end - - def default_attrs - {} - end - end -end diff --git a/lib/phlex_ui/select/content.rb b/lib/phlex_ui/select/select_content.rb similarity index 96% rename from lib/phlex_ui/select/content.rb rename to lib/phlex_ui/select/select_content.rb index 884219c..1057fb4 100644 --- a/lib/phlex_ui/select/content.rb +++ b/lib/phlex_ui/select/select_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Select::Content < Base + class SelectContent < Base def initialize(outlet_id:, **attrs) @outlet_id = outlet_id super(**attrs) diff --git a/lib/phlex_ui/select/group.rb b/lib/phlex_ui/select/select_group.rb similarity index 84% rename from lib/phlex_ui/select/group.rb rename to lib/phlex_ui/select/select_group.rb index 3c78dda..d043f36 100644 --- a/lib/phlex_ui/select/group.rb +++ b/lib/phlex_ui/select/select_group.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Select::Group < Base + class SelectGroup < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/select/input.rb b/lib/phlex_ui/select/select_input.rb similarity index 76% rename from lib/phlex_ui/select/input.rb rename to lib/phlex_ui/select/select_input.rb index 775533a..cf23d02 100644 --- a/lib/phlex_ui/select/input.rb +++ b/lib/phlex_ui/select/select_input.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true module PhlexUI - class Select::Input < Base + class SelectInput < Base def view_template - render PhlexUI::Input.new(**attrs) + PhlexUI.Input(**attrs) end private diff --git a/lib/phlex_ui/select/item.rb b/lib/phlex_ui/select/select_item.rb similarity index 98% rename from lib/phlex_ui/select/item.rb rename to lib/phlex_ui/select/select_item.rb index 75f7f2a..6cc1978 100644 --- a/lib/phlex_ui/select/item.rb +++ b/lib/phlex_ui/select/select_item.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Select::Item < Base + class SelectItem < Base def initialize(value: nil, **attrs) @value = value super(**attrs) diff --git a/lib/phlex_ui/select/label.rb b/lib/phlex_ui/select/select_label.rb similarity index 88% rename from lib/phlex_ui/select/label.rb rename to lib/phlex_ui/select/select_label.rb index fec9638..7ef44e0 100644 --- a/lib/phlex_ui/select/label.rb +++ b/lib/phlex_ui/select/select_label.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Select::Label < Base + class SelectLabel < Base def view_template(&) h3(**attrs, &) end diff --git a/lib/phlex_ui/select/trigger.rb b/lib/phlex_ui/select/select_trigger.rb similarity index 98% rename from lib/phlex_ui/select/trigger.rb rename to lib/phlex_ui/select/select_trigger.rb index c6bd82e..5536d89 100644 --- a/lib/phlex_ui/select/trigger.rb +++ b/lib/phlex_ui/select/select_trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Select::Trigger < Base + class SelectTrigger < Base def view_template(&block) button(**attrs) do block&.call diff --git a/lib/phlex_ui/select/value.rb b/lib/phlex_ui/select/select_value.rb similarity index 93% rename from lib/phlex_ui/select/value.rb rename to lib/phlex_ui/select/select_value.rb index 3778afa..a7d80f6 100644 --- a/lib/phlex_ui/select/value.rb +++ b/lib/phlex_ui/select/select_value.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Select::Value < Base + class SelectValue < Base def initialize(placeholder: nil, **attrs) @placeholder = placeholder super(**attrs) diff --git a/lib/phlex_ui/sheet/content.rb b/lib/phlex_ui/sheet/sheet_content.rb similarity index 99% rename from lib/phlex_ui/sheet/content.rb rename to lib/phlex_ui/sheet/sheet_content.rb index a90c3eb..c563614 100644 --- a/lib/phlex_ui/sheet/content.rb +++ b/lib/phlex_ui/sheet/sheet_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Sheet::Content < Base + class SheetContent < Base SIDE_CLASS = { top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top", right: "inset-y-0 right-0 h-full border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right", diff --git a/lib/phlex_ui/sheet/description.rb b/lib/phlex_ui/sheet/sheet_description.rb similarity index 86% rename from lib/phlex_ui/sheet/description.rb rename to lib/phlex_ui/sheet/sheet_description.rb index 20afd38..1a87331 100644 --- a/lib/phlex_ui/sheet/description.rb +++ b/lib/phlex_ui/sheet/sheet_description.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Sheet::Description < Base + class SheetDescription < Base def view_template(&) p(**attrs, &) end diff --git a/lib/phlex_ui/dialog/footer.rb b/lib/phlex_ui/sheet/sheet_footer.rb similarity index 89% rename from lib/phlex_ui/dialog/footer.rb rename to lib/phlex_ui/sheet/sheet_footer.rb index 0f4100d..7033b30 100644 --- a/lib/phlex_ui/dialog/footer.rb +++ b/lib/phlex_ui/sheet/sheet_footer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Dialog::Footer < Base + class SheetFooter < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/dialog/header.rb b/lib/phlex_ui/sheet/sheet_header.rb similarity index 88% rename from lib/phlex_ui/dialog/header.rb rename to lib/phlex_ui/sheet/sheet_header.rb index 52797a2..caf1d16 100644 --- a/lib/phlex_ui/dialog/header.rb +++ b/lib/phlex_ui/sheet/sheet_header.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Dialog::Header < Base + class SheetHeader < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/dialog/middle.rb b/lib/phlex_ui/sheet/sheet_middle.rb similarity index 86% rename from lib/phlex_ui/dialog/middle.rb rename to lib/phlex_ui/sheet/sheet_middle.rb index 26816a7..c024ef6 100644 --- a/lib/phlex_ui/dialog/middle.rb +++ b/lib/phlex_ui/sheet/sheet_middle.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Dialog::Middle < Base + class SheetMiddle < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/dialog/title.rb b/lib/phlex_ui/sheet/sheet_title.rb similarity index 89% rename from lib/phlex_ui/dialog/title.rb rename to lib/phlex_ui/sheet/sheet_title.rb index 5b49dd9..7730b5b 100644 --- a/lib/phlex_ui/dialog/title.rb +++ b/lib/phlex_ui/sheet/sheet_title.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Dialog::Title < Base + class SheetTitle < Base def view_template(&) h3(**attrs, &) end diff --git a/lib/phlex_ui/sheet/trigger.rb b/lib/phlex_ui/sheet/sheet_trigger.rb similarity index 87% rename from lib/phlex_ui/sheet/trigger.rb rename to lib/phlex_ui/sheet/sheet_trigger.rb index 4a36d68..6e50792 100644 --- a/lib/phlex_ui/sheet/trigger.rb +++ b/lib/phlex_ui/sheet/sheet_trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Sheet::Trigger < Base + class SheetTrigger < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/table/builder.rb b/lib/phlex_ui/table/builder.rb deleted file mode 100644 index 2fb06b5..0000000 --- a/lib/phlex_ui/table/builder.rb +++ /dev/null @@ -1,77 +0,0 @@ -# frozen_string_literal: true - -module PhlexUI - class Table::Builder < Base - include Phlex::DeferredRender - - Column = Struct.new(:header, :header_attrs, :footer, :footer_attrs, :block, keyword_init: true) - - def initialize(records = [], caption: nil, **attrs) - @records = records - @columns = [] - @caption = caption - super(**attrs) - end - - def view_template(&block) - render PhlexUI::Table.new(**attrs) do - header - body - caption if @caption - footer if @columns.any?(&:footer) - end - end - - def column(header, footer = nil, header_attrs: {}, footer_attrs: {}, &block) - @columns << Column.new( - header: header, - header_attrs: header_attrs, - footer: footer, - footer_attrs: footer_attrs, - block: block - ) - end - - def header - render PhlexUI::Table::Header.new do - render PhlexUI::Table::Row.new do - @columns.each do |column| - render PhlexUI::Table::Head.new(**column.header_attrs) do - column.header - end - end - end - end - end - - def body - render PhlexUI::Table::Body.new do - @records.each do |record| - render PhlexUI::Table::Row.new do - @columns.each do |column| - render PhlexUI::Table::Cell.new do - column.block.call(record) - end - end - end - end - end - end - - def footer - render PhlexUI::Table::Footer.new do - render PhlexUI::Table::Row.new do - @columns.each do |column| - render PhlexUI::Table::Head.new(**column.footer_attrs) do - column.footer - end - end - end - end - end - - def caption - render PhlexUI::Table::Caption.new { @caption } - end - end -end diff --git a/lib/phlex_ui/table/body.rb b/lib/phlex_ui/table/table_body.rb similarity index 88% rename from lib/phlex_ui/table/body.rb rename to lib/phlex_ui/table/table_body.rb index 480bacf..2376f97 100644 --- a/lib/phlex_ui/table/body.rb +++ b/lib/phlex_ui/table/table_body.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Table::Body < Base + class TableBody < Base def view_template(&) tbody(**attrs, &) end diff --git a/lib/phlex_ui/table/caption.rb b/lib/phlex_ui/table/table_caption.rb similarity index 88% rename from lib/phlex_ui/table/caption.rb rename to lib/phlex_ui/table/table_caption.rb index ed7630b..99b0705 100644 --- a/lib/phlex_ui/table/caption.rb +++ b/lib/phlex_ui/table/table_caption.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Table::Caption < Base + class TableCaption < Base def view_template(&) caption(**attrs, &) end diff --git a/lib/phlex_ui/table/cell.rb b/lib/phlex_ui/table/table_cell.rb similarity index 90% rename from lib/phlex_ui/table/cell.rb rename to lib/phlex_ui/table/table_cell.rb index 6d048a2..b8d3f86 100644 --- a/lib/phlex_ui/table/cell.rb +++ b/lib/phlex_ui/table/table_cell.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Table::Cell < Base + class TableCell < Base def view_template(&) td(**attrs, &) end diff --git a/lib/phlex_ui/table/footer.rb b/lib/phlex_ui/table/table_footer.rb similarity index 90% rename from lib/phlex_ui/table/footer.rb rename to lib/phlex_ui/table/table_footer.rb index 4688f59..ce631d6 100644 --- a/lib/phlex_ui/table/footer.rb +++ b/lib/phlex_ui/table/table_footer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Table::Footer < Base + class TableFooter < Base def view_template(&) tfoot(**attrs, &) end diff --git a/lib/phlex_ui/table/head.rb b/lib/phlex_ui/table/table_head.rb similarity index 92% rename from lib/phlex_ui/table/head.rb rename to lib/phlex_ui/table/table_head.rb index 89ce4dc..dc652bc 100644 --- a/lib/phlex_ui/table/head.rb +++ b/lib/phlex_ui/table/table_head.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Table::Head < Base + class TableHead < Base def view_template(&) th(**attrs, &) end diff --git a/lib/phlex_ui/table/header.rb b/lib/phlex_ui/table/table_header.rb similarity index 87% rename from lib/phlex_ui/table/header.rb rename to lib/phlex_ui/table/table_header.rb index 53abf0b..d19fe21 100644 --- a/lib/phlex_ui/table/header.rb +++ b/lib/phlex_ui/table/table_header.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Table::Header < Base + class TableHeader < Base def view_template(&) thead(**attrs, &) end diff --git a/lib/phlex_ui/table/row.rb b/lib/phlex_ui/table/table_row.rb similarity index 91% rename from lib/phlex_ui/table/row.rb rename to lib/phlex_ui/table/table_row.rb index 41c84bf..9a3c46b 100644 --- a/lib/phlex_ui/table/row.rb +++ b/lib/phlex_ui/table/table_row.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Table::Row < Base + class TableRow < Base def view_template(&) tr(**attrs, &) end diff --git a/lib/phlex_ui/tabs/content.rb b/lib/phlex_ui/tabs/tabs_content.rb similarity index 94% rename from lib/phlex_ui/tabs/content.rb rename to lib/phlex_ui/tabs/tabs_content.rb index 1a0b842..d0797cd 100644 --- a/lib/phlex_ui/tabs/content.rb +++ b/lib/phlex_ui/tabs/tabs_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Tabs::Content < Base + class TabsContent < Base def initialize(value:, **attrs) @value = value super(**attrs) diff --git a/lib/phlex_ui/tabs/list.rb b/lib/phlex_ui/tabs/tabs_list.rb similarity index 91% rename from lib/phlex_ui/tabs/list.rb rename to lib/phlex_ui/tabs/tabs_list.rb index a48a45c..fd11d06 100644 --- a/lib/phlex_ui/tabs/list.rb +++ b/lib/phlex_ui/tabs/tabs_list.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Tabs::List < Base + class TabsList < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/tabs/trigger.rb b/lib/phlex_ui/tabs/tabs_trigger.rb similarity index 96% rename from lib/phlex_ui/tabs/trigger.rb rename to lib/phlex_ui/tabs/tabs_trigger.rb index 996e02c..dfe5188 100644 --- a/lib/phlex_ui/tabs/trigger.rb +++ b/lib/phlex_ui/tabs/tabs_trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Tabs::Trigger < Base + class TabsTrigger < Base def initialize(value:, **attrs) @value = value super(**attrs) diff --git a/lib/phlex_ui/tooltip/content.rb b/lib/phlex_ui/tooltip/tooltip_content.rb similarity index 96% rename from lib/phlex_ui/tooltip/content.rb rename to lib/phlex_ui/tooltip/tooltip_content.rb index a5bf0d4..992b0c6 100644 --- a/lib/phlex_ui/tooltip/content.rb +++ b/lib/phlex_ui/tooltip/tooltip_content.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Tooltip::Content < Base + class TooltipContent < Base def view_template(&block) template_tag(data: {popover_target: "content"}) do div(**attrs, &block) diff --git a/lib/phlex_ui/tooltip/trigger.rb b/lib/phlex_ui/tooltip/tooltip_trigger.rb similarity index 88% rename from lib/phlex_ui/tooltip/trigger.rb rename to lib/phlex_ui/tooltip/tooltip_trigger.rb index 609a16a..ca13f2a 100644 --- a/lib/phlex_ui/tooltip/trigger.rb +++ b/lib/phlex_ui/tooltip/tooltip_trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Tooltip::Trigger < Base + class TooltipTrigger < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/typography.rb b/lib/phlex_ui/typography.rb new file mode 100644 index 0000000..e2e2c01 --- /dev/null +++ b/lib/phlex_ui/typography.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +module PhlexUI + class Typography < Base + end +end diff --git a/lib/phlex_ui/typography/blockquote.rb b/lib/phlex_ui/typography/typography_blockquote.rb similarity index 85% rename from lib/phlex_ui/typography/blockquote.rb rename to lib/phlex_ui/typography/typography_blockquote.rb index 8c35f28..e6a0ae2 100644 --- a/lib/phlex_ui/typography/blockquote.rb +++ b/lib/phlex_ui/typography/typography_blockquote.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Typography::Blockquote < Base + class TypographyBlockquote < Base def view_template(&) blockquote(**attrs, &) end diff --git a/lib/phlex_ui/typography/h1.rb b/lib/phlex_ui/typography/typography_h1.rb similarity index 90% rename from lib/phlex_ui/typography/h1.rb rename to lib/phlex_ui/typography/typography_h1.rb index d3fa4a5..1afc342 100644 --- a/lib/phlex_ui/typography/h1.rb +++ b/lib/phlex_ui/typography/typography_h1.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Typography::H1 < Base + class TypographyH1 < Base def view_template(&) h1(**attrs, &) end diff --git a/lib/phlex_ui/typography/h2.rb b/lib/phlex_ui/typography/typography_h2.rb similarity index 90% rename from lib/phlex_ui/typography/h2.rb rename to lib/phlex_ui/typography/typography_h2.rb index ec4a9dd..c779c14 100644 --- a/lib/phlex_ui/typography/h2.rb +++ b/lib/phlex_ui/typography/typography_h2.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Typography::H2 < Base + class TypographyH2 < Base def view_template(&) h2(**attrs, &) end diff --git a/lib/phlex_ui/typography/h3.rb b/lib/phlex_ui/typography/typography_h3.rb similarity index 88% rename from lib/phlex_ui/typography/h3.rb rename to lib/phlex_ui/typography/typography_h3.rb index 5a06ca7..f69e702 100644 --- a/lib/phlex_ui/typography/h3.rb +++ b/lib/phlex_ui/typography/typography_h3.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Typography::H3 < Base + class TypographyH3 < Base def view_template(&) h3(**attrs, &) end diff --git a/lib/phlex_ui/typography/h4.rb b/lib/phlex_ui/typography/typography_h4.rb similarity index 88% rename from lib/phlex_ui/typography/h4.rb rename to lib/phlex_ui/typography/typography_h4.rb index ea3bb32..5d22bbf 100644 --- a/lib/phlex_ui/typography/h4.rb +++ b/lib/phlex_ui/typography/typography_h4.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Typography::H4 < Base + class TypographyH4 < Base def view_template(&) h4(**attrs, &) end diff --git a/lib/phlex_ui/typography/inline_code.rb b/lib/phlex_ui/typography/typography_inline_code.rb similarity index 87% rename from lib/phlex_ui/typography/inline_code.rb rename to lib/phlex_ui/typography/typography_inline_code.rb index c742812..9d192fd 100644 --- a/lib/phlex_ui/typography/inline_code.rb +++ b/lib/phlex_ui/typography/typography_inline_code.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Typography::InlineCode < Base + class TypographyInlineCode < Base def view_template(&) code(**attrs, &) end diff --git a/lib/phlex_ui/typography/inline_link.rb b/lib/phlex_ui/typography/typography_inline_link.rb similarity index 90% rename from lib/phlex_ui/typography/inline_link.rb rename to lib/phlex_ui/typography/typography_inline_link.rb index 9ab1e64..acd41f8 100644 --- a/lib/phlex_ui/typography/inline_link.rb +++ b/lib/phlex_ui/typography/typography_inline_link.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Typography::InlineLink < Base + class TypographyInlineLink < Base def initialize(href:, **attrs) super(**attrs) @href = href diff --git a/lib/phlex_ui/typography/large.rb b/lib/phlex_ui/typography/typography_large.rb similarity index 86% rename from lib/phlex_ui/typography/large.rb rename to lib/phlex_ui/typography/typography_large.rb index 78f6135..1429426 100644 --- a/lib/phlex_ui/typography/large.rb +++ b/lib/phlex_ui/typography/typography_large.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Typography::Large < Base + class TypographyLarge < Base def view_template(&) div(**attrs, &) end diff --git a/lib/phlex_ui/typography/lead.rb b/lib/phlex_ui/typography/typography_lead.rb similarity index 87% rename from lib/phlex_ui/typography/lead.rb rename to lib/phlex_ui/typography/typography_lead.rb index 64e4549..0faced7 100644 --- a/lib/phlex_ui/typography/lead.rb +++ b/lib/phlex_ui/typography/typography_lead.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Typography::Lead < Base + class TypographyLead < Base def view_template(&) p(**attrs, &) end diff --git a/lib/phlex_ui/typography/list.rb b/lib/phlex_ui/typography/typography_list.rb similarity index 89% rename from lib/phlex_ui/typography/list.rb rename to lib/phlex_ui/typography/typography_list.rb index 3f7c241..8ad4e39 100644 --- a/lib/phlex_ui/typography/list.rb +++ b/lib/phlex_ui/typography/typography_list.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Typography::List < Base + class TypographyList < Base def initialize(items: [], numbered: false, **attrs) @items = items @numbered = numbered @@ -14,7 +14,7 @@ def view_template(&) else list(**attrs) do @items.each do |item| - render PhlexUI::Typography::ListItem.new { item } + PhlexUI.TypographyListItem { item } end end end diff --git a/lib/phlex_ui/typography/list_item.rb b/lib/phlex_ui/typography/typography_list_item.rb similarity index 84% rename from lib/phlex_ui/typography/list_item.rb rename to lib/phlex_ui/typography/typography_list_item.rb index c0114b2..a0801f3 100644 --- a/lib/phlex_ui/typography/list_item.rb +++ b/lib/phlex_ui/typography/typography_list_item.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Typography::ListItem < Base + class TypographyListItem < Base def view_template(&) li(**attrs, &) end diff --git a/lib/phlex_ui/dialog/description.rb b/lib/phlex_ui/typography/typography_muted.rb similarity index 86% rename from lib/phlex_ui/dialog/description.rb rename to lib/phlex_ui/typography/typography_muted.rb index 52b3618..a0f23c7 100644 --- a/lib/phlex_ui/dialog/description.rb +++ b/lib/phlex_ui/typography/typography_muted.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Dialog::Description < Base + class TypographyMuted < Base def view_template(&) p(**attrs, &) end diff --git a/lib/phlex_ui/typography/p.rb b/lib/phlex_ui/typography/typography_p.rb similarity index 88% rename from lib/phlex_ui/typography/p.rb rename to lib/phlex_ui/typography/typography_p.rb index 6969e81..ed91011 100644 --- a/lib/phlex_ui/typography/p.rb +++ b/lib/phlex_ui/typography/typography_p.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Typography::P < Base + class TypographyP < Base def view_template(&) p(**attrs, &) end diff --git a/lib/phlex_ui/typography/small.rb b/lib/phlex_ui/typography/typography_small.rb similarity index 87% rename from lib/phlex_ui/typography/small.rb rename to lib/phlex_ui/typography/typography_small.rb index 43baf64..669ae41 100644 --- a/lib/phlex_ui/typography/small.rb +++ b/lib/phlex_ui/typography/typography_small.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PhlexUI - class Typography::Small < Base + class TypographySmall < Base def view_template(&) small(**attrs, &) end diff --git a/phlex_ui.gemspec b/phlex_ui.gemspec index d45f51b..979a51e 100644 --- a/phlex_ui.gemspec +++ b/phlex_ui.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |s| s.add_dependency "phlex", "~> 1.10" s.add_dependency "rouge", "~> 4.2.0" s.add_dependency "zeitwerk", "~> 2.6" - s.add_dependency "activesupport", "~> 6.0" + s.add_dependency "activesupport", ">= 6.0" s.add_development_dependency "rake" s.add_development_dependency "standard" diff --git a/test/phlex_ui/accordion/builder_test.rb b/test/phlex_ui/accordion/builder_test.rb deleted file mode 100644 index a0158ae..0000000 --- a/test/phlex_ui/accordion/builder_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class PhlexUI::Accordion::BuilderTest < Minitest::Test - include Phlex::Testing::ViewHelper - - def test_render_with_default_attributes - output = render PhlexUI::Accordion::Builder.new { "test" } - - refute_empty(output) - end -end diff --git a/test/phlex_ui/accordion/content_test.rb b/test/phlex_ui/accordion/content_test.rb deleted file mode 100644 index e12cef5..0000000 --- a/test/phlex_ui/accordion/content_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class PhlexUI::Accordion::ContentTest < Minitest::Test - include Phlex::Testing::ViewHelper - - def test_render_with_default_attributes - output = render PhlexUI::Accordion::Content.new - - refute_empty(output) - end -end diff --git a/test/phlex_ui/accordion/default_content_test.rb b/test/phlex_ui/accordion/default_content_test.rb deleted file mode 100644 index 3b78413..0000000 --- a/test/phlex_ui/accordion/default_content_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class PhlexUI::Accordion::DefaultContentTest < Minitest::Test - include Phlex::Testing::ViewHelper - - def test_render_with_default_attributes - output = render PhlexUI::Accordion::DefaultContent.new - - refute_empty(output) - end -end diff --git a/test/phlex_ui/accordion/default_trigger_test.rb b/test/phlex_ui/accordion/default_trigger_test.rb deleted file mode 100644 index 7faea2c..0000000 --- a/test/phlex_ui/accordion/default_trigger_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class PhlexUI::Accordion::DefaultTriggerTest < Minitest::Test - include Phlex::Testing::ViewHelper - - def test_render_with_default_attributes - output = render PhlexUI::Accordion::DefaultTrigger.new - - refute_empty(output) - end -end diff --git a/test/phlex_ui/accordion/icon_test.rb b/test/phlex_ui/accordion/icon_test.rb deleted file mode 100644 index 89b32fd..0000000 --- a/test/phlex_ui/accordion/icon_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class PhlexUI::Accordion::IconTest < Minitest::Test - include Phlex::Testing::ViewHelper - - def test_render_with_default_attributes - output = render PhlexUI::Accordion::Icon.new - - refute_empty(output) - end -end diff --git a/test/phlex_ui/accordion/item_test.rb b/test/phlex_ui/accordion/item_test.rb deleted file mode 100644 index 7f67f8e..0000000 --- a/test/phlex_ui/accordion/item_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class PhlexUI::Accordion::ItemTest < Minitest::Test - include Phlex::Testing::ViewHelper - - def test_render_with_default_attributes - output = render PhlexUI::Accordion::Item.new - - refute_empty(output) - end -end diff --git a/test/phlex_ui/accordion/trigger_test.rb b/test/phlex_ui/accordion/trigger_test.rb deleted file mode 100644 index 7747280..0000000 --- a/test/phlex_ui/accordion/trigger_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require "test_helper" - -class PhlexUI::Accordion::TriggerTest < Minitest::Test - include Phlex::Testing::ViewHelper - - def test_render_with_default_attributes - output = render PhlexUI::Accordion::Trigger.new - - refute_empty(output) - end -end diff --git a/test/phlex_ui/accordion_test.rb b/test/phlex_ui/accordion_test.rb index bdf89e3..b570d33 100644 --- a/test/phlex_ui/accordion_test.rb +++ b/test/phlex_ui/accordion_test.rb @@ -5,9 +5,82 @@ class PhlexUI::AccordionTest < Minitest::Test include Phlex::Testing::ViewHelper - def test_render_with_default_attributes - output = render PhlexUI::Accordion.new + def test_render_with_default_items + output = phlex_context do + PhlexUI.Accordion do + PhlexUI.AccordionItem do + PhlexUI.AccordionDefaultTrigger { "Title" } + PhlexUI.AccordionDefaultContent { "Content" } + end + end + end - refute_empty(output) + assert_match(/