You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
carbon/components/WindowControls.js

89 lines
2.1 KiB
JavaScript

import React from 'react'
import { useCopyTextHandler } from '@dawnlabs/tacklebox'
import { COLORS } from '../lib/constants'
import { Controls, ControlsBW } from './svg/Controls'
import CopySVG from './svg/Copy'
import CheckMark from './svg/Checkmark'
const size = 24
const CopyButton = React.memo(function CopyButton({ text }) {
const { onClick, copied } = useCopyTextHandler(text)
return (
<button onClick={onClick} aria-label="Copy Button">
{copied ? (
<CheckMark color={COLORS.GRAY} width={size} height={size} />
) : (
<CopySVG size={size} color={COLORS.GRAY} />
)}
<style jsx>
{`
button {
border: none;
cursor: pointer;
color: ${COLORS.SECONDARY};
background: transparent;
}
&:active {
outline: none;
}
`}
</style>
</button>
)
})
export default ({ theme, copyable, code }) => (
<div className="window-controls">
7 years ago
{theme === 'bw' ? <ControlsBW /> : <Controls />}
<div className="window-title-container">
<input aria-label="Image Title" type="text" spellCheck="false" />
</div>
{copyable && (
<div className="copy-button">
<CopyButton text={code} />
</div>
)}
7 years ago
<style jsx>
{`
.window-controls {
7 years ago
margin-top: -24px;
position: relative;
top: ${theme === 'bw' ? 36 : 34}px;
margin-left: ${theme === 'bw' ? 16 : 14}px;
z-index: 2;
7 years ago
}
.window-title-container {
position: absolute;
margin: 0px;
top: -3px;
left: -9px;
width: 100%;
text-align: center;
}
input {
width: 250px;
background: none;
outline: none;
border: none;
color: white;
text-align: center;
font-size: 14px;
}
.copy-button {
cursor: pointer;
position: absolute;
top: 0px;
right: 16px;
}
7 years ago
`}
</style>
</div>
)