Improve checkbox
This commit is contained in:
@@ -39,7 +39,7 @@ export class Login extends React.Component {
|
|||||||
reactAutoBind(this)
|
reactAutoBind(this)
|
||||||
this.state = {
|
this.state = {
|
||||||
waitModal: false,
|
waitModal: false,
|
||||||
messageModal: { icon: 'hold', message: 'Wait there just a second', detail: 'This is just a test' },
|
messageModal: null,
|
||||||
binder: new FormBinder({}, Login.bindings)
|
binder: new FormBinder({}, Login.bindings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class Checkbox extends Component {
|
|||||||
value: PropTypes.bool,
|
value: PropTypes.bool,
|
||||||
label: PropTypes.string,
|
label: PropTypes.string,
|
||||||
visible: PropTypes.bool,
|
visible: PropTypes.bool,
|
||||||
// disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,27 +27,26 @@ class Checkbox extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { visible, name, label } = this.props
|
const { visible, name, label, disabled } = this.props
|
||||||
|
const { checked } = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={[!visible && { display: 'none' }]}>
|
<div style={[!visible && { display: 'none' }]}>
|
||||||
<div style={[style.checkbox, !this.state.checked && style.checkboxUnchecked]} onClick={this.onClick}>
|
<div style={[style.checkbox, disabled ? style.checkboxDisabled : !checked ? style.checkboxUnchecked : null]}
|
||||||
<div style={[style.checkmark, !this.state.checked && style.checkmarkUnchecked]} />
|
onClick={disabled ? null : this.onClick}>
|
||||||
|
<input id={name} type='checkbox' style={style.input} disabled={disabled} />
|
||||||
|
<div style={[style.checkmark, !checked && style.checkmarkUnchecked]} />
|
||||||
</div>
|
</div>
|
||||||
{ /* TODO: Move this into .style.js */ }
|
<label
|
||||||
{ /* TODO: Implement disabled */ }
|
htmlFor={name}
|
||||||
{ /* TODO: Add checkbox input element back in */ }
|
style={[style.label, {
|
||||||
{ /* TODO: Use an actual label element with a for (shortid) */ }
|
|
||||||
<span name={name}
|
|
||||||
style={{
|
|
||||||
verticalAlign: 'top',
|
verticalAlign: 'top',
|
||||||
fontSize: fontInfo.size.medium,
|
fontSize: fontInfo.size.medium,
|
||||||
fontFamily: fontInfo.family,
|
fontFamily: fontInfo.family,
|
||||||
color: fontInfo.color.normal,
|
color: disabled ? fontInfo.color.dimmed : fontInfo.color.normal,
|
||||||
marginLeft: 10
|
}]}>
|
||||||
}}>
|
|
||||||
{label}
|
{label}
|
||||||
</span>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,35 @@
|
|||||||
import { colorInfo } from './style'
|
import { colorInfo, sizeInfo } from './style'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
checkbox: {
|
checkbox: {
|
||||||
|
position: 'relative',
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
position: 'relative',
|
|
||||||
backgroundColor: colorInfo.buttonBackground,
|
backgroundColor: colorInfo.buttonBackground,
|
||||||
height: 25,
|
height: sizeInfo.checkboxSize,
|
||||||
width: 25,
|
width: sizeInfo.checkboxSize,
|
||||||
|
':hover': {
|
||||||
|
backgroundColor: colorInfo.buttonBackgroundHover
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
input: {
|
||||||
|
position: 'absolute',
|
||||||
|
opacity: 0,
|
||||||
|
cursor: 'pointer',
|
||||||
},
|
},
|
||||||
|
|
||||||
checkboxUnchecked: {
|
checkboxUnchecked: {
|
||||||
backgroundColor: '#E0E0E0',
|
backgroundColor: colorInfo.uncheckedCheckbox,
|
||||||
':hover': {
|
':hover': {
|
||||||
backgroundColor: '#C0C0C0'
|
backgroundColor: colorInfo.uncheckedCheckboxHover,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
checkboxDisabled: {
|
||||||
|
backgroundColor: colorInfo.disabledButtonBackground,
|
||||||
|
},
|
||||||
|
|
||||||
checkmark: {
|
checkmark: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
content: '',
|
content: '',
|
||||||
@@ -27,10 +40,14 @@ export default {
|
|||||||
borderStyle: 'solid',
|
borderStyle: 'solid',
|
||||||
borderColor: '#FFFFFF',
|
borderColor: '#FFFFFF',
|
||||||
borderWidth: '0 3px 3px 0',
|
borderWidth: '0 3px 3px 0',
|
||||||
transform: 'rotate(45deg)'
|
transform: 'rotate(45deg)',
|
||||||
},
|
},
|
||||||
|
|
||||||
checkmarkUnchecked: {
|
checkmarkUnchecked: {
|
||||||
display: 'none'
|
display: 'none'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
label: {
|
||||||
|
marginLeft: 10,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class Text extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { margin, width, align } = this.props
|
const { margin, width, align, children } = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span style={{
|
<span style={{
|
||||||
@@ -32,7 +32,7 @@ class Text extends Component {
|
|||||||
textAlign: align,
|
textAlign: align,
|
||||||
margin,
|
margin,
|
||||||
width,
|
width,
|
||||||
}}>{this.props.children}</span>
|
}}>{children}</span>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ export const colorInfo = {
|
|||||||
buttonBackgroundHover: '#3CB0FD',
|
buttonBackgroundHover: '#3CB0FD',
|
||||||
headerButtonBackground: '#FAFAFA',
|
headerButtonBackground: '#FAFAFA',
|
||||||
headerButtonBackgroundHover: '#DADADA',
|
headerButtonBackgroundHover: '#DADADA',
|
||||||
disabledButtonBackground: '#A0A0A0',
|
disabledButtonBackground: '#E0E0E0',
|
||||||
modalBackground: '#FFFFFF',
|
modalBackground: '#FFFFFF',
|
||||||
|
uncheckedCheckbox: '#A0A0A0',
|
||||||
|
uncheckedCheckboxHover: '#808080',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sizeInfo = {
|
export const sizeInfo = {
|
||||||
@@ -17,6 +19,7 @@ export const sizeInfo = {
|
|||||||
headerBorderWidth: 1,
|
headerBorderWidth: 1,
|
||||||
buttonHeight: 40,
|
buttonHeight: 40,
|
||||||
minButtonWidth: 100,
|
minButtonWidth: 100,
|
||||||
|
checkboxSize: 25,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fontInfo = {
|
export const fontInfo = {
|
||||||
|
|||||||
Reference in New Issue
Block a user