/** @jsx jsx */ import { jsx } from '@emotion/react'; // eslint-disable-line no-unused-vars import { CSSObject } from '@emotion/serialize'; import { Component } from 'react'; import CodeSandboxer, { GitInfo } from 'react-codesandboxer'; import { CodeBlock } from './markdown/renderer'; import pkg from '../packages/react-select/package.json'; import { defaultTheme } from 'react-select'; import Svg, { SvgProps } from './Svg'; const { colors } = defaultTheme; const gitInfo: GitInfo = { account: 'JedWatson', repository: 'react-select', branch: 'master', host: 'github', }; const sourceUrl = `https://github.com/${gitInfo.account}/react-select/tree/${gitInfo.branch}`; interface Props { readonly label: string; readonly raw: { readonly default: string }; readonly urlPath: string; readonly isEditable?: boolean; } interface State { readonly showCode: boolean; } export default class ExampleWrapper extends Component { state: State = { showCode: false }; static defaultProps = { isEditable: true }; renderCodeSample = () => { let { raw } = this.props; let { showCode } = this.state; if (!showCode || !raw) { return null; } else { return ; } }; renderSourceViewOption = () => { let { raw } = this.props; let { showCode } = this.state; if (!raw) { return ( ); } else { return ( this.setState({ showCode: !showCode })} title="View Source" > ); } }; renderCSBButton = () => { let { isEditable, raw, urlPath } = this.props; if (isEditable) { return ( {({ isLoading }) => ( {isLoading ? : } )} ); } else { return null; } }; render() { return (

{this.props.label}

{this.renderSourceViewOption()} {this.renderCSBButton()}
{this.renderCodeSample()} {this.props.children}
); } } const ExampleHeading = (props: any) => (
h4': { margin: 0, }, }} {...props} /> ); // ============================== // Source & Sandbox Actions // ============================== const SourceIcon = (props: Omit) => ( Source Code Icon ); const NewWindowIcon = (props: Omit) => ( New Window Icon ); const actionCSS: CSSObject = { alignItems: 'center', background: 0, border: 0, borderRadius: 3, boxSizing: 'border-box', color: colors.neutral40, cursor: 'pointer', display: 'flex', fontSize: 'inherit', height: 24, marginLeft: 2, justifyContent: 'center', position: 'relative', transition: 'background-color 150ms, box-shadow 150ms, color 150ms', width: 30, ':hover': { backgroundColor: colors.neutral5, outline: 0, }, ':active': { backgroundColor: colors.neutral10, bottom: -1, }, }; interface ActionProps { readonly css?: CSSObject; } const ButtonAction = ({ css, ...props }: ActionProps & Omit) => { return (