Class: Shadcn::ToggleGroupItemComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/shadcn/toggle_group_item_component.rb

Overview

Individual toggle item within a group

Constant Summary collapse

VARIANTS =
{
  default: "bg-transparent",
  outline: "border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground"
}.freeze
SIZES =
{
  sm: "h-8 px-2 min-w-8",
  default: "h-9 px-2.5 min-w-9",
  lg: "h-10 px-3 min-w-10"
}.freeze
BASE_CLASSES =
"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground"

Instance Attribute Summary

Attributes inherited from BaseComponent

#class_name, #data, #html_options

Instance Method Summary collapse

Methods inherited from BaseComponent

#content

Methods included from Rails::Helpers::ClassNameHelper

#cn

Constructor Details

#initialize(value:, pressed: false, disabled: false, aria_label: nil, variant: :default, size: :default, group_type: :single, **options, &block) ⇒ ToggleGroupItemComponent

Returns a new instance of ToggleGroupItemComponent.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/components/shadcn/toggle_group_item_component.rb', line 19

def initialize(
  value:,
  pressed: false,
  disabled: false,
  aria_label: nil,
  variant: :default,
  size: :default,
  group_type: :single,
  **options,
  &block
)
  super(**options, &block)
  @value = value
  @pressed = pressed
  @disabled = disabled
  @aria_label = aria_label
  @variant = variant
  @size = size
  @group_type = group_type
end

Instance Method Details

#callObject



40
41
42
# File 'app/components/shadcn/toggle_group_item_component.rb', line 40

def call
  (:button, content, button_attributes)
end