diff --git a/src-docs/src/views/color_picker/color_stops.js b/src-docs/src/views/color_picker/color_stops.tsx similarity index 72% rename from src-docs/src/views/color_picker/color_stops.js rename to src-docs/src/views/color_picker/color_stops.tsx index 779a5f09bd2..a035b8e6847 100644 --- a/src-docs/src/views/color_picker/color_stops.js +++ b/src-docs/src/views/color_picker/color_stops.tsx @@ -2,6 +2,7 @@ import React, { useState } from 'react'; import { EuiColorStops, + EuiColorStopsProps, EuiFormRow, EuiRange, EuiFlexGroup, @@ -24,7 +25,9 @@ export default () => { const [value, setValue] = useState(10); const [isPopoverOpen, setIsPopoverOpen] = useState(false); - const [extendedColorStops, setExtendedColorStops] = useState([ + const [extendedColorStops, setExtendedColorStops] = useState< + EuiColorStopsProps['colorStops'] + >([ { stop: 100, color: '#54B399', @@ -39,14 +42,18 @@ export default () => { }, ]); - const handleExtendedChange = (colorStops) => { + const handleExtendedChange = ( + colorStops: EuiColorStopsProps['colorStops'] + ) => { setExtendedColorStops(colorStops); }; - const [emptyColorStops, setEmptyColorStops] = useState([]); + const [emptyColorStops, setEmptyColorStops] = useState< + EuiColorStopsProps['colorStops'] + >([]); - const handleEmptyChange = (colorStops) => { - setEmptyColorStops(colorStops); + const handleEmptyChange: EuiColorStopsProps['onChange'] = (colorStops) => { + setEmptyColorStops(colorStops as EuiColorStopsProps['colorStops']); }; const onButtonClick = () => @@ -79,8 +86,8 @@ export default () => { @@ -88,17 +95,17 @@ export default () => { handleExtendedChange} colorStops={extendedColorStops} min={100} max={400} @@ -107,8 +114,8 @@ export default () => { { { setValue(parseInt(e.target.value))} + onChange={(e) => setValue(Number(e.currentTarget.value))} showInput aria-label="Change the number of steps" min={2} diff --git a/src/components/color_picker/_index.scss b/src/components/color_picker/_index.scss index 895912e9bc9..41255ed1181 100644 --- a/src/components/color_picker/_index.scss +++ b/src/components/color_picker/_index.scss @@ -3,6 +3,5 @@ @import 'color_picker_swatch'; @import 'hue'; @import 'saturation'; -@import 'color_stops/index'; @import 'color_palette_picker/index'; @import 'color_palette_display/index'; \ No newline at end of file diff --git a/src/components/color_picker/color_picker.styles.ts b/src/components/color_picker/color_picker.styles.ts new file mode 100644 index 00000000000..7a21fa44803 --- /dev/null +++ b/src/components/color_picker/color_picker.styles.ts @@ -0,0 +1,21 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { UseEuiTheme } from '../../services'; +import { mathWithUnits } from '../../global_styling'; + +export const euiColorPickerVariables = (euiThemeContext: UseEuiTheme) => { + const euiTheme = euiThemeContext.euiTheme; + + return { + width: mathWithUnits( + [euiTheme.size.l, euiTheme.size.s], + (x, y) => x * 5 + y * 4 + ), + }; +}; diff --git a/src/components/color_picker/color_stops/__snapshots__/color_stop_thumb.test.tsx.snap b/src/components/color_picker/color_stops/__snapshots__/color_stop_thumb.test.tsx.snap index 2ae715765ae..cea181cc1c7 100644 --- a/src/components/color_picker/color_stops/__snapshots__/color_stop_thumb.test.tsx.snap +++ b/src/components/color_picker/color_stops/__snapshots__/color_stop_thumb.test.tsx.snap @@ -2,12 +2,12 @@ exports[`renders EuiColorStopThumb 1`] = `