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,12 +75,18 @@ export default class ColorPicker extends Component {
zIndex: '100', zIndex: '100',
}, },
}; };
return (
<div> if (position === 'top') {
styles.wrapper.transform = 'translateY(-100%)';
styles.wrapper.paddingBottom = 8;
}
const swatch = (
<div style={styles.swatch} onClick={this.handleClick}> <div style={styles.swatch} onClick={this.handleClick}>
<div style={styles.color} /> <div style={styles.color} />
</div> </div>
{this.state.displayColorPicker ? ( );
const picker = this.state.displayColorPicker ? (
<div style={styles.popover}> <div style={styles.popover}>
<div style={styles.cover} onClick={this.handleClose} /> <div style={styles.cover} onClick={this.handleClose} />
<div style={styles.wrapper}> <div style={styles.wrapper}>
@ -91,8 +98,11 @@ export default class ColorPicker extends Component {
/> />
</div> </div>
</div> </div>
) : null} ) : null;
</div>
); 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',