Skip to content

Feature/show command running #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Nov 18, 2019
Prev Previous commit
Next Next commit
create indeterminate loading checkbox
  • Loading branch information
ShMcK committed Nov 17, 2019
commit 121d5cbca387ebc561577d413510a32c2f7d515c
66 changes: 44 additions & 22 deletions web-app/src/components/Checkbox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,56 @@
import * as React from 'react'

const styles = {
box: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
input: {
border: '1px solid black',
backgroundColor: 'yellow',
},
box: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
input: {
border: '1px solid black',
},
loading: {
backgroundColor: 'red',
},
}

interface Props {
status: 'COMPLETE' | 'INCOMPLETE' | 'ACTIVE' | 'LOADING'
status: 'COMPLETE' | 'INCOMPLETE' | 'ACTIVE' | 'LOADING'
}

const Checkbox = (props: Props) => {
const checked = props.status === 'COMPLETE'
// const loading = props.state === 'LOADING'
const onChange = () => {
/* read */
}
return (
<div style={styles.box}>
<label>
<input style={styles.input} type="checkbox" checked={checked} onChange={onChange} />
</label>
</div>
)
const onChange = () => {
/* read only */
}

if (props.status === 'LOADING') {
return (
<div style={styles.box}>
<input
ref={input => {
/* ref because unable to apply indeterminate on jsx */
if (input) {
input.indeterminate = true
}
}}
type="checkbox"
checked={false}
disabled={true}
onChange={onChange}
/>
</div>
)
}

const checked = props.status === 'COMPLETE'

return (
<div style={styles.box}>
<label>
<input style={styles.input} type="checkbox" checked={checked} onChange={onChange} />
</label>
</div>
)
}

export default Checkbox