Skip to content

Commit 74303a4

Browse files
authored
Updates from main: e5a1f6bb7e0e01a3d7584c9ab8b0a94a47f1611b (#364)
1 parent b8b88cb commit 74303a4

File tree

10 files changed

+30
-14
lines changed

10 files changed

+30
-14
lines changed

app/components/ruby_ui/checkbox/checkbox.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def default_attrs
1717
action: "change->ruby-ui--checkbox-group#onChange change->ruby-ui--form-field#onInput invalid->ruby-ui--form-field#onInvalid"
1818
},
1919
class: [
20-
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background accent-primary",
20+
"peer h-4 w-4 shrink-0 rounded-sm border-input ring-offset-background accent-primary",
2121
"disabled:cursor-not-allowed disabled:opacity-50",
22-
"checked:bg-primary checked:text-primary-foreground",
22+
"checked:bg-primary checked:text-primary-foreground dark:checked:bg-secondary checked:text-primary checked:border-primary",
2323
"aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:pointer-events-none",
2424
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
2525
]

app/components/ruby_ui/combobox/combobox_popover.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ def default_attrs
1717
data: {
1818
ruby_ui__combobox_target: "popover",
1919
action: %w[
20+
toggle->ruby-ui--combobox#handlePopoverToggle
2021
keydown.down->ruby-ui--combobox#keyDownPressed
2122
keydown.up->ruby-ui--combobox#keyUpPressed
2223
keydown.enter->ruby-ui--combobox#keyEnterPressed
23-
keydown.esc->ruby-ui--combobox#closeDialog:prevent
24+
keydown.esc->ruby-ui--combobox#closePopover:prevent
2425
resize@window->ruby-ui--combobox#updatePopoverWidth
2526
]
2627
}

app/components/ruby_ui/combobox/combobox_trigger.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def default_attrs
3131
data: {
3232
placeholder: @placeholder,
3333
ruby_ui__combobox_target: "trigger",
34-
action: "ruby-ui--combobox#openPopover"
34+
action: "ruby-ui--combobox#togglePopover"
3535
},
3636
aria: {
3737
haspopup: "listbox",

app/components/ruby_ui/context_menu/context_menu.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def default_attrs
1818
{
1919
data: {
2020
controller: "ruby-ui--context-menu",
21-
popover_options_value: @options.to_json
21+
ruby_ui__context_menu_options_value: @options.to_json
2222
}
2323
}
2424
end

app/components/ruby_ui/form/form_field_error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def default_attrs
1313
data: {
1414
ruby_ui__form_field_target: "error"
1515
},
16-
class: "text-sm font-medium text-destructive"
16+
class: "text-xs font-medium text-destructive"
1717
}
1818
end
1919
end

app/components/ruby_ui/form/form_field_label.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def view_template(&)
1111
def default_attrs
1212
{
1313
class: [
14-
"text-sm font-medium leading-none",
14+
"text-sm font-medium leading-none inline-block",
1515
"peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
1616
"peer-aria-disabled:cursor-not-allowed peer-aria-disabled:opacity-70 peer-aria-disabled:pointer-events-none"
1717
]

app/components/ruby_ui/input/input.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ def default_attrs
2020
action: "input->ruby-ui--form-field#onInput invalid->ruby-ui--form-field#onInvalid"
2121
},
2222
class: [
23-
"flex h-9 w-full rounded-md border bg-background px-3 py-1 text-sm shadow-sm transition-colors border-border",
23+
"flex h-9 w-full rounded-md border bg-background px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] border-border ring-0 ring-ring/0",
2424
"placeholder:text-muted-foreground",
2525
"disabled:cursor-not-allowed disabled:opacity-50",
2626
"file:border-0 file:bg-transparent file:text-sm file:font-medium",
27-
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
27+
"focus-visible:outline-none focus-visible:ring-ring/50 focus-visible:ring-2 focus-visible:border-ring focus-visible:shadow-sm",
2828
"aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:pointer-events-none"
2929
]
3030
}

app/components/ruby_ui/radio_button/radio_button.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def default_attrs
1818
class: [
1919
"h-4 w-4 p-0 border-primary rounded-full flex-none",
2020
"disabled:cursor-not-allowed disabled:opacity-50",
21-
"checked:bg-primary checked:text-primary-foreground",
21+
"checked:bg-primary checked:text-primary-foreground dark:checked:bg-secondary checked:text-primary checked:border-primary",
2222
"aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:pointer-events-none"
2323
]
2424
}

app/javascript/controllers/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
import { application } from "./application"
66

7+
import IframeThemeController from "./iframe_theme_controller"
8+
application.register("iframe-theme", IframeThemeController)
9+
710
import RubyUi__AccordionController from "./ruby_ui/accordion_controller"
811
application.register("ruby-ui--accordion", RubyUi__AccordionController)
912

@@ -82,8 +85,5 @@ application.register("ruby-ui--theme-toggle", RubyUi__ThemeToggleController)
8285
import RubyUi__TooltipController from "./ruby_ui/tooltip_controller"
8386
application.register("ruby-ui--tooltip", RubyUi__TooltipController)
8487

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

app/javascript/controllers/ruby_ui/combobox_controller.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export default class extends Controller {
2828
if (this.cleanup) { this.cleanup() }
2929
}
3030

31+
handlePopoverToggle(event) {
32+
// Keep ariaExpanded in sync with the actual popover state
33+
this.triggerTarget.ariaExpanded = event.newState === 'open' ? 'true' : 'false'
34+
}
35+
3136
inputChanged(e) {
3237
this.updateTriggerContent()
3338

@@ -62,9 +67,19 @@ export default class extends Controller {
6267
}
6368
}
6469

65-
openPopover(event) {
70+
togglePopover(event) {
6671
event.preventDefault()
6772

73+
if (this.triggerTarget.ariaExpanded === "true") {
74+
this.closePopover()
75+
} else {
76+
this.openPopover(event)
77+
}
78+
}
79+
80+
openPopover(event) {
81+
if (event) event.preventDefault()
82+
6883
this.updatePopoverPosition()
6984
this.updatePopoverWidth()
7085
this.triggerTarget.ariaExpanded = "true"

0 commit comments

Comments
 (0)