Class: ShadcnPhlexcomponents::ThemeSwitcher

Inherits:
Base
  • Object
show all
Defined in:
lib/shadcn_phlexcomponents/components/theme_switcher.rb

Constant Summary

Constants inherited from Base

Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from Base

#before_template, #convert_collection_hash_to_struct, #find_as_child, #icon, #initialize, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child

Constructor Details

This class inherits a constructor from ShadcnPhlexcomponents::Base

Instance Method Details

#default_attributesObject



12
13
14
15
16
17
18
19
# File 'lib/shadcn_phlexcomponents/components/theme_switcher.rb', line 12

def default_attributes
  {
    data: {
      controller: "theme-switcher",
      action: "theme-switcher#toggle",
    },
  }
end

#view_templateObject



5
6
7
8
9
10
# File 'lib/shadcn_phlexcomponents/components/theme_switcher.rb', line 5

def view_template
  Button(variant: :ghost, size: :icon, **@attributes) do
    icon("sun", class: "hidden dark:inline")
    icon("moon", class: "inline dark:hidden")
  end
end