New tokens for ToggleSwitch

pull/5701/head
Cagatay Civici 2024-05-08 13:51:06 +03:00
parent a0224a99fc
commit 86bc960d5f
3 changed files with 41 additions and 14 deletions

View File

@ -1,9 +1,21 @@
export default { export default {
handle: { handle: {
borderRadius: '50%' borderRadius: '50%',
size: '1rem'
}, },
root: { root: {
borderRadius: '30px' width: '2.5rem',
height: '1.5rem',
borderRadius: '30px',
gap: '0.25rem',
shadow: '{form.field.shadow}',
focusRing: {
width: '{focus.ring.width}',
style: '{focus.ring.style}',
color: '{focus.ring.color}',
offset: '{focus.ring.offset}',
shadow: '{focus.ring.shadow}'
}
}, },
colorScheme: { colorScheme: {
light: { light: {

View File

@ -1,9 +1,21 @@
export default { export default {
handle: { handle: {
borderRadius: '50%' borderRadius: '50%',
size: '1.25rem'
}, },
root: { root: {
borderRadius: '30px' width: '3rem',
height: '1.75rem',
borderRadius: '30px',
gap: '0.25rem',
shadow: '{form.field.shadow}',
focusRing: {
width: '{form.field.focus.ring.width}',
style: '{form.field.focus.ring.style}',
color: '{form.field.focus.ring.color}',
offset: '{form.field.focus.ring.offset}',
shadow: '{form.field.focus.ring.shadow}'
}
}, },
colorScheme: { colorScheme: {
light: { light: {

View File

@ -3,8 +3,8 @@ import BaseStyle from 'primevue/base/style';
const theme = ({ dt }) => ` const theme = ({ dt }) => `
.p-toggleswitch { .p-toggleswitch {
display: inline-block; display: inline-block;
width: 2.5rem; width: ${dt('toggleswitch.width')};
height: 1.5rem; height: ${dt('toggleswitch.height')};
} }
.p-toggleswitch-input { .p-toggleswitch-input {
@ -32,9 +32,10 @@ const theme = ({ dt }) => `
bottom: 0; bottom: 0;
border: 0 none; border: 0 none;
background: ${dt('toggleswitch.background')}; background: ${dt('toggleswitch.background')};
transition: background ${dt('transition.duration')}, color ${dt('transition.duration')}, border-color ${dt('transition.duration')}, box-shadow ${dt('transition.duration')}, outline-color ${dt('transition.duration')}; transition: background ${dt('transition.duration')}, color ${dt('transition.duration')}, border-color ${dt('transition.duration')}, outline-color ${dt('transition.duration')}, box-shadow ${dt('transition.duration')};
border-radius: ${dt('toggleswitch.border.radius')}; border-radius: ${dt('toggleswitch.border.radius')};
outline-color: transparent; outline-color: transparent;
box-shadow: ${dt('toggleswitch.shadow')};
} }
.p-toggleswitch-slider:before { .p-toggleswitch-slider:before {
@ -42,10 +43,10 @@ const theme = ({ dt }) => `
content: ""; content: "";
top: 50%; top: 50%;
background: ${dt('toggleswitch.handle.background')}; background: ${dt('toggleswitch.handle.background')};
width: 1rem; width: ${dt('toggleswitch.handle.size')};
height: 1rem; height: ${dt('toggleswitch.handle.size')};
left: 0.25rem; left: ${dt('toggleswitch.gap')};
margin-top: -0.5rem; margin-top: calc(-1 * calc(${dt('toggleswitch.handle.size')} / 2));
border-radius: ${dt('toggleswitch.handle.border.radius')}; border-radius: ${dt('toggleswitch.handle.border.radius')};
transition: all ${dt('transition.duration')}; transition: all ${dt('transition.duration')};
} }
@ -56,7 +57,7 @@ const theme = ({ dt }) => `
.p-toggleswitch.p-toggleswitch-checked .p-toggleswitch-slider:before { .p-toggleswitch.p-toggleswitch-checked .p-toggleswitch-slider:before {
background: ${dt('toggleswitch.handle.checked.background')}; background: ${dt('toggleswitch.handle.checked.background')};
left: 1.25rem; left: calc(${dt('toggleswitch.width')} - calc(${dt('toggleswitch.handle.size')} + ${dt('toggleswitch.gap')}));
} }
.p-toggleswitch:not(.p-disabled):has(.p-toggleswitch-input:hover) .p-toggleswitch-slider { .p-toggleswitch:not(.p-disabled):has(.p-toggleswitch-input:hover) .p-toggleswitch-slider {
@ -76,8 +77,10 @@ const theme = ({ dt }) => `
} }
.p-toggleswitch:not(.p-disabled):has(.p-toggleswitch-input:focus-visible) .p-toggleswitch-slider { .p-toggleswitch:not(.p-disabled):has(.p-toggleswitch-input:focus-visible) .p-toggleswitch-slider {
outline: ${dt('focus.ring.width')} ${dt('focus.ring.style')} ${dt('focus.ring.color')}; border-color: ${dt('toggleswitch.focus.border.color')};
outline-offset: ${dt('focus.ring.offset')}; box-shadow: ${dt('toggleswitch.focus.ring.shadow')};
outline: ${dt('toggleswitch.focus.ring.width')} ${dt('toggleswitch.focus.ring.style')} ${dt('toggleswitch.focus.ring.color')};
outline-offset: ${dt('toggleswitch.focus.ring.offset')};
} }
.p-toggleswitch.p-invalid > .p-toggleswitch-slider { .p-toggleswitch.p-invalid > .p-toggleswitch-slider {