diff --git a/docs/public/style.css b/docs/public/style.css index b54aad583b..f032fcb752 100644 --- a/docs/public/style.css +++ b/docs/public/style.css @@ -11,6 +11,13 @@ body { opacity: 0; } +blockquote { + border-left: 3px solid rgba(34, 36, 38, .15); + margin-left: 0; + padding-left: 10px; + font-style: italic; +} + h1:hover > .anchorjs-link:not(:hover), h2:hover > .anchorjs-link:not(:hover), h3:hover > .anchorjs-link:not(:hover), @@ -59,9 +66,11 @@ code:not(.hljs)::after { background: #fff; box-shadow: 0 1px 2px #ccc; } + .docs-example:hover { box-shadow: 0 2px 8px #bbb; } + .docs-example.active { box-shadow: 0 8px 32px #aaa; } @@ -109,6 +118,7 @@ code:not(.hljs)::after { font-size: 13px; color: #aaa; } + .carbon-text:hover { color: #ddd; } @@ -120,6 +130,7 @@ code:not(.hljs)::after { opacity: 0.5; white-space: nowrap; } + .carbon-poweredby:hover { color: #ddd; } diff --git a/docs/src/components/CodeEditor/CodeEditor.js b/docs/src/components/CodeEditor/CodeEditor.js index 9822e09a88..83f9ff37c5 100644 --- a/docs/src/components/CodeEditor/CodeEditor.js +++ b/docs/src/components/CodeEditor/CodeEditor.js @@ -5,6 +5,7 @@ import Ace from 'react-ace' import 'brace' import 'brace/ext/language_tools' import 'brace/mode/jsx' +import 'brace/mode/json' import 'brace/mode/html' import 'brace/mode/sh' import 'brace/theme/tomorrow_night' @@ -95,7 +96,7 @@ const semanticUIReactCompleter = { }, } -const CodeEditor = props => ( +const CodeEditor = (props) => ( formatCode(val, 'html'), + json: (val) => val, + jsx: (val) => formatCode(val, 'babel').replace(/^; val.replace(/^/g, '$ '), +} + const CodeSnippet = ({ fitted, label, mode, value, ...rest }) => (
{label || mode}
@@ -34,10 +41,7 @@ const CodeSnippet = ({ fitted, label, mode, value, ...rest }) => ( readOnly showGutter={false} showCursor={false} - value={(mode === 'sh' - ? value.replace(/^/g, '$ ') - : formatCode(value, mode === 'html' ? 'html' : 'babel') - ).trim()} + value={formatters[mode](value).trim()} {...rest} />
@@ -46,7 +50,7 @@ const CodeSnippet = ({ fitted, label, mode, value, ...rest }) => ( CodeSnippet.propTypes = { fitted: PropTypes.bool, label: PropTypes.string, - mode: PropTypes.oneOf(['html', 'jsx', 'sh']), + mode: PropTypes.oneOf(['html', 'json', 'jsx', 'sh']), value: PropTypes.string.isRequired, } diff --git a/docs/src/components/DocumentationPage/components.js b/docs/src/components/DocumentationPage/components.js index 57f17d4a9f..e2233a1d05 100644 --- a/docs/src/components/DocumentationPage/components.js +++ b/docs/src/components/DocumentationPage/components.js @@ -10,11 +10,14 @@ import CodeSnippet from 'docs/src/components/CodeSnippet' export const a = ({ children, href }) => {children} -export const code = ({ className, children }) => { - const mode = className.replace('language-', '') - - return -} +export const code = ({ className, children, fitted, label }) => ( + +) export const h1 = ({ children }) =>
diff --git a/docs/src/components/Sidebar/Sidebar.js b/docs/src/components/Sidebar/Sidebar.js index 7f17413f66..d843ff1578 100644 --- a/docs/src/components/Sidebar/Sidebar.js +++ b/docs/src/components/Sidebar/Sidebar.js @@ -120,7 +120,7 @@ class Sidebar extends Component { menuItemsByType = _.map((nextType) => { const items = _.flow( _.filter(({ type }) => type === nextType), - _.map(info => ( + _.map((info) => ( - Usage + Get Started + + + Augmentation + + + Shorthand Props Theming - Layouts + Layout examples Prototypes @@ -238,7 +244,7 @@ class Sidebar extends Component { + +React components are inherently composable. Semantic UI React makes them even more so with the `as` prop feature: you can control the rendered HTML tag, or render one component as another component. + +```jsx +<> + // will produce } content='Content' /> + // 💡 has identical effect to the previous one + Show} content={{ content: 'Content' }} /> + // ⛔ example below has broken styling, see section about React Element + Show} content={
Content
} /> + +``` + +## Disable shorthand's rendering + +It is also possible to pass falsy values (`false`, `null` or `undefined`) to shorthand prop - in that case there will be nothing rendered for the component's shorthand. + +```jsx + +``` + +## React Element as value + +There are cases where it might be necessary to customize element tree that will be rendered as a shorthand's value. Returning to `Button` example, we might want to render `` instead of default `` element. In that case necessary element might be directly provided as shorthand value: + +```jsx +