Skip to content

Commit 617c1e2

Browse files
authored
Update RubyUI (#137)
1 parent aec0f12 commit 617c1e2

File tree

209 files changed

+6225
-2321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+6225
-2321
lines changed

Gemfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ end
7474
gem "phlex", github: "phlex-ruby/phlex"
7575
gem "phlex-rails", github: "phlex-ruby/phlex-rails"
7676

77-
gem "ruby_ui", github: "ruby-ui/ruby_ui", branch: "main"
77+
gem "ruby_ui", github: "ruby-ui/ruby_ui", branch: "main", require: false
7878
# gem "ruby_ui", path: "../ruby_ui"
7979

8080
gem "pry"
81+
82+
gem "tailwind_merge", "~> 0.13.2"
83+
84+
gem "rouge", "~> 4.5"

Gemfile.lock

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@ GIT
1414

1515
GIT
1616
remote: https://github.com/ruby-ui/ruby_ui.git
17-
revision: 468d5804a217caaae933c70e2f76ad28636c6b82
17+
revision: 8909f0ecdd9ade28b01d76946e9d7438849b5856
1818
branch: main
1919
specs:
2020
ruby_ui (1.0.0.pre.alpha.4)
21-
phlex (>= 2.0.0.beta2)
22-
rouge (~> 4.2.0)
23-
tailwind_merge (~> 0.12)
2421

2522
GEM
2623
remote: https://rubygems.org/
@@ -234,7 +231,7 @@ GEM
234231
reline (0.5.11)
235232
io-console (~> 0.5)
236233
rexml (3.3.9)
237-
rouge (4.2.1)
234+
rouge (4.5.1)
238235
rubocop (1.66.1)
239236
json (~> 2.3)
240237
language_server-protocol (>= 3.17.0)
@@ -318,11 +315,13 @@ DEPENDENCIES
318315
pry
319316
puma (= 6.4.2)
320317
rails (= 7.2.0)
318+
rouge (~> 4.5)
321319
ruby_ui!
322320
selenium-webdriver
323321
sqlite3 (>= 1.4)
324322
standard
325323
stimulus-rails (= 1.3.3)
324+
tailwind_merge (~> 0.13.2)
326325
turbo-rails (= 2.0.6)
327326
tzinfo-data
328327
web-console

app/assets/stylesheets/application.tailwind.css

+6-5
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
--input: 240 5.9% 90%;
2525
--ring: 240 5.9% 10%;
2626
--radius: 0.5rem;
27-
28-
/* rbui especific */
27+
28+
/* ruby_ui especific */
2929
--warning: 38 92% 50%;
3030
--warning-foreground: 0 0% 100%;
3131
--success: 87 100% 37%;
3232
--success-foreground: 0 0% 100%;
3333
}
34-
34+
3535
.dark {
3636
--background: 240 10% 3.9%;
3737
--foreground: 0 0% 98%;
@@ -53,7 +53,7 @@
5353
--input: 240 3.7% 15.9%;
5454
--ring: 240 4.9% 83.9%;
5555

56-
/* rbui especific */
56+
/* ruby_ui especific */
5757
--warning: 38 92% 50%;
5858
--warning-foreground: 0 0% 100%;
5959
--success: 84 81% 44%;
@@ -65,6 +65,7 @@
6565
* {
6666
@apply border-border;
6767
}
68+
6869
body {
6970
@apply bg-background text-foreground;
7071
font-feature-settings: "rlig" 1, "calt" 1;
@@ -73,4 +74,4 @@
7374
/* https://css-tricks.com/snippets/css/system-font-stack/ */
7475
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
7576
}
76-
}
77+
}

app/components/base.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
class Components::Base < Phlex::HTML
2+
include Components
3+
include RubyUI
4+
5+
# Include any helpers you want to be available across all components
6+
include Phlex::Rails::Helpers::Routes
7+
28
TAILWIND_MERGER = ::TailwindMerge::Merger.new.freeze unless defined?(TAILWIND_MERGER)
39

410
attr_reader :attrs
@@ -8,7 +14,7 @@ def initialize(**user_attrs)
814
@attrs[:class] = TAILWIND_MERGER.merge(@attrs[:class]) if @attrs[:class]
915
end
1016

11-
if defined?(Rails) && Rails.env.development?
17+
if Rails.env.development?
1218
def before_template
1319
comment { "Before #{self.class.name}" }
1420
super

app/components/rbui/index.js

-8
This file was deleted.

app/components/ruby_ui/accordion.rb

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class Accordion < Base
5+
def view_template(&)
6+
div(**attrs, &)
7+
end
8+
9+
private
10+
11+
def default_attrs
12+
{
13+
class: "w-full"
14+
}
15+
end
16+
end
17+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class AccordionContent < Base
5+
def view_template(&)
6+
div(**attrs, &)
7+
end
8+
9+
private
10+
11+
def default_attrs
12+
{
13+
data: {
14+
ruby_ui__accordion_target: "content"
15+
},
16+
class: "overflow-y-hidden",
17+
style: "height: 0px;"
18+
}
19+
end
20+
end
21+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class AccordionDefaultContent < Base
5+
def view_template(&)
6+
div(**attrs, &)
7+
end
8+
9+
private
10+
11+
def default_attrs
12+
{
13+
class: "pb-4 pt-0 text-sm"
14+
}
15+
end
16+
end
17+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class AccordionDefaultTrigger < Base
5+
def view_template(&block)
6+
div(class: "flex items-center justify-between w-full") do
7+
p(&block)
8+
RubyUI.AccordionIcon
9+
end
10+
end
11+
12+
def default_attrs
13+
{
14+
data: {action: "click->ruby-ui--accordion#toggle"},
15+
class: "w-full flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline"
16+
}
17+
end
18+
end
19+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class AccordionIcon < Base
5+
def view_template(&block)
6+
span(**attrs) do
7+
if block
8+
block.call
9+
else
10+
icon
11+
end
12+
end
13+
end
14+
15+
def icon
16+
svg(
17+
xmlns: "http://www.w3.org/2000/svg",
18+
viewbox: "0 0 20 20",
19+
fill: "currentColor",
20+
class: "w-4 h-4"
21+
) do |s|
22+
s.path(
23+
fill_rule: "evenodd",
24+
d:
25+
"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",
26+
clip_rule: "evenodd"
27+
)
28+
end
29+
end
30+
31+
def default_attrs
32+
{
33+
class: "opacity-50",
34+
data: {ruby_ui__accordion_target: "icon"}
35+
}
36+
end
37+
end
38+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class AccordionItem < Base
5+
def initialize(open: false, rotate_icon: 180, **attrs)
6+
@open = open
7+
@rotate_icon = rotate_icon
8+
super(**attrs)
9+
end
10+
11+
def view_template(&)
12+
div(**attrs, &)
13+
end
14+
15+
private
16+
17+
def default_attrs
18+
{
19+
data: {
20+
controller: "ruby-ui--accordion",
21+
ruby_ui__accordion_open_value: @open,
22+
ruby_ui__accordion_rotate_icon_value: @rotate_icon
23+
},
24+
class: "border-b"
25+
}
26+
end
27+
end
28+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class AccordionTrigger < Base
5+
def view_template(&)
6+
button(**attrs, &)
7+
end
8+
9+
def default_attrs
10+
{
11+
type: "button",
12+
data: {action: "click->ruby-ui--accordion#toggle"},
13+
class: "w-full flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline"
14+
}
15+
end
16+
end
17+
end

app/components/ruby_ui/alert.rb

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class Alert < Base
5+
def initialize(variant: nil, **attrs)
6+
@variant = variant
7+
super(**attrs) # must be called after variant is set
8+
end
9+
10+
def view_template(&)
11+
div(**attrs, &)
12+
end
13+
14+
private
15+
16+
def colors
17+
case @variant
18+
when nil
19+
"ring-border bg-muted/20 text-foreground [&>svg]:opacity-80"
20+
when :warning
21+
"ring-warning/20 bg-warning/5 text-warning [&>svg]:text-warning/80"
22+
when :success
23+
"ring-success/20 bg-success/5 text-success [&>svg]:text-success/80"
24+
when :destructive
25+
"ring-destructive/20 bg-destructive/5 text-destructive [&>svg]:text-destructive/80"
26+
end
27+
end
28+
29+
def default_attrs
30+
base_classes = "backdrop-blur relative w-full ring-1 ring-inset rounded-lg px-4 py-4 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg~*]:pl-8"
31+
{
32+
class: [base_classes, colors]
33+
}
34+
end
35+
end
36+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class AlertDescription < Base
5+
def view_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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class AlertTitle < Base
5+
def view_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
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class AlertDialog < Base
5+
def initialize(open: false, **attrs)
6+
@open = open
7+
super(**attrs)
8+
end
9+
10+
def view_template(&)
11+
div(**attrs, &)
12+
end
13+
14+
private
15+
16+
def default_attrs
17+
{
18+
data: {
19+
controller: "ruby-ui--alert-dialog",
20+
ruby_ui__alert_dialog_open_value: @open.to_s
21+
},
22+
class: "inline-block"
23+
}
24+
end
25+
end
26+
end

0 commit comments

Comments
 (0)