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

LabeledField: Add a story for custom jsx for props #2426

Merged
merged 2 commits into from
Jan 15, 2025

Conversation

beaesguerra
Copy link
Member

@beaesguerra beaesguerra commented Jan 14, 2025

Summary:

The LabeledField accepts a ReactNode for the label, description, and errorMessage props already. This adds a story and documentation for this functionality!

Issue: WB-1785

Test plan:

Review Custom story docs in ?path=/docs/packages-labeledfield--docs#custom

@beaesguerra beaesguerra self-assigned this Jan 14, 2025
Copy link

changeset-bot bot commented Jan 14, 2025

⚠️ No Changeset found

Latest commit: 6af4b4c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

github-actions bot commented Jan 14, 2025

Size Change: 0 B

Total Size: 98.8 kB

ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3.77 kB
packages/wonder-blocks-banner/dist/es/index.js 1.53 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.77 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 887 B
packages/wonder-blocks-button/dist/es/index.js 4.04 kB
packages/wonder-blocks-cell/dist/es/index.js 2.01 kB
packages/wonder-blocks-clickable/dist/es/index.js 3.06 kB
packages/wonder-blocks-core/dist/es/index.js 3.52 kB
packages/wonder-blocks-data/dist/es/index.js 6.24 kB
packages/wonder-blocks-dropdown/dist/es/index.js 19.1 kB
packages/wonder-blocks-form/dist/es/index.js 6.2 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-icon-button/dist/es/index.js 2.95 kB
packages/wonder-blocks-icon/dist/es/index.js 871 B
packages/wonder-blocks-labeled-field/dist/es/index.js 1.93 kB
packages/wonder-blocks-layout/dist/es/index.js 1.82 kB
packages/wonder-blocks-link/dist/es/index.js 2.28 kB
packages/wonder-blocks-modal/dist/es/index.js 5.42 kB
packages/wonder-blocks-pill/dist/es/index.js 1.65 kB
packages/wonder-blocks-popover/dist/es/index.js 4.85 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.52 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.36 kB
packages/wonder-blocks-switch/dist/es/index.js 1.92 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.74 kB
packages/wonder-blocks-testing/dist/es/index.js 1.07 kB
packages/wonder-blocks-theming/dist/es/index.js 693 B
packages/wonder-blocks-timing/dist/es/index.js 1.8 kB
packages/wonder-blocks-tokens/dist/es/index.js 2.36 kB
packages/wonder-blocks-toolbar/dist/es/index.js 905 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.99 kB
packages/wonder-blocks-typography/dist/es/index.js 1.23 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Jan 14, 2025

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-swtrokabok.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 382
Tests with visual changes 1
Total stories 526
Inherited (not captured) snapshots [TurboSnap] 0
Tests on the build 382

@beaesguerra beaesguerra force-pushed the wb-1785-custom-example branch from e034db4 to 6af4b4c Compare January 14, 2025 18:27
@beaesguerra beaesguerra marked this pull request as ready for review January 14, 2025 18:57
@khan-actions-bot khan-actions-bot requested a review from a team January 14, 2025 18:57
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to __docs__/wonder-blocks-labeled-field/labeled-field.argtypes.ts, __docs__/wonder-blocks-labeled-field/labeled-field.stories.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

Copy link
Contributor

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (e4eb849) and published all packages with changesets to npm.

You can install the packages in webapp by running:

./services/static/dev/tools/deploy_wonder_blocks.js --tag="PR2426"

Packages can also be installed manually by running:

yarn add @khanacademy/wonder-blocks-<package-name>@PR2426

Comment on lines +603 to +606
* Custom ReactNode elements can be used for the `label`, `description`, and
* `error` props. Ideally, the styling of LabeledField should not be overridden.
* If there is a specific use case where the styling needs to be overridden,
* please reach out to the Wonder Blocks team!
Copy link
Member

Choose a reason for hiding this comment

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

praise: This is great! thanks for calling out reaching out to us!

suggestion: How do you feel about including a message mentioning that this is useful for things like toggletips? or including icons that represent meaning? This is kinda tricky as I'm a firmly believer that we should use description (or inlining content) instead of relying on Tooltips. wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm thinking we can leave it open-ended for now and see how often teams reach out about toggletips with fields. If it is a common pattern, I think we should create a separate prop for supporting the toggle tip so that it can be part of the API so it is consistent (ex: the same icon and styling/spacing is used for the hint).

Another thing to note is the contents of the label prop are wrapped with a <label> tag. I'm not sure if the toggle tip should be inside the label tag or outside, since clicking on the label will also focus on the associated field. And screen readers will read out the associated label when the field is interacted with, so the aria-label for the toggletip trigger will be included as part of that.

Inlining content in the description would simplify a lot of these things!

Another possible use case for the custom elements if adding the (optional) tag to the label. I think it isn't necessary to support this since we have the required indicator and we should stick with one of these approaches!

As always, let me know what you think!

Copy link
Member

Choose a reason for hiding this comment

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

I like that!

Copy link
Member

@jandrade jandrade left a comment

Choose a reason for hiding this comment

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

Yay!! this is an awesome wrap up. Amazing job for creating all of this for LabeledField 👏 💯 🚢 :shipit: 🚀

@beaesguerra beaesguerra merged commit c6a8cbf into feature/labeled-field Jan 15, 2025
22 checks passed
@beaesguerra beaesguerra deleted the wb-1785-custom-example branch January 15, 2025 21:06
Copy link

codecov bot commented Jan 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (3e40728) to head (6af4b4c).
Report is 2 commits behind head on feature/labeled-field.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##   feature/labeled-field   #2426   +/-   ##
=============================================
=============================================

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e40728...6af4b4c. Read the comment docs.

beaesguerra added a commit that referenced this pull request Jan 16, 2025
… `main` (#2429)

## Summary:
This PR includes the following commits:
- LabeledField (part 1): Initial set up for LabeledField component based on FieldHeading (#2322)
- LabeledField(part2): refactor to a function component (#2338)
- LabeledField(part3): Wire up attributes (#2339)
- LabeledField(part4): styling and error icon (#2344)
- LabeledField: integrate with field components and fixes (#2399)
- Use LabeledField in other component stories (#2400)
- Add more docs around different browser + screen reader behaviours for LabeledField (#2403)
- LabeledField: Make sure custom required message is shown (#2425)
- LabeledField: Add a story for custom jsx for props (#2426)
- LabeledField: fix import (#2427)

Issue: WB-1499

## Test plan:
- Confirm LabeledField is working as expected `?path=/docs/packages-labeledfield--docs`
- Review docs for LabeledField: `?path=/docs/packages-labeledfield--docs`

Author: beaesguerra

Reviewers: beaesguerra, jandrade

Required Reviewers:

Approved By: jandrade

Checks: ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ gerald, ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Check build sizes (ubuntu-latest, 20.x), ⏭️  Publish npm snapshot, ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ Chromatic - Build on regular PRs / chromatic (ubuntu-latest, 20.x), ⏭️  Chromatic - Skip on Release PR (changesets), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ gerald, ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Check build sizes (ubuntu-latest, 20.x), ⏭️  Publish npm snapshot, ✅ Chromatic - Build on regular PRs / chromatic (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏭️  Chromatic - Skip on Release PR (changesets), ✅ gerald, ⌛ undefined

Pull Request URL: #2429
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.

3 participants