2023-10-02 10:46:09 +00:00
|
|
|
import BaseStyle from 'primevue/base/style';
|
|
|
|
import { ObjectUtils } from 'primevue/utils';
|
|
|
|
|
2024-05-01 08:26:48 +00:00
|
|
|
const theme = ({ dt }) => `
|
|
|
|
.p-badge {
|
|
|
|
display: inline-flex;
|
2024-05-09 18:27:01 +00:00
|
|
|
border-radius: ${dt('badge.border.radius')};
|
2024-05-01 08:26:48 +00:00
|
|
|
justify-content: center;
|
2024-05-09 18:27:01 +00:00
|
|
|
padding: ${dt('badge.padding')};
|
2024-05-01 08:26:48 +00:00
|
|
|
background: ${dt('badge.primary.background')};
|
|
|
|
color: ${dt('badge.primary.color')};
|
2024-05-09 18:27:01 +00:00
|
|
|
font-size: ${dt('badge.font.size')};
|
|
|
|
font-weight: ${dt('badge.font.weight')};
|
|
|
|
min-width: ${dt('badge.min.width')};
|
|
|
|
height: ${dt('badge.height')};
|
|
|
|
line-height: ${dt('badge.height')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-overlay-badge {
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-overlay-badge .p-badge {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
right: 0;
|
|
|
|
transform: translate(50%, -50%);
|
|
|
|
transform-origin: 100% 0;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-badge-dot {
|
2024-05-09 18:27:01 +00:00
|
|
|
width: ${dt('badge.dot.size')};
|
|
|
|
min-width: ${dt('badge.dot.size')};
|
|
|
|
height: ${dt('badge.dot.size')};
|
2024-05-01 08:26:48 +00:00
|
|
|
border-radius: 50%;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-badge-circle {
|
|
|
|
padding: 0;
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-badge-secondary {
|
|
|
|
background: ${dt('badge.secondary.background')};
|
|
|
|
color: ${dt('badge.secondary.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-badge-success {
|
|
|
|
background: ${dt('badge.success.background')};
|
|
|
|
color: ${dt('badge.success.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-badge-info {
|
|
|
|
background: ${dt('badge.info.background')};
|
|
|
|
color: ${dt('badge.info.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-badge-warn {
|
|
|
|
background: ${dt('badge.warn.background')};
|
|
|
|
color: ${dt('badge.warn.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-badge-danger {
|
|
|
|
background: ${dt('badge.danger.background')};
|
|
|
|
color: ${dt('badge.danger.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-badge-contrast {
|
|
|
|
background: ${dt('badge.contrast.background')};
|
|
|
|
color: ${dt('badge.contrast.color')};
|
|
|
|
}
|
|
|
|
|
2024-05-13 15:09:09 +00:00
|
|
|
.p-badge-sm {
|
|
|
|
font-size: ${dt('badge.sm.font.size')};
|
|
|
|
min-width: ${dt('badge.sm.min.width')};
|
|
|
|
height: ${dt('badge.sm.height')};
|
|
|
|
line-height: ${dt('badge.sm.height')};
|
|
|
|
}
|
|
|
|
|
2024-05-01 08:26:48 +00:00
|
|
|
.p-badge-lg {
|
2024-05-09 18:27:01 +00:00
|
|
|
font-size: ${dt('badge.lg.font.size')};
|
|
|
|
min-width: ${dt('badge.lg.min.width')};
|
|
|
|
height: ${dt('badge.lg.height')};
|
|
|
|
line-height: ${dt('badge.lg.height')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-badge-xl {
|
2024-05-09 18:27:01 +00:00
|
|
|
font-size: ${dt('badge.xl.font.size')};
|
|
|
|
min-width: ${dt('badge.xl.min.width')};
|
|
|
|
height: ${dt('badge.xl.height')};
|
|
|
|
line-height: ${dt('badge.xl.height')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2023-10-02 10:46:09 +00:00
|
|
|
const classes = {
|
|
|
|
root: ({ props, instance }) => [
|
|
|
|
'p-badge p-component',
|
|
|
|
{
|
2024-04-08 10:55:04 +00:00
|
|
|
'p-badge-circle': ObjectUtils.isNotEmpty(props.value) && String(props.value).length === 1,
|
2023-10-02 10:46:09 +00:00
|
|
|
'p-badge-dot': ObjectUtils.isEmpty(props.value) && !instance.$slots.default,
|
2024-05-13 15:09:09 +00:00
|
|
|
'p-badge-sm': props.size === 'small',
|
2023-10-02 10:46:09 +00:00
|
|
|
'p-badge-lg': props.size === 'large',
|
|
|
|
'p-badge-xl': props.size === 'xlarge',
|
|
|
|
'p-badge-info': props.severity === 'info',
|
|
|
|
'p-badge-success': props.severity === 'success',
|
2024-04-07 21:44:30 +00:00
|
|
|
'p-badge-warn': props.severity === 'warn',
|
2024-02-03 09:41:06 +00:00
|
|
|
'p-badge-danger': props.severity === 'danger',
|
|
|
|
'p-badge-secondary': props.severity === 'secondary',
|
|
|
|
'p-badge-contrast': props.severity === 'contrast'
|
2023-10-02 10:46:09 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
export default BaseStyle.extend({
|
|
|
|
name: 'badge',
|
2024-05-01 08:26:48 +00:00
|
|
|
theme,
|
2023-10-02 10:46:09 +00:00
|
|
|
classes
|
|
|
|
});
|