site: update color picker position

This commit is contained in:
afc163 2017-09-04 12:24:40 +08:00
parent 24e2af63f2
commit 6cb3ae46a2
2 changed files with 30 additions and 19 deletions

View File

@ -12,6 +12,7 @@ export default class ColorPicker extends Component {
static defaultProps = { static defaultProps = {
onChange: noop, onChange: noop,
onChangeComplete: noop, onChangeComplete: noop,
position: 'bottom',
} }
constructor(props) { constructor(props) {
@ -39,7 +40,7 @@ export default class ColorPicker extends Component {
this.props.onChangeComplete(color.hex); this.props.onChangeComplete(color.hex);
}; };
render() { render() {
const { small, type } = this.props; const { small, type, position } = this.props;
const Picker = pickers[type]; const Picker = pickers[type];
@ -74,25 +75,34 @@ export default class ColorPicker extends Component {
zIndex: '100', zIndex: '100',
}, },
}; };
return (
<div> if (position === 'top') {
<div style={styles.swatch} onClick={this.handleClick}> styles.wrapper.transform = 'translateY(-100%)';
<div style={styles.color} /> styles.wrapper.paddingBottom = 8;
</div> }
{this.state.displayColorPicker ? (
<div style={styles.popover}> const swatch = (
<div style={styles.cover} onClick={this.handleClose} /> <div style={styles.swatch} onClick={this.handleClick}>
<div style={styles.wrapper}> <div style={styles.color} />
<Picker
{...this.props}
color={this.state.color}
onChange={this.handleChange}
onChangeComplete={this.handleChangeComplete}
/>
</div>
</div>
) : null}
</div> </div>
); );
const picker = this.state.displayColorPicker ? (
<div style={styles.popover}>
<div style={styles.cover} onClick={this.handleClose} />
<div style={styles.wrapper}>
<Picker
{...this.props}
color={this.state.color}
onChange={this.handleChange}
onChangeComplete={this.handleChangeComplete}
/>
</div>
</div>
) : null;
if (position === 'top') {
return <div>{picker}{swatch}</div>;
}
return <div>{swatch}{picker}</div>;
} }
} }

View File

@ -104,6 +104,7 @@ class Footer extends React.Component {
type="sketch" type="sketch"
small small
color={this.state.color} color={this.state.color}
position="top"
presetColors={[ presetColors={[
'#f04134', '#f04134',
'#00a854', '#00a854',