Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.

Commit f2f1dc9

Browse files
authored
Merge branch 'main' into dependabot/bundler/standard-1.51.1
2 parents c64d6a5 + e4ec8ca commit f2f1dc9

25 files changed

Lines changed: 1108 additions & 186 deletions

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ gem "rails", "8.0.2.1"
88
# The modern asset pipeline for Rails [https://github.com/rails/propshaft]
99
gem "propshaft", "1.2.1"
1010
# Use sqlite3 as the database for Active Record
11-
gem "sqlite3", "2.7.3"
11+
gem "sqlite3", "2.7.4"
1212
# Use the Puma web server [https://github.com/puma/puma]
13-
gem "puma", "7.0.1"
13+
gem "puma", "7.1.0"
1414
# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
1515
gem "jsbundling-rails", "1.3.1"
1616
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]

Gemfile.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ GEM
100100
benchmark (0.4.1)
101101
bigdecimal (3.2.2)
102102
bindex (0.8.1)
103-
bootsnap (1.18.6)
103+
bootsnap (1.19.0)
104104
msgpack (~> 1.2)
105105
builder (3.3.0)
106106
capybara (3.40.0)
@@ -138,7 +138,7 @@ GEM
138138
reline (>= 0.4.2)
139139
jsbundling-rails (1.3.1)
140140
railties (>= 6.0.0)
141-
json (2.13.2)
141+
json (2.15.1)
142142
language_server-protocol (3.17.0.5)
143143
lint_roller (1.1.0)
144144
logger (1.7.0)
@@ -181,7 +181,7 @@ GEM
181181
pp (0.6.2)
182182
prettyprint
183183
prettyprint (0.2.0)
184-
prism (1.5.1)
184+
prism (1.6.0)
185185
propshaft (1.2.1)
186186
actionpack (>= 7.0.0)
187187
activesupport (>= 7.0.0)
@@ -193,7 +193,7 @@ GEM
193193
date
194194
stringio
195195
public_suffix (6.0.1)
196-
puma (7.0.1)
196+
puma (7.1.0)
197197
nio4r (~> 2.0)
198198
racc (1.8.1)
199199
rack (3.2.0)
@@ -241,7 +241,7 @@ GEM
241241
regexp_parser (2.11.2)
242242
reline (0.6.2)
243243
io-console (~> 0.5)
244-
rexml (3.4.1)
244+
rexml (3.4.4)
245245
rouge (4.6.0)
246246
rubocop (1.80.2)
247247
json (~> 2.3)
@@ -262,19 +262,19 @@ GEM
262262
rubocop (>= 1.75.0, < 2.0)
263263
rubocop-ast (>= 1.38.0, < 2.0)
264264
ruby-progressbar (1.13.0)
265-
rubyzip (3.0.1)
265+
rubyzip (3.2.0)
266266
securerandom (0.4.1)
267-
selenium-webdriver (4.35.0)
267+
selenium-webdriver (4.37.0)
268268
base64 (~> 0.2)
269269
logger (~> 1.4)
270270
rexml (~> 3.2, >= 3.2.5)
271271
rubyzip (>= 1.2.2, < 4.0)
272272
websocket (~> 1.0)
273273
sin_lru_redux (2.5.2)
274-
sqlite3 (2.7.3)
274+
sqlite3 (2.7.4)
275275
mini_portile2 (~> 2.8.0)
276-
sqlite3 (2.7.3-x86_64-linux-gnu)
277-
standard (1.51.1)
276+
sqlite3 (2.7.4-x86_64-linux-gnu)
277+
standard (1.50.0)
278278
language_server-protocol (~> 3.17.0.2)
279279
lint_roller (~> 1.0)
280280
rubocop (~> 1.80.2)
@@ -333,12 +333,12 @@ DEPENDENCIES
333333
phlex-rails!
334334
propshaft (= 1.2.1)
335335
pry (= 0.15.2)
336-
puma (= 7.0.1)
336+
puma (= 7.1.0)
337337
rails (= 8.0.2.1)
338338
rouge (~> 4.6)
339339
ruby_ui!
340340
selenium-webdriver
341-
sqlite3 (= 2.7.3)
341+
sqlite3 (= 2.7.4)
342342
standard
343343
stimulus-rails (= 1.3.4)
344344
tailwind_merge (~> 1.3.1)

app/components/docs/visual_code_example.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ def self.reset_collected_code
1313
@@collected_code = []
1414
end
1515

16-
def initialize(title: nil, description: nil, context: nil)
16+
def initialize(title: nil, description: nil, src: nil, context: nil)
1717
@title = title
1818
@description = description
19+
@src = src
1920
@context = context
2021
end
2122

@@ -43,7 +44,7 @@ def view_template(&)
4344
def render_header
4445
div do
4546
if @title
46-
div(class: "flex items-center gap-x-2 mb-1") do
47+
div do
4748
Components.Heading(level: 4) { @title.capitalize }
4849
end
4950
end
@@ -71,6 +72,20 @@ def render_tab_contents(&)
7172
end
7273

7374
def render_preview_tab(&block)
75+
return iframe_preview if @src
76+
77+
raw_preview
78+
end
79+
80+
def iframe_preview
81+
div(class: "relative aspect-[4/2.5] w-full overflow-hidden rounded-md border", data: {controller: "iframe-theme"}) do
82+
div(class: "absolute inset-0 hidden w-[1600px] bg-background md:block") do
83+
iframe(src: @src, class: "size-full", data: {iframe_theme_target: "iframe"})
84+
end
85+
end
86+
end
87+
88+
def raw_preview
7489
div(class: "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 relative rounded-md border") do
7590
div(class: "preview flex min-h-[350px] w-full justify-center p-10 items-center") do
7691
decoded_code = CGI.unescapeHTML(@display_code)

app/components/shared/head.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ def view_template
1212
meta name: "turbo-refresh-method", content: "morph"
1313
meta name: "turbo-refresh-scroll", content: "preserve"
1414
meta name: "view-transition", content: "same-origin"
15+
16+
link rel: "apple-touch-icon", sizes: "180x180", href: "/apple-touch-icon.png"
17+
link rel: "icon", type: "image/png", sizes: "32x32", href: "/favicon-32x32.png"
18+
link rel: "icon", type: "image/png", sizes: "16x16", href: "/favicon-16x16.png"
19+
link rel: "manifest", href: "/site.webmanifest"
20+
1521
csp_meta_tag
1622
csrf_meta_tags
1723
stylesheet_link_tag "https://api.fontshare.com/v2/css?f[]=general-sans@1&display=swap", data_turbo_track: "reload"

app/components/shared/menu.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def components
9999
{name: "Separator", path: docs_separator_path, badge: "New"},
100100
{name: "Sheet", path: docs_sheet_path},
101101
{name: "Shortcut Key", path: docs_shortcut_key_path},
102+
{name: "Sidebar", path: docs_sidebar_path, badge: "New"},
102103
{name: "Skeleton", path: docs_skeleton_path, badge: "New"},
103104
{name: "Switch", path: docs_switch_path},
104105
{name: "Table", path: docs_table_path},
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
class Docs::SidebarController < ApplicationController
4+
layout -> { Views::Layouts::ExamplesLayout }
5+
6+
def example
7+
sidebar_state = cookies.fetch(:sidebar_state, "true") == "true"
8+
9+
render Views::Docs::Sidebar::Example.new(sidebar_state:)
10+
end
11+
12+
def inset_example
13+
sidebar_state = cookies.fetch(:sidebar_state, "true") == "true"
14+
15+
render Views::Docs::Sidebar::InsetExample.new(sidebar_state:)
16+
end
17+
end

app/controllers/docs_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ def shortcut_key
178178
render Views::Docs::ShortcutKey.new
179179
end
180180

181+
def sidebar
182+
render Views::Docs::Sidebar.new
183+
end
184+
181185
def skeleton
182186
render Views::Docs::Skeleton.new
183187
end
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { Controller } from "@hotwired/stimulus"
2+
3+
export default class extends Controller {
4+
static targets = ["iframe"]
5+
6+
connect() {
7+
this.setupThemeObserver()
8+
this.setupIframeListeners()
9+
this.syncAllIframes()
10+
}
11+
12+
disconnect() {
13+
this.observer?.disconnect()
14+
}
15+
16+
iframeTargetConnected(iframe) {
17+
this.setupIframeListener(iframe)
18+
this.syncThemeToIframe(iframe)
19+
}
20+
21+
setupThemeObserver() {
22+
this.observer = new MutationObserver(() => this.syncAllIframes())
23+
this.observer.observe(document.documentElement, {
24+
attributes: true,
25+
attributeFilter: ['class']
26+
})
27+
}
28+
29+
setupIframeListeners() {
30+
this.iframeTargets.forEach(iframe => this.setupIframeListener(iframe))
31+
}
32+
33+
setupIframeListener(iframe) {
34+
if (!iframe.src) return
35+
36+
iframe.addEventListener('load', () => this.syncThemeToIframe(iframe))
37+
38+
if (this.isIframeLoaded(iframe)) {
39+
this.syncThemeToIframe(iframe)
40+
}
41+
}
42+
43+
syncAllIframes() {
44+
this.iframeTargets.forEach(iframe => this.syncThemeToIframe(iframe))
45+
}
46+
47+
syncThemeToIframe(iframe) {
48+
if (!iframe.src) return
49+
50+
const iframeDoc = this.getIframeDocument(iframe)
51+
if (!iframeDoc?.documentElement) return
52+
53+
iframeDoc.documentElement.classList.toggle('dark', this.isDarkMode)
54+
}
55+
56+
getIframeDocument(iframe) {
57+
try {
58+
return iframe.contentDocument || iframe.contentWindow?.document
59+
} catch (e) {
60+
return null
61+
}
62+
}
63+
64+
isIframeLoaded(iframe) {
65+
const doc = this.getIframeDocument(iframe)
66+
return doc && doc.readyState === 'complete'
67+
}
68+
69+
get isDarkMode() {
70+
return document.documentElement.classList.contains('dark')
71+
}
72+
}
73+

app/javascript/controllers/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,8 @@ application.register("ruby-ui--theme-toggle", RubyUi__ThemeToggleController)
8282
import RubyUi__TooltipController from "./ruby_ui/tooltip_controller"
8383
application.register("ruby-ui--tooltip", RubyUi__TooltipController)
8484

85+
import IframeThemeController from "./iframe_theme_controller"
86+
application.register("iframe-theme", IframeThemeController)
87+
8588
import SidebarMenuController from "./sidebar_menu_controller"
8689
application.register("sidebar-menu", SidebarMenuController)

app/views/docs/select.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,28 @@ def view_template
3131
RUBY
3232
end
3333

34+
render Docs::VisualCodeExample.new(title: "Pre-selected Item", context: self) do
35+
<<~RUBY
36+
Select(class: "w-56") do
37+
SelectInput(value: "banana", id: "select-preselected-fruit")
38+
39+
SelectTrigger do
40+
SelectValue(placeholder: "Select a fruit", id: "select-preselected-fruit") { "Banana" }
41+
end
42+
43+
SelectContent(outlet_id: "select-preselected-fruit") do
44+
SelectGroup do
45+
SelectLabel { "Fruits" }
46+
SelectItem(value: "apple") { "Apple" }
47+
SelectItem(value: "orange") { "Orange" }
48+
SelectItem(value: "banana") { "Banana" }
49+
SelectItem(value: "watermelon") { "Watermelon" }
50+
end
51+
end
52+
end
53+
RUBY
54+
end
55+
3456
render Docs::VisualCodeExample.new(title: "Disabled", context: self) do
3557
<<~RUBY
3658
Select(class: "w-56") do

0 commit comments

Comments
 (0)