Skip to content

Commit

Permalink
Using Phlex::Kit to all components (#53)
Browse files Browse the repository at this point in the history
* Adding Phlex::Kit to all components

* Remove Builder

* fix activesupport dependency

* fix Gemfile.lock
  • Loading branch information
cirdes authored Jun 30, 2024
1 parent 87cc09e commit 1a08707
Show file tree
Hide file tree
Showing 271 changed files with 836 additions and 1,973 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Empty file removed lib/.rbnext/.keep
Empty file.
73 changes: 73 additions & 0 deletions lib/phlex_ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module PhlexUI
class Accordion::Content < Base
class AccordionContent < Base
def view_template(&)
div(**attrs, &)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module PhlexUI
class Accordion::DefaultContent < Base
class AccordionDefaultContent < Base
def view_template(&)
div(**attrs, &)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module PhlexUI
class Accordion::Trigger < Base
class AccordionTrigger < Base
def view_template(&)
button(**attrs, &)
end
Expand Down
22 changes: 0 additions & 22 deletions lib/phlex_ui/accordion/builder.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module PhlexUI
class Alert::Description < Base
class AlertDescription < Base
def view_template(&)
div(**attrs, &)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module PhlexUI
class Alert::Title < Base
class AlertTitle < Base
def view_template(&)
h5(**attrs, &)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 17 additions & 0 deletions lib/phlex_ui/alert_dialog/alert_dialog_description.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module PhlexUI
class AlertDialog::Footer < Base
class AlertDialogFooter < Base
def view_template(&)
div(**attrs, &)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module PhlexUI
class AlertDialog::Header < Base
class AlertDialogHeader < Base
def view_template(&)
div(**attrs, &)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module PhlexUI
class AlertDialog::Title < Base
class AlertDialogTitle < Base
def view_template(&)
h2(**attrs, &)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module PhlexUI
class AlertDialog::Trigger < Base
class AlertDialogTrigger < Base
def view_template(&)
div(**attrs, &)
end
Expand Down
17 changes: 0 additions & 17 deletions lib/phlex_ui/alert_dialog/description.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module PhlexUI
class Avatar::Fallback < Base
class AvatarFallback < Base
def view_template(&)
span(**attrs, &)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
36 changes: 0 additions & 36 deletions lib/phlex_ui/avatar/builder.rb

This file was deleted.

14 changes: 7 additions & 7 deletions lib/phlex_ui/calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module PhlexUI
class Calendar::Body < Base
class CalendarBody < Base
def view_template
table(**attrs)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module PhlexUI
class Calendar::Header < Base
class CalendarHeader < Base
def view_template(&)
div(**attrs, &)
end
Expand Down
Loading

0 comments on commit 1a08707

Please sign in to comment.