Skip to content

Allow passing props to value input in color stop popover#4669

Merged
flash1293 merged 5 commits intoelastic:masterfrom
flash1293:inputprops
Mar 30, 2021
Merged

Allow passing props to value input in color stop popover#4669
flash1293 merged 5 commits intoelastic:masterfrom
flash1293:inputprops

Conversation

@flash1293
Copy link
Copy Markdown
Contributor

Summary

Fixes #4587

This PR adds the ability to pass props to the value input element in the color stop thumb popover from the consumer side. This can be used to tweak the appearance a bit (e.g. using append to show a unit of the color scale)

I didn't add a documentation example as it doesn't seem important enough, but I can do so if desired

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs and playground toggles
    - [ ] Added documentation
    - [ ] Checked Code Sandbox works for the any docs examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
    - [ ] Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@flash1293 flash1293 requested a review from thompsongl March 27, 2021 13:09
@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_4669/

CHANGELOG.md Outdated
@@ -1,5 +1,7 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Added `inputValueProps` prop to `EuiColorStops`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Added `inputValueProps` prop to `EuiColorStops`
- Added `inputValueProps` prop to `EuiColorStops` ([#4669](https://github.com/elastic/eui/pull/4669))

Comment on lines +344 to +345
{...{
...(valueInputProps || {}),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interesting syntax. Was there a reason why not to simple leave the props as is and do {...valueInputProps}?

@flash1293
Copy link
Copy Markdown
Contributor Author

@cchaos No reason, that's way better, thanks.

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_4669/

Copy link
Copy Markdown
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

I agree, I don't think this needs a specific example. Thanks for the PR!

CHANGELOG.md Outdated
- Expanded `display` prop of `EuiCard` to inherit `color` values from `EuiPanel` ([#4649](https://github.com/elastic/eui/pull/4649))
- Added `element` prop to `EuiPanel` for forcing to `div` or `button` ([#4649](https://github.com/elastic/eui/pull/4649))
- Increased padding on `EuiCheckableCard` with refactor to use `EuiSplitPanel` ([#4649](https://github.com/elastic/eui/pull/4649))
- Added `inputValueProps` prop to `EuiColorStops` ([#4669](https://github.com/elastic/eui/pull/4669))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just noticed a mismatch in the prop name here

Suggested change
- Added `inputValueProps` prop to `EuiColorStops` ([#4669](https://github.com/elastic/eui/pull/4669))
- Added `valueInputProps` prop to `EuiColorStops` ([#4669](https://github.com/elastic/eui/pull/4669))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Haha, good catch!

closePopover: () => void;
'data-index'?: string;
'aria-valuetext'?: string;
valueInputProps?: Partial<EuiFieldNumberProps>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I keep waffling on whether we should be omitting the props that we don't let the consumer override here instead of just the simple Partial<>. I feel like it would make it clear to the TS consumer why valueInputProps.isInvalid isn't manually working.

showAlpha?: EuiColorPickerProps['showAlpha'];
/**
* Props passed to the value input field in the color stop popover.
* Can be used to configure functionality like append or prepend.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎉 Thanks for the comment!

@flash1293
Copy link
Copy Markdown
Contributor Author

I keep waffling on whether we should be omitting the props that we don't let the consumer override here instead of just the simple Partial<>. I feel like it would make it clear to the TS consumer why valueInputProps.isInvalid isn't manually working.

That's a good idea, I added that to the type props of the color stop component itself. In the docs it's expanded like this:
Screenshot 2021-03-30 at 16 15 08

So it's not immediately obvious which props will work, but Typescript will help when actually using it - IMHO it's worth it.

Copy link
Copy Markdown
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

Thanks, @flash1293! LGTM

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_4669/

@flash1293 flash1293 merged commit 81deaf2 into elastic:master Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[EuiColorStops] Allow passing props to value input in color stop popover

4 participants