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

Calendar component #1325

Merged
merged 5 commits into from
Dec 5, 2023
Merged

Calendar component #1325

merged 5 commits into from
Dec 5, 2023

Conversation

matheusps
Copy link
Contributor

@matheusps matheusps commented Nov 30, 2023

Summary

  • Create the calendar component
  • Create the store package
  • Improve locale to support react-aria components
  • Add invariant() util
  • Add warning() util
  • Add extended-components layer

Examples

<Calendar />

Controled

const now = today(getLocalTimeZone())
const [value, setValue] = useState(now)

<Calendar value={value} onChange={setValue} />

Localized

<LocaleProvider locale="en-US">
  <Calendar />
</LocaleProvider>

@matheusps matheusps self-assigned this Nov 30, 2023
Copy link

vercel bot commented Nov 30, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
shoreline-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2023 0:49am

Copy link

Hi @matheusps! Thanks for opening this PR. Please set the applicable project fields and labels to this PR to improve our workflow. You can do this by clicking on the "Projects" tab on the right side of the PR page and expanding the tab to set other fields, and by clicking on the "Labels" tab on top of it and selecting the applicable labels.

Copy link
Contributor

@lucasaarcoverde lucasaarcoverde left a comment

Choose a reason for hiding this comment

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

packages/date/src/calendar/calendar-provider.tsx Outdated Show resolved Hide resolved
packages/date/src/calendar/calendar.tsx Outdated Show resolved Hide resolved
packages/date/src/calendar/calendar.tsx Outdated Show resolved Hide resolved
packages/theme/src/preflight.css Outdated Show resolved Hide resolved
Comment on lines +18 to +19
{/** Some react-aria components require this to translate */}
<I18nProvider locale={locale}>{children}</I18nProvider>
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we use their provider instead then? Or maybe port whatever makes this required to our own locale provider? It seems to me that it does the same job we're doing here.

Or maybe just use the provider from react-aria on the components that require it.

Ref: https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/i18n/src/context.tsx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tried using it on each component, but it caused DX issues since it must wrap the hooks. Though in using the locale instead of wrapping it - buuut it would make the lib stuck on react-aria to do intl even in non-react-aria components. So, I've decided to plug into the LocaleProvider :)

packages/date/src/calendar/calendar-cell.tsx Show resolved Hide resolved
@matheusps matheusps merged commit 6dd5f67 into main Dec 5, 2023
7 checks passed
@matheusps matheusps deleted the feature/calendar branch December 5, 2023 12:59
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