2023-10-02 10:46:09 +00:00
|
|
|
import BaseStyle from 'primevue/base/style';
|
|
|
|
|
2024-05-01 08:26:48 +00:00
|
|
|
const theme = ({ dt }) => `
|
|
|
|
.p-togglebutton {
|
|
|
|
display: inline-flex;
|
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
overflow: hidden;
|
|
|
|
position: relative;
|
|
|
|
color: ${dt('togglebutton.color')};
|
|
|
|
background: ${dt('togglebutton.background')};
|
|
|
|
border: 1px solid ${dt('togglebutton.border.color')};
|
2024-05-08 23:50:16 +00:00
|
|
|
padding: ${dt('togglebutton.padding')};
|
2024-05-01 08:26:48 +00:00
|
|
|
font-size: 1rem;
|
2024-05-08 23:50:16 +00:00
|
|
|
font-family: inherit;
|
|
|
|
font-feature-settings: inherit;
|
2024-05-26 21:38:39 +00:00
|
|
|
transition: background ${dt('togglebutton.transition.duration')}, color ${dt('togglebutton.transition.duration')}, border-color ${dt('togglebutton.transition.duration')}, outline-color ${dt('togglebutton.transition.duration')}, box-shadow ${dt(
|
|
|
|
'togglebutton.transition.duration'
|
|
|
|
)};
|
2024-05-08 23:50:16 +00:00
|
|
|
border-radius: ${dt('togglebutton.border.radius')};
|
2024-05-01 08:26:48 +00:00
|
|
|
outline-color: transparent;
|
2024-05-08 23:50:16 +00:00
|
|
|
font-weight: ${dt('togglebutton.font.weight')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
2024-05-15 09:20:13 +00:00
|
|
|
.p-togglebutton-content {
|
|
|
|
position: relative;
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
gap: ${dt('togglebutton.gap')};
|
|
|
|
}
|
|
|
|
|
2024-05-01 08:26:48 +00:00
|
|
|
.p-togglebutton-label,
|
|
|
|
.p-togglebutton-icon {
|
|
|
|
position: relative;
|
|
|
|
transition: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-togglebutton::before {
|
|
|
|
content: "";
|
|
|
|
background: transparent;
|
2024-05-26 21:38:39 +00:00
|
|
|
transition: background ${dt('togglebutton.transition.duration')}, color ${dt('togglebutton.transition.duration')}, border-color ${dt('togglebutton.transition.duration')}, outline-color ${dt('togglebutton.transition.duration')}, box-shadow ${dt(
|
|
|
|
'togglebutton.transition.duration'
|
|
|
|
)};
|
2024-05-01 08:26:48 +00:00
|
|
|
position: absolute;
|
2024-05-08 23:50:16 +00:00
|
|
|
left: ${dt('togglebutton.content.left')};
|
|
|
|
top: ${dt('togglebutton.content.top')};
|
|
|
|
width: calc(100% - calc(2 * ${dt('togglebutton.content.left')}));
|
|
|
|
height: calc(100% - calc(2 * ${dt('togglebutton.content.top')}));
|
|
|
|
border-radius: ${dt('togglebutton.border.radius')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-togglebutton.p-togglebutton-checked::before {
|
2024-05-08 23:50:16 +00:00
|
|
|
background: ${dt('togglebutton.content.checked.background')};
|
|
|
|
box-shadow: ${dt('togglebutton.content.checked.shadow')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-togglebutton:not(:disabled):not(.p-togglebutton-checked):hover {
|
2024-05-08 23:50:16 +00:00
|
|
|
background: ${dt('togglebutton.hover.background')};
|
2024-05-01 08:26:48 +00:00
|
|
|
color: ${dt('togglebutton.hover.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-togglebutton.p-togglebutton-checked {
|
2024-05-08 23:50:16 +00:00
|
|
|
background: ${dt('togglebutton.checked.background')};
|
|
|
|
border-color: ${dt('togglebutton.checked.border.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
color: ${dt('togglebutton.checked.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-togglebutton:focus-visible {
|
2024-05-08 23:50:16 +00:00
|
|
|
box-shadow: ${dt('togglebutton.focus.ring.shadow')};
|
|
|
|
outline: ${dt('togglebutton.focus.ring.width')} ${dt('togglebutton.focus.ring.style')} ${dt('togglebutton.focus.ring.color')};
|
|
|
|
outline-offset: ${dt('togglebutton.focus.ring.offset')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-togglebutton.p-invalid {
|
|
|
|
border-color: ${dt('togglebutton.invalid.border.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-togglebutton:disabled {
|
|
|
|
opacity: 1;
|
|
|
|
cursor: default;
|
|
|
|
background: ${dt('togglebutton.disabled.background')};
|
|
|
|
border-color: ${dt('togglebutton.disabled.border.color')};
|
|
|
|
color: ${dt('togglebutton.disabled.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-togglebutton-icon {
|
|
|
|
color: ${dt('togglebutton.icon.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-togglebutton:not(:disabled):not(.p-togglebutton-checked):hover .p-togglebutton-icon {
|
|
|
|
color: ${dt('togglebutton.icon.hover.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-togglebutton.p-togglebutton-checked .p-togglebutton-icon {
|
|
|
|
color: ${dt('togglebutton.icon.checked.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-togglebutton:disabled .p-togglebutton-icon {
|
|
|
|
color: ${dt('togglebutton.icon.disabled.color')};
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2023-10-02 10:46:09 +00:00
|
|
|
const classes = {
|
|
|
|
root: ({ instance, props }) => [
|
2024-01-14 15:21:43 +00:00
|
|
|
'p-togglebutton p-component',
|
2023-10-02 10:46:09 +00:00
|
|
|
{
|
2024-04-07 10:58:33 +00:00
|
|
|
'p-togglebutton-checked': instance.active,
|
2024-01-30 11:27:56 +00:00
|
|
|
'p-invalid': props.invalid
|
2023-10-02 10:46:09 +00:00
|
|
|
}
|
|
|
|
],
|
2024-05-15 09:20:13 +00:00
|
|
|
content: 'p-togglebutton-content',
|
2024-04-07 10:58:33 +00:00
|
|
|
icon: 'p-togglebutton-icon',
|
2024-03-21 13:21:57 +00:00
|
|
|
label: 'p-togglebutton-label'
|
2023-10-02 10:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default BaseStyle.extend({
|
2024-01-12 07:07:55 +00:00
|
|
|
name: 'togglebutton',
|
2024-05-01 08:26:48 +00:00
|
|
|
theme,
|
2023-10-04 09:20:15 +00:00
|
|
|
classes
|
2023-10-02 10:46:09 +00:00
|
|
|
});
|