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

Icon: Auto-generate readme #67282

Merged
merged 1 commit into from
Nov 26, 2024
Merged

Icon: Auto-generate readme #67282

merged 1 commit into from
Nov 26, 2024

Conversation

mirka
Copy link
Member

@mirka mirka commented Nov 25, 2024

Companion to #67280

What?

Switch the README for Icon to an auto-generated one (see also #66035).

Why?

To improve accuracy and maintenance cost.

Testing Instructions

npm run docs:components to verify the changes to the README.

@mirka mirka added [Type] Developer Documentation Documentation for developers [Package] Components /packages/components labels Nov 25, 2024
@mirka mirka self-assigned this Nov 25, 2024
Comment on lines -7 to -12
#### With a Dashicon
Renders a raw icon without any initial styling or wrappers.

```jsx
import { Icon } from '@wordpress/components';
import { wordpress } from '@wordpress/icons';

const MyIcon = () => <Icon icon="screenoptions" />;
Copy link
Member Author

Choose a reason for hiding this comment

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

These usage examples are moved to the Storybook in #67280.

Instead, the most common use case (using an icon from @wordpress/icons) is highlighted in the main code snippet.

@@ -25,30 +25,45 @@ export type IconType =
| ( ( props: { size?: number } ) => JSX.Element )
| JSX.Element;

interface BaseProps {
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed this unnecessary layer of indirection, and inlined the prop types.

@mirka mirka marked this pull request as ready for review November 25, 2024 20:05
@mirka mirka requested a review from ajitbohra as a code owner November 25, 2024 20:05
@mirka mirka requested a review from a team November 25, 2024 20:05
Copy link

github-actions bot commented Nov 25, 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: mirka <[email protected]>
Co-authored-by: tyxla <[email protected]>

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

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

Autogenerated READM looks great 👍 🚀

Some stories seem broken, but I'll review #67280 separately, maybe you've addressed them there already.

Comment on lines -56 to -62
#### Specifying a className

```jsx
import { Icon } from '@wordpress/components';

const MyIcon = () => <Icon icon="screenoptions" className="example-class" />;
```
Copy link
Member

Choose a reason for hiding this comment

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

I don't see any mention of className in #67280, nor here. Is that intentional?

Copy link
Member Author

@mirka mirka Nov 26, 2024

Choose a reason for hiding this comment

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

Good question. We currently have kind of a mix, where some components pass through all rest props and some only pass through specific props (like className). In the former case, it is unreasonable to list out all possible props as allowed in TypeScript (id, aria-*, etc) and react-docgen-typescript suppresses them too by default, unless it's required or we add an explicit prop description.

I think almost all of our components pass through at least className, so it should be one of those things that just work and don't need to be mentioned for every component.

@mirka mirka merged commit 6cc6035 into trunk Nov 26, 2024
73 of 76 checks passed
@mirka mirka deleted the icon-autogen-readme branch November 26, 2024 13:43
@github-actions github-actions bot added this to the Gutenberg 19.8 milestone Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants