Fix styling of listview disabled items

Summary: Also improved some paddings

Reviewed By: passy

Differential Revision: D19640179

fbshipit-source-id: 44aa91d452fc857533c638e00d4fe9648592b6f2
This commit is contained in:
Michel Weststrate
2020-01-30 07:04:08 -08:00
committed by Facebook Github Bot
parent 40359a9b68
commit c33dbce242
4 changed files with 26 additions and 9 deletions

View File

@@ -55,6 +55,7 @@ type Props = OwnProps & StateFromProps & DispatchFromProps;
const Container = styled(FlexColumn)({
width: 700,
maxHeight: 700,
padding: 8,
});
type State = {

View File

@@ -19,6 +19,7 @@ import {
colors,
View,
Tooltip,
Glyph,
} from '../ui';
import React, {Component} from 'react';
@@ -56,7 +57,7 @@ type State = {
};
const Container = styled(FlexColumn)({
padding: 8,
padding: '8 0',
});
const Line = styled(View)({
@@ -90,7 +91,7 @@ type RowComponentProps = {
label: string;
selected: boolean;
onChange: (name: string, selected: boolean) => void;
disable: boolean;
disabled: boolean;
toolTipMessage?: string;
type: SelectionType;
};
@@ -102,25 +103,35 @@ class RowComponent extends Component<RowComponentProps> {
label,
selected,
onChange,
disable,
disabled,
toolTipMessage,
type,
} = this.props;
return (
<FlexColumn>
<Tooltip
title={disable ? toolTipMessage : null}
title={disabled ? toolTipMessage : null}
options={{position: 'toRight'}}>
<Padder
paddingRight={8}
paddingRight={0}
paddingTop={8}
paddingBottom={8}
paddingLeft={8}>
<FlexRow>
<Text> {label} </Text>
paddingLeft={0}>
<FlexRow style={{alignItems: 'center'}}>
<Text color={disabled ? colors.light20 : undefined}>{label}</Text>
<Spacer />
{disabled && (
<Glyph
name="caution-triangle"
color={colors.light20}
size={12}
variant="filled"
style={{marginRight: 5}}
/>
)}
{type === 'multiple' && (
<Checkbox
disabled={disabled}
checked={selected}
onChange={selected => {
onChange(id, selected);
@@ -129,6 +140,7 @@ class RowComponent extends Component<RowComponentProps> {
)}
{type === 'single' && (
<Radio
disabled={disabled}
checked={selected}
onChange={selected => {
onChange(id, selected);
@@ -194,7 +206,7 @@ export default class ListView extends Component<Props, State> {
type={type}
selected={this.state.selectedElements.has(id)}
onChange={this.handleChange}
disable={unselectable != null}
disabled={unselectable != null}
toolTipMessage={unselectable?.toolTipMessage}
/>
);

View File

@@ -16,6 +16,7 @@ type CheckboxProps = {
checked: boolean;
/** Called when a state change is triggered */
onChange: (checked: boolean) => void;
disabled?: boolean;
};
const CheckboxContainer = styled.input({
@@ -39,6 +40,7 @@ export default class Checkbox extends PureComponent<CheckboxProps> {
type="checkbox"
checked={this.props.checked}
onChange={this.onChange}
disabled={this.props.disabled}
/>
);
}

View File

@@ -16,6 +16,7 @@ type RadioProps = {
checked: boolean;
/** Called when a state change is triggered */
onChange: (selected: boolean) => void;
disabled?: boolean;
};
const RadioboxContainer = styled.input({
@@ -39,6 +40,7 @@ export default class Radio extends PureComponent<RadioProps> {
type="radio"
checked={this.props.checked}
onChange={this.onChange}
disabled={this.props.disabled}
/>
);
}