mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-18 20:59:39 +02:00
* Add lookbook + viewcomponent, organize design system file * Build menu component * Button updates * More button fixes * Replace all menus with new ViewComponent * Checkpoint: fix tests, all buttons and menus converted * Split into Link and Button components for clarity * Button cleanup * Simplify custom confirmation configuration in views * Finalize button, link component API * Add toggle field to custom form builder + Component * Basic tabs component * Custom tabs, convert all menu / tab instances in app * Gem updates * Centralized icon helper * Update all icon usage to central helper * Lint fixes * Centralize all disclosure instances * Dialog replacements * Consolidation of all dialog styles * Test fixes * Fix app layout issues, move to component with slots * Layout simplification * Flakey test fix * Fix dashboard mobile issues * Finalize homepage * Lint fixes * Fix shadows and borders in dark mode * Fix tests * Remove stale class * Fix filled icon logic * Move transparent? to public interface
26 lines
974 B
Ruby
26 lines
974 B
Ruby
class ToggleComponent < ViewComponent::Base
|
|
attr_reader :id, :name, :checked, :disabled, :checked_value, :unchecked_value, :opts
|
|
|
|
def initialize(id:, name: nil, checked: false, disabled: false, checked_value: "1", unchecked_value: "0", **opts)
|
|
@id = id
|
|
@name = name
|
|
@checked = checked
|
|
@disabled = disabled
|
|
@checked_value = checked_value
|
|
@unchecked_value = unchecked_value
|
|
@opts = opts
|
|
end
|
|
|
|
def label_classes
|
|
class_names(
|
|
"block w-9 h-5 cursor-pointer",
|
|
"rounded-full bg-gray-100 theme-dark:bg-gray-700",
|
|
"transition-colors duration-300",
|
|
"after:content-[''] after:block after:bg-white after:absolute after:rounded-full",
|
|
"after:top-0.5 after:left-0.5 after:w-4 after:h-4",
|
|
"after:transition-transform after:duration-300 after:ease-in-out",
|
|
"peer-checked:bg-green-600 peer-checked:after:translate-x-4",
|
|
"peer-disabled:opacity-70 peer-disabled:cursor-not-allowed"
|
|
)
|
|
end
|
|
end
|