Skip to content

Commit 1733769

Browse files
committed
feat(NotificationBadge): add support for plain variant
1 parent 6bcdcaf commit 1733769

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/react-core/src/components/NotificationBadge/NotificationBadge.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { css } from '@patternfly/react-styles';
88
export enum NotificationBadgeVariant {
99
read = 'read',
1010
unread = 'unread',
11-
attention = 'attention'
11+
attention = 'attention',
12+
plain = 'plain'
1213
}
1314

1415
export interface NotificationBadgeProps extends Omit<ButtonProps, 'variant'> {
@@ -29,7 +30,7 @@ export interface NotificationBadgeProps extends Omit<ButtonProps, 'variant'> {
2930
*/
3031
isExpanded?: boolean;
3132
/** Determines the variant of the notification badge. */
32-
variant?: NotificationBadgeVariant | 'read' | 'unread' | 'attention';
33+
variant?: NotificationBadgeVariant | 'read' | 'unread' | 'attention' | 'plain';
3334
/** Flag indicating whether the notification badge animation should be triggered. Each
3435
* time this prop is true, the animation will be triggered a single time.
3536
*/
@@ -55,6 +56,8 @@ export const NotificationBadge: React.FunctionComponent<NotificationBadgeProps>
5556
const hasCount = count > 0;
5657
const hasChildren = children !== undefined;
5758
const isAttention = variant === NotificationBadgeVariant.attention;
59+
const isPlain = variant === NotificationBadgeVariant.plain;
60+
const _buttonState = isPlain ? undefined : (variant as 'read' | 'unread' | 'attention');
5861
const notificationIcon = isAttention ? attentionIcon : icon;
5962
let notificationContent: React.ReactNode = null;
6063

@@ -77,10 +80,10 @@ export const NotificationBadge: React.FunctionComponent<NotificationBadgeProps>
7780

7881
return (
7982
<Button
80-
variant={ButtonVariant.stateful}
83+
variant={isPlain ? ButtonVariant.plain : ButtonVariant.stateful}
8184
className={buttonClassName}
8285
aria-expanded={isExpanded}
83-
state={variant}
86+
state={_buttonState}
8487
isClicked={isExpanded}
8588
icon={notificationIcon}
8689
onAnimationEnd={handleAnimationEnd}

0 commit comments

Comments
 (0)