Sha256: 4ac7840b205cae7ecb1c48aa9cfbfaf1f2f6ad1235748e3c591cd94835b50e9d

Contents?: true

Size: 1.28 KB

Versions: 5

Compression:

Stored size: 1.28 KB

Contents

# typed: false
# frozen_string_literal: true

module Ariadne
  module UI
    module Shortcut
      class Component < Ariadne::BaseComponent
        SPECIAL_KEYS = ["alt", "shift", "ctrl"]

        option :text, default: proc { "" }
        option :keys
        option :size, default: proc { :base }

        def special_keys = SPECIAL_KEYS

        accepts_html_attributes do |html_attrs|
          html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([style(:key, size:), html_attrs[:class]].join(" "))
        end

        style do
          base do
            [
              "ariadne-inline-flex",
              "ariadne-items-baseline",
              "ariadne-select-none",
              "*:ariadne-px-0",
            ]
          end
        end

        style :key do
          base do
            ["ariadne-font-mono"]
          end

          variants do
            size do
              xs do
                ["ariadne-text-xs", "ariadne-px-1", "ariadne-rounded-sm"]
              end

              sm do
                ["ariadne-text-sm", "ariadne-px-1.5", "ariadne-rounded"]
              end

              base do
                ["ariadne-text-base", "ariadne-px-1.5", "ariadne-rounded-md"]
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.92 app/components/ariadne/ui/shortcut/component.rb
ariadne_view_components-0.0.91 app/components/ariadne/ui/shortcut/component.rb
ariadne_view_components-0.0.90 app/components/ariadne/ui/shortcut/component.rb
ariadne_view_components-0.0.89.1 app/components/ariadne/ui/shortcut/component.rb
ariadne_view_components-0.0.89 app/components/ariadne/ui/shortcut/component.rb