Checkbox is more general

This commit is contained in:
joshaber 2016-12-07 13:51:50 -05:00
parent 885c401481
commit 45050612c8
4 changed files with 26 additions and 15 deletions

View file

@ -4,7 +4,7 @@ import { FileStatus, mapStatus, iconForStatus } from '../../models/status'
import { PathLabel } from '../lib/path-label'
import { Octicon } from '../octicons'
import { showContextualMenu } from '../main-process-proxy'
import { Checkbox, CheckboxValue } from './checkbox'
import { Checkbox, CheckboxValue } from '../lib/checkbox'
interface IChangedFileProps {
readonly path: string

View file

@ -6,7 +6,7 @@ import { List, ClickSource } from '../list'
import { WorkingDirectoryStatus } from '../../models/status'
import { DiffSelectionType } from '../../models/diff'
import { CommitIdentity } from '../../models/commit-identity'
import { Checkbox, CheckboxValue } from './checkbox'
import { Checkbox, CheckboxValue } from '../lib/checkbox'
import { ICommitMessage } from '../../lib/app-state'
import { IAutocompletionProvider } from '../autocompletion'
import { Dispatcher } from '../../lib/dispatcher'

View file

@ -9,12 +9,15 @@ export enum CheckboxValue {
interface ICheckboxProps {
/** The current value of the component. */
readonly value: CheckboxValue
readonly value?: CheckboxValue
/** The function to call on value change. */
readonly onChange?: (event: React.FormEvent<HTMLInputElement>) => void
/** The tab index of the input element. */
readonly tabIndex?: number
readonly label?: string
}
/** A checkbox component which supports the mixed value. */
@ -50,13 +53,16 @@ export class Checkbox extends React.Component<ICheckboxProps, void> {
public render() {
return (
<input
className='checkbox-component'
tabIndex={this.props.tabIndex}
type='checkbox'
onChange={this.onChange}
ref={this.onInputRef}
/>
<label className='checkbox-component'>
<input
tabIndex={this.props.tabIndex}
type='checkbox'
onChange={this.onChange}
ref={this.onInputRef}
/>
{this.props.label}
</label>
)
}
}

View file

@ -1,8 +1,13 @@
.checkbox-component {
&:focus {
// Don't know why but on Windows this is necessary to
// not have a 1px gap around the checkbox on the right
// hand side. I'm guessing it's the same on mac?
outline-offset: -1px;
display: flex;
flex-direction: row;
input {
&:focus {
// Don't know why but on Windows this is necessary to
// not have a 1px gap around the checkbox on the right
// hand side. I'm guessing it's the same on mac?
outline-offset: -1px;
}
}
}