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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Add selection property to child items in ListExampleSelection so that styles and roles are applied properly @jurokapsiar ([#70](https://github.com/stardust-ui/react/pull/70))
- Menu `onClick` handler moved from `li` to `a` (accessibility) @miroslavstastny ([#61](https://github.com/stardust-ui/react/pull/61))
- Image `fluid` is applied on the avatar variations @mnajdova ([#77](https://github.com/stardust-ui/react/pull/77))
- Include missing `types` directory in dist @smykhailov ([#76](https://github.com/stardust-ui/react/pull/76))

### Features
- Add `color` variables to Header and Header.Description @kuzhelov ([#72](https://github.com/stardust-ui/react/pull/72))
Expand Down
14 changes: 12 additions & 2 deletions build/gulp/tasks/dist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ task('build:dist:commonjs', () => {
const typescript = g.typescript.createProject(tsConfig, settings)

const { dts, js } = src(paths.src('**/*.{ts,tsx}')).pipe(typescript())
const types = src(paths.base('types/**'))

return merge2([dts.pipe(dest(paths.dist('commonjs'))), js.pipe(dest(paths.dist('commonjs')))])
return merge2([
dts.pipe(dest(paths.dist('commonjs'))),
js.pipe(dest(paths.dist('commonjs'))),
types.pipe(dest(paths.dist('types'))),
])
})

task('build:dist:es', () => {
Expand All @@ -36,8 +41,13 @@ task('build:dist:es', () => {
const typescript = g.typescript.createProject(tsConfig, settings)

const { dts, js } = src(paths.src('**/*.{ts,tsx}')).pipe(typescript())
const types = src(paths.base('types/**'))

return merge2([dts.pipe(dest(paths.dist('es'))), js.pipe(dest(paths.dist('es')))])
return merge2([
dts.pipe(dest(paths.dist('es'))),
js.pipe(dest(paths.dist('es'))),
types.pipe(dest(paths.dist('types'))),
])
})

task('build:dist:umd', cb => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { AutoControlledComponent, customPropTypes, childrenExist } from '../../l
import AccordionTitle from './AccordionTitle'
import AccordionContent from './AccordionContent'
import { DefaultBehavior } from '../../lib/accessibility'
import { Accessibility } from '../../lib/accessibility/interfaces'

/**
* A standard Accordion.
Expand Down Expand Up @@ -61,7 +62,7 @@ class Accordion extends AutoControlledComponent<any, any> {
),
]),

/** Accessibility behavior if overriden by the user. */
/** Accessibility behavior if overridden by the user. */
accessibility: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
}

Expand All @@ -78,7 +79,7 @@ class Accordion extends AutoControlledComponent<any, any> {
]

public static defaultProps = {
accessibility: DefaultBehavior,
accessibility: DefaultBehavior as Accessibility,
}

static autoControlledProps = ['activeIndex']
Expand Down
5 changes: 3 additions & 2 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { UIComponent, childrenExist, customPropTypes } from '../../lib'
import Icon from '../Icon'
import Text from '../Text'
import { ButtonBehavior } from '../../lib/accessibility'
import { Accessibility } from '../../lib/accessibility/interfaces'

/**
* A button.
Expand Down Expand Up @@ -54,7 +55,7 @@ class Button extends UIComponent<any, any> {
/** A button can be formatted to show different levels of emphasis. */
type: PropTypes.oneOf(['primary', 'secondary']),

/** Accessibility behavior if overriden by the user. */
/** Accessibility behavior if overridden by the user. */
accessibility: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
}

Expand All @@ -75,7 +76,7 @@ class Button extends UIComponent<any, any> {

public static defaultProps = {
as: 'button',
accessibility: ButtonBehavior,
accessibility: ButtonBehavior as Accessibility,
}

public renderComponent({ ElementType, classes, accessibility, rest }): React.ReactNode {
Expand Down
5 changes: 3 additions & 2 deletions src/components/Image/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as React from 'react'

import { customPropTypes, UIComponent } from '../../lib'
import { ImageBehavior } from '../../lib/accessibility'
import { Accessibility } from '../../lib/accessibility/interfaces'

/**
* An image is a graphic representation of something.
Expand All @@ -13,7 +14,7 @@ class Image extends UIComponent<any, any> {
static displayName = 'Image'

static propTypes = {
/** Accessibility behavior if overriden by the user. */
/** Accessibility behavior if overridden by the user. */
accessibility: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),

/** An element type to render as. */
Expand Down Expand Up @@ -51,7 +52,7 @@ class Image extends UIComponent<any, any> {

static defaultProps = {
as: 'img',
accessibility: ImageBehavior,
accessibility: ImageBehavior as Accessibility,
}

renderComponent({ ElementType, classes, accessibility, rest }) {
Expand Down
5 changes: 3 additions & 2 deletions src/components/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as PropTypes from 'prop-types'
import { customPropTypes, UIComponent, childrenExist } from '../../lib'
import ListItem from './ListItem'
import { ListBehavior } from '../../lib/accessibility'
import { Accessibility } from '../../lib/accessibility/interfaces'

class List extends UIComponent<any, any> {
static displayName = 'List'
Expand Down Expand Up @@ -37,13 +38,13 @@ class List extends UIComponent<any, any> {
/** Variables */
variables: PropTypes.object,

/** Accessibility behavior if overriden by the user. */
/** Accessibility behavior if overridden by the user. */
accessibility: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
}

static defaultProps = {
as: 'ul',
accessibility: ListBehavior,
accessibility: ListBehavior as Accessibility,
}

static handledProps = [
Expand Down
5 changes: 3 additions & 2 deletions src/components/List/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as cx from 'classnames'
import { createShorthandFactory, customPropTypes, pxToRem, UIComponent } from '../../lib'
import Layout from '../Layout'
import { ListItemBehavior } from '../../lib/accessibility'
import { Accessibility } from '../../lib/accessibility/interfaces'

class ListItem extends UIComponent<any, any> {
static create: Function
Expand Down Expand Up @@ -43,7 +44,7 @@ class ListItem extends UIComponent<any, any> {
truncateContent: PropTypes.bool,
truncateHeader: PropTypes.bool,

/** Accessibility behavior if overriden by the user. */
/** Accessibility behavior if overridden by the user. */
accessibility: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
}

Expand All @@ -69,7 +70,7 @@ class ListItem extends UIComponent<any, any> {

static defaultProps = {
as: 'li',
accessibility: ListItemBehavior,
accessibility: ListItemBehavior as Accessibility,

renderMainArea: (props, state, classes) => {
const { renderHeaderArea, renderContentArea } = props
Expand Down
5 changes: 3 additions & 2 deletions src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as React from 'react'
import { AutoControlledComponent, childrenExist, customPropTypes } from '../../lib'
import MenuItem from './MenuItem'
import { MenuBehavior } from '../../lib/accessibility'
import { Accessibility } from '../../lib/accessibility/interfaces'

class Menu extends AutoControlledComponent<any, any> {
static displayName = 'Menu'
Expand Down Expand Up @@ -43,13 +44,13 @@ class Menu extends AutoControlledComponent<any, any> {
/** A vertical menu displays elements vertically. */
vertical: PropTypes.bool,

/** Accessibility behavior if overriden by the user. */
/** Accessibility behavior if overridden by the user. */
accessibility: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
}

static defaultProps = {
as: 'ul',
accessibility: MenuBehavior,
accessibility: MenuBehavior as Accessibility,
}

static handledProps = [
Expand Down
5 changes: 3 additions & 2 deletions src/components/Menu/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as React from 'react'

import { childrenExist, createShorthandFactory, customPropTypes, UIComponent } from '../../lib'
import { MenuItemBehavior } from '../../lib/accessibility'
import { Accessibility } from '../../lib/accessibility/interfaces'

class MenuItem extends UIComponent<any, any> {
static displayName = 'MenuItem'
Expand Down Expand Up @@ -49,13 +50,13 @@ class MenuItem extends UIComponent<any, any> {
/** A vertical menu displays elements vertically. */
vertical: PropTypes.bool,

/** Accessibility behavior if overriden by the user. */
/** Accessibility behavior if overridden by the user. */
accessibility: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
}

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

static handledProps = [
Expand Down
6 changes: 3 additions & 3 deletions test/specs/commonTests/handlesAccessibility.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ const getProp = (renderedComponent, propName, partSelector) => {
* @param {Object} [options.requiredProps={}] Props required to render Component without errors or warnings.
* @param {string} [options.defaultRootRole=''] Default root role rendered when no override provided
* @param {string} [options.accessibilityOverride=ButtonBehavior] Override to test accessibility property override
* @param {string} [options.overridenRootRole=ButtonBehavior] Overriden root role when accessibility property overriden
* @param {string} [options.overriddenRootRole=ButtonBehavior] Overridden root role when accessibility property overridden
* @param {string} [options.partSelector=''] Selector to scope the test to a part
*/
export default (Component, options: any = {}) => {
const {
requiredProps = {},
defaultRootRole = ButtonBehavior,
accessibilityOverride = ButtonBehavior,
overridenRootRole = 'button',
overriddenRootRole = 'button',
partSelector = '',
} = options

Expand All @@ -53,7 +53,7 @@ export default (Component, options: any = {}) => {
<Component {...requiredProps} accessibility={accessibilityOverride} />,
)
const role = getProp(rendered, 'role', partSelector)
expect(role).toBe(overridenRootRole)
expect(role).toBe(overriddenRootRole)
})

test('gets correct role when overrides role', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/specs/components/Button/Button-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Button', () => {
handlesAccessibility(Button, {
defaultRootRole: 'button',
accessibilityOverride: MenuBehavior,
overridenRootRole: 'menu',
overriddenRootRole: 'menu',
})

describe('type', () => {
Expand Down
6 changes: 4 additions & 2 deletions types/theme.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ export interface ComponentStyleFunctionParam {
variables: ComponentVariablesObject
}

export type ComponentPartStyleFunction = (styleParam?: ComponentStyleFunctionParam) => ICSSInJSStyle
export type ComponentPartStyleFunction =
| ((styleParam?: ComponentStyleFunctionParam) => ICSSInJSStyle)
| undefined

export type ComponentPartStyle = ComponentPartStyleFunction | ICSSInJSStyle
export type ComponentPartStyle = ComponentPartStyleFunction | ICSSInJSStyle | undefined
Copy link
Member

Choose a reason for hiding this comment

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

I'm still not sure this is required. This doesn't exist on master yet typings compile, tests pass, and all functionality is working.

Could you recap why we need this again?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Whenever you have compiler option "strictNullChecks": true, then it will complain.
This happens only because there is an indexed property defined together with optional. If you use one of them it is fine even with the compiler option enabled

image


export interface IComponentPartStylesInput {
[part: string]: ComponentPartStyle
Expand Down