Skip to content

Commit 4e7acd7

Browse files
authored
fix(Badge): Add uniform padding and modify gaps (#20974)
* fix(Badge): Add uniform padding and modify gaps Adds uniform padding around the badge to achieve the desired effect for circular icon and one character badges. The wider variants still look OK. I'm not sure if they are pixel perfect, but it's the only way I could find that would achieve the desired effect for icon only badges 🤷 * Change files * revert bagde stories * update counter badge styles * update counter badge styles
1 parent 3dc992e commit 4e7acd7

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "fix: Add uniform padding and modify gaps",
4+
"packageName": "@fluentui/react-badge",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/react-badge/src/components/Badge/useBadgeStyles.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,28 @@ const useStyles = makeStyles({
3131
rootSmall: {
3232
minWidth: '16px',
3333
height: '16px',
34-
paddingRight: '6px',
35-
paddingLeft: '6px',
34+
...shorthands.padding('2px'),
3635
...shorthands.gap('4px'),
3736
fontSize: '8px',
3837
},
3938
rootMedium: {
4039
height: '20px',
4140
minWidth: '20px',
4241
...shorthands.gap('4px'),
43-
paddingRight: '8px',
44-
paddingLeft: '8px',
42+
...shorthands.padding('4px'),
4543
fontSize: '10px',
4644
},
4745
rootLarge: {
4846
minWidth: '24px',
4947
height: '24px',
50-
paddingRight: '8px',
51-
paddingLeft: '8px',
48+
...shorthands.padding('4px'),
5249
fontSize: '12px',
53-
...shorthands.gap('6px'),
50+
...shorthands.gap('4px'),
5451
},
5552
rootExtraLarge: theme => ({
5653
minWidth: '32px',
5754
height: '32px',
58-
paddingRight: '12px',
59-
paddingLeft: '12px',
55+
...shorthands.padding('6px'),
6056
...shorthands.gap('6px'),
6157
fontSize: '12px',
6258
...shorthands.borderWidth(theme.strokeWidthThick),
@@ -97,7 +93,7 @@ const useStyles = makeStyles({
9793
rootTintDanger: theme => ({
9894
backgroundColor: theme.colorPaletteRedBackground1,
9995
color: theme.colorPaletteRedForeground1,
100-
...shorthands.borderColor(theme.colorPaletteRedForeground2),
96+
...shorthands.borderColor(theme.colorPaletteRedBorder1),
10197
}),
10298
rootGhostDanger: theme => ({
10399
color: theme.colorPaletteRedForeground3,

packages/react-badge/src/components/CounterBadge/useCounterBadgeStyles.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import type { CounterBadgeState } from './CounterBadge.types';
55
export const counterBadgeClassName = 'fui-CounterBadge';
66

77
const useStyles = makeStyles({
8-
root: {
9-
minWidth: 'auto',
10-
},
118
dot: {
9+
minWidth: 'auto',
1210
width: '6px',
1311
height: '6px',
1412
...shorthands.padding('0'),
@@ -25,7 +23,6 @@ export const useCounterBadgeStyles = (state: CounterBadgeState): CounterBadgeSta
2523
const styles = useStyles();
2624
state.root.className = mergeClasses(
2725
counterBadgeClassName,
28-
styles.root,
2926
state.dot && styles.dot,
3027
!state.showZero && state.count === 0 && !state.dot && styles.hide,
3128
state.root.className,

0 commit comments

Comments
 (0)