Skip to content

Commit 80e2f0e

Browse files
author
Joe Seifi
committed
simplified aphrodite button code
1 parent e43a631 commit 80e2f0e

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

04-aphrodite/button/Button/Button.js

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { Component } from 'react'
22
import { css, StyleSheet } from 'aphrodite'
3-
import classnames from 'classnames'
43

54
const styles = StyleSheet.create({
65
btn: {
@@ -14,17 +13,13 @@ const styles = StyleSheet.create({
1413
color: '#fff',
1514
backgroundColor: '#ec4800',
1615
transition: 'all 300ms',
17-
},
18-
depressed: {
19-
color: '#848484',
20-
backgroundColor: '#bebebe',
21-
},
22-
hover: {
2316
':hover': {
2417
backgroundColor: '#f98d00'
2518
}
2619
},
27-
hoverDepressed: {
20+
depressed: {
21+
color: '#848484',
22+
backgroundColor: '#bebebe',
2823
':hover': {
2924
backgroundColor: '#bebebe'
3025
}
@@ -40,17 +35,10 @@ export class Button extends Component {
4035
})
4136

4237
render () {
43-
const normalClassnames = css(styles.btn, styles.hover, styles.hover.depressed)
44-
const depressedClassnames = css(styles.depressed, styles.hoverDepressed)
45-
const buttonClassNames = classnames(normalClassnames,
46-
{
47-
[depressedClassnames]: this.state.depressed
48-
}
49-
)
50-
38+
const { depressed } = this.state
5139
return (
5240
<button
53-
className={ buttonClassNames }
41+
className={ css(styles.btn, depressed && styles.depressed) }
5442
onClick={ this.onButtonClicked }
5543
{ ...this.props }>
5644
</button>

0 commit comments

Comments
 (0)