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

a11y: fix accessibility issue 2011 #2830

Merged
merged 5 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -29,7 +29,6 @@ export const link = (active: boolean, disabled: boolean) => css`
: `&:hover {
background-color: ${NeutralColors.gray50};
}

&:focus {
outline: none;
.ms-Fabric--isFocusVisible &::after {
Expand Down
37 changes: 26 additions & 11 deletions Composer/packages/client/src/pages/home/ItemContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
/** @jsx jsx */
import { jsx, SerializedStyles } from '@emotion/core';
import React from 'react';
import { Button } from 'office-ui-fabric-react/lib/Button';

import { itemContainerWrapper, itemContainer, itemContainerContent, itemContainerTitle, disabledItem } from './styles';
import {
itemContainerWrapper,
itemContainer,
itemContainerContent,
itemContainerTitle,
disabledItem,
childrenContainer,
} from './styles';

interface ItemContainerProps {
onClick?: () => void | Promise<void>;
Expand All @@ -29,8 +37,21 @@ export const ItemContainer: React.FC<ItemContainerProps> = ({
forwardedRef,
...rest
}) => {
const onRenderChildren = () => {
return (
<div css={childrenContainer}>
<div css={[itemContainer, styles.title, disabled ? disabledItem.title : undefined]}>
<div css={itemContainerTitle}>{title}</div>
</div>
<div css={[itemContainer, styles.content, disabled ? disabledItem.content : undefined]}>
<div css={itemContainerContent}>{content}</div>
</div>
</div>
);
};

return (
<div
<Button
css={[itemContainerWrapper(disabled), styles.container]}
onClick={async e => {
e.preventDefault();
Expand All @@ -39,15 +60,9 @@ export const ItemContainer: React.FC<ItemContainerProps> = ({
}
}}
ref={forwardedRef}
tabIndex={0}
{...rest}
>
<div css={[itemContainer, styles.title, disabled ? disabledItem.title : undefined]}>
<div css={itemContainerTitle}>{title}</div>
</div>
<div css={[itemContainer, styles.content, disabled ? disabledItem.content : undefined]}>
<div css={itemContainerContent}>{content}</div>
</div>
</div>
onRenderChildren={onRenderChildren}
disabled={disabled}
/>
);
};
3 changes: 2 additions & 1 deletion Composer/packages/client/src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ const Home: React.FC<RouteComponentProps> = () => {
{linksButtom.map(link => {
return (
<Link
style={{ width: '150px' }}
href={link.to}
tabIndex={-1}
tabIndex={0}
key={'homePageLeftLinks-' + link.text}
target="_blank"
rel="noopener noreferrer"
Expand Down
25 changes: 22 additions & 3 deletions Composer/packages/client/src/pages/home/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,18 @@ export const leftContainer = css`

export const itemContainerWrapper = (disabled?: boolean) => css`
border-radius: 2px;
border-width: 0;
cursor: ${disabled ? 'auto' : 'pointer'};
display: block;
min-width: 180px;
height: 130px;
width: 11vw;
margin-right: 30px;
padding: 0;
`;

export const itemContainer = css`
outline: none;
height: 50%;
`;

Expand All @@ -88,14 +91,19 @@ export const itemContainerTitle = css`
font-weight: 600;
padding: 0.5rem 1rem;
box-sizing: border-box;
outline: none;
`;

export const itemContainerContent = css`
height: 100%;
font-size: 16px;
font-weight: 600;
text-align: left;
padding: 10px 0 0 16px;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-word;
padding: 0.5rem 1rem;
outline: none;
`;

export const subtitle = css`
Expand Down Expand Up @@ -159,14 +167,16 @@ export const disabledItem = {
font-size: smaller;
word-wrap: break-word;
color: #a19f9d;
background: white;
`,
};

const baseBotItem = {
container: css`
padding: 0;
border-width: 0;
box-shadow: ${Depths.depth4};
transition: box-shadow ${MotionDurations.duration2} ${MotionTimings.standard};

&:hover,
&:focus {
box-shadow: ${Depths.depth16};
Expand Down Expand Up @@ -195,6 +205,13 @@ export const lastestBotItem = {
`,
};

export const childrenContainer = css`
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
`;

export const detailListContainer = css`
position: relative;
max-height: 40vh;
Expand Down Expand Up @@ -225,7 +242,9 @@ export const exampleListCell = css`
padding: 16px;
box-sizing: border-box;
display: flex;

&:focus {
outline: rgb(102, 102, 102) solid 1px;
}
&:hover {
background: ${palette.neutralLight};
}
Expand Down