forked from elastic/eui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EuiColorPalettePicker (elastic#3192)
* Adding initial code * Adding initial code * Adding getLinearGradient method * Improving palettes * initial tests * More improvements * Deleting palettes file * Adding display togles * Simplifying button * Custom option value * Update some types * getFixedLinearGradient * Text as an option * Improving props description * Improving sass * Adding selectionDisplay * More examples * Addressing pr review * Update src-docs/src/views/color_picker/color_palette_picker.tsx Co-authored-by: Caroline Horn <[email protected]> * Update src/components/color_picker/color_palette_picker/color_palette_picker.tsx Co-authored-by: Caroline Horn <[email protected]> * Update src/components/color_picker/color_palette_picker/color_palette_picker.tsx Co-authored-by: Caroline Horn <[email protected]> * Extending EuiSuperSelectProp * Simplifying structure * Changelog * Improving example * Improving snippet * Adding more tests * Improving props description * Improving docs text * Improve text * Addressing review * Update src/components/color_picker/utils.ts Co-authored-by: Greg Thompson <[email protected]> * Update src/components/color_picker/utils.ts Co-authored-by: Greg Thompson <[email protected]> * Update src/components/color_picker/color_palette_picker/color_palette_picker.tsx Co-authored-by: Greg Thompson <[email protected]> * Update src/components/color_picker/color_palette_picker/color_palette_picker.tsx Co-authored-by: Greg Thompson <[email protected]> * Update src/components/color_picker/utils.ts Co-authored-by: Greg Thompson <[email protected]> * Update src/components/color_picker/color_palette_picker/color_palette_picker.tsx Co-authored-by: Greg Thompson <[email protected]> * Improving TS * Improving palette doc * Palette doc * Changing name of gray palette * Slimming the description a bit * removing console log * more strict types * Update src/components/color_picker/color_palette_picker/color_palette_picker.tsx Co-authored-by: cchaos <[email protected]> Co-authored-by: Caroline Horn <[email protected]> Co-authored-by: Greg Thompson <[email protected]>
- Loading branch information
1 parent
ed9d7b7
commit 02edfaa
Showing
14 changed files
with
967 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
@import 'hue'; | ||
@import 'saturation'; | ||
@import 'color_stops/index'; | ||
@import 'color_palette_picker/index'; |
Oops, something went wrong.