Switching to @Radium decorator

This commit is contained in:
John Lyon-Smith
2018-03-22 15:27:12 -07:00
parent 06ae76047e
commit 1b35ac8b22
32 changed files with 115 additions and 122 deletions

View File

@@ -370,11 +370,6 @@
"integrity": "sha1-GcenYEc3dEaPILLS0DNyrX1Mv10=", "integrity": "sha1-GcenYEc3dEaPILLS0DNyrX1Mv10=",
"dev": true "dev": true
}, },
"auto-bind2": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/auto-bind2/-/auto-bind2-1.0.3.tgz",
"integrity": "sha512-+br9nya9M8ayHjai7m9rdpRxuEr8xcYRDrIp7HybNe0ixUHbc1kDiWXKMb0ldsfWb9Zi+SqJ9JfjW8nTkYD0QQ=="
},
"autobind-decorator": { "autobind-decorator": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/autobind-decorator/-/autobind-decorator-2.1.0.tgz", "resolved": "https://registry.npmjs.org/autobind-decorator/-/autobind-decorator-2.1.0.tgz",

View File

@@ -4,7 +4,6 @@
"private": true, "private": true,
"dependencies": { "dependencies": {
"animejs": "^2.2.0", "animejs": "^2.2.0",
"auto-bind2": "^1.0.2",
"autobind-decorator": "^2.1.0", "autobind-decorator": "^2.1.0",
"eventemitter3": "^2.0.3", "eventemitter3": "^2.0.3",
"npm": "^5.7.1", "npm": "^5.7.1",

View File

@@ -9,8 +9,8 @@ import logoImage from 'images/logo.png'
import { versionInfo } from './version' import { versionInfo } from './version'
import { sizeInfo, colorInfo } from 'ui/style' import { sizeInfo, colorInfo } from 'ui/style'
import { api } from 'src/API' import { api } from 'src/API'
import { reactAutoBind } from 'auto-bind2'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import autobind from 'autobind-decorator'
export class App extends Component { export class App extends Component {
static propTypes = { static propTypes = {
@@ -19,16 +19,11 @@ export class App extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
reactAutoBind(this)
this.state = { this.state = {
loggedInUser: api.loggedInUser loggedInUser: api.loggedInUser
} }
} }
handleUpdate() {
this.setState({ loggedInUser: api.loggedInUser })
}
componentDidMount() { componentDidMount() {
api.addListener('login', this.handleUpdate) api.addListener('login', this.handleUpdate)
api.addListener('logout', this.handleUpdate) api.addListener('logout', this.handleUpdate)
@@ -39,6 +34,11 @@ export class App extends Component {
api.removeListener('logout', this.handleUpdate) api.removeListener('logout', this.handleUpdate)
} }
@autobind
handleUpdate() {
this.setState({ loggedInUser: api.loggedInUser })
}
handleLogout() { handleLogout() {
// We have to use window here because App does not have history in it's props // We have to use window here because App does not have history in it's props
window.location.replace('/logout') window.location.replace('/logout')
@@ -52,6 +52,7 @@ export class App extends Component {
window.location.replace('/profile') window.location.replace('/profile')
} }
@autobind
handleChangeTitle(title) { handleChangeTitle(title) {
this.setState({ title }) this.setState({ title })
} }

View File

@@ -7,7 +7,7 @@ import { Box, Image, Link, Text, Row, Column, BoundInput, BoundCheckbox, BoundBu
import headerLogo from 'images/deighton.png' import headerLogo from 'images/deighton.png'
import { versionInfo } from '../version' import { versionInfo } from '../version'
import { FormBinder } from 'react-form-binder' import { FormBinder } from 'react-form-binder'
import { reactAutoBind } from 'auto-bind2' import autobind from 'autobind-decorator'
import { sizeInfo, colorInfo } from 'ui/style' import { sizeInfo, colorInfo } from 'ui/style'
export class Login extends Component { export class Login extends Component {
@@ -36,7 +36,6 @@ export class Login extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
reactAutoBind(this)
this.state = { this.state = {
waitModal: false, waitModal: false,
messageModal: null, messageModal: null,
@@ -44,6 +43,7 @@ export class Login extends Component {
} }
} }
@autobind
handleSubmit(e) { handleSubmit(e) {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
@@ -79,6 +79,7 @@ export class Login extends Component {
} }
} }
@autobind
handleMessageModalDismiss() { handleMessageModalDismiss() {
this.setState({ this.setState({
messageModal: null, messageModal: null,

View File

@@ -1,6 +1,6 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { autoBind } from 'auto-bind2' import autobind from 'autobind-decorator'
import { Modal, Button, Row, Column, BoundInput, BoundButton, Text } from 'ui' import { Modal, Button, Row, Column, BoundInput, BoundButton, Text } from 'ui'
import { regExpPattern } from 'regexp-pattern' import { regExpPattern } from 'regexp-pattern'
import { FormBinder } from 'react-form-binder' import { FormBinder } from 'react-form-binder'
@@ -25,7 +25,6 @@ export class ChangeEmailModal extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
autoBind(this, (name) => (name.startsWith('handle')))
this.state = { this.state = {
binder: new FormBinder({}, ChangeEmailModal.bindings) binder: new FormBinder({}, ChangeEmailModal.bindings)
} }
@@ -36,10 +35,12 @@ export class ChangeEmailModal extends React.Component {
this.props.onDismiss(newEmail) this.props.onDismiss(newEmail)
} }
@autobind
handleClose() { handleClose() {
this.close(null) this.close(null)
} }
@autobind
handleSubmit(e) { handleSubmit(e) {
e.preventDefault() e.preventDefault()
let newEmail = null let newEmail = null
@@ -51,6 +52,7 @@ export class ChangeEmailModal extends React.Component {
this.close(newEmail) this.close(newEmail)
} }
@autobind
handleClick(e) { handleClick(e) {
this.close(null) this.close(null)
} }

View File

@@ -1,6 +1,6 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { autoBind } from 'auto-bind2' import autobind from 'autobind-decorator'
import { Modal, Button, Icon, Column, Row, Text, BoundInput, BoundButton } from 'ui' import { Modal, Button, Icon, Column, Row, Text, BoundInput, BoundButton } from 'ui'
import { FormBinder } from 'react-form-binder' import { FormBinder } from 'react-form-binder'
@@ -31,7 +31,6 @@ export class ChangePasswordModal extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
autoBind(this, (name) => (name.startsWith('handle')))
this.state = { this.state = {
binder: new FormBinder({}, ChangePasswordModal.bindings) binder: new FormBinder({}, ChangePasswordModal.bindings)
} }
@@ -42,10 +41,12 @@ export class ChangePasswordModal extends React.Component {
this.props.onDismiss(passwords) this.props.onDismiss(passwords)
} }
@autobind
handleClose() { handleClose() {
close(null) this.close(null)
} }
@autobind
handleSubmit(e) { handleSubmit(e) {
e.preventDefault() e.preventDefault()
let passwords = null let passwords = null
@@ -58,6 +59,7 @@ export class ChangePasswordModal extends React.Component {
this.close(passwords) this.close(passwords)
} }
@autobind
handleClick(e) { handleClick(e) {
this.close(null) this.close(null)
} }

View File

@@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { Modal, Button, Row, Column, Text, Icon } from 'ui' import { Modal, Button, Row, Column, Text, Icon } from 'ui'
import { sizeInfo } from 'ui/style' import { sizeInfo } from 'ui/style'
import { reactAutoBind } from 'auto-bind2' import autobind from 'autobind-decorator'
export class YesNoMessageModal extends React.Component { export class YesNoMessageModal extends React.Component {
static propTypes = { static propTypes = {
@@ -11,11 +11,7 @@ export class YesNoMessageModal extends React.Component {
onDismiss: PropTypes.func onDismiss: PropTypes.func
} }
constructor(props) { @autobind
super(props)
reactAutoBind(this)
}
onSubmit(e, yes) { onSubmit(e, yes) {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()

View File

@@ -2,12 +2,11 @@ import React from 'react'
import { ProfileForm } from './ProfileForm' import { ProfileForm } from './ProfileForm'
import { api } from 'src/API' import { api } from 'src/API'
import { WaitModal, MessageModal, ChangePasswordModal, ChangeEmailModal } from '../Modal' import { WaitModal, MessageModal, ChangePasswordModal, ChangeEmailModal } from '../Modal'
import { autoBind } from 'auto-bind2' import autobind from 'autobind-decorator'
export class Profile extends React.Component { export class Profile extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
autoBind(this, (name) => (name.startsWith('handle')))
const user = api.loggedInUser const user = api.loggedInUser
this.state = { this.state = {
@@ -29,6 +28,7 @@ export class Profile extends React.Component {
api.removeListener('newProfileImage', this.handleNewProfileImage) api.removeListener('newProfileImage', this.handleNewProfileImage)
} }
@autobind
handleSaved(user) { handleSaved(user) {
this.setState({ waitModal: { message: 'Updating Profile' } }) this.setState({ waitModal: { message: 'Updating Profile' } })
api.updateUser(user).then((updatedUser) => { api.updateUser(user).then((updatedUser) => {
@@ -44,14 +44,17 @@ export class Profile extends React.Component {
}) })
} }
@autobind
handleMessageModalDismiss() { handleMessageModalDismiss() {
this.setState({ messageModal: null }) this.setState({ messageModal: null })
} }
@autobind
handleChangePassword() { handleChangePassword() {
this.setState({ changePasswordModal: true }) this.setState({ changePasswordModal: true })
} }
@autobind
handleProgress(uploadData) { handleProgress(uploadData) {
if (this.state.progressModal) { if (this.state.progressModal) {
this.setState({ uploadPercent: Math.round(uploadData.uploadedChunks / uploadData.numberOfChunks * 100) }) this.setState({ uploadPercent: Math.round(uploadData.uploadedChunks / uploadData.numberOfChunks * 100) })
@@ -61,10 +64,12 @@ export class Profile extends React.Component {
} }
} }
@autobind
handleUploadCancel(result) { handleUploadCancel(result) {
this.setState({ progressModal: null }) this.setState({ progressModal: null })
} }
@autobind
handleChangePasswordDismiss(passwords) { handleChangePasswordDismiss(passwords) {
this.setState({ changePasswordModal: false }) this.setState({ changePasswordModal: false })
@@ -86,10 +91,12 @@ export class Profile extends React.Component {
} }
} }
@autobind
handleChangeEmail() { handleChangeEmail() {
this.setState({ changeEmailModal: {} }) this.setState({ changeEmailModal: {} })
} }
@autobind
handleChangeEmailDismiss(newEmail) { handleChangeEmailDismiss(newEmail) {
this.setState({ changeEmailModal: null }) this.setState({ changeEmailModal: null })
if (!newEmail) { if (!newEmail) {

View File

@@ -1,6 +1,6 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { reactAutoBind } from 'auto-bind2' import autobind from 'autobind-decorator'
import { regExpPattern } from 'regexp-pattern' import { regExpPattern } from 'regexp-pattern'
import { api } from 'src/API' import { api } from 'src/API'
import { Row, Column, BoundInput, BoundButton, BoundCheckbox, BoundEmailIcon } from 'ui' import { Row, Column, BoundInput, BoundButton, BoundCheckbox, BoundEmailIcon } from 'ui'
@@ -65,7 +65,6 @@ export class UserForm extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
reactAutoBind(this)
this.state = { this.state = {
binder: new FormBinder(this.props.user, UserForm.bindings, this.props.onModifiedChanged) binder: new FormBinder(this.props.user, UserForm.bindings, this.props.onModifiedChanged)
} }
@@ -79,6 +78,7 @@ export class UserForm extends React.Component {
} }
} }
@autobind
handleSubmit(e) { handleSubmit(e) {
e.preventDefault() e.preventDefault()
@@ -89,6 +89,7 @@ export class UserForm extends React.Component {
} }
} }
@autobind
handleReset() { handleReset() {
const { user, onModifiedChanged } = this.props const { user, onModifiedChanged } = this.props
@@ -99,10 +100,12 @@ export class UserForm extends React.Component {
} }
} }
@autobind
handleChangeEmail() { handleChangeEmail() {
this.props.onChangeEmail() this.props.onChangeEmail()
} }
@autobind
handleResendEmail() { handleResendEmail() {
this.props.onResendEmail() this.props.onResendEmail()
} }

View File

@@ -1,6 +1,6 @@
import React, { Component, Fragment } from 'react' import React, { Component, Fragment } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { reactAutoBind } from 'auto-bind2' import autobind from 'autobind-decorator'
import { UserList } from './UserList' import { UserList } from './UserList'
import { UserForm } from './UserForm' import { UserForm } from './UserForm'
import { UserFormPlaceholder } from './UserFormPlaceholder' import { UserFormPlaceholder } from './UserFormPlaceholder'
@@ -16,7 +16,6 @@ export class Users extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
reactAutoBind(this)
this.state = { this.state = {
modified: false, modified: false,
selectedUser: null, selectedUser: null,
@@ -57,6 +56,7 @@ export class Users extends Component {
} }
} }
@autobind
handleUserListClick(e, index) { handleUserListClick(e, index) {
let user = this.state.users[index] let user = this.state.users[index]
@@ -74,6 +74,7 @@ export class Users extends Component {
} }
} }
@autobind
handleSave(user) { handleSave(user) {
if (user._id) { if (user._id) {
this.setState({ waitModal: { message: 'Updating User' } }) this.setState({ waitModal: { message: 'Updating User' } })
@@ -118,10 +119,12 @@ export class Users extends Component {
} }
} }
@autobind
handleChangeEmail() { handleChangeEmail() {
this.setState({ changeEmailModal: { oldEmail: this.state.selectedUser.email } }) this.setState({ changeEmailModal: { oldEmail: this.state.selectedUser.email } })
} }
@autobind
handleResendEmail() { handleResendEmail() {
this.setState({ this.setState({
waitModal: { message: 'Resending Email...' } waitModal: { message: 'Resending Email...' }
@@ -147,6 +150,7 @@ export class Users extends Component {
}) })
} }
@autobind
handleChangeEmailDismiss(newEmail) { handleChangeEmailDismiss(newEmail) {
this.setState({ changeEmailModal: null }) this.setState({ changeEmailModal: null })
if (!newEmail) { if (!newEmail) {
@@ -178,6 +182,7 @@ export class Users extends Component {
} }
} }
@autobind
handleRemove() { handleRemove() {
this.setState({ this.setState({
yesNoModal: { yesNoModal: {
@@ -187,6 +192,7 @@ export class Users extends Component {
}) })
} }
@autobind
handleRemoveModalDismiss(yes) { handleRemoveModalDismiss(yes) {
if (yes) { if (yes) {
// TODO: Pass the _id back from the dialog input data // TODO: Pass the _id back from the dialog input data
@@ -219,6 +225,7 @@ export class Users extends Component {
}) })
} }
@autobind
handleModifiedModalDismiss(yes) { handleModifiedModalDismiss(yes) {
if (yes) { if (yes) {
this.setState({ this.setState({
@@ -234,14 +241,17 @@ export class Users extends Component {
}) })
} }
@autobind
handleMessageModalDismiss() { handleMessageModalDismiss() {
this.setState({ messageModal: null }) this.setState({ messageModal: null })
} }
@autobind
handleModifiedChanged(modified) { handleModifiedChanged(modified) {
this.setState({ modified: modified }) this.setState({ modified: modified })
} }
@autobind
handleAddNewUser() { handleAddNewUser() {
let newUser = {} let newUser = {}
let newUsers = [newUser].concat(this.state.users) let newUsers = [newUser].concat(this.state.users)

View File

@@ -2,7 +2,7 @@ import React from 'react'
import anime from 'animejs' import anime from 'animejs'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
export default class Anime extends React.Component { export class Anime extends React.Component {
static propTypes = { static propTypes = {
as: PropTypes.string, as: PropTypes.string,
children: PropTypes.node, children: PropTypes.node,

View File

@@ -1,9 +1,9 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { Button } from 'ui' import { Button } from 'ui'
import { reactAutoBind } from 'auto-bind2' import autobind from 'autobind-decorator'
export default class BoundButton extends React.Component { export class BoundButton extends React.Component {
static propTypes = { static propTypes = {
name: PropTypes.string.isRequired, name: PropTypes.string.isRequired,
text: PropTypes.string, text: PropTypes.string,
@@ -15,14 +15,12 @@ export default class BoundButton extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
reactAutoBind(this)
let { name, binder } = this.props let { name, binder } = this.props
binder.addListener(name, this.updateValue) binder.addListener(name, this.updateValue)
this.state = binder.getFieldState(name) this.state = binder.getFieldState(name)
} }
@autobind
updateValue(e) { updateValue(e) {
this.setState(e.state) this.setState(e.state)
} }

View File

@@ -1,10 +1,10 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { Checkbox } from 'ui' import { Checkbox } from 'ui'
import { reactAutoBind } from 'auto-bind2' import autobind from 'autobind-decorator'
import { fontInfo } from 'ui/style' import { fontInfo } from 'ui/style'
export default class BoundCheckbox extends React.Component { export class BoundCheckbox extends React.Component {
static propTypes = { static propTypes = {
name: PropTypes.string.isRequired, name: PropTypes.string.isRequired,
label: PropTypes.string, label: PropTypes.string,
@@ -13,10 +13,10 @@ export default class BoundCheckbox extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
reactAutoBind(this)
this.state = props.binder.getFieldState(props.name) this.state = props.binder.getFieldState(props.name)
} }
@autobind
handleChange(e, data) { handleChange(e, data) {
const { binder, name } = this.props const { binder, name } = this.props
const state = binder.getFieldState(name) const state = binder.getFieldState(name)

View File

@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import { Text, Icon } from 'ui' import { Text, Icon } from 'ui'
import { sizeInfo } from 'ui/style' import { sizeInfo } from 'ui/style'
export default class BoundEmailIcon extends React.Component { export class BoundEmailIcon extends React.Component {
static propTypes = { static propTypes = {
name: PropTypes.string, name: PropTypes.string,
binder: PropTypes.object, binder: PropTypes.object,

View File

@@ -1,9 +1,9 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { Input, Text } from 'ui' import { Input, Text } from 'ui'
import { reactAutoBind } from 'auto-bind2' import autobind from 'autobind-decorator'
export default class BoundInput extends React.Component { export class BoundInput extends React.Component {
static propTypes = { static propTypes = {
name: PropTypes.string.isRequired, name: PropTypes.string.isRequired,
message: PropTypes.string, message: PropTypes.string,
@@ -15,10 +15,10 @@ export default class BoundInput extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
reactAutoBind(this)
this.state = props.binder.getFieldState(props.name) this.state = props.binder.getFieldState(props.name)
} }
@autobind
handleChange(e) { handleChange(e) {
const { binder, name } = this.props const { binder, name } = this.props
const state = binder.getFieldState(name) const state = binder.getFieldState(name)

View File

@@ -2,7 +2,8 @@ import Radium from 'radium'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import React, { Component } from 'react' import React, { Component } from 'react'
class Box extends Component { @Radium
export class Box extends Component {
static propTypes = { static propTypes = {
borderTop: PropTypes.object, borderTop: PropTypes.object,
borderBottom: PropTypes.object, borderBottom: PropTypes.object,
@@ -53,5 +54,3 @@ class Box extends Component {
) )
} }
} }
export default Radium(Box)

View File

@@ -3,7 +3,8 @@ import PropTypes from 'prop-types'
import React, { Component } from 'react' import React, { Component } from 'react'
import { fontInfo, colorInfo, sizeInfo } from './style' import { fontInfo, colorInfo, sizeInfo } from './style'
class Button extends Component { @Radium
export class Button extends Component {
static propTypes = { static propTypes = {
text: PropTypes.node, text: PropTypes.node,
visible: PropTypes.bool, visible: PropTypes.bool,
@@ -54,5 +55,3 @@ class Button extends Component {
) )
} }
} }
export default Radium(Button)

View File

@@ -1,10 +1,11 @@
import Radium from 'radium' import Radium from 'radium'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import React, { Component } from 'react' import React, { Component } from 'react'
import { reactAutoBind } from 'auto-bind2' import autobind from 'autobind-decorator'
import { colorInfo, sizeInfo } from './style' import { colorInfo, sizeInfo } from './style'
class Checkbox extends Component { @Radium
export class Checkbox extends Component {
static propTypes = { static propTypes = {
value: PropTypes.bool, value: PropTypes.bool,
disabled: PropTypes.bool, disabled: PropTypes.bool,
@@ -62,7 +63,6 @@ class Checkbox extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
reactAutoBind(this)
this.state = { this.state = {
checked: props.value checked: props.value
} }
@@ -74,7 +74,8 @@ class Checkbox extends Component {
} }
} }
onClick(e) { @autobind
handleClick(e) {
const checked = !this.state.checked const checked = !this.state.checked
this.setState({ checked }) this.setState({ checked })
@@ -90,12 +91,10 @@ class Checkbox extends Component {
return ( return (
<div style={[Checkbox.style.checkbox, disabled ? Checkbox.style.checkboxDisabled : !checked ? Checkbox.style.checkboxUnchecked : null]} <div style={[Checkbox.style.checkbox, disabled ? Checkbox.style.checkboxDisabled : !checked ? Checkbox.style.checkboxUnchecked : null]}
onClick={disabled ? null : this.onClick}> onClick={disabled ? null : this.handleClick}>
<input id={id} type='checkbox' style={Checkbox.style.input} disabled={disabled} /> <input id={id} type='checkbox' style={Checkbox.style.input} disabled={disabled} />
<div style={[Checkbox.style.checkmark, !checked && Checkbox.style.checkmarkUnchecked]} /> <div style={[Checkbox.style.checkmark, !checked && Checkbox.style.checkmarkUnchecked]} />
</div> </div>
) )
} }
} }
export default Radium(Checkbox)

View File

@@ -2,7 +2,8 @@ import Radium from 'radium'
import React, { Component } from 'react' import React, { Component } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
class Column extends Component { @Radium
export class Column extends Component {
static propTypes = { static propTypes = {
children: PropTypes.node, children: PropTypes.node,
minHeight: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]), minHeight: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]),
@@ -41,5 +42,3 @@ Column.Item = Radium(class StackLayoutItem extends Component {
) )
} }
}) })
export default Radium(Column)

View File

@@ -1,8 +1,8 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import Radium from 'radium' import Radium from 'radium'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { reactAutoBind } from 'auto-bind2'
@Radium
export class Dimmer extends Component { export class Dimmer extends Component {
static propTypes = { static propTypes = {
active: PropTypes.bool.isRequired, active: PropTypes.bool.isRequired,
@@ -27,22 +27,15 @@ export class Dimmer extends Component {
} }
} }
constructor(props) { handleClick(e) {
super(props)
reactAutoBind(this)
}
preventPropagation(e) {
e.stopPropagation() e.stopPropagation()
} }
render() { render() {
return this.props.active ? ( return this.props.active ? (
<div style={Dimmer.style.div} onClick={this.preventPropagation}> <div style={Dimmer.style.div} onClick={this.handleClick}>
{this.props.children} {this.props.children}
</div> </div>
) : null ) : null
} }
} }
export default Radium(Dimmer)

View File

@@ -3,7 +3,8 @@ import PropTypes from 'prop-types'
import React, { Component } from 'react' import React, { Component } from 'react'
import { sizeInfo, fontInfo } from 'ui/style' import { sizeInfo, fontInfo } from 'ui/style'
class HeaderText extends Component { @Radium
export class HeaderText extends Component {
static propTypes = { static propTypes = {
text: PropTypes.string, text: PropTypes.string,
} }
@@ -31,5 +32,3 @@ class HeaderText extends Component {
) )
} }
} }
export default Radium(HeaderText)

View File

@@ -4,7 +4,7 @@ import { sizeInfo } from './style'
// See https://www.flaticon.com/packs/free-basic-ui-elements // See https://www.flaticon.com/packs/free-basic-ui-elements
export default class Icon extends Component { export class Icon extends Component {
static propTypes = { static propTypes = {
name: PropTypes.string.isRequired, name: PropTypes.string.isRequired,
size: PropTypes.number, size: PropTypes.number,

View File

@@ -3,7 +3,8 @@ import PropTypes from 'prop-types'
import React, { Component } from 'react' import React, { Component } from 'react'
import { sizeInfo } from './style' import { sizeInfo } from './style'
class Image extends Component { @Radium
export class Image extends Component {
static propTypes = { static propTypes = {
source: PropTypes.string, source: PropTypes.string,
width: PropTypes.number, width: PropTypes.number,
@@ -23,5 +24,3 @@ class Image extends Component {
) )
} }
} }
export default Radium(Image)

View File

@@ -5,7 +5,8 @@ import { colorInfo, sizeInfo, fontInfo } from 'ui/style'
// See https://stackoverflow.com/a/6891562/576235 for why we wrap the <input /> element // See https://stackoverflow.com/a/6891562/576235 for why we wrap the <input /> element
class Input extends Component { @Radium
export class Input extends Component {
static propTypes = { static propTypes = {
password: PropTypes.bool, password: PropTypes.bool,
placeholder: PropTypes.string, placeholder: PropTypes.string,
@@ -58,5 +59,3 @@ class Input extends Component {
) )
} }
} }
export default Radium(Input)

View File

@@ -3,7 +3,8 @@ import PropTypes from 'prop-types'
import React, { Component } from 'react' import React, { Component } from 'react'
import { fontInfo } from './style' import { fontInfo } from './style'
class Link extends Component { @Radium
export class Link extends Component {
static propTypes = { static propTypes = {
to: PropTypes.string, to: PropTypes.string,
size: PropTypes.string, size: PropTypes.string,
@@ -26,5 +27,3 @@ class Link extends Component {
) )
} }
} }
export default Radium(Link)

View File

@@ -4,7 +4,8 @@ import React, { Component } from 'react'
import { Box, Icon } from '.' import { Box, Icon } from '.'
import { sizeInfo, colorInfo, fontInfo } from './style' import { sizeInfo, colorInfo, fontInfo } from './style'
class List extends Component { @Radium
export class List extends Component {
static propTypes = { static propTypes = {
data: PropTypes.array, data: PropTypes.array,
render: PropTypes.func.isRequired, render: PropTypes.func.isRequired,
@@ -91,5 +92,3 @@ List.Text = Radium(class ListText extends Component {
) )
} }
}) })
export default Radium(List)

View File

@@ -3,7 +3,8 @@ import Radium from 'radium'
import { colorInfo, sizeInfo } from 'ui/style' import { colorInfo, sizeInfo } from 'ui/style'
import anime from 'animejs' import anime from 'animejs'
class Loader extends React.Component { @Radium
export class Loader extends React.Component {
render() { render() {
const size = sizeInfo.loaderSize const size = sizeInfo.loaderSize
const spacing = sizeInfo.loaderSpacing const spacing = sizeInfo.loaderSpacing
@@ -40,5 +41,3 @@ class Loader extends React.Component {
) )
} }
} }
export default Radium(Loader)

View File

@@ -4,7 +4,8 @@ import Radium from 'radium'
import { Dimmer } from 'ui' import { Dimmer } from 'ui'
import { colorInfo, sizeInfo } from 'ui/style' import { colorInfo, sizeInfo } from 'ui/style'
class Modal extends Component { @Radium
export class Modal extends Component {
static propTypes = { static propTypes = {
children: PropTypes.node, children: PropTypes.node,
open: PropTypes.bool, open: PropTypes.bool,
@@ -34,5 +35,3 @@ class Modal extends Component {
) )
} }
} }
export default Radium(Modal)

View File

@@ -4,7 +4,8 @@ import React, { Component } from 'react'
import { Icon } from '.' import { Icon } from '.'
import { sizeInfo, fontInfo, colorInfo } from 'ui/style' import { sizeInfo, fontInfo, colorInfo } from 'ui/style'
class PanelButton extends Component { @Radium
export class PanelButton extends Component {
static propTypes = { static propTypes = {
onClick: PropTypes.func, onClick: PropTypes.func,
icon: PropTypes.string.isRequired, icon: PropTypes.string.isRequired,
@@ -59,5 +60,3 @@ class PanelButton extends Component {
) )
} }
} }
export default Radium(PanelButton)

View File

@@ -2,7 +2,8 @@ import Radium from 'radium'
import React, { Component } from 'react' import React, { Component } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
class Row extends Component { @Radium
export class Row extends Component {
static propTypes = { static propTypes = {
children: PropTypes.node, children: PropTypes.node,
minWidth: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]), minWidth: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]),
@@ -41,5 +42,3 @@ Row.Item = Radium(class RowLayoutItem extends Component {
) )
} }
}) })
export default Radium(Row)

View File

@@ -3,7 +3,8 @@ import PropTypes from 'prop-types'
import React, { Component } from 'react' import React, { Component } from 'react'
import { fontInfo } from './style' import { fontInfo } from './style'
class Text extends Component { @Radium
export class Text extends Component {
static propTypes = { static propTypes = {
size: PropTypes.oneOf(['small', 'medium', 'large', 'huge']), size: PropTypes.oneOf(['small', 'medium', 'large', 'huge']),
color: PropTypes.oneOf(['normal', 'inverse', 'alert', 'dimmed']), color: PropTypes.oneOf(['normal', 'inverse', 'alert', 'dimmed']),
@@ -37,5 +38,3 @@ class Text extends Component {
) )
} }
} }
export default Radium(Text)

View File

@@ -1,22 +1,22 @@
export { default as Anime } from './Anime' export { Anime } from './Anime'
export { default as Box } from './Box' export { Box } from './Box'
export { default as Button } from './Button' export { Button } from './Button'
export { HeaderButton } from './HeaderButton' export { HeaderButton } from './HeaderButton'
export { default as HeaderText } from './HeaderText' export { HeaderText } from './HeaderText'
export { default as PanelButton } from './PanelButton' export { PanelButton } from './PanelButton'
export { default as Checkbox } from './Checkbox' export { Checkbox } from './Checkbox'
export { default as Input } from './Input' export { Input } from './Input'
export { default as Image } from './Image' export { Image } from './Image'
export { default as Text } from './Text' export { Text } from './Text'
export { default as Link } from './Link' export { Link } from './Link'
export { default as Icon } from './Icon' export { Icon } from './Icon'
export { default as List } from './List' export { List } from './List'
export { default as Modal } from './Modal' export { Modal } from './Modal'
export { default as Dimmer } from './Dimmer' export { Dimmer } from './Dimmer'
export { default as Loader } from './Loader' export { Loader } from './Loader'
export { default as Row } from './Row' export { Row } from './Row'
export { default as Column } from './Column' export { Column } from './Column'
export { default as BoundButton } from './BoundButton' export { BoundButton } from './BoundButton'
export { default as BoundCheckbox } from './BoundCheckbox' export { BoundCheckbox } from './BoundCheckbox'
export { default as BoundInput } from './BoundInput' export { BoundInput } from './BoundInput'
export { default as BoundEmailIcon } from './BoundEmailIcon' export { BoundEmailIcon } from './BoundEmailIcon'