-
Notifications
You must be signed in to change notification settings - Fork 858
Adds prepend and append to the EuiColorPicker #2819
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
Merged
thompsongl
merged 8 commits into
elastic:master
from
elizabetdev:color-picker-prepend-append
Feb 4, 2020
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4aab989
Adding prepend and append to the color picker
elizabetdev df6348a
Adding missing className
elizabetdev f44ed23
Updating tests
elizabetdev fe0152f
Adding changelog
elizabetdev 10d1715
Merge branch 'master' into color-picker-prepend-append
elizabetdev 944d7dc
Fixing border radius when in group
elizabetdev b1d1764
Improving prepend and append props description
elizabetdev c818e18
Addibg missing popover className
elizabetdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -17,7 +17,10 @@ import { EuiFocusTrap } from '../focus_trap'; | |
| import { EuiFlexGroup, EuiFlexItem } from '../flex'; | ||
| // @ts-ignore | ||
| import { EuiFieldText } from '../form/field_text'; | ||
| import { EuiFormControlLayout } from '../form/form_control_layout'; | ||
| import { | ||
| EuiFormControlLayout, | ||
| EuiFormControlLayoutProps, | ||
| } from '../form/form_control_layout'; | ||
| import { EuiI18n } from '../i18n'; | ||
| import { EuiPopover } from '../popover'; | ||
| import { | ||
|
|
@@ -77,6 +80,16 @@ export interface EuiColorPickerProps | |
| * Array of hex strings (3 or 6 character) to use as swatch options. Defaults to EUI visualization colors | ||
| */ | ||
| swatches?: string[]; | ||
|
|
||
| /** | ||
| * Creates an input group with element(s) coming before input. It only shows when the `display` is set to `default`. | ||
| */ | ||
| prepend?: EuiFormControlLayoutProps['prepend']; | ||
|
|
||
| /** | ||
| * Creates an input group with element(s) coming after input. It only shows when the `display` is set to `default`. | ||
| */ | ||
| append?: EuiFormControlLayoutProps['append']; | ||
| } | ||
|
|
||
| function isKeyboardEvent( | ||
|
|
@@ -102,6 +115,8 @@ export const EuiColorPicker: FunctionComponent<EuiColorPickerProps> = ({ | |
| readOnly = false, | ||
| swatches = VISUALIZATION_COLORS, | ||
| popoverZIndex, | ||
| prepend, | ||
| append, | ||
| }) => { | ||
| const [isColorSelectorShown, setIsColorSelectorShown] = useState(false); | ||
| const [colorAsHsv, setColorAsHsv] = useState( | ||
|
|
@@ -124,13 +139,17 @@ export const EuiColorPicker: FunctionComponent<EuiColorPickerProps> = ({ | |
| }, [color, lastHex]); | ||
|
|
||
| const classes = classNames('euiColorPicker', className); | ||
| const popoverClass = 'euiColorPicker__popoverAnchor'; | ||
| const panelClasses = classNames('euiColorPicker__popoverPanel', { | ||
| 'euiColorPicker__popoverPanel--pickerOnly': mode === 'picker', | ||
| 'euiColorPicker__popoverPanel--customButton': button, | ||
| }); | ||
| const swatchClass = 'euiColorPicker__swatchSelect'; | ||
| const testSubjAnchor = 'colorPickerAnchor'; | ||
| const testSubjPopover = 'colorPickerPopover'; | ||
| const inputClasses = classNames('euiColorPicker__input', { | ||
| 'euiColorPicker__input--inGroup': prepend || append, | ||
| }); | ||
|
|
||
| const handleOnChange = (hex: string) => { | ||
| setLastHex(hex); | ||
|
|
@@ -313,7 +332,9 @@ export const EuiColorPicker: FunctionComponent<EuiColorPickerProps> = ({ | |
| readOnly={readOnly} | ||
| fullWidth={fullWidth} | ||
| compressed={compressed} | ||
| onKeyDown={handleToggleOnKeyDown}> | ||
| onKeyDown={handleToggleOnKeyDown} | ||
| prepend={prepend} | ||
| append={append}> | ||
| <div | ||
| // Used to pass the chosen color through to form layout SVG using currentColor | ||
| style={{ color: showColor && color ? color : undefined }}> | ||
|
|
@@ -325,7 +346,7 @@ export const EuiColorPicker: FunctionComponent<EuiColorPickerProps> = ({ | |
| ]}> | ||
| {([openLabel, closeLabel]: string[]) => ( | ||
| <EuiFieldText | ||
| className="euiColorPicker__input" | ||
| className={inputClasses} | ||
| onClick={handleInputActivity} | ||
| onKeyDown={handleInputActivity} | ||
| value={color ? color.toUpperCase() : ''} | ||
|
|
@@ -360,6 +381,7 @@ export const EuiColorPicker: FunctionComponent<EuiColorPickerProps> = ({ | |
| isOpen={isColorSelectorShown} | ||
| closePopover={handleFinalSelection} | ||
| zIndex={popoverZIndex} | ||
| className={popoverClass} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| panelClassName={panelClasses} | ||
| display={button ? 'inlineBlock' : 'block'} | ||
| attachToAnchor={button ? false : true} | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Uh oh!
There was an error while loading. Please reload this page.