pleroma-fe/src/components/scrollbar_element.style.js

100 lines
2.1 KiB
JavaScript
Raw Normal View History

const border = (top, shadow) => ({
x: 0,
y: top ? 1 : -1,
blur: 0,
spread: 0,
color: shadow ? '#000000' : '#FFFFFF',
alpha: 0.2,
2026-01-06 16:22:52 +02:00
inset: true,
})
const buttonInsetFakeBorders = [border(true, false), border(false, true)]
const inputInsetFakeBorders = [border(true, true), border(false, false)]
const buttonOuterShadow = {
x: 0,
y: 0,
blur: 2,
spread: 0,
color: '#000000',
2026-01-06 16:22:52 +02:00
alpha: 1,
}
const hoverGlow = {
x: 0,
y: 0,
blur: 4,
spread: 0,
color: '--text',
2026-01-06 16:22:52 +02:00
alpha: 1,
}
export default {
name: 'ScrollbarElement',
selector: '::-webkit-scrollbar-button',
notEditable: true, // for now
states: {
pressed: ':active',
hover: ':is(:hover, :focus-visible, :has(:focus-visible)):not(:disabled)',
2026-01-06 16:22:52 +02:00
disabled: ':disabled',
},
2026-01-06 16:22:52 +02:00
validInnerComponents: ['Text'],
defaultRules: [
{
directives: {
background: '--fg',
shadow: [buttonOuterShadow, ...buttonInsetFakeBorders],
2026-01-06 16:22:52 +02:00
roundness: 3,
},
},
{
state: ['hover'],
directives: {
2026-01-06 16:22:52 +02:00
shadow: [hoverGlow, ...buttonInsetFakeBorders],
},
},
{
state: ['pressed'],
directives: {
2026-01-06 16:22:52 +02:00
shadow: [buttonOuterShadow, ...inputInsetFakeBorders],
},
},
{
state: ['hover', 'pressed'],
directives: {
2026-01-06 16:22:52 +02:00
shadow: [hoverGlow, ...inputInsetFakeBorders],
},
},
{
state: ['toggled'],
directives: {
background: '--accent,-24.2',
2026-01-06 16:22:52 +02:00
shadow: [buttonOuterShadow, ...inputInsetFakeBorders],
},
},
{
state: ['toggled', 'hover'],
directives: {
background: '--accent,-24.2',
2026-01-06 16:22:52 +02:00
shadow: [hoverGlow, ...inputInsetFakeBorders],
},
},
{
state: ['disabled'],
directives: {
background: '$blend(--inheritedBackground 0.25 --parent)',
2026-01-06 16:22:52 +02:00
shadow: [...buttonInsetFakeBorders],
},
},
{
component: 'Text',
parent: {
component: 'Button',
2026-01-06 16:22:52 +02:00
state: ['disabled'],
},
directives: {
textOpacity: 0.25,
2026-01-06 16:22:52 +02:00
textOpacityMode: 'blend',
},
},
],
}