mirror of
https://github.com/tabler/tabler.git
synced 2026-10-12 21:27:06 +04:00
33 lines
1.2 KiB
Plaintext
33 lines
1.2 KiB
Plaintext
---
|
|
import Icon from './Icon.astro'
|
|
|
|
/** core/scss/ui/_switch-icon.scss `.switch-icon-{variant}` transition classes */
|
|
type SwitchIconVariant = 'fade' | 'scale' | 'flip' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'slide-start' | 'slide-end'
|
|
|
|
interface Props {
|
|
icon?: string
|
|
/** text-{activeColor} on the switched-on icon */
|
|
activeColor?: string
|
|
variant?: SwitchIconVariant | undefined
|
|
class?: string
|
|
/** remaining attributes (id, data-*, aria-*, …) are forwarded to the root element */
|
|
[key: string]: unknown
|
|
}
|
|
|
|
const { icon = 'heart', activeColor = 'red', variant, class: className, ...rest } = Astro.props
|
|
|
|
// star/heart force the filled variant; otherwise no extra class.
|
|
const resolvedIconBClass = icon === 'star' || icon === 'heart' ? 'icon-filled' : undefined
|
|
|
|
const buttonClass = ['switch-icon', variant && `switch-icon-${variant}`, className]
|
|
---
|
|
|
|
<button type="button" class:list={buttonClass} data-bs-toggle="switch-icon" aria-pressed="false" aria-label="Favorite" {...rest}>
|
|
<span class="switch-icon-a text-muted">
|
|
<Icon name={icon} />
|
|
</span>
|
|
<span class={`switch-icon-b text-${activeColor}`}>
|
|
<Icon name={icon} class={resolvedIconBClass} />
|
|
</span>
|
|
</button>
|