import * as React from 'react' import { SFC } from 'react' import { useConfig } from 'docz' import lighten from 'polished/lib/color/lighten' import darken from 'polished/lib/color/darken' import Maximize from 'react-feather/dist/icons/maximize' import Minimize from 'react-feather/dist/icons/minimize' import Refresh from 'react-feather/dist/icons/refresh-cw' import Code from 'react-feather/dist/icons/code' import styled, { css } from 'styled-components' import { get as themeGet } from '@utils/theme' import { CodeSandboxLogo } from './CodeSandboxLogo' import { ActionButton, ClipboardAction } from '../Editor/elements' interface ActionsProps { theme: any withRadius: boolean } const borderColor = themeGet('colors.border') const getActionsBg = (p: ActionsProps) => p.theme.docz.mode === 'light' ? lighten(0.13, borderColor(p)) : darken(0.04, borderColor(p)) const Actions = styled.div` display: flex; justify-content: flex-end; padding: 0 5px; background: ${getActionsBg}; ` const actionStyle = css` padding: 3px 10px; border-left: 1px solid ${borderColor}; ` const Action = styled(ActionButton)>` ${actionStyle}; ` const Clipboard = styled(ClipboardAction)` ${actionStyle}; ` export interface ActionsBarProps { code: string showEditor: boolean fullscreen: boolean codesandboxUrl: string onClickRefresh: () => void onClickFullscreen: () => void onClickEditor: () => void } export const ActionsBar: SFC = ({ showEditor, code, fullscreen, codesandboxUrl, onClickRefresh, onClickFullscreen, onClickEditor, }) => { const config = useConfig() const hasSandbox = Boolean(config.codeSandbox) return ( {hasSandbox && ( )} {fullscreen ? : } ) }