Skip to content

Commit 04b9fe1

Browse files
fix: add static color to s2 notification badge (#8055)
* fix: add static color to s2 notification badge * make opaque * updates * use locale * fix lint --------- Co-authored-by: Robert Snow <rsnow@adobe.com>
1 parent c81a23c commit 04b9fe1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

packages/@react-spectrum/s2/src/ActionButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ export const ActionButton = forwardRef(function ActionButton(props: ActionButton
312312
styles: style({marginStart: '--iconMargin', flexShrink: 0, order: 0})
313313
}],
314314
[NotificationBadgeContext, {
315+
staticColor: staticColor,
315316
size: props.size === 'XS' ? undefined : props.size,
316317
isDisabled: props.isDisabled,
317318
styles: style({position: 'absolute', top: '--badgeTop', insetStart: '[var(--badgePosition)]', marginTop: '[calc((self(height) * -1)/2)]', marginStart: '[calc((self(height) * -1)/2)]'})

packages/@react-spectrum/s2/src/NotificationBadge.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export interface NotificationBadgeProps extends DOMProps, AriaLabelingProps, Sty
4040
}
4141

4242
interface NotificationBadgeContextProps extends Partial<NotificationBadgeProps> {
43-
isDisabled?: boolean
43+
isDisabled?: boolean,
44+
staticColor?: 'black' | 'white' | 'auto'
4445
}
4546

4647
export const NotificationBadgeContext = createContext<ContextValue<Partial<NotificationBadgeContextProps>, DOMRefValue<HTMLDivElement>>>(null);
@@ -53,6 +54,7 @@ const badge = style({
5354
font: 'control',
5455
color: {
5556
default: 'white',
57+
isStaticColor: 'auto',
5658
forcedColors: 'ButtonText'
5759
},
5860
fontSize: {
@@ -76,6 +78,7 @@ const badge = style({
7678
alignItems: 'center',
7779
backgroundColor: {
7880
default: 'accent',
81+
isStaticColor: 'transparent-overlay-1000',
7982
forcedColors: 'ButtonFace'
8083
},
8184
height: {
@@ -102,7 +105,7 @@ const badge = style({
102105
isIndicatorOnly: 'square',
103106
isSingleDigit: 'square'
104107
},
105-
width: 'fit',
108+
width: 'max',
106109
paddingX: {
107110
isDoubleDigit: 'edge-to-text'
108111
},
@@ -119,6 +122,7 @@ export const NotificationBadge = forwardRef(function Badge(props: NotificationBa
119122
size = 'S',
120123
value,
121124
isDisabled = false,
125+
staticColor,
122126
...otherProps
123127
} = props as NotificationBadgeContextProps;
124128
let domRef = useDOMRef(ref);
@@ -159,7 +163,7 @@ export const NotificationBadge = forwardRef(function Badge(props: NotificationBa
159163
{...filterDOMProps(otherProps, {labelable: true})}
160164
role={ariaLabel && 'img'}
161165
aria-label={ariaLabel}
162-
className={(props.UNSAFE_className || '') + badge({size, isIndicatorOnly, isSingleDigit, isDoubleDigit, isDisabled}, props.styles)}
166+
className={(props.UNSAFE_className || '') + badge({size, isIndicatorOnly, isSingleDigit, isDoubleDigit, isDisabled, isStaticColor: !!staticColor}, props.styles)}
163167
style={props.UNSAFE_style}
164168
ref={domRef}>
165169
{formattedValue}

0 commit comments

Comments
 (0)