diff --git a/CHANGELOG.md b/CHANGELOG.md index 29dc190b5b..e17033c190 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Add `Indicator` component and used it in `MenuItem` and `AccordionTitle` @mnajdova ([#721](https://github.com/stardust-ui/react/pull/721)) - Expose `renderItem` and `renderSelectedItem` callbacks API for `Dropdown` @layershifter ([#746](https://github.com/stardust-ui/react/pull/746)) +### Documentation +- Refine Shorthand docs page content @kuzhelov ([#751](https://github.com/stardust-ui/react/pull/751)) + ## [v0.17.0](https://github.com/stardust-ui/react/tree/v0.17.0) (2019-01-17) [Compare changes](https://github.com/stardust-ui/react/compare/v0.16.2...v0.17.0) diff --git a/docs/src/components/CodeSnippet.tsx b/docs/src/components/CodeSnippet.tsx index 8231eed77d..f58678f11c 100644 --- a/docs/src/components/CodeSnippet.tsx +++ b/docs/src/components/CodeSnippet.tsx @@ -7,10 +7,14 @@ export interface CodeSnippetProps { fitted?: boolean label?: string mode?: 'jsx' | 'html' | 'sh' - value: string + value: string | string[] style?: React.CSSProperties } +const joinToString = (stringOrArray: string | string[]) => { + return typeof stringOrArray === 'string' ? stringOrArray : stringOrArray.join('\n') +} + const formatters = { sh: (val: string = ''): string => val.replace(/^/g, '$ '), html: (val: string = ''): string => formatCode(val, 'html'), @@ -19,7 +23,7 @@ const formatters = { const CodeSnippet = ({ fitted, label, value, mode = 'jsx', ...restProps }: CodeSnippetProps) => { const format = formatters[mode] - const formattedValue = format(value) + const formattedValue = format(joinToString(value)) // remove eof line break, they are not helpful for snippets .replace(/\n$/, '') diff --git a/docs/src/views/ShorthandProps.tsx b/docs/src/views/ShorthandProps.tsx index af300df509..469bb5a2dd 100644 --- a/docs/src/views/ShorthandProps.tsx +++ b/docs/src/views/ShorthandProps.tsx @@ -1,42 +1,251 @@ import * as React from 'react' import { NavLink } from 'react-router-dom' +import { Header } from 'semantic-ui-react' import DocPage from '../components/DocPage/DocPage' import CodeSnippet from '../components/CodeSnippet' import Button from '../../../src/components/Button/Button' -class ShorthandProps extends React.Component { - render() { - return ( - -

- Most components support two APIs: shorthand and children. With - the shorthand definition we are adding some props to the component in order - to define it’s content and behavior. -

-

- When defining the icon and text content displayed in the Button component, we can pass the - icon and content props. -

- '} /> - -

- With the children API, you are responsible for constructing the proper - markup. You are also responsible for managing the component's state, styling, and - accessibility. Due to this, you should strive to use the shorthand API wherever possible. - It is best to leave the details to the component to solve for you. -

- `, - ` `, - ``, - ].join('\n')} - /> -
-