-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SharedUX] Migrate PageTemplate > NoDataPage > NoDataCard #127025
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally - great storybook addition! LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple quick comments, but in general should there also be Markdown docs pages being created next to these components?
import { EuiCardProps } from '@elastic/eui'; | ||
import { MouseEventHandler, ReactNode } from 'react'; | ||
|
||
export type NoDataPageActions = Partial<EuiCardProps> & { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why separate the component type into a separate file?
Also since it's the direct props of NoDataCard, let's name it consistently:
export type NoDataPageActions = Partial<EuiCardProps> & { | |
export type NoDataCardProps = Partial<EuiCardProps> & { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this type will be reused for ElasticAgentCard
once I migrate it over, so that component can read from types
file as well.
...plugins/shared_ux/public/components/page_template/no_data_page/no_data_card/no_data_card.tsx
Outdated
Show resolved
Hide resolved
...shared_ux/public/components/page_template/no_data_page/no_data_card/no_data_card.stories.tsx
Outdated
Show resolved
Hide resolved
...shared_ux/public/components/page_template/no_data_page/no_data_card/no_data_card.stories.tsx
Outdated
Show resolved
Hide resolved
src/plugins/shared_ux/public/components/page_template/no_data_page/no_data_card/index.ts
Outdated
Show resolved
Hide resolved
...shared_ux/public/components/page_template/no_data_page/no_data_card/no_data_card.stories.tsx
Outdated
Show resolved
Hide resolved
...plugins/shared_ux/public/components/page_template/no_data_page/no_data_card/no_data_card.tsx
Outdated
Show resolved
Hide resolved
/** | ||
* Applies the `Recommended` beta badge and makes the button `fill` | ||
*/ | ||
recommended?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recommended?: boolean; | |
isRecommended?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to be changing prop names at this time, as I don't know where down the line in PageTemplate is this component used, and renaming them all will add additional work.
src/plugins/shared_ux/public/components/page_template/no_data_page/no_data_card/types.ts
Show resolved
Hide resolved
src/plugins/shared_ux/public/components/page_template/no_data_page/no_data_card/types.ts
Outdated
Show resolved
Hide resolved
/** | ||
* Provide just a string for the button's label, or a whole component | ||
*/ | ||
button?: string | ReactNode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cchaos How does EUI handle this kind of flexibility? Is there a pattern?
@majagrubic Be sure this is the TS type you want to use.
https://dev.to/fromaline/jsxelement-vs-reactelement-vs-reactnode-2mh2
https://github.com/typescript-cheatsheets/react#useful-react-prop-type-examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure there's a specific pattern, but the idea here is that the consumer can supply just the button label (string) or replace the whole button their own (in case they don't want to use the same medium, filled button). I guess technically string
is included in ReactNode
, so maybe that's duplicative. But I think the explicitness here is helpful because an element would replace the whole default EuiButton where the string is just the label. Up to you all if you think there's a better pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I was thinking maybe string | EuiButtonProps
.
<Card button="Click Me" />
<Card button={{ label: 'Click Me', onClick: () => {}, fill: true }} />
Then we'd have some control over precisely what component we rendered there, and could force a fill
or color
to keep the usage consistent, now or in the future.
It's probably minor, but I'm one who leans toward keeping the contract strict at the start, and then expanding outward as necessary, to avoid large-scale refactors later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do that. But specifically EuiButton doesn't have a label
prop, it's label is just the children
, so you'd likely need to append this prop type or rely on consumers to pass children
as a key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, I think the problem with that, that I'm now remembering, is that you can't go from say an EuiButton to EuiEmptyButton by props alone since they're completely different components. So an example is if the footer button is actually not a CTA we want to promote, or say we need to provide 2 actions instead of just one, there's no way to remove the default button without replacing it completely with a ReactNode
.
src/plugins/shared_ux/public/components/page_template/no_data_page/no_data_card/types.ts
Outdated
Show resolved
Hide resolved
@clintandrewhall do you know how and why |
c55c35b
to
ba87e76
Compare
ba87e76
to
112e6d9
Compare
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @majagrubic !
...shared_ux/public/components/page_template/no_data_page/no_data_card/no_data_card.stories.tsx
Outdated
Show resolved
Hide resolved
…page/no_data_card/no_data_card.stories.tsx Co-authored-by: Caroline Horn <[email protected]>
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Summary
This is a first PR in migrating
PageTemplate
fromkibana_react
toshared_ux
plugin. This PR tacklesNoDataCard
component. It is not exported from the plugin, as it's not used outside ofPageTemplate
.Part of #122961
Checklist
Delete any items that are not applicable to this PR.
- [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list- [ ] This renders correctly on smaller devices using a responsive layout. (You can test this in your browser)- [ ] This was checked for cross-browser compatibilityFor maintainers