Skip to content

Commit a6c1388

Browse files
authored
New Default theme: New York (#363)
* Upgrade colors to use new york default theme * Fix home components accessibility heading structure * Modify the copy code from the theme gererator to support tailwindCSS 4
1 parent ae0738d commit a6c1388

File tree

7 files changed

+49
-41
lines changed

7 files changed

+49
-41
lines changed

app/assets/stylesheets/application.tailwind.css

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,23 @@
5454
.dark {
5555
--background: oklch(0.145 0 0);
5656
--foreground: oklch(0.985 0 0);
57-
--card: oklch(0.145 0 0);
57+
--card: oklch(0.205 0 0);
5858
--card-foreground: oklch(0.985 0 0);
59-
--popover: oklch(0.145 0 0);
59+
--popover: oklch(0.205 0 0);
6060
--popover-foreground: oklch(0.985 0 0);
61-
--primary: oklch(0.985 0 0);
61+
--primary: oklch(0.922 0 0);
6262
--primary-foreground: oklch(0.205 0 0);
6363
--secondary: oklch(0.269 0 0);
6464
--secondary-foreground: oklch(0.985 0 0);
6565
--muted: oklch(0.269 0 0);
6666
--muted-foreground: oklch(0.708 0 0);
6767
--accent: oklch(0.269 0 0);
6868
--accent-foreground: oklch(0.985 0 0);
69-
--destructive: oklch(0.396 0.141 25.723);
69+
--destructive: oklch(0.704 0.191 22.216);
7070
--destructive-foreground: oklch(0.637 0.237 25.331);
71-
--border: oklch(0.269 0 0);
72-
--input: oklch(0.269 0 0);
73-
--ring: oklch(0.439 0 0);
71+
--border: oklch(1 0 0 / 10%);
72+
--input: oklch(1 0 0 / 15%);
73+
--ring: oklch(0.556 0 0);
7474
--chart-1: oklch(0.488 0.243 264.376);
7575
--chart-2: oklch(0.696 0.17 162.48);
7676
--chart-3: oklch(0.769 0.188 70.08);
@@ -82,8 +82,8 @@
8282
--sidebar-primary-foreground: oklch(0.985 0 0);
8383
--sidebar-accent: oklch(0.269 0 0);
8484
--sidebar-accent-foreground: oklch(0.985 0 0);
85-
--sidebar-border: oklch(0.269 0 0);
86-
--sidebar-ring: oklch(0.439 0 0);
85+
--sidebar-border: oklch(1 0 0 / 10%);
86+
--sidebar-ring: oklch(0.556 0 0);
8787

8888
/* ruby_ui specific */
8989
--warning: hsl(38 92% 50%);

app/components/home_view/banner.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ def view_template(&block)
99
div(class: "relative overflow-hidden") do
1010
render Shared::GridPattern.new(spacing: :md)
1111
render HomeView::Shapes.new(size: :xl, color: :pink, class: "hidden sm:block absolute right-0 top-1/2 transform -translate-y-1/2 sm:translate-x-2/3 md:translate-x-1/2")
12-
div(class: "relative container mx-auto max-w-3xl py-24 lg:py-32 px-4 sm:text-center flex flex-col sm:items-center gap-y-6") do
12+
div(class: "relative container mx-auto max-w-3xl py-24 px-4 sm:text-center flex flex-col sm:items-center gap-y-6") do
1313
Heading(level: 1) do
1414
plain "A UI component library, crafted precisely for Ruby devs"
15-
span(class: "text-foreground opacity-30") { " who want to stay organised and build modern apps, fast." }
15+
span(class: "text-primary/70") { " who want to stay organised and build modern apps, fast." }
1616
end
1717
if @cta
1818
div(class: "grid grid-cols-1 sm:grid-cols-2 gap-4", &@cta)

app/components/home_view/card.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def view_template(&block)
3131
end
3232
if @title || @subtitle
3333
div(class: "space-y-2") do
34-
h3(class: "font-semibold leading-none tracking-tight") { @title } if @title
34+
h2(class: "font-semibold leading-none tracking-tight") { @title } if @title
3535
p { @subtitle } if @subtitle
3636
end
3737
end

app/components/shared/logo.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Shared
55
class Logo < Components::Base
66
def view_template
77
a(href: root_url, class: "mr-6 flex items-center space-x-2") do
8-
Heading(level: 4, class: "flex items-center") {
8+
Heading(level: 2, class: "flex items-center pb-0 border-0") {
99
img(src: image_url("logo.svg"), class: "h-4 block dark:hidden")
1010
img(src: image_url("logo_dark.svg"), class: "h-4 hidden dark:block")
1111
span(class: "sr-only") { "RubyUI" }

app/components/themes/copy_code.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ def view_template
1515
SheetTrigger do
1616
Button(variant: :primary) { "Copy Code" }
1717
end
18-
SheetContent(class: "sm:max-w-md w-screen flex flex-col h-screen overflow-y-scroll") do
18+
SheetContent(class: "sm:max-w-lg lg:max-w-xl flex flex-col h-screen overflow-y-scroll") do
1919
SheetHeader do
2020
SheetTitle { "Theme" }
21-
SheetDescription { "Copy and paste the following code into your CSS file." }
21+
SheetDescription { "Copy and paste the following code into your CSS file. These styles are compatible with TailwindCSS 4." }
2222
end
2323
SheetMiddle(class: "flex-1 relative") do
24-
Codeblock(Theme::CSS.retrieve(@theme, with_directive: true), syntax: :css, class: "h-full max-h-none")
24+
Codeblock(Theme::CSS.retrieve(@theme, with_directive: true, exclude_ruby_ui_vars: true), syntax: :css, class: "h-full max-h-none")
2525
end
2626
end
2727
end

app/views/pages/home.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def view_template
2929
iframe(width: "100%", height: "720", src: "https://www.youtube.com/embed/OQZam7rug00?si=JmZNzS5u194Q0AWQ", title: "YouTube video player", frameborder: "0", allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share", referrerpolicy: "strict-origin-when-cross-origin", allowfullscreen: true)
3030
end
3131

32-
div(class: "relative z-10 container mx-auto max-w-5xl pt-16 lg:pt-16 py-24 lg:py-32 px-4") do
32+
div(class: "relative z-10 container mx-auto max-w-5xl pt-16 lg:pt-16 py-24 px-4") do
3333
div(class: "grid grid-cols-6 gap-4") do
3434
render HomeView::Card.new(class: "col-span-6 sm:col-span-3 md:col-span-4", title: "Built for Speed", subtitle: "Dive into a world where your Rails UI development happens at light speed. Phlex is not just fast - it's blazing fast.", color: :secondary) do |card|
3535
card.icon do

lib/theme/c_s_s.rb

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
module Theme
22
class CSS
3-
def self.retrieve(theme, with_directive: true, format: :css)
3+
# Ruby UI specific variables that are not part of the standard shadcn theme
4+
RUBY_UI_SPECIFIC_VARS = %w[warning warning-foreground success success-foreground].freeze
5+
6+
def self.retrieve(theme, with_directive: true, format: :css, exclude_ruby_ui_vars: false)
47
theme_hash = send(theme)
8+
theme_hash = filter_ruby_ui_vars(theme_hash) if exclude_ruby_ui_vars
59

610
case format
711
when :css
@@ -14,6 +18,12 @@ def self.retrieve(theme, with_directive: true, format: :css)
1418
end
1519
end
1620

21+
def self.filter_ruby_ui_vars(theme_hash)
22+
theme_hash.transform_values do |properties|
23+
properties.reject { |key, _| RUBY_UI_SPECIFIC_VARS.include?(key.to_s) }
24+
end
25+
end
26+
1727
def self.all_themes
1828
{
1929
default: default,
@@ -86,23 +96,23 @@ def self.neutral
8696
dark: {
8797
background: "oklch(0.145 0 0)",
8898
foreground: "oklch(0.985 0 0)",
89-
card: "oklch(0.145 0 0)",
99+
card: "oklch(0.205 0 0)",
90100
"card-foreground": "oklch(0.985 0 0)",
91-
popover: "oklch(0.145 0 0)",
101+
popover: "oklch(0.205 0 0)",
92102
"popover-foreground": "oklch(0.985 0 0)",
93-
primary: "oklch(0.985 0 0)",
103+
primary: "oklch(0.922 0 0)",
94104
"primary-foreground": "oklch(0.205 0 0)",
95105
secondary: "oklch(0.269 0 0)",
96106
"secondary-foreground": "oklch(0.985 0 0)",
97107
muted: "oklch(0.269 0 0)",
98108
"muted-foreground": "oklch(0.708 0 0)",
99109
accent: "oklch(0.269 0 0)",
100110
"accent-foreground": "oklch(0.985 0 0)",
101-
destructive: "oklch(0.396 0.141 25.723)",
111+
destructive: "oklch(0.704 0.191 22.216)",
102112
"destructive-foreground": "oklch(0.637 0.237 25.331)",
103-
border: "oklch(0.269 0 0)",
104-
input: "oklch(0.269 0 0)",
105-
ring: "oklch(0.439 0 0)",
113+
border: "oklch(1 0 0 / 10%)",
114+
input: "oklch(1 0 0 / 15%)",
115+
ring: "oklch(0.556 0 0)",
106116
"chart-1": "oklch(0.488 0.243 264.376)",
107117
"chart-2": "oklch(0.696 0.17 162.48)",
108118
"chart-3": "oklch(0.769 0.188 70.08)",
@@ -114,8 +124,8 @@ def self.neutral
114124
"sidebar-primary-foreground": "oklch(0.985 0 0)",
115125
"sidebar-accent": "oklch(0.269 0 0)",
116126
"sidebar-accent-foreground": "oklch(0.985 0 0)",
117-
"sidebar-border": "oklch(0.269 0 0)",
118-
"sidebar-ring": "oklch(0.439 0 0)",
127+
"sidebar-border": "oklch(1 0 0 / 10%)",
128+
"sidebar-ring": "oklch(0.556 0 0)",
119129
warning: "hsl(38 92% 50%)",
120130
"warning-foreground": "hsl(0 0% 100%)",
121131
success: "hsl(84 81% 44%)",
@@ -457,23 +467,23 @@ def self.default_dark
457467
{
458468
background: "oklch(0.145 0 0)",
459469
foreground: "oklch(0.985 0 0)",
460-
card: "oklch(0.145 0 0)",
470+
card: "oklch(0.205 0 0)",
461471
"card-foreground": "oklch(0.985 0 0)",
462-
popover: "oklch(0.145 0 0)",
472+
popover: "oklch(0.205 0 0)",
463473
"popover-foreground": "oklch(0.985 0 0)",
464-
primary: "oklch(0.985 0 0)",
474+
primary: "oklch(0.922 0 0)",
465475
"primary-foreground": "oklch(0.205 0 0)",
466476
secondary: "oklch(0.269 0 0)",
467477
"secondary-foreground": "oklch(0.985 0 0)",
468478
muted: "oklch(0.269 0 0)",
469479
"muted-foreground": "oklch(0.708 0 0)",
470480
accent: "oklch(0.269 0 0)",
471481
"accent-foreground": "oklch(0.985 0 0)",
472-
destructive: "oklch(0.396 0.141 25.723)",
482+
destructive: "oklch(0.704 0.191 22.216)",
473483
"destructive-foreground": "oklch(0.637 0.237 25.331)",
474-
border: "oklch(0.269 0 0)",
475-
input: "oklch(0.269 0 0)",
476-
ring: "oklch(0.439 0 0)",
484+
border: "oklch(1 0 0 / 10%)",
485+
input: "oklch(1 0 0 / 15%)",
486+
ring: "oklch(0.556 0 0)",
477487
"chart-1": "oklch(0.488 0.243 264.376)",
478488
"chart-2": "oklch(0.696 0.17 162.48)",
479489
"chart-3": "oklch(0.769 0.188 70.08)",
@@ -485,8 +495,8 @@ def self.default_dark
485495
"sidebar-primary-foreground": "oklch(0.985 0 0)",
486496
"sidebar-accent": "oklch(0.269 0 0)",
487497
"sidebar-accent-foreground": "oklch(0.985 0 0)",
488-
"sidebar-border": "oklch(0.269 0 0)",
489-
"sidebar-ring": "oklch(0.439 0 0)",
498+
"sidebar-border": "oklch(1 0 0 / 10%)",
499+
"sidebar-ring": "oklch(0.556 0 0)",
490500
warning: "hsl(38 92% 50%)",
491501
"warning-foreground": "hsl(0 0% 100%)",
492502
success: "hsl(84 81% 44%)",
@@ -510,11 +520,9 @@ def self.format_selector(selector)
510520
end
511521

512522
def self.wrap_with_directive(css)
513-
<<~CSS
514-
@layer base {
515-
#{css}
516-
}
517-
CSS
523+
# Tailwind 4: :root and .dark selectors should NOT be wrapped in @layer base
524+
# This ensures CSS variables are properly accessible to @theme inline
525+
css
518526
end
519527
end
520528
end

0 commit comments

Comments
 (0)