diff --git a/packages/dnb-design-system-portal/src/shared/inlineTags/CodeBlock.js b/packages/dnb-design-system-portal/src/shared/inlineTags/CodeBlock.js index 9970af03382..2ea377a51fd 100644 --- a/packages/dnb-design-system-portal/src/shared/inlineTags/CodeBlock.js +++ b/packages/dnb-design-system-portal/src/shared/inlineTags/CodeBlock.js @@ -3,10 +3,13 @@ * */ -import React from 'react' +import React, { PureComponent } from 'react' +import PropTypes from 'prop-types' import { css } from '@emotion/core' +import styled from '@emotion/styled' import Highlight, { defaultProps } from 'prism-react-renderer' import dnbTheme from './themes/dnb-prism-theme' +import { Button } from 'dnb-ui-lib/src' import { LiveProvider, LiveEditor, @@ -30,28 +33,7 @@ const CodeBlock = ({ } if (((props && props.scope) || isReactLive) && language === 'jsx') { - const { caption, hideCode, hideExample, ...restProps } = props - return ( - - {!hideExample && ( - - - - )} - {caption && {caption}} - {!hideCode && } - {!hideCode && } - - ) + return } else { return ( { + this.setState(() => ({ hideCode: !this.state.hideCode })) + } + togglePreview = () => { + this.setState(() => ({ hidePreview: !this.state.hidePreview })) + } + + render() { + const { code, caption, scope } = this.props + const { hideCode, hidePreview } = this.state + + return ( + + { + // console.log('error', e) + // }} + > + {!hidePreview && ( + <> + + {this.props.hideCode && ( + + )} + + {caption && {caption}} + + > + )} + + {!hideCode && ( + + )} + {hidePreview && ( + + )} + + {!hideCode && } + + + ) + } +} + +const LiveCodeEditor = styled.div` + position: relative; + + p.example-caption { + margin-bottom: -1rem; + } +` + +const Toolbar = styled.div` + position: absolute; + bottom: 0; + left: 0; + width: 100%; + + display: flex; + flex-direction: row; + align-items: space-between; + justify-content: flex-end; + + padding: 0 1rem 1rem; +` + /** Removes the last token from a code example if it's empty. */ const cleanTokens = tokens => { const tokensLength = tokens.length diff --git a/packages/dnb-design-system-portal/src/shared/inlineTags/ComponentBox.js b/packages/dnb-design-system-portal/src/shared/inlineTags/ComponentBox.js index 6acc282de4f..73bc3de25dc 100644 --- a/packages/dnb-design-system-portal/src/shared/inlineTags/ComponentBox.js +++ b/packages/dnb-design-system-portal/src/shared/inlineTags/ComponentBox.js @@ -10,7 +10,7 @@ import { getComponents } from 'dnb-ui-lib/src/components' const ComponentBox = ({ children, ...rest }) => { return ( - + {children} ) diff --git a/packages/dnb-design-system-portal/src/shared/inlineTags/Tabs.js b/packages/dnb-design-system-portal/src/shared/inlineTags/Tabs.js index 6533981bb10..9c61b779fc2 100644 --- a/packages/dnb-design-system-portal/src/shared/inlineTags/Tabs.js +++ b/packages/dnb-design-system-portal/src/shared/inlineTags/Tabs.js @@ -7,7 +7,6 @@ import React, { PureComponent } from 'react' import PropTypes from 'prop-types' import { css } from '@emotion/core' -// import styled from '@emotion/styled' import { navigate, parsePath } from 'gatsby' import { CloseButton } from 'dnb-ui-lib/src/components/modal' import { fullscreen as fullscreenIcon } from 'dnb-ui-lib/src/icons/secondary_icons' @@ -27,10 +26,6 @@ const getLocation = () => { } } -// const DemoWrapper = styled.div` -// padding: 2rem 0 0; -// ` - const tabsWrapperStyle = css` .fullscreen-page & { top: 0; @@ -101,7 +96,6 @@ class CustomTabs extends PureComponent { return ( { it('has to work with "Tabs.Content" as children Components', () => { const Comp = mount( - - first - + + first + second ) expect(Comp.find('button.selected').exists()).toBe(true) expect(Comp.find('div.dnb-tabs__content').text()).toBe('second') + expect( + Comp.find('button[aria-selected=true] span.dnb-tablink-title').text() + ).toBe('second title') }) })
{caption}