refactor(ui): replace RoleBadge with generic Badge component
- add `dot` and `onRemove` props to Badge for colored dot and removable tag support - delete RoleBadge component in favor of Badge with dot prop - update UserCreateModal, UserEditModal, and UsersPage to use Badge instead of RoleBadge - remove RoleBadge export from shared components index
This commit is contained in:
@@ -7,10 +7,12 @@ const Badge = ({
|
||||
variant = 'default',
|
||||
size = 'sm',
|
||||
color = null,
|
||||
dot = false,
|
||||
onRemove,
|
||||
className = '',
|
||||
...props
|
||||
}) => {
|
||||
const baseClassName = 'inline-flex items-center font-medium border font-ibm-plex-mono';
|
||||
const baseClassName = 'inline-flex items-center gap-1 font-medium border font-ibm-plex-mono';
|
||||
|
||||
const variants = {
|
||||
default: 'bg-neutral-700/10 text-neutral-700 border-neutral-800/30 dark:bg-neutral-600/10 dark:text-neutral-400 dark:border-neutral-800',
|
||||
@@ -43,7 +45,20 @@ const Badge = ({
|
||||
style={colorStyle}
|
||||
{...props}
|
||||
>
|
||||
{dot && color && (
|
||||
<span className="inline-block w-2 h-2 rounded-full flex-shrink-0" style={{ backgroundColor: color }} />
|
||||
)}
|
||||
{children}
|
||||
{onRemove && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => { e.stopPropagation(); onRemove(); }}
|
||||
className="ml-0.5 hover:opacity-70 transition-opacity leading-none"
|
||||
aria-label="Retirer"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user