Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Features
- Accessibility for menu divider @jurokapsiar ([#822](https://github.com/stardust-ui/react/pull/822))

<!--------------------------------[ v0.19.2 ]------------------------------- -->
## [v0.19.2](https://github.com/stardust-ui/react/tree/v0.19.2) (2019-02-01)
[Compare changes](https://github.com/stardust-ui/react/compare/v0.19.1...v0.19.2)
Expand Down
20 changes: 18 additions & 2 deletions src/components/Menu/MenuDivider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as React from 'react'
import * as PropTypes from 'prop-types'
import { Accessibility } from '../../lib/accessibility/types'
import { menuDividerBehavior } from '../../lib/accessibility'

import {
createShorthandFactory,
Expand All @@ -11,6 +13,12 @@ import {
import { ReactProps } from '../../../types/utils'

export interface MenuDividerProps extends UIComponentProps, ColorComponentProps {
/**
* Accessibility behavior if overridden by the user.
* @default menuDividerBehavior
*/
accessibility?: Accessibility

vertical?: boolean
primary?: boolean
secondary?: boolean
Expand All @@ -28,17 +36,25 @@ class MenuDivider extends UIComponent<ReactProps<MenuDividerProps>, any> {

static defaultProps = {
as: 'li',
accessibility: menuDividerBehavior as Accessibility,
}

static propTypes = {
...commonPropTypes.createCommon({ content: false, children: false, color: true }),
accessibility: PropTypes.func,
primary: PropTypes.bool,
secondary: PropTypes.bool,
vertical: PropTypes.bool,
}

renderComponent({ ElementType, classes, unhandledProps }) {
return <ElementType {...unhandledProps} className={classes.root} />
renderComponent({ ElementType, classes, unhandledProps, accessibility }) {
return (
<ElementType
{...accessibility.attributes.root}
{...unhandledProps}
className={classes.root}
/>
)
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ export { default as Indicator, IndicatorProps } from './components/Indicator/Ind
// Accessibility
//
export * from './lib/accessibility/types'
export { default as menuBehavior } from './lib/accessibility/Behaviors/Menu/menuBehavior'
export { default as menuItemBehavior } from './lib/accessibility/Behaviors/Menu/menuItemBehavior'
export {
default as menuDividerBehavior,
} from './lib/accessibility/Behaviors/Menu/menuDividerBehavior'
export { default as tabBehavior } from './lib/accessibility/Behaviors/Tab/tabBehavior'
export { default as tabListBehavior } from './lib/accessibility/Behaviors/Tab/tabListBehavior'
export { default as toolbarBehavior } from './lib/accessibility/Behaviors/Toolbar/toolbarBehavior'
Expand Down
19 changes: 19 additions & 0 deletions src/lib/accessibility/Behaviors/Menu/menuDividerBehavior.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Accessibility } from '../../types'

/**
* @description
* Behavior for menu divider
*
* @specification
* Adds role 'presentation' to 'root' component's part.
*/

const menuDividerBehavior: Accessibility = (props: any) => ({
attributes: {
root: {
role: 'presentation',
},
},
})
Copy link
Member

Choose a reason for hiding this comment

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

A little confused with this, we don't have a behavior for Divider. How are they differenced?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's just that we did not get to divider yet. it will be done soon. If it turns out to be the same, we will consolidate.

Copy link
Contributor

Choose a reason for hiding this comment

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

The MenuDivider is part of the list (it is li) element and I guess as the other elements in the menu has this role.


export default menuDividerBehavior
1 change: 1 addition & 0 deletions src/lib/accessibility/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export { default as toggleButtonBehavior } from './Behaviors/Button/toggleButton
export { default as imageBehavior } from './Behaviors/Image/imageBehavior'
export { default as menuBehavior } from './Behaviors/Menu/menuBehavior'
export { default as menuItemBehavior } from './Behaviors/Menu/menuItemBehavior'
export { default as menuDividerBehavior } from './Behaviors/Menu/menuDividerBehavior'
export { default as submenuBehavior } from './Behaviors/Menu/submenuBehavior'
export { default as basicListBehavior } from './Behaviors/List/listBehavior'
export { default as basicListItemBehavior } from './Behaviors/List/basicListItemBehavior'
Expand Down
2 changes: 2 additions & 0 deletions test/specs/behaviors/behavior-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
loaderBehavior,
menuBehavior,
menuItemBehavior,
menuDividerBehavior,
submenuBehavior,
popupBehavior,
popupFocusTrapBehavior,
Expand Down Expand Up @@ -49,6 +50,7 @@ testHelper.addBehavior('imageBehavior', imageBehavior)
testHelper.addBehavior('loaderBehavior', loaderBehavior)
testHelper.addBehavior('menuBehavior', menuBehavior)
testHelper.addBehavior('menuItemBehavior', menuItemBehavior)
testHelper.addBehavior('menuDividerBehavior', menuDividerBehavior)
testHelper.addBehavior('submenuBehavior', submenuBehavior)
testHelper.addBehavior('popupBehavior', popupBehavior)
testHelper.addBehavior('popupFocusTrapBehavior', popupFocusTrapBehavior)
Expand Down