Skip to content
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

Add EuiColorPalettePicker #3192

Merged
merged 59 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
7620c69
Adding initial code
miukimiu Mar 30, 2020
c13ec9c
Adding initial code
miukimiu Mar 30, 2020
8cf0339
Merge branch 'color-palette-picker' of https://github.com/miukimiu/eu…
miukimiu Mar 30, 2020
e6482ac
Merge remote-tracking branch 'upstream/master' into color-palette-picker
miukimiu Apr 22, 2020
079488a
Adding getLinearGradient method
miukimiu Apr 24, 2020
5541dbc
Improving palettes
miukimiu Apr 24, 2020
25e684e
initial tests
miukimiu Apr 24, 2020
2c353dc
More improvements
miukimiu Apr 24, 2020
f4da589
Merge remote-tracking branch 'upstream/master' into color-palette-picker
miukimiu Apr 24, 2020
b3357fe
Deleting palettes file
miukimiu Apr 27, 2020
9858418
Adding display togles
miukimiu Apr 28, 2020
5740a20
Simplifying button
miukimiu Apr 28, 2020
5996803
Custom option value
miukimiu Apr 28, 2020
d695167
Update some types
May 5, 2020
7cc2855
Merge pull request #2 from cchaos/miukimiu-color-palette-picker
miukimiu May 5, 2020
f57b801
getFixedLinearGradient
miukimiu May 6, 2020
01b88f8
Merge remote-tracking branch 'upstream/master' into color-palette-picker
miukimiu May 6, 2020
c3ae30b
Text as an option
miukimiu May 8, 2020
1ae241c
Improving props description
miukimiu May 12, 2020
94c0efd
Improving sass
miukimiu May 12, 2020
d17c797
Merge remote-tracking branch 'upstream/master' into color-palette-picker
miukimiu May 12, 2020
c2ebf33
Adding selectionDisplay
miukimiu May 14, 2020
e68ee37
Merge remote-tracking branch 'upstream/master' into color-palette-picker
miukimiu May 14, 2020
18d79da
More examples
miukimiu May 14, 2020
aaa3692
Addressing pr review
miukimiu May 15, 2020
eb2d66d
Update src-docs/src/views/color_picker/color_palette_picker.tsx
miukimiu May 15, 2020
391e49d
Update src/components/color_picker/color_palette_picker/color_palette…
miukimiu May 15, 2020
16aeb06
Update src/components/color_picker/color_palette_picker/color_palette…
miukimiu May 15, 2020
8dc7046
Merge branch 'color-palette-picker' of https://github.com/miukimiu/eu…
miukimiu May 15, 2020
1f9c89a
Extending EuiSuperSelectProp
miukimiu May 15, 2020
ddec2ca
Simplifying structure
miukimiu May 15, 2020
9020be3
Merge remote-tracking branch 'upstream/master' into color-palette-picker
miukimiu May 15, 2020
1ad7005
Changelog
miukimiu May 15, 2020
b4bd5c3
Improving example
miukimiu May 15, 2020
12d841d
Improving snippet
miukimiu May 15, 2020
2477f90
Adding more tests
miukimiu May 20, 2020
b165463
Improving props description
miukimiu May 20, 2020
32d3ea1
Improving docs text
miukimiu May 20, 2020
3b86ed2
Merge remote-tracking branch 'upstream/master' into color-palette-picker
miukimiu May 20, 2020
c2bf5b2
Improve text
miukimiu May 21, 2020
6983edd
Merge remote-tracking branch 'upstream/master' into color-palette-picker
miukimiu May 26, 2020
c199152
Merge remote-tracking branch 'upstream/master' into color-palette-picker
miukimiu May 28, 2020
1d9c50b
Addressing review
miukimiu May 28, 2020
6dfb4e4
Update src/components/color_picker/utils.ts
miukimiu May 28, 2020
dab0fc3
Update src/components/color_picker/utils.ts
miukimiu May 28, 2020
4d69d19
Update src/components/color_picker/color_palette_picker/color_palette…
miukimiu May 28, 2020
aa276d9
Update src/components/color_picker/color_palette_picker/color_palette…
miukimiu May 28, 2020
4743542
Merge branch 'color-palette-picker' of https://github.com/miukimiu/eu…
miukimiu May 28, 2020
4e4d2e5
Update src/components/color_picker/utils.ts
miukimiu May 28, 2020
8e558e5
Update src/components/color_picker/color_palette_picker/color_palette…
miukimiu May 28, 2020
77b7bc8
Improving TS
miukimiu May 28, 2020
7794f0b
Improving palette doc
miukimiu May 28, 2020
45c7323
Palette doc
miukimiu May 28, 2020
a6674a3
Changing name of gray palette
cchaos May 29, 2020
344ab48
Slimming the description a bit
cchaos May 29, 2020
9003578
removing console log
miukimiu Jun 1, 2020
93fc2b9
more strict types
thompsongl Jun 2, 2020
ee7b0b7
Update src/components/color_picker/color_palette_picker/color_palette…
miukimiu Jun 2, 2020
62dc72c
Merge pull request #5 from thompsongl/color-palette-picker
miukimiu Jun 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Added exports for `EuiSteps` and related components types ([#3471](https://github.com/elastic/eui/pull/3471))
- Added `displayName` to components using `React.forwardRef` ([#3451](https://github.com/elastic/eui/pull/3451))
- Added event target checker for `EuiOverlayMask`'s `onClick` prop ([#3462](https://github.com/elastic/eui/pull/3462))
- Added `EuiColorPalettePicker` component ([#3192](https://github.com/elastic/eui/pull/3192))
- Added `left-start` popover placement to `EuiDatePicker` ([#3511](https://github.com/elastic/eui/pull/3511))

**Bug Fixes**
Expand All @@ -30,7 +31,6 @@
- Added `partition` key to `EuiChartThemeType` for Partition chart support ([#3387](https://github.com/elastic/eui/pull/3387))
- Updated `EuiImage`'s `caption` prop type from `string` to `ReactNode` ([#3387](https://github.com/elastic/eui/pull/3387))
- Improved contrast for `EuiCollapsibleNav` close button ([#3465](https://github.com/elastic/eui/pull/3465))
- Added exports for `EuiSteps` and related components types ([#3471](https://github.com/elastic/eui/pull/3471))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this removal was accidental?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it's weird in master this line doesn't exist: https://github.com/elastic/eui/blob/master/CHANGELOG.md


**Bug Fixes**

Expand Down
92 changes: 92 additions & 0 deletions src-docs/src/views/color_picker/color_palette_picker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import React, { useState } from 'react';
import {
euiPaletteColorBlind,
euiPaletteForStatus,
euiPaletteForTemperature,
} from '../../../../src/services';
import { EuiSwitch } from '../../../../src/components/form';
import { EuiSpacer } from '../../../../src/components/spacer';
import { EuiCode } from '../../../../src/components/code';
import {
EuiColorPalettePicker,
EuiColorPalettePickerPaletteProps,
} from '../../../../src/components/color_picker/color_palette_picker';
// @ts-ignore
import { DisplayToggles } from '../form_controls/display_toggles';

const palettes: EuiColorPalettePickerPaletteProps[] = [
{
value: 'pallette_1',
title: 'EUI color blind (fixed)',
palette: euiPaletteColorBlind(),
type: 'fixed',
},
{
value: 'pallette_2',
title: 'EUI palette for temperature (fixed)',
palette: euiPaletteForTemperature(5),
type: 'fixed',
},
{
value: 'pallette_3',
title: 'Grayscale (gradient with stops)',
palette: [
{
stop: 100,
color: 'white',
},
{
stop: 250,
color: 'gray',
},
{
stop: 350,
color: 'dimgray',
},
{
stop: 470,
color: 'black',
},
],
type: 'gradient',
},
{
value: 'pallette_4',
title: 'EUI palette for status (gradient)',
palette: euiPaletteForStatus(5),
type: 'gradient',
},
{
value: 'custom',
title: 'Plain text as a custom option',
type: 'text',
},
];

export const ColorPalettePicker = () => {
const [selectionDisplay, setSelectionDisplay] = useState(false);
const [pallette, setPallette] = useState('pallette_1');

return (
<>
<EuiSwitch
label={
<span>
Display selected item as a <EuiCode>title</EuiCode>
</span>
}
checked={selectionDisplay}
onChange={() => setSelectionDisplay(!selectionDisplay)}
/>
<EuiSpacer />
<DisplayToggles canPrepend={true} canAppend={true} canReadOnly={false}>
<EuiColorPalettePicker
palettes={palettes}
onChange={setPallette}
valueOfSelected={pallette}
selectionDisplay={selectionDisplay ? 'title' : 'palette'}
/>
</DisplayToggles>
</>
);
};
58 changes: 56 additions & 2 deletions src-docs/src/views/color_picker/color_picker_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import { GuideSectionTypes } from '../../components';
import {
EuiCode,
EuiColorPicker,
EuiColorPalettePicker,
EuiColorStops,
EuiSpacer,
EuiText,
} from '../../../../src/components';
import { EuiColorPalettePickerPalette } from './props';
cchaos marked this conversation as resolved.
Show resolved Hide resolved

import { ColorPicker } from './color_picker';
const colorPickerSource = require('!!raw-loader!./color_picker');
Expand All @@ -23,6 +25,23 @@ const colorPickerSnippet = `<EuiColorPicker
/>
`;

import { ColorPalettePicker } from './color_palette_picker';
const colorPalettePickerSource = require('!!raw-loader!./color_palette_picker');
const colorPalettePickerHtml = renderToHtml(ColorPalettePicker);
const colorPalettePickerSnippet = `<EuiColorPalettePicker
palettes={[
{
value: 'palette1',
title: 'Palette 1',
palette: euiPaletteColorBlind(),
type: 'fixed',
},
]}
onChange={onPaletteChange}
valueOfSelected={palette}
/>
`;

import { ColorStops } from './color_stops';
const colorStopsSource = require('!!raw-loader!./color_stops');
const colorStopsHtml = renderToHtml(ColorStops);
Expand Down Expand Up @@ -248,8 +267,10 @@ export const ColorPickerExample = {
<React.Fragment>
<EuiText>
<p>
Two components exist to aid color selection:{' '}
<strong>EuiColorPicker</strong> and <strong>EuiColorStops</strong>.
Three components exist to aid color selection:{' '}
<strong>EuiColorPicker</strong>,{' '}
<strong>EuiColorPalettePicker</strong> and{' '}
<strong>EuiColorStops</strong>.
</p>
</EuiText>
<EuiSpacer />
Expand Down Expand Up @@ -291,6 +312,39 @@ export const ColorPickerExample = {
snippet: colorPickerSnippet,
demo: <ColorPicker />,
},
{
title: 'Color palette picker',
text: (
<React.Fragment>
<EuiText>
<p>
Use <strong>EuiColorPalettePicker</strong> to select palettes to
apply colors to data visualization like maps and charts.
</p>
<p>
Use the <EuiCode>palettes</EuiCode> prop to pass your palettes as
an array of objects. For each object, you should pass a palette
(array of hex values) and specify the <EuiCode>type</EuiCode>. Use{' '}
<EuiCode>fixed</EuiCode> palettes for categorical data and{' '}
<EuiCode>gradient</EuiCode> palettes for continuous data.
</p>
</EuiText>
</React.Fragment>
),
source: [
{
type: GuideSectionTypes.JS,
code: colorPalettePickerSource,
},
{
type: GuideSectionTypes.HTML,
code: colorPalettePickerHtml,
},
],
props: { EuiColorPalettePicker, EuiColorPalettePickerPalette },
snippet: colorPalettePickerSnippet,
demo: <ColorPalettePicker />,
},
{
title: 'Color stops',
text: (
Expand Down
7 changes: 7 additions & 0 deletions src-docs/src/views/color_picker/props.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React, { FunctionComponent } from 'react';

import { EuiColorPalettePickerPaletteProps } from '../../../../src/components/color_picker/color_palette_picker';

export const EuiColorPalettePickerPalette: FunctionComponent<
EuiColorPalettePickerPaletteProps
> = () => <div />;
1 change: 1 addition & 0 deletions src/components/color_picker/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
@import 'hue';
@import 'saturation';
@import 'color_stops/index';
@import 'color_palette_picker/index';
Loading