Skip to content

Fix sidebar typo #294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module RubyUI
class CollapsiableSidebar < Base
class CollapsibleSidebar < Base
def initialize(side: :left, variant: :sidebar, collapsible: :offcanvas, open: true, **attrs)
@side = side
@variant = variant
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_ui/sidebar/non_collapsible_sidebar.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module RubyUI
class NonCollpapsibleSidebar < Base
class NonCollapsibleSidebar < Base
def view_template(&)
div(**attrs, &)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/ruby_ui/sidebar/sidebar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def initialize(side: :left, variant: :sidebar, collapsible: :offcanvas, open: tr

def view_template(&)
if @collapsible == :none
NonCollapsiableSidebar(**attrs, &)
NonCollapsibleSidebar(**attrs, &)
else
CollapsiableSidebar(side: @side, variant: @variant, collapsible: @collapsible, open: @open, **attrs, &)
CollapsibleSidebar(side: @side, variant: @variant, collapsible: @collapsible, open: @open, **attrs, &)
end
end
end
Expand Down
60 changes: 60 additions & 0 deletions test/ruby_ui/sidebar_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,66 @@ def test_render_with_all_items
assert_match(/Footer/, output)
end

def test_render_non_collapsible_sidebar
output = phlex do
RubyUI.SidebarWrapper do
RubyUI.Sidebar(collapsible: :none) do
RubyUI.SidebarHeader do
RubyUI.SidebarGroup do
RubyUI.SidebarGroupContent do
RubyUI.SidebarInput(id: "search", placeholder: "Search the docs")
end
end
end
RubyUI.SidebarContent do
RubyUI.SidebarGroup do
RubyUI.SidebarGroupLabel { "Application" }
RubyUI.SidebarGroupAction { "Group Action" }
RubyUI.SidebarGroupContent do
RubyUI.SidebarMenu do
RubyUI.SidebarMenuItem do
RubyUI.SidebarMenuSub do
RubyUI.SidebarMenuSubItem do
RubyUI.SidebarMenuSubButton(as: :a, href: "#") { "Sub Item 1" }
end
end
end
RubyUI.SidebarMenuItem do
RubyUI.SidebarMenuButton(as: :a, href: "#") { "Settings" }
RubyUI.SidebarMenuAction { "Settings" }
end
RubyUI.SidebarMenuItem do
RubyUI.SidebarMenuButton { "Dashboard" }
RubyUI.SidebarMenuAction { "Dashboard" }
RubyUI.SidebarMenuBadge { "Dashboard Badge" }
end
RubyUI.SidebarMenuItem do
RubyUI.SidebarMenuSkeleton()
end
end
end
end
RubyUI.SidebarSeparator()
end
RubyUI.SidebarFooter { "Footer" }
RubyUI.SidebarRail()
end
RubyUI.SidebarInset do
RubyUI.SidebarTrigger()
end
end
end

assert_match(/Search the docs/, output)
assert_match(/Application/, output)
assert_match(/Group Action/, output)
assert_match(/Sub Item 1/, output)
assert_match(/Settings/, output)
assert_match(/Dashboard/, output)
assert_match(/Dashboard Badge/, output)
assert_match(/Footer/, output)
end

def test_with_side_right
output = phlex do
RubyUI.Sidebar(side: :right)
Expand Down