Skip to content

Conversation

@marcysutton
Copy link
Member

@marcysutton marcysutton commented Dec 11, 2025

Summary:

To split off some of the DatePicker work, I separated the finalizing of locales. This PR needs to be integrated into the frontend repo where all the other supported locales are imported.

Consolidation of shared date functions will happen in a later follow-up: https://khanacademy.atlassian.net/browse/WB-2180

Implementation plan:

  1. Combine this PR into the base WB PR and release: WB Date Picker: initial migration #2876
  2. Integrate into the base frontend PR, starting with Storybook (if possible): https://github.com/Khan/frontend/pull/6323
  3. Integrate into the broader frontend PR, deprecating shared DatePicker/MaybeNativeDatePicker and swapping out certain components (if we can avoid doing everything with the version upgrade: https://github.com/Khan/frontend/pull/6324/

Issue: FEI-7342

Test plan:

  1. Review French Locale story: /?path=/story/packages-datepicker-datepicker--with-alternate-locale&globals=theme:thunderblocks
  2. Compare with English Locale story: /?path=/story/packages-datepicker-datepicker--open-calendar-overlay&globals=theme:thunderblocks
  3. Ensure tests pass

Cool thing to note: we get RTL support for free!

Date Picker overlay in Right to Left orientation

@changeset-bot
Copy link

changeset-bot bot commented Dec 11, 2025

🦋 Changeset detected

Latest commit: 59047af

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@khanacademy/wonder-blocks-date-picker Patch

Not sure what this means? Click here to learn what changesets are.

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

@khan-actions-bot khan-actions-bot requested a review from a team December 11, 2025 20:51
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Dec 11, 2025

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/short-wolves-remember.md, __docs__/wonder-blocks-date-picker/date-picker.stories.tsx, config/jest/css.mock.js, config/jest/test.config.js, packages/wonder-blocks-date-picker/src/components/date-picker-input.tsx, packages/wonder-blocks-date-picker/src/components/date-picker.tsx, packages/wonder-blocks-date-picker/src/components/focus-manager.tsx, packages/wonder-blocks-date-picker/src/util/temporal-locale-utils.ts, packages/wonder-blocks-date-picker/src/components/__tests__/date-picker.test.tsx, packages/wonder-blocks-date-picker/src/util/__tests__/temporal-locale-utils.test.ts

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

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

npm Snapshot: Published

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

You can install the packages in frontend by running:

./dev/tools/deploy_wonder_blocks.js --tag="PR2904"

Packages can also be installed manually by running:

pnpm add @khanacademy/wonder-blocks-<package-name>@PR2904

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

Size Change: +190 B (+0.17%)

Total Size: 115 kB

Filename Size Change
packages/wonder-blocks-date-picker/dist/es/index.js 4.82 kB +190 B (+4.11%)
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3 kB
packages/wonder-blocks-announcer/dist/es/index.js 1.74 kB
packages/wonder-blocks-badge/dist/es/index.js 2.02 kB
packages/wonder-blocks-banner/dist/es/index.js 2.01 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.92 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 755 B
packages/wonder-blocks-button/dist/es/index.js 4.25 kB
packages/wonder-blocks-card/dist/es/index.js 1.08 kB
packages/wonder-blocks-cell/dist/es/index.js 2.18 kB
packages/wonder-blocks-clickable/dist/es/index.js 2.66 kB
packages/wonder-blocks-core/dist/es/index.js 2.59 kB
packages/wonder-blocks-data/dist/es/index.js 5.48 kB
packages/wonder-blocks-dropdown/dist/es/index.js 19.5 kB
packages/wonder-blocks-form/dist/es/index.js 6.2 kB
packages/wonder-blocks-grid/dist/es/index.js 1.24 kB
packages/wonder-blocks-icon-button/dist/es/index.js 4 kB
packages/wonder-blocks-icon/dist/es/index.js 1.91 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 3.48 kB
packages/wonder-blocks-layout/dist/es/index.js 1.63 kB
packages/wonder-blocks-link/dist/es/index.js 1.52 kB
packages/wonder-blocks-modal/dist/es/index.js 7.06 kB
packages/wonder-blocks-pill/dist/es/index.js 1.31 kB
packages/wonder-blocks-popover/dist/es/index.js 4.32 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.48 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.1 kB
packages/wonder-blocks-styles/dist/es/index.js 464 B
packages/wonder-blocks-switch/dist/es/index.js 1.55 kB
packages/wonder-blocks-tabs/dist/es/index.js 3.8 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.25 kB
packages/wonder-blocks-testing/dist/es/index.js 978 B
packages/wonder-blocks-theming/dist/es/index.js 384 B
packages/wonder-blocks-timing/dist/es/index.js 1.37 kB
packages/wonder-blocks-tokens/dist/es/index.js 5.01 kB
packages/wonder-blocks-toolbar/dist/es/index.js 906 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.02 kB
packages/wonder-blocks-typography/dist/es/index.js 1.57 kB

compressed-size-action

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

A new build was pushed to Chromatic! 🚀

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

Chromatic results:

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

@marcysutton marcysutton force-pushed the FEI-7342-locales branch 2 times, most recently from fbfdd04 to 39965ca Compare December 11, 2025 20:59
@codecov
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (88d2302) to head (6cd6bf1).

Additional details and impacted files

Impacted file tree graph

@@       Coverage Diff       @@
##   WB-1112   #2904   +/-   ##
===============================
===============================

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 88d2302...6cd6bf1. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@beaesguerra beaesguerra left a comment

Choose a reason for hiding this comment

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

Thanks for working on this Marcy! Left some questions I wanted to get your thoughts on!

* Useful for overlays that render outside of normal tree with `dir="rtl"`,
* such as in consumer stories.
*/
dir?: "ltr" | "rtl";
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if dir should be determined programmatically using something like closest() to see if an ancestor has the dir attribute set. Or if we should start adding the dir prop to all components. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good idea. There's a mismatch in the frontend Storybook where the story toggle and the prop in the story code can diverge. Querying the DOM seems like a possible way to improve it!

Copy link
Member Author

Choose a reason for hiding this comment

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

Added this, along with some tests! I'll test it in frontend in my next update.

* imported from react-day-picker.
* If not provided, it will fall back to enUS.
*/
locale?: Locale;
Copy link
Member

Choose a reason for hiding this comment

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

Should we export the Locale type from wonder-blocks-date-picker so that consumers don't need to import from react-day-picker directly?

I think this is similar to @jandrade's current work with the popper migration where we encapsulate the 3rd party dependency so that consumers will only use the WB abstraction. This would make it easier if we wanted to switch out the DatePicker implementation internally

That said, if we were to export all the locale objects from WB, I'm not sure if that would all get bundled or if we support tree shaking. Or if we could do dynamic imports with that from frontend

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good question. The Locale is definitely tied to the implementation, but that was already true with DatePicker in the codebase... and moment.locale runs deep! This Locale type will already be in the codebase -- so maybe it doesn't matter? I pushed up some draft PRs to show how I'm approaching it, by leveraging the Moment locales but creating an adapter (which has the date-fns Locale type defined): https://github.com/Khan/frontend/pull/6323/changes#diff-9fd18ebd6eed39299dd5ca30a0008c8b9b2f2d9c1cd02292a537e964c143e25f

import {Temporal} from "temporal-polyfill";
import * as React from "react";

import {fr} from "react-day-picker/locale";
Copy link
Member

Choose a reason for hiding this comment

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

Related to https://github.com/Khan/wonder-blocks/pull/2904/changes#r2615159044, I wonder if it would be possible for consumers to import the locales from wonder-blocks-date-picker, rather than react-day-picker directly!

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 not really sure. We have a lot of future infrastructure work to do regarding locales in frontend, so I'd suggest we reconsider it at that time given so much is subject to change.

import {Temporal} from "temporal-polyfill";
import {CustomModifiers} from "./types";

export const enUSLocaleCode = "en-US";
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

Choose a reason for hiding this comment

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

Cool thing to note: we get RTL support for free!

Nice! Could we add snapshots for the DatePicker in RTL? And snapshots for the DatePicker in the TB theme? (I'm not sure if you had plans to go over the stories/snapshots in a later PR!)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, good call! I added some to the two overlay stories. We can fine tune them as needed!

import DatePickerOverlay from "./date-picker-overlay";

// eslint-disable-next-line import/no-unassigned-import
import "react-day-picker/style.css";
Copy link
Member Author

@marcysutton marcysutton Dec 16, 2025

Choose a reason for hiding this comment

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

After FEI pairing and looking at dependency requirements for maintaining multiple ReactDayPicker versions in frontend, I changed to importing the stylesheet and getting it into the WB bundle. That way WB can ship its direct ReactDayPicker dependencies and we don't actually have to change package.json as drastically! It seems to work with the WB CSS variable setup... at least I haven't noticed anything broken with theming.

@marcysutton marcysutton changed the title DatePicker part 2: Finalize support for locales WB DatePicker part 2: Finalize support for locales Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants