Skip to content

Commit 1fd5893

Browse files
authored
Fix Sidebar Menu (#16)
* fix: Update stimulus targets and outlines with the correct information * feat: Add and register the missing `SidebarController` This controller was needed since it was being reference in the `header.rb` file. Because this controller didn't exist, the sidebar menu couldn't be accessed on mobile devices. * feat: Build assets after adding `SidebarController` * feat: Show the color mode controls on sidebar for small screen devices #16
1 parent 4d17244 commit 1fd5893

File tree

8 files changed

+51
-40
lines changed

8 files changed

+51
-40
lines changed

app/assets/plutonium.js

+5
Original file line numberDiff line numberDiff line change
@@ -24313,8 +24313,13 @@ this.ifd0Offset: ${this.ifd0Offset}, file.byteLength: ${e4.byteLength}`), e4.tif
2431324313
}
2431424314
};
2431524315

24316+
// src/js/controllers/sidebar_controller.js
24317+
var sidebar_controller_default = class extends Controller {
24318+
};
24319+
2431624320
// src/js/controllers/register_controllers.js
2431724321
function register_controllers_default(application2) {
24322+
application2.register("sidebar", sidebar_controller_default);
2431824323
application2.register("resource-header", resource_header_controller_default);
2431924324
application2.register("nested-resource-form-fields", nested_resource_form_fields_controller_default);
2432024325
application2.register("form", form_controller_default);

app/assets/plutonium.js.map

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/plutonium.min.js

+28-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/plutonium.min.js.map

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/plutonium/ui/layout/header.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def view_template
4444
class: "bg-white border-b border-gray-200 px-4 py-2.5 dark:bg-gray-800 dark:border-gray-700 fixed left-0 right-0 top-0 z-50",
4545
data: {
4646
controller: "resource-header",
47-
header_sidebar_outlet: "#sidebar-navigation"
47+
resource_header_sidebar_outlet: "#sidebar-navigation"
4848
}
4949
) do
5050
div(class: "flex flex-wrap justify-between items-center") do
@@ -70,7 +70,7 @@ def render_brand_section
7070
# @private
7171
def render_sidebar_toggle
7272
button(
73-
data_action: "header#toggleDrawer",
73+
data_action: "resource-header#toggleDrawer",
7474
aria_controls: "#sidebar-navigation",
7575
class: %(p-2 mr-2 text-gray-600 rounded-lg cursor-pointer lg:hidden hover:text-gray-900
7676
hover:bg-gray-100 focus:bg-gray-100 dark:focus:bg-gray-700 focus:ring-2
@@ -97,11 +97,11 @@ def render_brand
9797
# Renders the toggle icons for the sidebar button
9898
# @private
9999
def render_toggle_icons
100-
span(data_header_target: "openIcon") do
100+
span(data_resource_header_target: "openIcon") do
101101
render Phlex::TablerIcons::Menu.new(class: "w-6 h-6")
102102
end
103103

104-
span(data_header_target: "closeIcon", class: "hidden", aria_hidden: "true") do
104+
span(data_resource_header_target: "closeIcon", class: "hidden", aria_hidden: "true") do
105105
render Phlex::TablerIcons::X.new(class: "w-6 h-6")
106106
end
107107

lib/plutonium/ui/layout/sidebar.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def view_template(&)
2424
# @private
2525
def render_sidebar_container(&)
2626
aside(
27+
data: {controller: "sidebar"},
2728
id: "sidebar-navigation",
2829
aria: {label: "Sidebar Navigation"},
2930
class: "fixed top-0 left-0 z-40 w-64 h-screen pt-14 transition-transform -translate-x-full lg:translate-x-0",
@@ -43,7 +44,7 @@ def render_content(&)
4344

4445
# @private
4546
def render_color_mode_controls
46-
div(class: "hidden absolute bottom-0 left-0 justify-center p-4 space-x-4 w-full lg:flex bg-white dark:bg-gray-800 z-20 border-r border-gray-200 dark:border-gray-700") do
47+
div(class: "absolute bottom-0 left-0 justify-center p-4 space-x-4 w-full flex bg-white dark:bg-gray-800 z-20 border-r border-gray-200 dark:border-gray-700") do
4748
render ColorModeSelector.new
4849
end
4950
end

src/js/controllers/register_controllers.js

+2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ import ResourceTabListController from "./resource_tab_list_controller.js"
1616
import AttachmentInputController from "./attachment_input_controller.js"
1717
import AttachmentPreviewController from "./attachment_preview_controller.js"
1818
import AttachmentPreviewContainerController from "./attachment_preview_container_controller.js"
19+
import SidebarController from "./sidebar_controller.js"
1920

2021
export default function (application) {
2122
// Register controllers here
23+
application.register("sidebar", SidebarController)
2224
application.register("resource-header", ResourceHeaderController)
2325
application.register("nested-resource-form-fields", NestedResourceFormFieldsController)
2426
application.register("form", FormController)
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { Controller } from "@hotwired/stimulus";
2+
3+
export default class extends Controller {}

0 commit comments

Comments
 (0)