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

95 lines
2.2 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 ({ titleBar, theme, handleTitleBarChange, copyable, code }) => (
<div className="window-controls">
7 years ago
{theme === 'bw' ? <ControlsBW /> : <Controls />}
<div className="window-title-container">
<input
6 years ago
aria-label="Image Title"
Add preset feature (#595) * Add preset feature without create * fix lint errors * Add presets to Editor state * add remove, update -> apply, omit presets * replace name with index, add undo functionality * fix reduce function * Tweaks: - Make remove filter setState atomic - Remove broken sCU in BackgroundSelect - Touch up style of arrow functions a little - Remove titleBar from default settings - Don't expose SETTINGS_KEYS - Use hasOwnProperty instead of includes() * refactor preset state into Settings * move format code into editor and make it work again * omit custom in applyPreset * move presets array state into Settings * keep custom sCU in BackgroundSelect * pull out inline objects * revert pages/index * increase Presets font-size, remove margin-top * Add ability to create presets * also enable passing exportSize as prop * move selectedPreset back into Settings (my bad Sean) * replace splice with filter, getSavedX -> getX * Revert "move selectedPreset back into Settings (my bad Sean)" This reverts commit ae5da4700ea36ad7c31e697e83a2724be4b448f4. * make sure background updates remove selected preset * selectedPreset -> preset * use onChange instead of selectPreset * use preset id's instead of indexes * bug fixes * use disabled instead of pointer-events * make .settings-presets-applied flex 💪 * make .settings-presets-arrow flex 💪 * move getPresets outside of `setState` * move inline styles to style tag * refactor using omitBy and isFunction * remove lodash.isfunction * fix applyPreset to disclude preset field * move omit to getSettingsFromProps * replace lodash.omit with omitBy solution * .includes -> .indexOf * add default preset and presetApplied state * fix lint error * remove presetApplied * add more default presets * fix default preset functionality * tweaks * preserve preset list scrollLeft b/w updates with a hack * Use ref for preset content * remove forwardRef
6 years ago
value={titleBar || ''}
type="text"
spellCheck="false"
onChange={e => handleTitleBarChange(e.target.value)}
/>
</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: 20px;
right: 16px;
}
7 years ago
`}
</style>
</div>
)