diff --git a/docs/src/App/App.tsx b/docs/src/App/App.tsx index 2f3019c9994..3f7ad2cfba5 100644 --- a/docs/src/App/App.tsx +++ b/docs/src/App/App.tsx @@ -103,54 +103,64 @@ export default withRouter( paddingLeft="gutter" paddingRight="gutter" > - - Tools - - - - - Source - - - - - Playroom - - - - - Components - - - {Object.keys(components) - .filter(x => !/icon/i.test(x)) - .sort() - .map(componentName => ( - - - {componentName} - - - ))} - - - Icons - + + + Tools + + + + + + + Source + + + + + Playroom + + + + + + + Components + + + + + {Object.keys(components) + .filter(x => !/icon/i.test(x)) + .sort() + .map(componentName => ( + + + {componentName} + + + ))} + + + + + Icons + + {Object.keys(components) .filter(x => /icon/i.test(x) && x !== 'Icon') diff --git a/docs/src/App/ComponentProps/ComponentProps.tsx b/docs/src/App/ComponentProps/ComponentProps.tsx index d9032990ceb..9c6da2676e4 100644 --- a/docs/src/App/ComponentProps/ComponentProps.tsx +++ b/docs/src/App/ComponentProps/ComponentProps.tsx @@ -27,9 +27,9 @@ export default class ComponentProps extends Component { return Object.keys(props).length === 0 ? null : ( - - Options - + + Options + {map(props, (option, propName) => { if (!option) { return null; diff --git a/docs/src/App/ComponentRoute/ComponentRoute.tsx b/docs/src/App/ComponentRoute/ComponentRoute.tsx index 38f713e4c77..a056b44bc3f 100644 --- a/docs/src/App/ComponentRoute/ComponentRoute.tsx +++ b/docs/src/App/ComponentRoute/ComponentRoute.tsx @@ -34,36 +34,42 @@ export default class ComponentRoute extends Component { return ( - - {componentName} - - {examples.length > 0 ? ( - - Example - {examples.length > 1 ? 's' : ''} + + + {componentName} + + {examples.length > 0 ? ( + + + Example + {examples.length > 1 ? 's' : ''} + + ) : null} {examples.map(({ label, render, code }, index) => ( - {label ? {label} : null} + {label ? ( + + {label} + + ) : null} {render ? themes.map(theme => ( - - Theme: {theme.name} - + + Theme: {theme.name} + {render({ id: `${index}_${theme.name}` })} )) : null} - - Code: - - + Code: + + { overflowX: 'auto' }} > - {render - ? reactElementToJSXString(render({ id: 'id' }), { - useBooleanShorthandSyntax: false, - showDefaultProps: false, - showFunctions: true - }) - : null} - {code ? dedent(code) : null} - + + {render + ? reactElementToJSXString(render({ id: 'id' }), { + useBooleanShorthandSyntax: false, + showDefaultProps: false, + showFunctions: true + }) + : null} + {code ? dedent(code) : null} + + ))} @@ -90,14 +98,16 @@ export default class ComponentRoute extends Component { - - Source - - - - View on GitHub - - + + Source + + + + + View on GitHub + + + ); } diff --git a/lib/componentDocs/globsToReactDocgen.js b/lib/componentDocs/globsToReactDocgen.js index 4b44be85694..2276a76caed 100644 --- a/lib/componentDocs/globsToReactDocgen.js +++ b/lib/componentDocs/globsToReactDocgen.js @@ -1,10 +1,7 @@ const path = require('path'); const fastGlob = require('fast-glob').async; const { parse: parseTs } = require('react-docgen-typescript').withCustomConfig( - path.join(process.cwd(), 'tsconfig.json'), - { - propFilter: prop => !/node_modules/.test(prop.parent.fileName) - } + path.join(process.cwd(), 'tsconfig.json') ); module.exports = async ({ include = '', exclude: ignore = [] } = {}) => { diff --git a/lib/components/Alert/Alert.tsx b/lib/components/Alert/Alert.tsx index 8b0e7151f6b..694da841f4b 100644 --- a/lib/components/Alert/Alert.tsx +++ b/lib/components/Alert/Alert.tsx @@ -1,5 +1,5 @@ import React, { Component, ReactNode } from 'react'; -import Box, { BoxProps } from '../Box/Box'; +import Box from '../Box/Box'; import Text from '../Text/Text'; import InfoIcon from '../icons/InfoIcon/InfoIcon'; import ErrorIcon from '../icons/ErrorIcon/ErrorIcon'; @@ -7,18 +7,26 @@ import styles from './Alert.css.js'; type Tone = 'info' | 'critical'; -export interface AlertProps extends BoxProps { +export interface AlertProps { tone?: Tone; children: ReactNode; } const iconForTone = (tone: Tone) => { if (tone === 'info') { - return ; + return ( + + + + ); } if (tone === 'critical') { - return ; + return ( + + + + ); } return null; @@ -40,7 +48,7 @@ export default class Alert extends Component { static displayName = 'Alert'; render() { - const { tone = 'info', children, ...restProps } = this.props; + const { tone = 'info', children } = this.props; const icon = iconForTone(tone); const color = textColorForTone(tone); @@ -52,7 +60,6 @@ export default class Alert extends Component { paddingRight="gutter" paddingTop="medium" paddingBottom="medium" - {...restProps} >
{icon}
diff --git a/lib/components/Alert/__snapshots__/Alert.test.tsx.snap b/lib/components/Alert/__snapshots__/Alert.test.tsx.snap index 168ad742d14..24d4a298d2b 100644 --- a/lib/components/Alert/__snapshots__/Alert.test.tsx.snap +++ b/lib/components/Alert/__snapshots__/Alert.test.tsx.snap @@ -10,16 +10,20 @@ exports[`Alert Theme: jobStreet Tones critical 1`] = `
- - - + + + +
- - - - - + + + + + +
- - - - - + + + + + +
- - - + + + +
- - - - - + + + + + +
- - - - - + + + + + +
- - - + + + +
- - - - - + + + + + +
- - - - - + + + + + +
- - - + + + +
- - - - - + + + + + +
- - - - - + + + + + +
{ static displayName = 'Bullet'; render() { - const { className } = this.props; + const { children } = this.props; return ( - + + + {children} + + ); } } diff --git a/lib/components/Bullet/__snapshots__/Bullet.test.tsx.snap b/lib/components/Bullet/__snapshots__/Bullet.test.tsx.snap index e2d988043ff..9b7839895c6 100644 --- a/lib/components/Bullet/__snapshots__/Bullet.test.tsx.snap +++ b/lib/components/Bullet/__snapshots__/Bullet.test.tsx.snap @@ -2,32 +2,48 @@ exports[`Bullet Theme: jobStreet Default 1`] = `
  • - Bullet + + Bullet +
  • `; exports[`Bullet Theme: seekAnz Default 1`] = `
  • - Bullet + + Bullet +
  • `; exports[`Bullet Theme: seekAsia Default 1`] = `
  • - Bullet + + Bullet +
  • `; exports[`Bullet Theme: wireframe Default 1`] = `
  • - Bullet + + Bullet +
  • `; diff --git a/lib/components/BulletList/BulletList.tsx b/lib/components/BulletList/BulletList.tsx index 316d40e2cb2..fe73c6945e0 100644 --- a/lib/components/BulletList/BulletList.tsx +++ b/lib/components/BulletList/BulletList.tsx @@ -1,12 +1,16 @@ -import React, { Component } from 'react'; -import Box, { BoxProps } from '../Box/Box'; +import React, { Component, ReactNode } from 'react'; +import Box from '../Box/Box'; -export type BulletListProps = BoxProps; +export interface BulletListProps { + children?: ReactNode; +} export default class BulletList extends Component { static displayName = 'BulletList'; render() { - return ; + const { children } = this.props; + + return {children}; } } diff --git a/lib/components/Card/Card.docs.tsx b/lib/components/Card/Card.docs.tsx index 3e297e2252e..a3f52761611 100644 --- a/lib/components/Card/Card.docs.tsx +++ b/lib/components/Card/Card.docs.tsx @@ -10,28 +10,30 @@ const docs: ComponentDocs = { label: 'Standard Card', render: () => ( - - This text is inside a card. + + + This text is inside a card. + - - This text is inside a card. + + + This text is inside a card. + ) diff --git a/lib/components/Card/Card.tsx b/lib/components/Card/Card.tsx index 67715d2b3f7..0f5528711f0 100644 --- a/lib/components/Card/Card.tsx +++ b/lib/components/Card/Card.tsx @@ -1,12 +1,20 @@ -import React, { Component } from 'react'; -import Box, { BoxProps } from '../Box/Box'; +import React, { Component, ReactNode } from 'react'; +import Box from '../Box/Box'; -export type CardProps = BoxProps; +export interface CardProps { + children?: ReactNode; +} export default class Card extends Component { static displayName = 'Card'; render() { - return ; + const { children } = this.props; + + return ( + + {children} + + ); } } diff --git a/lib/components/Card/__snapshots__/Card.test.tsx.snap b/lib/components/Card/__snapshots__/Card.test.tsx.snap index 7b8fe529365..7031be0ad96 100644 --- a/lib/components/Card/__snapshots__/Card.test.tsx.snap +++ b/lib/components/Card/__snapshots__/Card.test.tsx.snap @@ -2,32 +2,48 @@ exports[`Card Theme: jobStreet Default 1`] = `
    - Children +
    + Children +
    `; exports[`Card Theme: seekAnz Default 1`] = `
    - Children +
    + Children +
    `; exports[`Card Theme: seekAsia Default 1`] = `
    - Children +
    + Children +
    `; exports[`Card Theme: wireframe Default 1`] = `
    - Children +
    + Children +
    `; diff --git a/lib/components/Checkbox/Checkbox.css.js b/lib/components/Checkbox/Checkbox.css.js index 6c09204099c..a8212aa1ff6 100644 --- a/lib/components/Checkbox/Checkbox.css.js +++ b/lib/components/Checkbox/Checkbox.css.js @@ -67,7 +67,7 @@ export default { '.children': { display: 'none' }, - '.realCheckbox:checked ~ .content > * > .children': { + '.realCheckbox:checked ~ .content > .children': { display: 'block' } }; diff --git a/lib/components/Checkbox/Checkbox.tsx b/lib/components/Checkbox/Checkbox.tsx index 62f6cafc8d6..f7948b49a90 100644 --- a/lib/components/Checkbox/Checkbox.tsx +++ b/lib/components/Checkbox/Checkbox.tsx @@ -1,6 +1,5 @@ import React, { Component, ReactNode, AllHTMLAttributes } from 'react'; import classnames from 'classnames'; -import { Omit } from 'utility-types'; import ThemeConsumer from '../ThemeConsumer/ThemeConsumer'; import getCheckboxRadioSize from '../private/getCheckboxRadioSize'; import Box from '../Box/Box'; @@ -22,18 +21,15 @@ const textColorForState = (disabled: boolean, hovered: boolean) => { return 'neutral'; }; +type InputProps = AllHTMLAttributes; +type RequiredInputProps = 'id' | 'checked' | 'onChange'; +type OptionalInputProps = 'disabled' | 'children'; export interface CheckboxProps - extends Omit, 'label'> { - variant?: 'default' | 'inChecklistCard'; - id: string; - checked: boolean; + extends Required>, + Pick { label: ReactNode; - disabled?: boolean; - inputProps?: object; - labelProps?: object; tone?: 'neutral' | 'critical' | 'positive'; message?: ReactNode | false; - messageProps?: object; children?: ReactNode; } @@ -68,60 +64,34 @@ export default class Checkbox extends Component { {theme => { const { - variant, id, checked, + onChange, label, disabled = false, - className, - style, - inputProps, - labelProps, tone, message, - messageProps, - children, - ...restProps + children } = this.props; const { hovered } = this.state; - const inChecklistCard = variant === 'inChecklistCard'; const fieldMessageId = `${id}-message`; const checkboxSize = getCheckboxRadioSize(theme); return ( - +
    { ) }} htmlFor={id} - {...labelProps} onMouseOver={this.handleMouseOver} onMouseOut={this.handleMouseOut} > { theme.atoms.transition.fast )} /> - {!inChecklistCard ? ( - - ) : null} - + + + { {children ? ( - - {children} - + {children} ) : null}
    {message !== false ? ( - - - + ) : null} - +
    ); }}
    diff --git a/lib/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap b/lib/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap index 8e5e48ab9ea..5efcca48293 100644 --- a/lib/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +++ b/lib/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap @@ -1,9 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Checkbox Theme: jobStreet Checked 1`] = ` -
    +
    - - - + + + +
    +
    - - - + + + +
    -
    - Children -
    + Children
    +
    - - - + + + +
    -
    - Children -
    + Children
    +
    - - - + + + +
    +
    - - - + + + +
    -
    - Children -
    + Children
    - - - + + + +
    Message
    @@ -446,9 +448,7 @@ exports[`Checkbox Theme: jobStreet With message 1`] = ` `; exports[`Checkbox Theme: seekAnz Checked 1`] = ` -
    +
    - - - + + + +
    +
    - - - + + + +
    -
    - Children -
    + Children
    +
    - - - + + + +
    -
    - Children -
    + Children
    +
    - - - + + + +
    +
    - - - + + + +
    -
    - Children -
    + Children
    - - - + + + +
    Message
    @@ -891,9 +895,7 @@ exports[`Checkbox Theme: seekAnz With message 1`] = ` `; exports[`Checkbox Theme: seekAsia Checked 1`] = ` -
    +
    - - - + + + +
    +
    - - - + + + +
    -
    - Children -
    + Children
    +
    - - - + + + +
    -
    - Children -
    + Children
    +
    - - - + + + +
    +
    - - - + + + +
    -
    - Children -
    + Children
    - - - + + + +
    Message
    @@ -1336,9 +1342,7 @@ exports[`Checkbox Theme: seekAsia With message 1`] = ` `; exports[`Checkbox Theme: wireframe Checked 1`] = ` -
    +
    - - - + + + +
    +
    - - - + + + +
    -
    - Children -
    + Children
    +
    - - - + + + +
    -
    - Children -
    + Children
    +
    - - - + + + +
    +
    - - - + + + +
    -
    - Children -
    + Children
    - - - + + + +
    Message
    diff --git a/lib/components/ChecklistCard/ChecklistCard.docs.tsx b/lib/components/ChecklistCard/ChecklistCard.docs.tsx deleted file mode 100644 index b6c9cc58c4b..00000000000 --- a/lib/components/ChecklistCard/ChecklistCard.docs.tsx +++ /dev/null @@ -1,121 +0,0 @@ -import React from 'react'; -import ChecklistCard from './ChecklistCard'; -import Checkbox from '../Checkbox/Checkbox'; -import Text from '../Text/Text'; -import { ComponentDocs } from '../../../docs/src/types'; - -const handleChange = () => undefined; - -const docs: ComponentDocs = { - examples: [ - { - label: 'Standard Checklist Card', - render: ({ id }) => ( - - - - - - ) - }, - { - label: 'Nested Checklist Card', - render: ({ id }) => ( - - - This text is visible when the checkbox is checked. - - - This text is visible when the checkbox is checked. - - - This text is visible when the checkbox is checked. - - - ) - }, - { - label: 'Nested Checklist Card With Critical Messages', - render: ({ id }) => ( - - - This text is visible when the checkbox is checked. - - - This text is visible when the checkbox is checked. - - - This text is visible when the checkbox is checked. - - - This text is visible when the checkbox is checked. - - - ) - } - ] -}; - -export default docs; diff --git a/lib/components/ChecklistCard/ChecklistCard.test.tsx b/lib/components/ChecklistCard/ChecklistCard.test.tsx deleted file mode 100644 index f11dd5b2c5c..00000000000 --- a/lib/components/ChecklistCard/ChecklistCard.test.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; -import { ChecklistCard, Checkbox } from '..'; -import { render } from 'react-testing-library'; -import forEachTheme from '../../test/utils/forEachTheme'; - -const noop = () => undefined; - -describe('ChecklistCard', () => { - forEachTheme(({ ThemeProvider }) => { - test('Default', () => { - const { container } = render( - - - - - - - - ); - expect(container.firstChild).toMatchSnapshot(); - }); - }); -}); diff --git a/lib/components/ChecklistCard/ChecklistCard.tsx b/lib/components/ChecklistCard/ChecklistCard.tsx deleted file mode 100644 index b01e6d3bcdf..00000000000 --- a/lib/components/ChecklistCard/ChecklistCard.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import React, { Component, Fragment, ReactElement } from 'react'; -import Card, { CardProps } from '../Card/Card'; -import Divider from '../Divider/Divider'; -import { CheckboxProps } from '../Checkbox/Checkbox'; -import { RadioProps } from '../Radio/Radio'; - -export interface ChecklistCardProps extends CardProps { - children: - | Array> - | Array> - | ReactElement - | ReactElement; -} - -export default class ChecklistCard extends Component { - static displayName = 'ChecklistCard'; - - render() { - const { children, ...restProps } = this.props; - return ( - - {React.Children.map(children, (child, i) => { - if (typeof child !== 'object') { - return null; - } - - const checkboxChild = child as ReactElement; - - return ( - - {i > 0 && checkboxChild.props.tone !== 'critical' ? ( - - ) : null} - {React.cloneElement(child, { - variant: 'inChecklistCard' - })} - - ); - })} - - ); - } -} diff --git a/lib/components/ChecklistCard/__snapshots__/ChecklistCard.test.tsx.snap b/lib/components/ChecklistCard/__snapshots__/ChecklistCard.test.tsx.snap deleted file mode 100644 index 07775e38b85..00000000000 --- a/lib/components/ChecklistCard/__snapshots__/ChecklistCard.test.tsx.snap +++ /dev/null @@ -1,961 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ChecklistCard Theme: jobStreet Default 1`] = ` -
    -
    - -
    -