Skip to content

Commit

Permalink
fix: minor story accessibility updates to v9 utility examples (#31089)
Browse files Browse the repository at this point in the history
  • Loading branch information
smhigley committed Apr 18, 2024
1 parent f7ab06d commit 98265bb
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
shorthands,
tokens,
createFocusOutlineStyle,
useId,
} from '@fluentui/react-components';

const useStyles = makeStyles({
Expand Down Expand Up @@ -40,24 +41,30 @@ const useStyles = makeStyles({
export const Default = () => {
const styles = useStyles();
const attributes = useFocusableGroup();
const labelId1 = useId('chat1');
const labelId2 = useId('chat2');

return (
<div className={styles.pane}>
<div tabIndex={0} aria-label="A chat message" {...attributes} className={styles.container}>
<div className={styles.body}>Hello world!</div>
<ul className={styles.pane}>
<li tabIndex={0} aria-labelledby={labelId1} {...attributes} className={styles.container}>
<div className={styles.body} id={labelId1}>
Hello world!
</div>
<div className={styles.actions}>
<Button aria-label="Copy message" icon={<CopyRegular />} size="small" />
<Button aria-label="Delete message" icon={<DeleteRegular />} size="small" />
</div>
</div>
</li>

<div tabIndex={0} aria-label="A chat message" {...attributes} className={styles.container}>
<div className={styles.body}>How are you doing?</div>
<li tabIndex={0} aria-labelledby={labelId2} {...attributes} className={styles.container}>
<div className={styles.body} id={labelId2}>
How are you doing?
</div>
<div className={styles.actions}>
<Button aria-label="Copy message" icon={<CopyRegular />} size="small" />
<Button aria-label="Delete message" icon={<DeleteRegular />} size="small" />
</div>
</div>
</div>
</li>
</ul>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
shorthands,
tokens,
createFocusOutlineStyle,
useId,
} from '@fluentui/react-components';

const useStyles = makeStyles({
Expand Down Expand Up @@ -40,25 +41,31 @@ const useStyles = makeStyles({
export const Limited = () => {
const styles = useStyles();
const attributes = useFocusableGroup({ tabBehavior: 'limited' });
const labelId1 = useId('chat1');
const labelId2 = useId('chat2');

return (
<div className={styles.pane}>
<div tabIndex={0} aria-label="A chat message" {...attributes} className={styles.container}>
<div className={styles.body}>Hello world!</div>
<ul className={styles.pane}>
<li tabIndex={0} aria-labelledby={labelId1} {...attributes} className={styles.container}>
<div className={styles.body} id={labelId1}>
Hello world!
</div>
<div className={styles.actions}>
<Button aria-label="Copy message" icon={<CopyRegular />} size="small" />
<Button aria-label="Delete message" icon={<DeleteRegular />} size="small" />
</div>
</div>
</li>

<div tabIndex={0} aria-label="A chat message" {...attributes} className={styles.container}>
<div className={styles.body}>How are you doing?</div>
<li tabIndex={0} aria-labelledby={labelId2} {...attributes} className={styles.container}>
<div className={styles.body} id={labelId2}>
How are you doing?
</div>
<div className={styles.actions}>
<Button aria-label="Copy message" icon={<CopyRegular />} size="small" />
<Button aria-label="Delete message" icon={<DeleteRegular />} size="small" />
</div>
</div>
</div>
</li>
</ul>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
shorthands,
tokens,
createFocusOutlineStyle,
useId,
} from '@fluentui/react-components';

const useStyles = makeStyles({
Expand All @@ -33,32 +34,41 @@ const useStyles = makeStyles({
pane: {
display: 'flex',
flexDirection: 'column',
listStyleType: 'none',
...shorthands.gap('10px'),
...shorthands.margin(0),
...shorthands.padding(0),
},
});

export const LimitedTrapFocus = () => {
const styles = useStyles();
const attributes = useFocusableGroup({ tabBehavior: 'limited-trap-focus' });
const labelId1 = useId('chat1');
const labelId2 = useId('chat2');

return (
<div className={styles.pane}>
<div tabIndex={0} aria-label="A chat message" {...attributes} className={styles.container}>
<div className={styles.body}>Hello world!</div>
<ul className={styles.pane}>
<li tabIndex={0} aria-labelledby={labelId1} {...attributes} className={styles.container}>
<div className={styles.body} id={labelId1}>
Hello world!
</div>
<div className={styles.actions}>
<Button aria-label="Copy message" icon={<CopyRegular />} size="small" />
<Button aria-label="Delete message" icon={<DeleteRegular />} size="small" />
</div>
</div>
</li>

<div tabIndex={0} aria-label="A chat message" {...attributes} className={styles.container}>
<div className={styles.body}>How are you doing?</div>
<li tabIndex={0} aria-labelledby={labelId2} {...attributes} className={styles.container}>
<div className={styles.body} id={labelId2}>
How are you doing?
</div>
<div className={styles.actions}>
<Button aria-label="Copy message" icon={<CopyRegular />} size="small" />
<Button aria-label="Delete message" icon={<DeleteRegular />} size="small" />
</div>
</div>
</div>
</li>
</ul>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,18 @@ export const Default = () => {
{!feedbackSent ? (
<div {...restoreFocusSourceAttribute} className={styles.feedback}>
How was your experience completing this task?
<Button appearance="subtle" onClick={() => setFeedbackSent(true)} icon={<ThumbLikeRegular />} />
<Button appearance="subtle" onClick={() => setFeedbackSent(true)} icon={<ThumbDislikeRegular />} />
<Button
appearance="subtle"
onClick={() => setFeedbackSent(true)}
icon={<ThumbLikeRegular />}
aria-label="Like"
/>
<Button
appearance="subtle"
onClick={() => setFeedbackSent(true)}
icon={<ThumbDislikeRegular />}
aria-label="Dislike"
/>
</div>
) : (
<div>Thanks for submitting feedback!</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ export const FocusRestoreHistory = () => {
appearance="subtle"
onClick={() => setExperienceFeedbackSent(true)}
icon={<ThumbLikeRegular />}
aria-label="Like"
/>
<Button
appearance="subtle"
onClick={() => setExperienceFeedbackSent(true)}
icon={<ThumbDislikeRegular />}
aria-label="Dislike"
/>
</div>
</>
Expand All @@ -74,8 +76,18 @@ export const FocusRestoreHistory = () => {
<>
<div {...restoreFocusSourceAttribute} className={styles.feedback}>
Was your message delivered successfully?
<Button appearance="subtle" onClick={() => setDeliveryFeedbackSent(true)} icon={<ThumbLikeRegular />} />
<Button appearance="subtle" onClick={() => setDeliveryFeedbackSent(true)} icon={<ThumbDislikeRegular />} />
<Button
appearance="subtle"
onClick={() => setDeliveryFeedbackSent(true)}
icon={<ThumbLikeRegular />}
aria-label="Like"
/>
<Button
appearance="subtle"
onClick={() => setDeliveryFeedbackSent(true)}
icon={<ThumbDislikeRegular />}
aria-label="Dislike"
/>
</div>
</>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ export const UserRestoreFocus = () => {
appearance="subtle"
onClick={() => setExperienceFeedbackSent(true)}
icon={<ThumbLikeRegular />}
aria-label="Like"
/>
<Button
appearance="subtle"
onClick={() => setExperienceFeedbackSent(true)}
icon={<ThumbDislikeRegular />}
aria-label="Dislike"
/>
</div>
</>
Expand All @@ -78,8 +80,18 @@ export const UserRestoreFocus = () => {
<>
<div {...restoreFocusSourceAttribute} className={styles.feedback}>
Was your message delivered successfully?
<Button appearance="subtle" onClick={() => setDeliveryFeedbackSent(true)} icon={<ThumbLikeRegular />} />
<Button appearance="subtle" onClick={() => setDeliveryFeedbackSent(true)} icon={<ThumbDislikeRegular />} />
<Button
appearance="subtle"
onClick={() => setDeliveryFeedbackSent(true)}
icon={<ThumbLikeRegular />}
aria-label="Like"
/>
<Button
appearance="subtle"
onClick={() => setDeliveryFeedbackSent(true)}
icon={<ThumbDislikeRegular />}
aria-label="Dislike"
/>
</div>
</>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const useClasses = makeStyles({
display: 'flex',
flexDirection: 'column',

...shorthands.border('3px', 'solid', tokens.colorNeutralForeground3),
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorNeutralForeground3),
...shorthands.borderRadius(tokens.borderRadiusMedium),
...shorthands.padding('10px'),

Expand All @@ -23,6 +23,7 @@ const useClasses = makeStyles({
},
item: {
backgroundColor: tokens.colorBrandBackground,
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorTransparentStroke),
width: '100px',
height: '100px',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ const useClasses = makeStyles({
display: 'flex',
},
card: {
...shorthands.border('3px', 'solid', tokens.colorNeutralForeground3),
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorNeutralForeground3),
...shorthands.borderRadius(tokens.borderRadiusMedium),

...shorthands.padding('20px'),
...shorthands.margin('20px'),
},
item: {
backgroundColor: tokens.colorBrandBackground,
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorTransparentStroke),
...shorthands.borderRadius('50%'),

width: '100px',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ const useClasses = makeStyles({
display: 'flex',
flexDirection: 'column',

...shorthands.border('3px', 'solid', tokens.colorNeutralForeground3),
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorNeutralForeground3),
...shorthands.borderRadius(tokens.borderRadiusMedium),
...shorthands.padding('10px'),

alignItems: 'center',
},
item: {
backgroundColor: tokens.colorBrandBackground,
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorTransparentStroke),
...shorthands.borderRadius('50%'),

width: '100px',
Expand All @@ -37,7 +38,7 @@ const useClasses = makeStyles({

marginTop: '20px',

...shorthands.border('3px', 'solid', tokens.colorNeutralForeground3),
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorNeutralForeground3),
...shorthands.borderRadius(tokens.borderRadiusMedium),
...shorthands.padding('10px'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const useClasses = makeStyles({
display: 'flex',
flexDirection: 'column',

...shorthands.border('3px', 'solid', tokens.colorNeutralForeground3),
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorNeutralForeground3),
...shorthands.borderRadius(tokens.borderRadiusMedium),
...shorthands.padding('10px'),

Expand All @@ -25,6 +25,7 @@ const useClasses = makeStyles({
...shorthands.borderRadius(tokens.borderRadiusCircular),
width: '100px',
height: '100px',
forcedColorAdjust: 'none',
},
description: {
...shorthands.margin('5px'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ const useClasses = makeStyles({
display: 'flex',
flexDirection: 'column',

...shorthands.border('3px', 'solid', tokens.colorNeutralForeground3),
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorNeutralForeground3),
...shorthands.borderRadius(tokens.borderRadiusMedium),
...shorthands.padding('10px'),

alignItems: 'center',
},
item: {
backgroundColor: tokens.colorBrandBackground,
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorTransparentStroke),
...shorthands.borderRadius('50%'),

width: '100px',
Expand All @@ -37,7 +38,7 @@ const useClasses = makeStyles({

marginTop: '20px',

...shorthands.border('3px', 'solid', tokens.colorNeutralForeground3),
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorNeutralForeground3),
...shorthands.borderRadius(tokens.borderRadiusMedium),
...shorthands.padding('10px'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ const useClasses = makeStyles({
display: 'flex',
flexDirection: 'column',

...shorthands.border('3px', 'solid', tokens.colorNeutralForeground3),
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorNeutralForeground3),
...shorthands.borderRadius(tokens.borderRadiusMedium),
...shorthands.padding('10px'),

alignItems: 'center',
},
item: {
backgroundColor: tokens.colorBrandBackground,
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorTransparentStroke),
...shorthands.borderRadius('50%'),

width: '100px',
Expand All @@ -34,7 +35,7 @@ const useClasses = makeStyles({

marginTop: '20px',

...shorthands.border('3px', 'solid', tokens.colorNeutralForeground3),
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorNeutralForeground3),
...shorthands.borderRadius(tokens.borderRadiusMedium),
...shorthands.padding('10px'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const useClasses = makeStyles({
display: 'flex',
flexDirection: 'column',

...shorthands.border('3px', 'solid', tokens.colorNeutralForeground3),
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorNeutralForeground3),
...shorthands.borderRadius(tokens.borderRadiusMedium),
...shorthands.padding('10px'),

Expand All @@ -24,7 +24,7 @@ const useClasses = makeStyles({
minHeight: '200px',
},
item: {
...shorthands.border('3px', 'solid', tokens.colorBrandBackground),
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorBrandBackground),
...shorthands.padding('8px'),

width: '300px',
Expand All @@ -36,7 +36,7 @@ const useClasses = makeStyles({

marginTop: '20px',

...shorthands.border('3px', 'solid', tokens.colorNeutralForeground3),
...shorthands.border(tokens.strokeWidthThicker, 'solid', tokens.colorNeutralForeground3),
...shorthands.borderRadius(tokens.borderRadiusMedium),
...shorthands.padding('10px'),
},
Expand Down

0 comments on commit 98265bb

Please sign in to comment.