phlex_ui 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/lib/phlex_ui/alert/description.rb +17 -0
  3. data/lib/phlex_ui/alert/title.rb +17 -0
  4. data/lib/phlex_ui/alert.rb +36 -0
  5. data/lib/phlex_ui/alert_dialog/action.rb +17 -0
  6. data/lib/phlex_ui/alert_dialog/cancel.rb +21 -0
  7. data/lib/phlex_ui/alert_dialog/content.rb +45 -0
  8. data/lib/phlex_ui/alert_dialog/description.rb +17 -0
  9. data/lib/phlex_ui/alert_dialog/footer.rb +17 -0
  10. data/lib/phlex_ui/alert_dialog/header.rb +17 -0
  11. data/lib/phlex_ui/alert_dialog/title.rb +17 -0
  12. data/lib/phlex_ui/alert_dialog/trigger.rb +18 -0
  13. data/lib/phlex_ui/alert_dialog.rb +26 -0
  14. data/lib/phlex_ui/aspect_ratio.rb +33 -0
  15. data/lib/phlex_ui/avatar/fallback.rb +17 -0
  16. data/lib/phlex_ui/avatar/image.rb +26 -0
  17. data/lib/phlex_ui/avatar.rb +49 -0
  18. data/lib/phlex_ui/badge.rb +46 -62
  19. data/lib/phlex_ui/button.rb +86 -63
  20. data/lib/phlex_ui/card/content.rb +17 -0
  21. data/lib/phlex_ui/card/description.rb +17 -0
  22. data/lib/phlex_ui/card/footer.rb +17 -0
  23. data/lib/phlex_ui/card/header.rb +17 -0
  24. data/lib/phlex_ui/card/title.rb +17 -0
  25. data/lib/phlex_ui/card.rb +17 -0
  26. data/lib/phlex_ui/checkbox.rb +18 -0
  27. data/lib/phlex_ui/clipboard/popover.rb +36 -0
  28. data/lib/phlex_ui/clipboard/source.rb +19 -0
  29. data/lib/phlex_ui/clipboard/trigger.rb +20 -0
  30. data/lib/phlex_ui/clipboard.rb +39 -0
  31. data/lib/phlex_ui/codeblock.rb +105 -0
  32. data/lib/phlex_ui/collapsible/content.rb +18 -0
  33. data/lib/phlex_ui/collapsible/trigger.rb +19 -0
  34. data/lib/phlex_ui/collapsible.rb +25 -0
  35. data/lib/phlex_ui/context_menu/content.rb +25 -0
  36. data/lib/phlex_ui/context_menu/item.rb +66 -0
  37. data/lib/phlex_ui/context_menu/label.rb +24 -0
  38. data/lib/phlex_ui/context_menu/separator.rb +19 -0
  39. data/lib/phlex_ui/context_menu/trigger.rb +20 -0
  40. data/lib/phlex_ui/context_menu.rb +26 -0
  41. data/lib/phlex_ui/dialog/content.rb +78 -0
  42. data/lib/phlex_ui/dialog/description.rb +17 -0
  43. data/lib/phlex_ui/dialog/footer.rb +17 -0
  44. data/lib/phlex_ui/dialog/header.rb +17 -0
  45. data/lib/phlex_ui/dialog/middle.rb +17 -0
  46. data/lib/phlex_ui/dialog/title.rb +17 -0
  47. data/lib/phlex_ui/dialog/trigger.rb +19 -0
  48. data/lib/phlex_ui/dialog.rb +25 -0
  49. data/lib/phlex_ui/dropdown_menu/content.rb +22 -0
  50. data/lib/phlex_ui/dropdown_menu/item.rb +28 -0
  51. data/lib/phlex_ui/dropdown_menu/label.rb +17 -0
  52. data/lib/phlex_ui/dropdown_menu/separator.rb +19 -0
  53. data/lib/phlex_ui/dropdown_menu/trigger.rb +17 -0
  54. data/lib/phlex_ui/dropdown_menu.rb +26 -0
  55. data/lib/phlex_ui/form/item.rb +17 -0
  56. data/lib/phlex_ui/form/spacer.rb +17 -0
  57. data/lib/phlex_ui/form.rb +34 -0
  58. data/lib/phlex_ui/hint.rb +17 -0
  59. data/lib/phlex_ui/hover_card/content.rb +22 -0
  60. data/lib/phlex_ui/hover_card/trigger.rb +19 -0
  61. data/lib/phlex_ui/hover_card.rb +27 -0
  62. data/lib/phlex_ui/input.rb +29 -0
  63. data/lib/phlex_ui/input_error.rb +17 -0
  64. data/lib/phlex_ui/label.rb +17 -0
  65. data/lib/phlex_ui/link.rb +97 -0
  66. data/lib/phlex_ui/popover/content.rb +22 -0
  67. data/lib/phlex_ui/popover/trigger.rb +19 -0
  68. data/lib/phlex_ui/popover.rb +25 -0
  69. data/lib/phlex_ui/shortcut_key.rb +17 -0
  70. data/lib/phlex_ui/table/body.rb +17 -0
  71. data/lib/phlex_ui/table/builder.rb +77 -0
  72. data/lib/phlex_ui/table/caption.rb +17 -0
  73. data/lib/phlex_ui/table/cell.rb +17 -0
  74. data/lib/phlex_ui/table/footer.rb +17 -0
  75. data/lib/phlex_ui/table/head.rb +17 -0
  76. data/lib/phlex_ui/table/header.rb +17 -0
  77. data/lib/phlex_ui/table/row.rb +17 -0
  78. data/lib/phlex_ui/table.rb +19 -0
  79. data/lib/phlex_ui/tabs/content.rb +26 -0
  80. data/lib/phlex_ui/tabs/list.rb +17 -0
  81. data/lib/phlex_ui/tabs/trigger.rb +28 -0
  82. data/lib/phlex_ui/tabs.rb +25 -0
  83. data/lib/phlex_ui/theme_toggle.rb +41 -0
  84. data/lib/phlex_ui/tooltip/content.rb +22 -0
  85. data/lib/phlex_ui/tooltip/trigger.rb +17 -0
  86. data/lib/phlex_ui/tooltip.rb +25 -0
  87. data/lib/phlex_ui/typography/blockquote.rb +17 -0
  88. data/lib/phlex_ui/typography/h1.rb +17 -0
  89. data/lib/phlex_ui/typography/h2.rb +17 -0
  90. data/lib/phlex_ui/typography/h3.rb +17 -0
  91. data/lib/phlex_ui/typography/h4.rb +17 -0
  92. data/lib/phlex_ui/typography/inline_code.rb +17 -0
  93. data/lib/phlex_ui/typography/large.rb +17 -0
  94. data/lib/phlex_ui/typography/lead.rb +17 -0
  95. data/lib/phlex_ui/typography/list.rb +47 -0
  96. data/lib/phlex_ui/typography/list_item.rb +17 -0
  97. data/lib/phlex_ui/typography/muted.rb +17 -0
  98. data/lib/phlex_ui/typography/p.rb +17 -0
  99. data/lib/phlex_ui/typography/small.rb +17 -0
  100. metadata +112 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e94d694e97786f20a88cc28497e9fbda569229a4b60688745e1faef5bb6a794
4
- data.tar.gz: 3c06ca211012a28ad741ec3d66db56c7ecde93e637d07b24e2da5f987c759eef
3
+ metadata.gz: 997466eeaf90ee785e93f2bbb17ddf3014db28e538cfd2b5bb1177800b7eff41
4
+ data.tar.gz: a876736cf42046f4eda6e974ca8d48a2ffceb29dc49679bf2a857815a2d14c4e
5
5
  SHA512:
6
- metadata.gz: e45505146ef033bef4bc13725b1abc4dd450ca5f9b0a76981a109570044f50c68523dc4cd48aa69b0e9731e6ce5a7497788a08341012e2ea583ae9eab1fdae2e
7
- data.tar.gz: 197a7019398397c7cff18c24c5e0a5822f183d98ef9ac6f7852f0ccb782f70653941ac3eda20eeb40015303d34b6291a171b9d1777ac68d8ce32a8e2774cff72
6
+ metadata.gz: ca6af73e57c9c22983f4eab367a894bbcdba53e8b16b707ec14accf80f1faa81994f45f2ea34ffb1867cc800875bce96c7d716043f418b1aa88aa1adfcc3049d
7
+ data.tar.gz: 6fb432282362714d0a1b048e476dc15d7ad38f60ef26c311eaeefe35fcca31b9b34b72224f61147b991fd832c148f1380fa556eb878abe5ecf27dd3a50c8ea46
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexUI
4
+ class Alert::Description < Base
5
+ def template(&)
6
+ div(**attrs, &)
7
+ end
8
+
9
+ private
10
+
11
+ def default_attrs
12
+ {
13
+ class: "text-sm [&_p]:leading-relaxed",
14
+ }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexUI
4
+ class Alert::Title < Base
5
+ def template(&)
6
+ h5(**attrs, &)
7
+ end
8
+
9
+ private
10
+
11
+ def default_attrs
12
+ {
13
+ class: "mb-1 font-medium leading-none tracking-tight",
14
+ }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexUI
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 template(&)
11
+ div(**attrs, &)
12
+ end
13
+
14
+ private
15
+
16
+ def colors
17
+ case @variant
18
+ when nil
19
+ 'ring-border bg-muted-background text-text [&>svg]:opacity-80'
20
+ when :warning
21
+ 'ring-warning/20 bg-warning/10 text-warning [&>svg]:text-warning/80'
22
+ when :success
23
+ 'ring-success/20 bg-success/10 text-success [&>svg]:text-success/80'
24
+ when :destructive
25
+ 'ring-destructive/10 dark:ring-destructive/20 text-destructive bg-destructive/10 [&>svg]:text-destructive/80'
26
+ end
27
+ end
28
+
29
+ def default_attrs
30
+ base_classes = '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,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexUI
4
+ class AlertDialog::Action < Base
5
+ def template(&)
6
+ render PhlexUI::Button.new(**attrs, &)
7
+ end
8
+
9
+ private
10
+
11
+ def default_attrs
12
+ {
13
+ variant: :primary,
14
+ }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexUI
4
+ class AlertDialog::Cancel < Base
5
+ def template(&)
6
+ render PhlexUI::Button.new(**attrs, &)
7
+ end
8
+
9
+ private
10
+
11
+ def default_attrs
12
+ {
13
+ variant: :outline,
14
+ data: {
15
+ action: 'click->dismissable#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 PhlexUI
4
+ class AlertDialog::Content < Base
5
+ def template(&)
6
+ template_tag(**attrs) do
7
+ div(data: { controller: 'dismissable' }) do
8
+ background
9
+ container(&)
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-background/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
+ alert_dialog_target: "content"
41
+ }
42
+ }
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexUI
4
+ class AlertDialog::Description < Base
5
+ def template(&)
6
+ p(**attrs, &)
7
+ end
8
+
9
+ private
10
+
11
+ def default_attrs
12
+ {
13
+ class: "text-sm text-muted-text"
14
+ }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexUI
4
+ class AlertDialog::Footer < Base
5
+ def 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 PhlexUI
4
+ class AlertDialog::Header < Base
5
+ def 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,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexUI
4
+ class AlertDialog::Title < Base
5
+ def template(&)
6
+ h2(**attrs, &)
7
+ end
8
+
9
+ private
10
+
11
+ def default_attrs
12
+ {
13
+ class: "text-lg font-semibold"
14
+ }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexUI
4
+ class AlertDialog::Trigger < Base
5
+ def template(&)
6
+ div(**attrs, &)
7
+ end
8
+
9
+ private
10
+
11
+ def default_attrs
12
+ {
13
+ data: { action: "click->alert-dialog#open" },
14
+ class: 'inline-block'
15
+ }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexUI
4
+ class AlertDialog < Base
5
+ def initialize(open: false, **attrs)
6
+ @open = open
7
+ super(**attrs)
8
+ end
9
+
10
+ def template(&)
11
+ div(**attrs, &)
12
+ end
13
+
14
+ private
15
+
16
+ def default_attrs
17
+ {
18
+ data: {
19
+ controller: 'alert-dialog',
20
+ alert_dialog_open_value: @open
21
+ },
22
+ class: 'inline-block'
23
+ }
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexUI
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 template(&)
13
+ div(
14
+ class: "relative w-full",
15
+ style: "padding-bottom: #{padding_bottom}%;",
16
+ ) do
17
+ div(**attrs, &)
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-background 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,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexUI
4
+ class Avatar::Fallback < Base
5
+ def 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-background"
14
+ }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexUI
4
+ class Avatar::Image < Base
5
+ def initialize(src:, alt: '', **attrs)
6
+ @src = src
7
+ @alt = alt
8
+ super(**attrs)
9
+ end
10
+
11
+ def 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,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexUI
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, src: nil, alt: nil, initials: nil, **attrs)
14
+ @size = size
15
+ @src = src
16
+ @alt = alt
17
+ @initials = initials
18
+ @size_classes = SIZES[@size]
19
+ super(**attrs)
20
+ end
21
+
22
+ def template(&block)
23
+ if block_given?
24
+ span(**attrs, &block)
25
+ else
26
+ span(**attrs) do
27
+ render_image if @src
28
+ render_initials
29
+ end
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def render_image
36
+ render ::PhlexUI::Avatar::Image.new(src: @src, alt: @alt)
37
+ end
38
+
39
+ def render_initials
40
+ render ::PhlexUI::Avatar::Fallback.new { @initials }
41
+ end
42
+
43
+ def default_attrs
44
+ {
45
+ class: tokens("relative flex shrink-0 overflow-hidden rounded-full", @size_classes)
46
+ }
47
+ end
48
+ end
49
+ end
@@ -2,75 +2,59 @@
2
2
 
3
3
  module PhlexUI
4
4
  class Badge < Base
5
- def initialize(variant: :primary, size: :md, **kwargs)
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-50 dark:bg-primary-400/20 ring-primary-600/20",
13
+ secondary: "text-text bg-muted-background ring-border",
14
+ outline: "text-text bg-background ring-border",
15
+ destructive: "text-destructive-600 bg-destructive-50 dark:bg-destructive-400/20 dark:text-destructive-400 ring-destructive-600/20",
16
+ success: "text-success-600 bg-success-50 dark:bg-success-400/20 dark:text-success-400 ring-success-600/20",
17
+ warning: "text-warning-600 bg-warning-50 dark:bg-warning-400/20 dark:text-warning-400 ring-warning-600/20",
18
+ slate: "text-slate-600 bg-slate-50 dark:bg-slate-400/20 dark:text-slate-400 ring-slate-600/20",
19
+ gray: "text-gray-600 bg-gray-50 dark:bg-gray-400/20 dark:text-gray-400 ring-gray-600/20",
20
+ zinc: "text-zinc-600 bg-zinc-50 dark:bg-zinc-400/20 dark:text-zinc-400 ring-zinc-600/20",
21
+ neutral: "text-neutral-600 bg-neutral-50 dark:bg-neutral-400/20 dark:text-neutral-400 ring-neutral-600/20",
22
+ stone: "text-stone-600 bg-stone-50 dark:bg-stone-400/20 dark:text-stone-400 ring-stone-600/20",
23
+ red: "text-red-600 bg-red-50 dark:bg-red-400/20 dark:text-red-400 ring-red-600/20",
24
+ orange: "text-orange-600 bg-orange-50 dark:bg-orange-400/20 dark:text-orange-400 ring-orange-600/20",
25
+ amber: "text-amber-600 bg-amber-50 dark:bg-amber-400/20 dark:text-amber-400 ring-amber-600/20",
26
+ yellow: "text-yellow-600 bg-yellow-50 dark:bg-yellow-400/20 dark:text-yellow-400 ring-yellow-600/20",
27
+ lime: "text-lime-600 bg-lime-50 dark:bg-lime-400/20 dark:text-lime-400 ring-lime-600/20",
28
+ green: "text-green-600 bg-green-50 dark:bg-green-400/20 dark:text-green-400 ring-green-600/20",
29
+ emerald: "text-emerald-600 bg-emerald-50 dark:bg-emerald-400/20 dark:text-emerald-400 ring-emerald-600/20",
30
+ teal: "text-teal-600 bg-teal-50 dark:bg-teal-400/20 dark:text-teal-400 ring-teal-600/20",
31
+ cyan: "text-cyan-600 bg-cyan-50 dark:bg-cyan-400/20 dark:text-cyan-400 ring-cyan-600/20",
32
+ sky: "text-sky-600 bg-sky-50 dark:bg-sky-400/20 dark:text-sky-400 ring-sky-600/20",
33
+ blue: "text-blue-600 bg-blue-50 dark:bg-blue-400/20 dark:text-blue-400 ring-blue-600/20",
34
+ indigo: "text-indigo-600 bg-indigo-50 dark:bg-indigo-400/20 dark:text-indigo-400 ring-indigo-600/20",
35
+ violet: "text-violet-600 bg-violet-50 dark:bg-violet-400/20 dark:text-violet-400 ring-violet-600/20",
36
+ purple: "text-purple-600 bg-purple-50 dark:bg-purple-400/20 dark:text-purple-400 ring-purple-600/20",
37
+ fuchsia: "text-fuchsia-600 bg-fuchsia-50 dark:bg-fuchsia-400/20 dark:text-fuchsia-400 ring-fuchsia-600/20",
38
+ pink: "text-pink-600 bg-pink-50 dark:bg-pink-400/20 dark:text-pink-400 ring-pink-600/20",
39
+ rose: "text-rose-600 bg-rose-50 dark:bg-rose-400/20 dark:text-rose-400 ring-rose-600/20"
40
+ }
41
+
42
+ def initialize(variant: :primary, size: :md, **args)
6
43
  @variant = variant
7
44
  @size = size
8
- @kwargs = kwargs
45
+ super(**args)
9
46
  end
10
47
 
11
48
  def template(&)
12
- case @variant
13
- when :primary
14
- div(class: tokens("inline-flex items-center rounded-md border font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80", size_classes, @kwargs[:class]), &)
15
- when :secondary
16
- div(class: tokens("inline-flex items-center rounded-md border font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", size_classes, @kwargs[:class]), &)
17
- when :outline
18
- div(class: tokens("inline-flex items-center rounded-md border font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 text-foreground", size_classes, @kwargs[:class]), &)
19
- when :destructive
20
- div(class: tokens("inline-flex items-center rounded-md border font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80", size_classes, @kwargs[:class]), &)
21
- when :slate
22
- div(class: tokens("inline-flex items-center rounded-md bg-slate-100 font-medium text-slate-600 bg-slate-100/80 dark:bg-slate-400/10 dark:text-slate-400", size_classes, @kwargs[:class]), &)
23
- when :gray
24
- div(class: tokens("inline-flex items-center rounded-md bg-gray-100 font-medium text-gray-600 bg-gray-100/80 dark:bg-gray-400/10 dark:text-gray-400", size_classes, @kwargs[:class]), &)
25
- when :zinc
26
- div(class: tokens("inline-flex items-center rounded-md bg-zinc-100 font-medium text-zinc-600 bg-zinc-100/80 dark:bg-zinc-400/10 dark:text-zinc-400", size_classes, @kwargs[:class]), &)
27
- when :neutral
28
- div(class: tokens("inline-flex items-center rounded-md bg-neutral-100 font-medium text-neutral-600 bg-neutral-100/80 dark:bg-neutral-400/10 dark:text-neutral-400", size_classes, @kwargs[:class]), &)
29
- when :stone
30
- div(class: tokens("inline-flex items-center rounded-md bg-stone-100 font-medium text-stone-600 bg-stone-100/80 dark:bg-stone-400/10 dark:text-stone-400", size_classes, @kwargs[:class]), &)
31
- when :red
32
- div(class: tokens("inline-flex items-center rounded-md bg-red-100 font-medium text-red-600 bg-red-100/80 dark:bg-red-400/10 dark:text-red-400", size_classes, @kwargs[:class]), &)
33
- when :orange
34
- div(class: tokens("inline-flex items-center rounded-md bg-orange-100 font-medium text-orange-600 bg-orange-100/80 dark:bg-orange-400/10 dark:text-orange-400", size_classes, @kwargs[:class]), &)
35
- when :amber
36
- div(class: tokens("inline-flex items-center rounded-md bg-amber-100 font-medium text-amber-600 bg-amber-100/80 dark:bg-amber-400/10 dark:text-amber-400", size_classes, @kwargs[:class]), &)
37
- when :yellow
38
- div(class: tokens("inline-flex items-center rounded-md bg-yellow-100 font-medium text-yellow-600 bg-yellow-100/80 dark:bg-yellow-400/10 dark:text-yellow-400", size_classes, @kwargs[:class]), &)
39
- when :lime
40
- div(class: tokens("inline-flex items-center rounded-md bg-lime-100 font-medium text-lime-600 bg-lime-100/80 dark:bg-lime-400/10 dark:text-lime-400", size_classes, @kwargs[:class]), &)
41
- when :green
42
- div(class: tokens("inline-flex items-center rounded-md bg-green-100 font-medium text-green-600 bg-green-100/80 dark:bg-green-400/10 dark:text-green-400", size_classes, @kwargs[:class]), &)
43
- when :emerald
44
- div(class: tokens("inline-flex items-center rounded-md bg-emerald-100 font-medium text-emerald-600 bg-emerald-100/80 dark:bg-emerald-400/10 dark:text-emerald-400", size_classes, @kwargs[:class]), &)
45
- when :teal
46
- div(class: tokens("inline-flex items-center rounded-md bg-teal-100 font-medium text-teal-600 bg-teal-100/80 dark:bg-teal-400/10 dark:text-teal-400", size_classes, @kwargs[:class]), &)
47
- when :cyan
48
- div(class: tokens("inline-flex items-center rounded-md bg-cyan-100 font-medium text-cyan-600 bg-cyan-100/80 dark:bg-cyan-400/10 dark:text-cyan-400", size_classes, @kwargs[:class]), &)
49
- when :sky
50
- div(class: tokens("inline-flex items-center rounded-md bg-sky-100 font-medium text-sky-600 bg-sky-100/80 dark:bg-sky-400/10 dark:text-sky-400", size_classes, @kwargs[:class]), &)
51
- when :blue
52
- div(class: tokens("inline-flex items-center rounded-md bg-blue-100 font-medium text-blue-600 bg-blue-100/80 dark:bg-blue-400/10 dark:text-blue-400", size_classes, @kwargs[:class]), &)
53
- when :indigo
54
- div(class: tokens("inline-flex items-center rounded-md bg-indigo-100 font-medium text-indigo-600 bg-indigo-100/80 dark:bg-indigo-400/10 dark:text-indigo-400", size_classes, @kwargs[:class]), &)
55
- when :violet
56
- div(class: tokens("inline-flex items-center rounded-md bg-violet-100 font-medium text-violet-600 bg-violet-100/80 dark:bg-violet-400/10 dark:text-violet-400", size_classes, @kwargs[:class]), &)
57
- when :purple
58
- div(class: tokens("inline-flex items-center rounded-md bg-purple-100 font-medium text-purple-600 bg-purple-100/80 dark:bg-purple-400/10 dark:text-purple-400", size_classes, @kwargs[:class]), &)
59
- when :fuchsia
60
- div(class: tokens("inline-flex items-center rounded-md bg-fuchsia-100 font-medium text-fuchsia-600 bg-fuchsia-100/80 dark:bg-fuchsia-400/10 dark:text-fuchsia-400", size_classes, @kwargs[:class]), &)
61
- when :pink
62
- div(class: tokens("inline-flex items-center rounded-md bg-pink-100 font-medium text-pink-600 bg-pink-100/80 dark:bg-pink-400/10 dark:text-pink-400", size_classes, @kwargs[:class]), &)
63
- when :rose
64
- div(class: tokens("inline-flex items-center rounded-md bg-rose-100 font-medium text-rose-600 bg-rose-100/80 dark:bg-rose-400/10 dark:text-rose-400", size_classes, @kwargs[:class]), &)
65
- end
49
+ span(**attrs, &)
66
50
  end
67
51
 
68
- def size_classes
69
- case @size
70
- when :sm then "px-1.5 py-0.5 text-xs"
71
- when :md then "px-2 py-1 text-xs"
72
- when :lg then "px-3 py-1 text-sm"
73
- end
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
+ }
74
58
  end
75
59
  end
76
60
  end