Skip to content
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

Navigator: stabilize and export APIs #64613

Open
wants to merge 28 commits into
base: trunk
Choose a base branch
from

Conversation

ciampo
Copy link
Contributor

@ciampo ciampo commented Aug 19, 2024

What?

Part of #59418
Supersedes #60927
Follow-up to #63317

Export the Navigator component, its subcomponents, and the useNavigator hook as stable APIs from the @wordpress/components package

Why?

This is part of a larger effort to remove __experimental prefix from all "experimental" components, effectively promoting them to regular stable components. See the related issue for more context.

How?

  • Spit legacy and stable exports:
    • Legacy exports will keep adopting the same naming conventions as the experimental API currently do;
    • The stable exports will adopt slightly different names and the overloaded naming convention that we agreed to apply for component components:
      • NavigatorProvider => Navigator
      • NavigatorScreen => Navigator.Screen
      • NavigatorButton => Navigator.Button
      • NavigatorBackButton => Navigator.BackButton
      • NavigatorToParentButton won't be exported since it's already deprecated in the experimental version of the component
  • Updated all JSDocs and README
  • Updated Storybook and Unit Tests to use the stable version of the component
  • Added Storybook redirect to avoid getting broken links
  • A few smaller changes:
    • Updated the internal context namespacing (which shouldn't be a breaking change since context is an internal API of the @wordpress/components package)
    • Moved away from default exports to named exports-only internally to the component

Next steps?

  • refactor existing usages in Gutenberg to stable version
  • deprecate experimental version (both in JSDocs and with a runtime warning) (+ add unit tests for deprecation warnings)

Testing Instructions

  • Technically there shouldn't be any runtime (behavioral) changes to Navigator;
  • Make sure that Storybook examples are documented correctly and work as expected;
  • Smoke test Navigator usages across the editor;
  • Review JSDocs, READMEs, and IntelliSense snippets for both legacy and stable APIs

✍️  Dev note

TBD

Copy link
Contributor Author

@ciampo ciampo Aug 19, 2024

Choose a reason for hiding this comment

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

Legacy exports have been moved to a separate legacy.ts file (including the legacy JSDocs mentioning the components with their experimental export name).

This makes it easy to have separate names from the stable version, different JSDocs, and deprecation warnings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

New exports (and their up-to-date JSDocs) have been moved to the folder's main index.ts file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All READMEs have also been updated:

  • removed experimental snippet
  • updated the naming of all Navigator sub-components, including internal links to other READMEs

Copy link
Contributor Author

@ciampo ciampo Aug 19, 2024

Choose a reason for hiding this comment

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

This file was actually renamed to packages/components/src/navigator/navigator/index.tsx, but GitHub is not picking that up

* The `NavigatorProvider` component allows rendering nested views/panels/menus
* (via the `NavigatorScreen` component and navigate between these different
* view (via the `NavigatorButton` and `NavigatorBackButton` components or the
* The `Navigator` component allows rendering nested views/panels/menus
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The top level Navigator component (previously named NavigatorProvider) is the only component for which I've kept a JSDoc for the internal implementation, because apparently Storybook uses it when displaying docs 🤷 Not sure why it doesn't use the one defined in packages/components/src/navigator/index.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it seems like the ts extension was the problem — changing it to .tsx seems to allow Storybook to pick the JSDoc up 😅 85471a9

cc @mirka

// @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
BackButton: Navigator.BackButton,
},
title: 'Components/Navigator',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the PREVIOUSLY_EXPERIMENTAL_COMPONENTS in storybook/manager-head.html to make sure old links still work

@ciampo ciampo self-assigned this Aug 19, 2024
@ciampo ciampo added [Package] Components /packages/components [Type] New API New API to be used by plugin developers or package users. labels Aug 19, 2024
@ciampo ciampo marked this pull request as ready for review August 19, 2024 14:51
@ciampo ciampo requested review from youknowriad and a team August 19, 2024 14:51
Copy link

github-actions bot commented Aug 19, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ciampo ciampo added the Needs Dev Note Requires a developer note for a major WordPress release cycle label Aug 19, 2024
@ciampo ciampo force-pushed the feat/stabilize-navigator/introduce-stable-version branch from 965220a to 85471a9 Compare August 21, 2024 15:37
Comment on lines -1106 to -1111
{
"title": "NavigatorProvider",
"slug": "navigator-provider",
"markdown_source": "../packages/components/src/navigator/navigator-provider/README.md",
"parent": "components"
},
Copy link
Member

Choose a reason for hiding this comment

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

FYI, removing things from the manifest is not going to remove it from the Block Editor Handbook 😱 There are some extra steps, see #60003 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! I'll follow-up accordingly

packages/components/CHANGELOG.md Outdated Show resolved Hide resolved
packages/components/src/navigator/index.tsx Outdated Show resolved Hide resolved
packages/components/src/navigator/index.tsx Show resolved Hide resolved
packages/components/src/navigator/index.tsx Outdated Show resolved Hide resolved
packages/components/src/navigator/test/index.tsx Outdated Show resolved Hide resolved
@ciampo
Copy link
Contributor Author

ciampo commented Aug 22, 2024

I'm going to resume work on this PR after #64675 is merged.

@tyxla
Copy link
Member

tyxla commented Aug 23, 2024

I'm going to resume work on this PR after #64675 is merged.

Sounds good. I was starting to review it, but I will halt it for now.

I wonder if it's a good idea to approach this modularly and split whatever we can to separate PRs to keep this one smaller.

@ciampo ciampo force-pushed the feat/stabilize-navigator/introduce-stable-version branch from 85471a9 to 0f2d077 Compare August 26, 2024 09:03
@ciampo
Copy link
Contributor Author

ciampo commented Aug 26, 2024

I rebased and addressed simple feedback.

I would still wait before reviewing this PR. The current plan of action is:

I've also updated the tracking issue adding all of the planned follow-up step to this PR.

I wonder if it's a good idea to approach this modularly and split whatever we can to separate PRs to keep this one smaller.

@tyxla , Even if the size of the PR is medium-large, I believe 99% of the changes left in this PR are simple renames — and in that sense I feel ok with the current size. Having said that, I'll re-assess once all dependency PRs are merged, before asking for a final round of review.

@tyxla
Copy link
Member

tyxla commented Aug 28, 2024

@tyxla , Even if the size of the PR is medium-large, I believe 99% of the changes left in this PR are simple renames — and in that sense I feel ok with the current size. Having said that, I'll re-assess once all dependency PRs are merged, before asking for a final round of review.

That makes sense, @ciampo, will help with the review once all the dependencies are merged 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Dev Note Requires a developer note for a major WordPress release cycle [Package] Components /packages/components [Type] New API New API to be used by plugin developers or package users.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants