Sha256: b2d463bdae66ce949adee525102a6df6985e7a2adb3d1f38e70752c777159a47

Contents?: true

Size: 1.59 KB

Versions: 12

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

module Plutonium
  module UI
    module Layout
      # A sidebar navigation component that provides a responsive layout with light/dark mode toggle
      # @example Basic usage with navigation content
      #   render Sidebar.new do
      #     ...
      #   end
      class Sidebar < Base
        # Renders the sidebar navigation template
        # @yield [void] The block containing sidebar content
        # @return [void]
        def view_template(&)
          render_sidebar_container do
            render_content(&) if block_given?
            render_color_mode_controls
          end
        end

        private

        # @private
        def render_sidebar_container(&)
          aside(
            id: "sidebar-navigation",
            aria: {label: "Sidebar Navigation"},
            class: "fixed top-0 left-0 z-40 w-64 h-screen pt-14 transition-transform -translate-x-full lg:translate-x-0",
            &
          )
        end

        # @private
        def render_content(&)
          div(
            id: "sidebar-navigation-content",
            data: {turbo_permanent: true},
            class: "overflow-y-auto py-5 px-3 h-full bg-white border-r border-gray-200 dark:bg-gray-800 dark:border-gray-700",
            &
          )
        end

        # @private
        def render_color_mode_controls
          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
            render ColorModeSelector.new
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
plutonium-0.19.2 lib/plutonium/ui/layout/sidebar.rb
plutonium-0.19.1 lib/plutonium/ui/layout/sidebar.rb
plutonium-0.19.0 lib/plutonium/ui/layout/sidebar.rb
plutonium-0.18.8 lib/plutonium/ui/layout/sidebar.rb
plutonium-0.18.7 lib/plutonium/ui/layout/sidebar.rb
plutonium-0.18.6 lib/plutonium/ui/layout/sidebar.rb
plutonium-0.18.5 lib/plutonium/ui/layout/sidebar.rb
plutonium-0.18.4 lib/plutonium/ui/layout/sidebar.rb
plutonium-0.18.3 lib/plutonium/ui/layout/sidebar.rb
plutonium-0.18.2 lib/plutonium/ui/layout/sidebar.rb
plutonium-0.18.1 lib/plutonium/ui/layout/sidebar.rb
plutonium-0.18.0 lib/plutonium/ui/layout/sidebar.rb