Class: Shadcn::ToastActionComponent

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

Overview

Toast Action component

Constant Summary collapse

BASE_CLASSES =
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive"

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(alt_text:, **options, &block) ⇒ ToastActionComponent

Returns a new instance of ToastActionComponent.

Parameters:

  • alt_text (String)

    Alternative text for accessibility



9
10
11
12
# File 'app/components/shadcn/toast_action_component.rb', line 9

def initialize(alt_text:, **options, &block)
  super(**options, &block)
  @alt_text = alt_text
end

Instance Method Details

#callObject



14
15
16
# File 'app/components/shadcn/toast_action_component.rb', line 14

def call
  (:div, content, class: merge_classes(BASE_CLASSES), "aria-label": @alt_text)
end