From e7732c3499077c5bc63ab92a6ef298c0982b76f4 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 23 Jan 2019 09:45:46 +0100 Subject: [PATCH] fix: sending in a true React Component with a title, did not work properly on #tabs --- .../src/shared/inlineTags/CodeBlock.js | 134 +++++++++++++++--- .../src/shared/inlineTags/ComponentBox.js | 2 +- .../src/shared/inlineTags/Tabs.js | 6 - .../dnb-ui-lib/src/components/tabs/Tabs.js | 25 ++-- .../components/tabs/__tests__/Tabs.test.js | 9 +- 5 files changed, 132 insertions(+), 44 deletions(-) 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 && ( +
+ + )} + + {!hideCode && ( + + )} + {hidePreview && ( +