Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "pass in icon props to presence badge icon slot, and use default strings",
"packageName": "@fluentui/react-badge",
"email": "mgodbolt@microsoft.com",
"dependentChangeType": "patch"
}
2 changes: 1 addition & 1 deletion packages/react-badge/etc/react-badge.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const presenceBadgeClassName = "fui-PresenceBadge";
export const presenceBadgeClassNames: SlotClassNames<BadgeSlots>;

// @public (undocumented)
export type PresenceBadgeProps = Omit<ComponentProps<Pick<BadgeSlots, 'root'>>, 'color'> & Pick<BadgeProps, 'size'> & {
export type PresenceBadgeProps = Omit<ComponentProps<Pick<BadgeSlots, 'root' | 'icon'>>, 'color'> & Pick<BadgeProps, 'size'> & {
status?: PresenceBadgeStatus;
outOfOffice?: boolean;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type PresenceBadgeStatus =
| 'doNotDisturb'
| 'unknown';

export type PresenceBadgeProps = Omit<ComponentProps<Pick<BadgeSlots, 'root'>>, 'color'> &
export type PresenceBadgeProps = Omit<ComponentProps<Pick<BadgeSlots, 'root' | 'icon'>>, 'color'> &
Pick<BadgeProps, 'size'> & {
/**
* Represents several status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
presenceOofRegular,
presenceUnknownRegular,
} from './presenceIcons';
import { useBadge_unstable, BadgeProps } from '../Badge/index';
import { useBadge_unstable } from '../Badge/index';
import type { PresenceBadgeProps, PresenceBadgeState } from './PresenceBadge.types';

const iconMap = (
Expand All @@ -37,6 +37,16 @@ const iconMap = (
}
};

export const DEFAULT_STRINGS = {
Comment thread
micahgodbolt marked this conversation as resolved.
Outdated
busy: 'busy',
outOfOffice: 'out of office',
away: 'away',
available: 'available',
offline: 'offline',
doNotDisturb: 'do not disturb',
unknown: 'unknown',
};

/**
* Returns the props and state required to render the component
*/
Expand All @@ -49,8 +59,11 @@ export const usePresenceBadge_unstable = (
{
size: 'medium',
...props,
icon: resolveShorthand(undefined as BadgeProps['icon'], {
icon: resolveShorthand(props.icon, {
required: true,
defaultProps: {
'aria-label': props.status && DEFAULT_STRINGS[props.status],
},
}),
},
ref,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const Status = () => {
<PresenceBadge status="doNotDisturb" />
<PresenceBadge status="offline" />
<PresenceBadge status="outOfOffice" />
<PresenceBadge icon={{ 'aria-label': 'OOF' }} status="outOfOffice" />
Comment thread
micahgodbolt marked this conversation as resolved.
Outdated
<PresenceBadge status="unknown" />
</>
);
Expand Down