-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Panel: Convert to TypeScript #47259
Panel: Convert to TypeScript #47259
Conversation
Not going to add to the Storybook for now because it shouldn't really be used independently. No usages in the repo either.
Size Change: +18 B (0%) Total Size: 1.31 MB
βΉοΈ View Unchanged
|
* This is used by the `Panel` component under the hood, | ||
* so it does not typically need to be used. | ||
*/ | ||
function PanelHeader( { label, children }: PanelHeaderProps ) { |
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.
Not going to add PanelHeader
the Storybook for now because it shouldn't really be used independently. No usages in the repo either. If it weren't for back compat I would remove it from the public exports.
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.
Should we consider deprecating it to discourage further usage?
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.
The thing is, I doubt anyone is using it because there is no reason to π So it's not that I want to discourage people from using it per se, it's more that I don't want to clutter our docs with something that is irrelevant to 99.9% of people.
* `PanelRow` is a generic container for rows within a `PanelBody`. | ||
* It is a flex container with a top margin for spacing. | ||
*/ | ||
export const _PanelRow = Template.bind( {} ); |
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 added this story to clarify what the default styling of PanelRow looks like. I don't quite understand why it is space-between
, but that's something we'll have to keep for back compat. Also the 8px margin-top seems way too narrow.
Though I'm wondering whether we can somehow salvage and update this component to use as #43423 π€ Something to think about!
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.
Good point! I think that Panel
overall needs a refresh (or a deprecation), especially since more and more of our UI uses ToolsPanel
. Something that we could at some point discuss with @jasmussen
Flaky tests detected in 3346967. π Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4077213550
|
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.
Changes look good to me - one question I have though is should the stories
and test
files also be converted to .ts{x}
?
You're right, most of the test files can already be converted! Done in edab3c1 π The story file and the test file for PanelBody will have to wait until PanelBody is typed. (Btw an intentional but quirky thing about the wp-components tsconfig setup is that all files are typechecked by default regardless of file extension, except for tests/stories which need to be |
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.
Well done! Left a few comments, but I'll leave final review & approval to @chad1008 as the main reviewer here π
* This is used by the `Panel` component under the hood, | ||
* so it does not typically need to be used. | ||
*/ | ||
function PanelHeader( { label, children }: PanelHeaderProps ) { |
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.
Should we consider deprecating it to discourage further usage?
|
||
/** | ||
* `PanelRow` is a generic container for rows within a `PanelBody`. | ||
* It is a flex container with a top margin for spacing. |
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 understand that these info can be useful for a dev using this component, but should we expose implementation details like layout APIs (flex) and design details (margin top) ? An interesting dilemma, I personally don't have a strong opinion
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.
For this one I decided it was necessary to mention because it's essential to what PanelRow is. Those two styles are the only reason the component exists, and I phrased it in a way that we can stick to as a contract. In other words, if it ceases to be a flex container, or if it ceases to have a top margin, I would consider it a breaking change.
* `PanelRow` is a generic container for rows within a `PanelBody`. | ||
* It is a flex container with a top margin for spacing. | ||
*/ | ||
export const _PanelRow = Template.bind( {} ); |
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.
Good point! I think that Panel
overall needs a refresh (or a deprecation), especially since more and more of our UI uses ToolsPanel
. Something that we could at some point discuss with @jasmussen
It's probably too soon to deprecate it. It's still useful in the main post inspector (Categories, tags, featured image, etc.) and I believe it's also used in the prepublish flow still. It seems fine to refactor and optimize, we can't be sure that all of it will be replaced with tools panels. There might still be use cases for the collapsible. |
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.
Looks like playwright CI tasks got stuck.. maybe you can push a new commit to force them to re-run ? |
Huh, that's strange. |
Part of #35744
What?
Converts Panel, PanelHeader, and PanelRow to TypeScript.
πββοΈ PanelBody will be done in a separate PR for easier review.
How?
This one is really straightforward in terms of types. No runtime changes.
Testing Instructions
npm run storybook:dev