Add toolbar hover with pixel hacks

This commit is contained in:
Lukas Martinelli 2016-12-22 14:18:07 +01:00
parent a30779193f
commit a5a7dab8e7

View file

@ -29,10 +29,10 @@ const IconText = props => <span style={{ paddingLeft: margins[0] }}>
const actionStyle = { const actionStyle = {
display: "inline-block", display: "inline-block",
padding: margins[1], padding: 12.5,
fontSize: fontSizes[4], fontSize: fontSizes[4],
cursor: "pointer", cursor: "pointer",
color: colors.white, color: colors.white,
textDecoration: 'none', textDecoration: 'none',
} }
@ -46,14 +46,30 @@ const ToolbarLink = props => <a
{props.children} {props.children}
</a> </a>
const ToolbarAction = props => <a onClick={props.onClick} class ToolbarAction extends React.Component {
static propTypes = {
onClick: React.PropTypes.func.isRequired,
}
constructor(props) {
super(props)
this.state = { hover: false }
}
render() {
return <a
onClick={this.props.onClick}
onMouseOver={e => this.setState({hover: true})}
onMouseOut={e => this.setState({hover: false})}
style={{ style={{
...actionStyle, ...actionStyle,
...props.style, ...this.props.style,
backgroundColor: this.state.hover ? colors.gray : null,
}}> }}>
{props.children} {this.props.children}
</a> </a>
}
}
export default class Toolbar extends React.Component { export default class Toolbar extends React.Component {
static propTypes = { static propTypes = {
@ -124,7 +140,8 @@ export default class Toolbar extends React.Component {
<ToolbarAction style={{ <ToolbarAction style={{
width: 180, width: 180,
textAlign: 'left', textAlign: 'left',
backgroundColor: colors.black backgroundColor: colors.black,
padding: 5,
}}> }}>
<img src="https://github.com/maputnik/editor/raw/master/media/maputnik.png" alt="Maputnik" style={{width: 30, height: 30, paddingRight: 5, verticalAlign: 'middle'}}/> <img src="https://github.com/maputnik/editor/raw/master/media/maputnik.png" alt="Maputnik" style={{width: 30, height: 30, paddingRight: 5, verticalAlign: 'middle'}}/>
<span style={{fontSize: 20, verticalAlign: 'middle' }}>Maputnik</span> <span style={{fontSize: 20, verticalAlign: 'middle' }}>Maputnik</span>