Class: ShadcnPhlexcomponents::CommandTrigger
- Defined in:
- lib/shadcn_phlexcomponents/components/command.rb
Constant Summary
Constants inherited from Base
Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER
Instance Method Summary collapse
- #class_variants(**args) ⇒ Object
- #default_attributes ⇒ Object
-
#initialize(modifier_key: nil, shortcut_key: nil, aria_id: nil, **attributes) ⇒ CommandTrigger
constructor
A new instance of CommandTrigger.
- #view_template ⇒ Object
Methods inherited from Base
#before_template, #convert_collection_hash_to_struct, #find_as_child, #icon, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child
Constructor Details
#initialize(modifier_key: nil, shortcut_key: nil, aria_id: nil, **attributes) ⇒ CommandTrigger
Returns a new instance of CommandTrigger.
94 95 96 97 98 99 |
# File 'lib/shadcn_phlexcomponents/components/command.rb', line 94 def initialize(modifier_key: nil, shortcut_key: nil, aria_id: nil, **attributes) @modifier_key = modifier_key @shortcut_key = shortcut_key @aria_id = aria_id super(**attributes) end |
Instance Method Details
#class_variants(**args) ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'lib/shadcn_phlexcomponents/components/command.rb', line 101 def class_variants(**args) Button.new.class_variants( variant: :secondary, class: " bg-surface text-surface-foreground/60 dark:bg-card relative h-8 w-full justify-start pl-2.5 font-normal\n shadow-none sm:pr-12 md:w-40 lg:w-56 xl:w-64 \#{args[:class]}\n HEREDOC\n )\nend\n", |
#default_attributes ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/shadcn_phlexcomponents/components/command.rb', line 111 def default_attributes { role: "button", aria: { haspopup: "dialog", expanded: "false", controls: "#{@aria_id}-content", }, data: { command_target: "trigger", action: "click->command#open", }, } end |
#view_template ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/shadcn_phlexcomponents/components/command.rb', line 126 def view_template(&) (**@attributes) do yield if @modifier_key || @shortcut_key span(class: "absolute top-1.5 right-1.5 hidden gap-1 sm:flex") do if @modifier_key CommandKbd(class: "capitalize", data: { command_target: "modifierKey" }) { @modifier_key } end if @shortcut_key CommandKbd(class: "capitalize") { @shortcut_key } end end end end end |