Sha256: 3d68622a1d54d7e09b8dac60942c1685c1e0259c2c9e6ead1483f8159b817803

Contents?: true

Size: 1.85 KB

Versions: 7

Compression:

Stored size: 1.85 KB

Contents

# typed: false
# frozen_string_literal: true

module Ariadne
  module Layout
    module NavBar
      class Component < Ariadne::BaseComponent
        # Leading items at the far left of the header.
        renders_many :leading_items, BaseComponent::ACCEPT_ANYTHING

        # Leading items at the far left of the header.
        renders_many :trailing_items, lambda { |static_content = nil, &block|
          next static_content if static_content.present?

          view_context.capture { block&.call }
        }

        renders_many :navigation_items, lambda { |static_content = nil, &block|
          next static_content if static_content.present?

          view_context.capture { block&.call }
        }

        def initial?(position)
          position.zero?
        end

        def final?(position)
          position == (leading_items.size - 1)
        end

        style do
          base do
            [
              "ariadne-bg-white",
              "ariadne-border-b",
              "ariadne-z-50",
              "ariadne-overflow-hidden",
              "ariadne-border-zinc-100",
              "dark:ariadne-border-zinc-900",
            ]
          end
        end

        style(:leading_item) do
          base do
            [
              "",
            ]
          end

          variants do
            initial do
              yes { "ariadne-flex ariadne-flex-shrink-0 ariadne-items-center" }
              no { "ariadne-hidden lg:ariadne-ml-6 lg:ariadne-flex lg:ariadne-space-x-8" }
            end
          end
        end

        style(:trailing_item) do
          base do
            [
              "ariadne-flex",
              "ariadne-flex-1",
              "ariadne-items-center",
              "ariadne-justify-end",
              "ariadne-gap-x-1",
            ]
          end

          variants do
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.70 app/components/ariadne/layout/nav_bar/component.rb
ariadne_view_components-0.0.69 app/components/ariadne/layout/nav_bar/component.rb
ariadne_view_components-0.0.68 app/components/ariadne/layout/nav_bar/component.rb
ariadne_view_components-0.0.67 app/components/ariadne/layout/nav_bar/component.rb
ariadne_view_components-0.0.66 app/components/ariadne/layout/nav_bar/component.rb
ariadne_view_components-0.0.65 app/components/ariadne/layout/nav_bar/component.rb
ariadne_view_components-0.0.64 app/components/ariadne/layout/nav_bar/component.rb