Add watermark feature (#274)

* Add watermark feature

* Change watermark to carbon logo

* Fix double borders
main
Jake Dexheimer 7 years ago committed by GitHub
parent 3168ddb0ad
commit 9499248e1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,7 +6,9 @@ import ResizeObserver from 'resize-observer-polyfill'
import toHash from 'tohash' import toHash from 'tohash'
import debounce from 'lodash.debounce' import debounce from 'lodash.debounce'
import ms from 'ms' import ms from 'ms'
import WindowControls from '../components/WindowControls' import WindowControls from '../components/WindowControls'
import Watermark from '../components/svg/Watermark'
import CodeMirror from '../lib/react-codemirror' import CodeMirror from '../lib/react-codemirror'
import { import {
COLORS, COLORS,
@ -121,6 +123,7 @@ class Carbon extends React.Component {
value={this.props.children} value={this.props.children}
options={options} options={options}
/> />
{config.watermark && <Watermark />}
<div id="container-bg"> <div id="container-bg">
<div className="white eliminateOnRender" /> <div className="white eliminateOnRender" />
<div className="alpha eliminateOnRender" /> <div className="alpha eliminateOnRender" />
@ -135,6 +138,14 @@ class Carbon extends React.Component {
padding: ${config.paddingVertical} ${config.paddingHorizontal}; padding: ${config.paddingVertical} ${config.paddingHorizontal};
} }
#container :global(.watermark) {
fill-opacity: 0.3;
position: absolute;
z-index: 2;
bottom: calc(${config.paddingVertical} + 16px);
right: calc(${config.paddingHorizontal} + 16px);
}
#container #container-bg { #container #container-bg {
position: absolute; position: absolute;
top: 0px; top: 0px;

@ -86,9 +86,9 @@ const SelectedItem = ({ children, isOpen, color, ...rest }) => {
const itemColor = color || COLORS.SECONDARY const itemColor = color || COLORS.SECONDARY
return ( return (
<span {...rest} tabIndex="0" className="dropdown-display"> <span {...rest} tabIndex="0" className={`dropdown-display ${isOpen ? 'is-open' : ''}`}>
<span className="dropdown-display-text">{children}</span> <span className="dropdown-display-text">{children}</span>
<div className={`dropdown-arrow ${isOpen ? 'is-reverse' : ''}`}> <div className={`dropdown-arrow`}>
<ArrowDown fill={itemColor} /> <ArrowDown fill={itemColor} />
</div> </div>
<style jsx>{` <style jsx>{`
@ -104,11 +104,16 @@ const SelectedItem = ({ children, isOpen, color, ...rest }) => {
.dropdown-display:hover { .dropdown-display:hover {
background: ${COLORS.HOVER}; background: ${COLORS.HOVER};
} }
.dropdown-display.is-open {
border-radius: 3px 3px 0 0;
}
.dropdown-display-text { .dropdown-display-text {
flex-grow: 1; flex-grow: 1;
color: ${itemColor}; color: ${itemColor};
} }
.dropdown-arrow.is-reverse { .is-open > .dropdown-arrow {
transform: rotate(180deg); transform: rotate(180deg);
} }
`}</style> `}</style>
@ -148,6 +153,11 @@ const ListItem = ({ children, color, isHighlighted, isSelected, ...rest }) => {
padding: 8px 16px; padding: 8px 16px;
border-bottom: 1px solid ${itemColor}; border-bottom: 1px solid ${itemColor};
} }
.dropdown-list-item:last-child {
border-bottom: none;
}
.dropdown-list-item:hover { .dropdown-list-item:hover {
background: ${COLORS.HOVER}; background: ${COLORS.HOVER};
} }

@ -100,6 +100,11 @@ class Settings extends React.Component {
enabled={this.props.enabled.squaredImage} enabled={this.props.enabled.squaredImage}
onChange={this.props.onChange.bind(null, 'squaredImage')} onChange={this.props.onChange.bind(null, 'squaredImage')}
/> />
<Toggle
label="Watermark"
enabled={this.props.enabled.watermark}
onChange={this.props.onChange.bind(null, 'watermark')}
/>
<ExportSizeSelect <ExportSizeSelect
selected={this.props.enabled.exportSize || '2x'} selected={this.props.enabled.exportSize || '2x'}
onChange={this.props.onChange.bind(null, 'exportSize')} onChange={this.props.onChange.bind(null, 'exportSize')}
@ -162,6 +167,7 @@ class Settings extends React.Component {
} }
.settings-settings > :global(div):first-child, .settings-settings > :global(div):first-child,
.settings-settings > :global(div):last-child,
.settings-settings > :global(.collapse) { .settings-settings > :global(.collapse) {
border-bottom: none; border-bottom: none;
} }

File diff suppressed because one or more lines are too long

@ -460,5 +460,6 @@ export const DEFAULT_SETTINGS = {
widthAdjustment: true, widthAdjustment: true,
lineNumbers: false, lineNumbers: false,
exportSize: '2x', exportSize: '2x',
titleBar: '' titleBar: '',
watermark: false
} }

Loading…
Cancel
Save