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

feat: add @role for elements #190

Draft
wants to merge 46 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
1046aa5
[NF] Добавил @role к элементам p.1
Jul 31, 2019
fe03732
[NF] @role for elements Accordion, Content, Breadcrumbs
Aug 6, 2019
bf73d5e
[NF] @role for core elements Block, Grid, Input and rf Button, Popup
Aug 6, 2019
79327d6
Merge branch 'master' of https://github.com/qiwi/pijma into roles
Aug 6, 2019
3618d69
[NF] option field parameters for checkbox, switch, radio
Aug 6, 2019
3a2a700
[RF] Change simple modal to alertdialog @role
Aug 6, 2019
abe1343
[NF] @role for mask input
Aug 6, 2019
f54e27e
[RF] change button labels (brand,simple => labelledby)
Aug 6, 2019
4879c55
merge with upstream
Aug 26, 2019
e08308f
fix after merge
Aug 26, 2019
2d6c8f7
Merge branch 'master' into roles
AcesAndEights Sep 5, 2019
3351367
Merge branch 'master' of https://github.com/qiwi/pijma into roles
Sep 16, 2019
3da6536
add @role for core/Icon
Sep 16, 2019
3f42304
add @role for core/image
Sep 16, 2019
8b61e61
change @role for desktop/block-accordion
Sep 16, 2019
2b6c163
change @role for mobile/block-accordion
Sep 16, 2019
3b57dd0
add @role for desktop/breadcrumbs
Sep 16, 2019
00451dd
add @role for mobile/breadcrumbs
Sep 16, 2019
759f77c
refactor @role for desktop/button
Sep 16, 2019
c7c952f
refactor @role for mobile/button
Sep 16, 2019
f8612f9
add @role for desktop/oops
Sep 16, 2019
63f53db
add @role for mobile/oops
Sep 16, 2019
5be33d7
add @role for mobile/text
Sep 16, 2019
4575dc2
add @role for desktop/text
Sep 16, 2019
0d5c37a
rf @role for desktop/button
Sep 17, 2019
0518431
rf @role for mobile/button
Sep 17, 2019
9b1d727
rf @role for desktop/checkboxfield
Sep 17, 2019
a438072
rf @role for mobile/checkboxfield
Sep 17, 2019
07e0ae6
rf @role for core/basicinput and desktop+mobile textfield/passfield
Sep 18, 2019
41fa93b
add @alt for icon
Sep 18, 2019
5e4d7b6
rf @alt for icon + add alt to svg interface
Sep 18, 2019
5454fe7
rf @role for desktop/breadcrumbs
Sep 18, 2019
fd40714
rf @role for mobile/breadcrumbs
Sep 18, 2019
5d25d0d
delete @role for navlink mobile and desktop
Sep 18, 2019
c56b79e
delete @role for button mobile and desktop
Sep 18, 2019
cb5d880
delete @role for all links mobile and desktop
Sep 18, 2019
a33b942
fix checkbox field
Sep 18, 2019
373a873
rf @role for headermenu
Sep 18, 2019
2cc765e
delete @role for textfield
Sep 18, 2019
ecf1fa6
review fixes
Sep 18, 2019
9232b03
Merge branch 'master' into roles
AcesAndEights Sep 18, 2019
b17e486
title for desktop/blocklink
Sep 19, 2019
112d15b
title for mobile/blocklink
Sep 19, 2019
2a9986b
turn label to string
Sep 19, 2019
d074981
Merge branch 'master' of https://github.com/qiwi/pijma into roles
Sep 19, 2019
2dc4df0
Merge remote-tracking branch 'origin/roles' into roles
Sep 19, 2019
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
2 changes: 2 additions & 0 deletions packages/core/src/block/Block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export interface BlockProps {

export const Block: FC<BlockProps> = (props) => (
<Card
role="section"
aria-label="block"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Атрибут aria-label создаёт текстовую метку текущего элемента в случае отсутствия видимого текста описания элемента. зачем тут просто block всегда?

r={10}
tabIndex={props.tabIndex}
s={props.hover || props.focus || props.active ? '0 10px 24px 0 rgba(0,0,0,0.08)' : '0 1px 2px 0 rgba(0,0,0,0.12)'}
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/field/OptionField.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React, {ReactNode, FocusEventHandler, KeyboardEventHandler} from 'react'
import React, {FocusEventHandler, KeyboardEventHandler, ReactNode} from 'react'

import styled from '../styled'
import {Typo, Box, Flex, FlexItem, BoxProps} from '../primitive'
import {Box, BoxProps, Flex, FlexItem, Typo} from '../primitive'
import {Spacer} from '../spacer'

export interface OptionFieldProps {
title?: ReactNode
hint?: ReactNode
help?: ReactNode
role?: string
tabIndex?: number
autoFocus?: boolean
onFocus: FocusEventHandler
Expand All @@ -33,6 +34,8 @@ export const OptionField: React.FunctionComponent<OptionFieldProps> = (props) =>
<Input
tabIndex={props.tabIndex}
autoFocus={props.autoFocus}
role={props.role}
aria-label={typeof props.title === 'string' ? props.title : undefined}
onFocus={props.onFocus}
onBlur={props.onBlur}
onKeyDown={props.onKeyDown}
Expand Down
12 changes: 9 additions & 3 deletions packages/core/src/field/OptionFieldItem.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import React, {ReactNode, MouseEventHandler} from 'react'
import React, {MouseEventHandler, ReactNode} from 'react'

import {Box, Pos, Typo, Flex} from '../primitive'
import {Box, Flex, Pos, Typo} from '../primitive'

export interface OptionFieldItemProps {
checked?: boolean
disabled?: boolean
reverse?: boolean
role?: string
icon: ReactNode
label: ReactNode
label: string
description?: ReactNode
onClick: MouseEventHandler
onMouseEnter: MouseEventHandler
onMouseLeave: MouseEventHandler
}

export const OptionFieldItem: React.FunctionComponent<OptionFieldItemProps> = ({
checked,
disabled,
icon,
label,
Expand All @@ -24,6 +27,9 @@ export const OptionFieldItem: React.FunctionComponent<OptionFieldItemProps> = ({
reverse,
}) => (
<Pos
role="menuitemcheckbox"
aria-checked={checked ? 'true' : 'false'}
aria-label={label}
type="relative"
cursor={disabled ? 'not-allowed' : 'pointer'}
onClick={onClick}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const Grid: FC<GridProps> = ({gutter = 20, columns = 12, layout = columns
const rowBlocksCount: number = columns / layoutSum * layoutLength

return (
<Flex wrap="wrap">
<Flex wrap="wrap" role="section" aria-label="grid">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

есть роль grid и опять label один для всех и не понятно зачем он тут

{Children.map(elements, (child: ReactNode, index: number) => (
<FlexItem
key={index}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export const Icon: FC<IconProps> = ({
size = 6,
color = '#000',
}) => (
<Svg width={size} height={size} viewBox="0 0 24 24" focusable="false">
<Svg width={size} height={size} viewBox="0 0 24 24" focusable="false" role="img" alt={name}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

как я понял тут aria-label нужен, а не alt

<Path d={IconPaths[name]} fill={color}/>
</Svg>
)
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/image/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const Image: FC<ImageProps> = ({
children={(renderProps) => (
renderProps.loaded ? (
<Img
role="img"
key={src}
width={width}
height={height}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/input/BasicInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const BasicInput: FunctionComponent<BasicInputProps> = (props) => {
onBlur: props.onBlur,
onKeyDown: props.onKeyDown,
onKeyUp: props.onKeyUp,
role: 'textbox',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

перед хендлерами

}
return (
props.mask ? (
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/link/LinkControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface LinkControlProps {
onFocus?: () => void
onBlur?: () => void
href?: string
title?: string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем?

target?: string
download?: string | boolean
rel?: string
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/primitive/Svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface SvgProps {
transition?: string
transform?: string
transformOrigin?: string
alt?: string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

как выше писал, возможно aria-label, а не alt

}

export const SvgNonProps = ['width', 'height', 'animation', 'transition', 'transform', 'transformOrigin']
Expand Down
3 changes: 3 additions & 0 deletions packages/desktop/src/block-accordion/BlockAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const BlockAccordionIndent: {

export const BlockAccordion: FunctionComponent<BlockAccordionProps<BlockAccordionItemModel>> = ({items, indent = 'm', tabIndex = 0, opened, onChange}) => (
<AccordionControl<BlockAccordionItemModel>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лишняя строчка

items={items}
opened={opened}
onChange={onChange}
Expand All @@ -35,6 +36,8 @@ export const BlockAccordion: FunctionComponent<BlockAccordionProps<BlockAccordio
{renderProps.items.map((item, index) => (
<Card
key={index}
role="region"
aria-label={typeof item.title === 'string' ? item.title : undefined}
s={
item.hovered || item.focused
? '0 0 16px 0 rgba(0, 0, 0, 0.12)'
Expand Down
2 changes: 2 additions & 0 deletions packages/desktop/src/block-content/BlockContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const BlockContentIdent: { [indent in NonNullable<BlockContentProps['indent']>]:

export const BlockContent: FC<BlockContentProps> = ({indent = 'm', children}) => (
<Box
role="section"
aria-label="content"
p={BlockContentIdent[indent]}
children={children}
/>
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/src/breadcrumbs/Breadcrumbs.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
```jsx
<Spacer size="xl">
<Breadcrumbs
title="Хлебные крошки"
children={[
{href: 'https://qiwi.com/', children: 'Главная'},
{href: 'https://qiwi.com/support/', children: 'Помощь'},
Expand Down
39 changes: 21 additions & 18 deletions packages/desktop/src/breadcrumbs/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,28 @@ import {NavLink, NavLinkProps} from '../nav-link'
import {Paragraph} from '../typography'

export interface BreadcrumbsProps {
title?: string
children: NavLinkProps[]
}

export const Breadcrumbs: FC<BreadcrumbsProps> = ({children}) => (
<Paragraph size="s" color="support">
{children.map((item, i) => (
<Fragment key={i} >
{i > 0 ? (
<Fragment>
<Box as="span" mx={2} display="inline">
&#8226;
</Box>
&shy;
</Fragment>
) : (
null
)}
<NavLink {...item} />
</Fragment>
))}
</Paragraph>
export const Breadcrumbs: FC<BreadcrumbsProps> = ({title, children}) => (
<Box as="nav" aria-label={title}>
<Paragraph size="s" color="support">
{children.map((item, i) => (
<Fragment key={i} >
{i > 0 ? (
<Fragment>
<Box as="span" mx={2} display="inline">
&#8226;
</Box>
&shy;
</Fragment>
) : (
null
)}
<NavLink {...item} />
</Fragment>
))}
</Paragraph>
</Box>
)
4 changes: 3 additions & 1 deletion packages/desktop/src/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {FunctionComponent, ReactElement, Fragment} from 'react'
import React, {FunctionComponent, Fragment, ReactElement} from 'react'

import {
ButtonControl,
Expand Down Expand Up @@ -165,6 +165,8 @@ export const Button: FunctionComponent<ButtonProps> = (props) => (
onBlur={props.onBlur}
children={(renderProps) => (
<Btn
aria-label={props.text}
aria-labelledby={props.kind}
disabled={props.disabled}
type={props.type}
width={!props.icon || props.text ? 1 : buttonSize[props.size]}
Expand Down
4 changes: 3 additions & 1 deletion packages/desktop/src/checkbox-field/CheckboxField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import CheckboxFieldOptionModel from './CheckboxFieldOptionModel'

const CheckboxField: FunctionComponent<
CheckboxFieldProps<CheckboxFieldOptionModel<any>, any>
> = props => (
> = props => (
props.stub ? (
<Box maxWidth={1}>
<Stub
Expand Down Expand Up @@ -58,6 +58,8 @@ const CheckboxField: FunctionComponent<
onBlur={props.onBlur}
children={(renderProps) => (
<OptionField
role="checkbox"
aria-label={props.title}
title={props.title}
hint={props.hint}
help={props.help}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import {ReactNode} from 'react'
import {OptionModel} from '@qiwi/pijma-core'

export default interface CheckboxFieldOptionModel<V> extends OptionModel<V> {
label: ReactNode
label: string
description?: ReactNode
}
1 change: 1 addition & 0 deletions packages/desktop/src/checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const Checkbox: FunctionComponent<CheckboxProps> = props => (
onKeyDown={renderProps.onKeyDown}
children={(
<OptionFieldItem
role="menuitemcheckbox"
disabled={props.disabled}
label={props.label}
description={props.description}
Expand Down
22 changes: 12 additions & 10 deletions packages/desktop/src/header-menu/HeaderMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import React, {FC} from 'react'

import {Flex, FlexItem} from '@qiwi/pijma-core'
import {Flex, FlexItem, Box} from '@qiwi/pijma-core'
import {HeaderMenuItem, HeaderMenuItemProps} from './HeaderMenuItem'

export interface HeaderMenuProps {
children: HeaderMenuItemProps[]
}

export const HeaderMenu: FC<HeaderMenuProps> = (props) => (
<Flex height={1} width={1} justify="flex-start">
{props.children.map((item, i) => (
<FlexItem key={i} ml={i > 0 ? 6 : 0}>
<HeaderMenuItem
{...item}
/>
</FlexItem>
))}
</Flex>
<Box as="nav" height={1} width={1}>
<Flex height={1} width={1} justify="flex-start" role="menubar">
{props.children.map((item, i) => (
<FlexItem key={i} ml={i > 0 ? 6 : 0}>
<HeaderMenuItem
{...item}
/>
</FlexItem>
))}
</Flex>
</Box>
)
4 changes: 3 additions & 1 deletion packages/desktop/src/header-menu/HeaderMenuItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {FC} from 'react'

import {LinkControl, Lnk, Flex, Pos, Card} from '@qiwi/pijma-core'
import {Card, Flex, LinkControl, Lnk, Pos} from '@qiwi/pijma-core'
import {Text} from '../typography/Text'

export interface HeaderMenuItemProps {
Expand Down Expand Up @@ -35,6 +35,8 @@ export const HeaderMenuItem: FC<HeaderMenuItemProps> = (props) => (
cursor="pointer"
tabIndex={props.tabIndex}
href={props.href}
role="menuitem"
aria-label={props.title}
target={props.target}
download={props.download}
rel={props.rel}
Expand Down
4 changes: 3 additions & 1 deletion packages/desktop/src/link/BlockLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {FC} from 'react'

import {LinkControl, RenderChild, Lnk, Card} from '@qiwi/pijma-core'
import {Card, LinkControl, Lnk, RenderChild} from '@qiwi/pijma-core'

export interface BlockLinkProps {
onClick?: (href?: string, target?: string, download?: string | boolean, rel?: string) => void
Expand Down Expand Up @@ -28,11 +28,13 @@ export const BlockLink: FC<BlockLinkProps> = (props) => (
onFocus={props.onFocus}
onBlur={props.onBlur}
href={props.href}
title={props.title}
target={props.target}
download={props.download}
rel={props.rel}
children={(renderProps) => (
<CardLink
aria-label={props.title}
display="block"
overflow="hidden"
bg="#fff"
Expand Down
1 change: 0 additions & 1 deletion packages/desktop/src/link/FileLink.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {FC} from 'react'

import {LinkControl, Lnk, FlexItem, Flex, Icon} from '@qiwi/pijma-core'

import {Text} from '../typography'

export interface FileLinkProps {
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/src/link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const Link: FC<LinkProps> = (props) => (
<TypoLink
tabIndex={props.tabIndex}
href={props.href}
aria-label={props.title}
onClick={renderProps.onClick}
onFocus={renderProps.onFocus}
onBlur={renderProps.onBlur}
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/src/list/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const LetterSize: {[size in NonNullable<ListProps['size']>]: number} = {
}

export const List: FunctionComponent<ListProps> = ({type, size = 'm', children}) => (
<Box as={ListType[type]}>
<Box as={ListType[type]} role="list">
{children.map((item, index) => (
<Flex key={index} as="li" mt={index > 0 ? ItemIndent[type] : 0}>
{type === 'number' ? (
Expand Down
4 changes: 3 additions & 1 deletion packages/desktop/src/modal/SimpleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ const SimpleModal: FunctionComponent<SimpleModalProps> = (props) => (
)}
children={(
<Pos type="relative" display="inline-block" p={12} css={{verticalAlign: 'middle', textAlign: 'left'}}>
<Card s="0 20px 64px 8px rgba(0, 0, 0, 0.16)" r={10} bg="#fff" pt={11} pb={12} px={11} width={ModalWidth[props.size]}>
<Card role="alertdialog" s="0 20px 64px 8px rgba(0, 0, 0, 0.16)" r={10} bg="#fff" pt={11} pb={12} px={11} width={ModalWidth[props.size]}>
AcesAndEights marked this conversation as resolved.
Show resolved Hide resolved
<Fragment>
{props.closable && props.onHide ? (
<Pos
role="button"
aria-label="exit"
type="absolute"
top={16}
right={16}
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/src/nav-link/NavLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const NavLink: FC<NavLinkProps> = (props) => (
<TypoLink
tabIndex={props.tabIndex}
href={props.href}
aria-label={props.title}
onClick={renderProps.onClick}
onFocus={renderProps.onFocus}
onBlur={renderProps.onBlur}
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/src/notice/Notice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface NoticeProps {
}

export const Notice: FC<NoticeProps> = ({icon, title, children}) => (
<Flex>
<Flex role="alertdialog" aria-label="notice">
<FlexItem
shrink={0}
basis={6}
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/src/oops/Oops.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface OopsProps {
}

export const Oops: FC<OopsProps> = ({logo, error, title, content, footer}) => (
<Card minWidth={295} width="100%" pt={22} minHeight="100%" bg="#fff">
<Card minWidth={295} width="100%" pt={22} minHeight="100%" bg="#fff" role="section" aria-label={title}>
<Flex mx="auto" width={235} direction="column">
<FlexItem
width={60}
Expand Down
Loading