Skip to content

Commit

Permalink
feat(Badge): rework sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac committed Dec 13, 2024
1 parent cef16cd commit d9967f5
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/content/3.components/badge.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Use the `size` prop to change the size of the Badge.
::component-code
---
props:
size: lg
size: xl
slots:
default: Badge
---
Expand Down
18 changes: 15 additions & 3 deletions src/theme/badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ export default (options: Required<ModuleOptions>) => ({
subtle: ''
},
size: {
xs: {
base: 'text-[8px]/3 px-1 py-0.5 gap-1 rounded-[calc(var(--ui-radius))]',
leadingIcon: 'size-3',
leadingAvatarSize: '3xs',
trailingIcon: 'size-3'
},
sm: {
base: 'text-xs px-1.5 py-0.5 gap-1 rounded-[calc(var(--ui-radius))]',
leadingIcon: 'size-4',
base: 'text-[10px]/3 px-1.5 py-1 gap-1 rounded-[calc(var(--ui-radius))]',
leadingIcon: 'size-3',
leadingAvatarSize: '3xs',
trailingIcon: 'size-4'
trailingIcon: 'size-3'
},
md: {
base: 'text-xs px-2 py-1 gap-1 rounded-[calc(var(--ui-radius)*1.5)]',
Expand All @@ -38,6 +44,12 @@ export default (options: Required<ModuleOptions>) => ({
leadingIcon: 'size-5',
leadingAvatarSize: '2xs',
trailingIcon: 'size-5'
},
xl: {
base: 'text-base px-2.5 py-1 gap-1.5 rounded-[calc(var(--ui-radius)*1.5)]',
leadingIcon: 'size-6',
leadingAvatarSize: '2xs',
trailingIcon: 'size-6'
}
}
},
Expand Down
12 changes: 11 additions & 1 deletion test/components/__snapshots__/Badge.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,17 @@ exports[`Badge > renders with size md correctly 1`] = `
`;
exports[`Badge > renders with size sm correctly 1`] = `
"<span class="font-medium inline-flex items-center text-xs px-1.5 py-0.5 gap-1 rounded-[calc(var(--ui-radius))] bg-[var(--ui-primary)] text-[var(--ui-bg)]"><!--v-if--><span class="truncate">Badge</span>
"<span class="font-medium inline-flex items-center text-[10px]/3 px-1.5 py-1 gap-1 rounded-[calc(var(--ui-radius))] bg-[var(--ui-primary)] text-[var(--ui-bg)]"><!--v-if--><span class="truncate">Badge</span>
<!--v-if--></span>"
`;
exports[`Badge > renders with size xl correctly 1`] = `
"<span class="font-medium inline-flex items-center text-base px-2.5 py-1 gap-1.5 rounded-[calc(var(--ui-radius)*1.5)] bg-[var(--ui-primary)] text-[var(--ui-bg)]"><!--v-if--><span class="truncate">Badge</span>
<!--v-if--></span>"
`;
exports[`Badge > renders with size xs correctly 1`] = `
"<span class="font-medium inline-flex items-center text-[8px]/3 px-1 py-0.5 gap-1 rounded-[calc(var(--ui-radius))] bg-[var(--ui-primary)] text-[var(--ui-bg)]"><!--v-if--><span class="truncate">Badge</span>
<!--v-if--></span>"
`;
Expand Down
Loading

0 comments on commit d9967f5

Please sign in to comment.