mirror of
https://github.com/tabler/tabler.git
synced 2026-08-29 13:21:29 +04:00
33 lines
1.1 KiB
Plaintext
33 lines
1.1 KiB
Plaintext
---
|
|
import Icon from './Icon.astro'
|
|
|
|
interface Props {
|
|
icon?: string
|
|
iconB?: string
|
|
iconAColor?: string
|
|
iconBColor?: string
|
|
iconBClass?: string
|
|
variant?: string
|
|
active?: boolean
|
|
/** accessible name announced alongside the pressed state, e.g. "Favorite" */
|
|
label?: string
|
|
}
|
|
|
|
const { icon = 'heart', iconB, iconAColor = 'muted', iconBColor = 'red', iconBClass, variant, active, label = 'Favorite' } = Astro.props
|
|
|
|
const resolvedIconB = iconB ?? icon ?? 'heart'
|
|
// star/heart force the filled variant; otherwise use the passed class.
|
|
const resolvedIconBClass = icon === 'star' || icon === 'heart' ? 'icon-filled' : iconBClass
|
|
|
|
const buttonClass = ['switch-icon', variant && `switch-icon-${variant}`, active && 'active']
|
|
---
|
|
|
|
<button type="button" class:list={buttonClass} data-bs-toggle="switch-icon" aria-pressed={active ? 'true' : 'false'} aria-label={label}>
|
|
<span class={`switch-icon-a text-${iconAColor}`}>
|
|
<Icon name={icon} />
|
|
</span>
|
|
<span class={`switch-icon-b text-${iconBColor}`}>
|
|
<Icon name={resolvedIconB} class={resolvedIconBClass} />
|
|
</span>
|
|
</button>
|