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 26 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
11 changes: 9 additions & 2 deletions packages/core/src/field/OptionFieldItem.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
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
description?: ReactNode
Expand All @@ -14,6 +16,7 @@ export interface OptionFieldItemProps {
}

export const OptionFieldItem: React.FunctionComponent<OptionFieldItemProps> = ({
checked,
disabled,
icon,
label,
Expand All @@ -22,8 +25,12 @@ export const OptionFieldItem: React.FunctionComponent<OptionFieldItemProps> = ({
onMouseEnter,
onMouseLeave,
reverse,
role,
}) => (
<Pos
role={role}
aria-checked={checked ? 'true' : 'false'}
aria-label={typeof label === 'string' ? label : undefined}
AcesAndEights marked this conversation as resolved.
Show resolved Hide resolved
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">
AcesAndEights marked this conversation as resolved.
Show resolved Hide resolved
<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
2 changes: 2 additions & 0 deletions packages/core/src/input/BasicInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const BasicInput: FunctionComponent<BasicInputProps> = (props) => {
return (
props.mask ? (
<MaskInput
role="textbox"
AcesAndEights marked this conversation as resolved.
Show resolved Hide resolved
{...common}
type={props.type === undefined ? (isMaskDigital(props.mask) ? 'tel' : 'text') : (['text', 'password', 'tel'].includes(props.type) ? props.type : 'text')}
mask={props.mask}
Expand All @@ -68,6 +69,7 @@ export const BasicInput: FunctionComponent<BasicInputProps> = (props) => {
/>
) : (
<Input
role="textbox"
{...common}
type={props.type === undefined ? 'text' : props.type}
/>
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
36 changes: 19 additions & 17 deletions packages/desktop/src/breadcrumbs/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@ export interface BreadcrumbsProps {
}

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>
<Box role="menubar" aria-label="Breadcrumbs">
AcesAndEights marked this conversation as resolved.
Show resolved Hide resolved
<Paragraph size="s" color="support">
{children.map((item, i) => (
<Fragment key={i} >
{i > 0 ? (
<Fragment>
<Box as="span" mx={2} display="inline" role="section">
&#8226;
</Box>
&shy;
</Fragment>
) : (
null
)}
<NavLink {...item} />
</Fragment>
))}
</Paragraph>
</Box>
)
5 changes: 4 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,9 @@ export const Button: FunctionComponent<ButtonProps> = (props) => (
onBlur={props.onBlur}
children={(renderProps) => (
<Btn
role="button"
AcesAndEights marked this conversation as resolved.
Show resolved Hide resolved
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
130 changes: 48 additions & 82 deletions packages/desktop/src/checkbox-field/CheckboxField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import {
OptionField,
OptionFieldItem,
Box,
Stub,
Spacer,
Flex,
} from '@qiwi/pijma-core'

import CheckboxFieldProps from './CheckboxFieldProps'
Expand All @@ -18,87 +15,56 @@ import CheckboxFieldOptionModel from './CheckboxFieldOptionModel'
const CheckboxField: FunctionComponent<
CheckboxFieldProps<CheckboxFieldOptionModel<any>, any>
> = props => (
props.stub ? (
<Box maxWidth={1}>
<Stub
width={24}
height={3}
top={2}
bottom={4}
/>
<Spacer size="s">
{[33, 38, 30].map((width: number, id: number) => (
<Flex key={id} align="center">
<Stub
width={5}
height={5}
right={3}
left={0.5}
/>
<Box width={width} maxWidth={1}>
<Stub
width={1}
height={2}
top={2}
bottom={2}
<CheckboxControl<CheckboxFieldOptionModel<any>, any>
AcesAndEights marked this conversation as resolved.
Show resolved Hide resolved
tabIndex={props.tabIndex}
options={props.options}
values={props.values}
equals={props.equals}
onChange={props.onChange}
onFocus={props.onFocus}
onBlur={props.onBlur}
children={(renderProps) => (
<OptionField
title={props.title}
hint={props.hint}
help={props.help}
tabIndex={renderProps.tabIndex}
autoFocus={props.autoFocus}
onFocus={renderProps.onFocus}
onBlur={renderProps.onBlur}
onKeyDown={renderProps.onKeyDown}
children={renderProps.options.map((option, index) => (
<OptionControl<any>
key={index}
disabled={option.disabled}
value={option.value}
onClick={option.onClick}
onMouseEnter={option.onMouseEnter}
onMouseLeave={renderProps.onMouseLeave}
children={(renderOptionProps) => (
<OptionFieldItem
disabled={option.disabled}
icon={(
<Box width={6}>
<Check
disabled={option.disabled}
checked={option.checked}
focused={option.focused}
/>
</Box>
)}
label={option.label}
description={option.description}
onClick={renderOptionProps.onClick}
onMouseLeave={renderOptionProps.onMouseLeave}
onMouseEnter={renderOptionProps.onMouseEnter}
/>
</Box>
</Flex>
)}
/>
))}
</Spacer>
</Box>
) : (
<CheckboxControl<CheckboxFieldOptionModel<any>, any>
tabIndex={props.tabIndex}
options={props.options}
values={props.values}
equals={props.equals}
onChange={props.onChange}
onFocus={props.onFocus}
onBlur={props.onBlur}
children={(renderProps) => (
<OptionField
title={props.title}
hint={props.hint}
help={props.help}
tabIndex={renderProps.tabIndex}
autoFocus={props.autoFocus}
onFocus={renderProps.onFocus}
onBlur={renderProps.onBlur}
onKeyDown={renderProps.onKeyDown}
children={renderProps.options.map((option, index) => (
<OptionControl<any>
key={index}
disabled={option.disabled}
value={option.value}
onClick={option.onClick}
onMouseEnter={option.onMouseEnter}
onMouseLeave={renderProps.onMouseLeave}
children={(renderOptionProps) => (
<OptionFieldItem
disabled={option.disabled}
icon={(
<Box width={6}>
<Check
disabled={option.disabled}
checked={option.checked}
focused={option.focused}
/>
</Box>
)}
label={option.label}
description={option.description}
onClick={renderOptionProps.onClick}
onMouseLeave={renderOptionProps.onMouseLeave}
onMouseEnter={renderOptionProps.onMouseEnter}
/>
)}
/>
))}
/>
)}
/>
)
/>
)}
/>
)

export default CheckboxField
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
2 changes: 1 addition & 1 deletion packages/desktop/src/header-menu/HeaderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface HeaderMenuProps {
}

export const HeaderMenu: FC<HeaderMenuProps> = (props) => (
<Flex height={1} width={1} justify="flex-start">
<Flex height={1} width={1} justify="flex-start" role="menubar">
AcesAndEights marked this conversation as resolved.
Show resolved Hide resolved
{props.children.map((item, i) => (
<FlexItem key={i} ml={i > 0 ? 6 : 0}>
<HeaderMenuItem
Expand Down
3 changes: 2 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,7 @@ export const HeaderMenuItem: FC<HeaderMenuItemProps> = (props) => (
cursor="pointer"
tabIndex={props.tabIndex}
href={props.href}
role="menuitem"
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 @@ -33,6 +33,8 @@ export const BlockLink: FC<BlockLinkProps> = (props) => (
rel={props.rel}
children={(renderProps) => (
<CardLink
role="link"
aria-label="blockLink"
AcesAndEights marked this conversation as resolved.
Show resolved Hide resolved
display="block"
overflow="hidden"
bg="#fff"
Expand Down
Loading