diff --git a/ui/src/shared/components/ColorDropdown.tsx b/ui/src/shared/components/ColorDropdown.tsx index bd5bf5764c..33958986d7 100644 --- a/ui/src/shared/components/ColorDropdown.tsx +++ b/ui/src/shared/components/ColorDropdown.tsx @@ -7,28 +7,41 @@ import {Dropdown, ComponentStatus, DropdownMenuColors} from 'src/clockface' // Types import {ColorLabel} from 'src/types/colors' -interface Props { +interface PassedProps { selected: ColorLabel - disabled?: boolean - stretchToFit?: boolean colors: ColorLabel[] onChoose: (colors: ColorLabel) => void } +interface DefaultProps { + disabled?: boolean + stretchToFit?: boolean + widthPixels?: number +} + +type Props = PassedProps & DefaultProps + const titleCase = (name: string) => `${name[0].toUpperCase()}${name.slice(1)}` const ColorDropdown: SFC = props => { - const {selected, colors, onChoose, disabled, stretchToFit} = props + const { + selected, + colors, + onChoose, + disabled, + stretchToFit, + widthPixels, + } = props const status = disabled ? ComponentStatus.Disabled : ComponentStatus.Default - const widthPixels = stretchToFit ? null : 124 + const width = stretchToFit ? null : widthPixels return ( {colors.map(color => ( @@ -46,4 +59,10 @@ const ColorDropdown: SFC = props => { ) } +ColorDropdown.defaultProps = { + stretchToFit: false, + disabled: false, + widthPixels: 100, +} + export default ColorDropdown diff --git a/ui/src/timeMachine/components/view_options/ThresholdItem.tsx b/ui/src/timeMachine/components/view_options/ThresholdItem.tsx index 79d69993f9..b251ae3e4e 100644 --- a/ui/src/timeMachine/components/view_options/ThresholdItem.tsx +++ b/ui/src/timeMachine/components/view_options/ThresholdItem.tsx @@ -37,7 +37,7 @@ interface State { @ErrorHandling class Threshold extends PureComponent { public static defaultProps: Partial = { - label: 'Threshold', + label: 'Value is <=', disableColor: false, isDeletable: true, isBase: false, @@ -58,19 +58,7 @@ class Threshold extends PureComponent { return (
-
- {this.props.label} - {isDeletable && - !isBase && ( -
+
{this.props.label}
{!isBase && ( { onChoose={this.handleChooseColor} disabled={disableColor} stretchToFit={isBase} + widthPixels={this.dropdownWidthPixels} /> + {isDeletable && + !isBase && ( +
) } @@ -100,6 +99,12 @@ class Threshold extends PureComponent { onChooseColor({...threshold, hex, name}) } + private get dropdownWidthPixels(): number { + const {isDeletable} = this.props + + return isDeletable ? 124 : 124 + 34 + } + private get selectedColor(): SeverityColor { const { threshold: {hex, name}, @@ -120,14 +125,6 @@ class Threshold extends PureComponent { return ComponentStatus.Valid } - private get labelClass(): string { - if (this.props.isDeletable) { - return 'threshold-item--label threshold-item--label__editable' - } else { - return 'threshold-item--label' - } - } - private handleChangeWorkingValue = (e: ChangeEvent) => { const {threshold, onValidateColorValue} = this.props const targetValue = e.target.value diff --git a/ui/src/timeMachine/components/view_options/ThresholdList.scss b/ui/src/timeMachine/components/view_options/ThresholdList.scss index b2b5e9d216..0a55f94383 100644 --- a/ui/src/timeMachine/components/view_options/ThresholdList.scss +++ b/ui/src/timeMachine/components/view_options/ThresholdList.scss @@ -5,6 +5,8 @@ and Table type cells */ +@import 'src/style/modules'; + .threshold-list { display: flex; flex-direction: column; @@ -28,7 +30,7 @@ } .threshold-item--label { - flex: 0 0 106px; + flex: 0 0 76px; display: flex; align-items: center; justify-content: space-between; @@ -40,11 +42,7 @@ border-radius: $radius; @include no-user-select(); background-color: $g4-onyx; - color: $g9-mountain; - - &.threshold-item--label__editable { - color: $g13-mist; - } + color: $g13-mist; } .threshold-item--input { diff --git a/ui/src/timeMachine/components/view_options/ThresholdList.tsx b/ui/src/timeMachine/components/view_options/ThresholdList.tsx index 0d96c75221..b978740546 100644 --- a/ui/src/timeMachine/components/view_options/ThresholdList.tsx +++ b/ui/src/timeMachine/components/view_options/ThresholdList.tsx @@ -24,7 +24,7 @@ import { } from 'src/shared/constants/thresholds' // Styles -import 'src/timeMachine/components/view_options/ThresholdList' +import 'src/timeMachine/components/view_options/ThresholdList.scss' // Types import {Color, ThresholdConfig} from 'src/types/colors'