2024-02-07 13:53:34 +00:00
|
|
|
const border = (top, shadow) => ({
|
|
|
|
x: 0,
|
|
|
|
y: top ? 1 : -1,
|
|
|
|
blur: 0,
|
|
|
|
spread: 0,
|
|
|
|
color: shadow ? '#000000' : '#FFFFFF',
|
|
|
|
alpha: 0.2,
|
|
|
|
inset: true
|
|
|
|
})
|
|
|
|
|
|
|
|
const buttonInsetFakeBorders = [border(true, false), border(false, true)]
|
|
|
|
const inputInsetFakeBorders = [border(true, true), border(false, false)]
|
|
|
|
|
|
|
|
const hoverGlow = {
|
|
|
|
x: 0,
|
|
|
|
y: 0,
|
|
|
|
blur: 4,
|
|
|
|
spread: 0,
|
|
|
|
color: '--text',
|
|
|
|
alpha: 1
|
|
|
|
}
|
|
|
|
|
2024-01-18 12:35:25 +00:00
|
|
|
export default {
|
|
|
|
name: 'Button',
|
2024-02-08 16:18:01 +00:00
|
|
|
selector: '.button',
|
2024-01-18 12:35:25 +00:00
|
|
|
states: {
|
|
|
|
disabled: ':disabled',
|
2024-01-23 17:18:55 +00:00
|
|
|
toggled: '.toggled',
|
2024-01-18 12:35:25 +00:00
|
|
|
pressed: ':active',
|
2024-02-07 13:53:34 +00:00
|
|
|
hover: ':hover',
|
|
|
|
focused: ':focus-within'
|
2024-01-18 12:35:25 +00:00
|
|
|
},
|
|
|
|
variants: {
|
2024-02-08 16:18:01 +00:00
|
|
|
normal: '-default',
|
2024-01-18 12:35:25 +00:00
|
|
|
danger: '.danger',
|
2024-02-08 16:18:01 +00:00
|
|
|
unstyled: '-unstyled'
|
2024-01-18 12:35:25 +00:00
|
|
|
},
|
|
|
|
validInnerComponents: [
|
|
|
|
'Text',
|
|
|
|
'Icon'
|
2024-01-31 23:27:30 +00:00
|
|
|
],
|
|
|
|
defaultRules: [
|
|
|
|
{
|
|
|
|
component: 'Button',
|
|
|
|
directives: {
|
2024-02-07 13:53:34 +00:00
|
|
|
background: '--fg',
|
|
|
|
shadow: [{
|
|
|
|
x: 0,
|
|
|
|
y: 0,
|
|
|
|
blur: 2,
|
|
|
|
spread: 0,
|
|
|
|
color: '#000000',
|
|
|
|
alpha: 1
|
|
|
|
}, ...buttonInsetFakeBorders]
|
2024-01-31 23:27:30 +00:00
|
|
|
}
|
|
|
|
},
|
2024-02-08 16:18:01 +00:00
|
|
|
{
|
|
|
|
component: 'Button',
|
|
|
|
variant: 'unstyled',
|
|
|
|
directives: {
|
|
|
|
background: '--fg',
|
|
|
|
opacity: 0
|
|
|
|
}
|
|
|
|
},
|
2024-01-31 23:27:30 +00:00
|
|
|
{
|
|
|
|
component: 'Button',
|
|
|
|
state: ['hover'],
|
|
|
|
directives: {
|
2024-02-07 13:53:34 +00:00
|
|
|
shadow: [hoverGlow, ...buttonInsetFakeBorders]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: 'Button',
|
|
|
|
state: ['hover', 'pressed'],
|
|
|
|
directives: {
|
|
|
|
background: '--accent,-24.2',
|
|
|
|
shadow: [hoverGlow, ...inputInsetFakeBorders]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: 'Button',
|
|
|
|
state: ['disabled'],
|
|
|
|
directives: {
|
|
|
|
background: '$blend(--background, 0.25, --parent)',
|
|
|
|
shadow: [...buttonInsetFakeBorders]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: 'Text',
|
|
|
|
parent: {
|
|
|
|
component: 'Button',
|
|
|
|
state: ['disabled']
|
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
textOpacity: 0.25,
|
|
|
|
textOpacityMode: 'blend'
|
2024-01-31 23:27:30 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-18 12:35:25 +00:00
|
|
|
]
|
|
|
|
}
|