Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: minor story accessibility updates to v9 utility examples #31089

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -23,6 +23,7 @@ const useClasses = makeStyles({
},
item: {
backgroundColor: tokens.colorBrandBackground,
...shorthands.border('3px', 'solid', tokens.colorTransparentStroke),
width: '100px',
height: '100px',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const useClasses = makeStyles({
},
item: {
backgroundColor: tokens.colorBrandBackground,
...shorthands.border('3px', 'solid', tokens.colorTransparentStroke),
smhigley marked this conversation as resolved.
Show resolved Hide resolved
...shorthands.borderRadius('50%'),

width: '100px',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const useClasses = makeStyles({
},
item: {
backgroundColor: tokens.colorBrandBackground,
...shorthands.border('3px', 'solid', tokens.colorTransparentStroke),
...shorthands.borderRadius('50%'),

width: '100px',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -23,6 +23,7 @@ const useClasses = makeStyles({
},
item: {
backgroundColor: tokens.colorBrandBackground,
...shorthands.border('3px', 'solid', tokens.colorTransparentStroke),
...shorthands.borderRadius('50%'),

width: '100px',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const useClasses = makeStyles({
},
item: {
backgroundColor: tokens.colorBrandBackground,
...shorthands.border('3px', 'solid', tokens.colorTransparentStroke),
...shorthands.borderRadius('50%'),

width: '100px',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const useClasses = makeStyles({
},
item: {
backgroundColor: tokens.colorBrandBackground,
...shorthands.border('3px', 'solid', tokens.colorTransparentStroke),
...shorthands.borderRadius('50%'),

width: '100px',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const useClasses = makeStyles({
},
item: {
backgroundColor: tokens.colorBrandBackground,
...shorthands.border('3px', 'solid', tokens.colorTransparentStroke),
...shorthands.borderRadius('50%'),

width: '100px',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const useClasses = makeStyles({
},
item: {
backgroundColor: tokens.colorBrandBackground,
...shorthands.border('3px', 'solid', tokens.colorTransparentStroke),
...shorthands.borderRadius('50%'),

width: '100px',
Expand Down