Devon Govett's banner
Devon Govett's profile picture

Devon Govett

@devongovett41,728 subscribers

Creator of @parceljs. Engineer @adobe working on React Aria and React Spectrum.

Shorts

Seems like a good opportunity to share a trick I used on the React Aria website to make headings scale to fit the viewport on mobile, even with SSR. I used fontkit, a library I wrote 10 years ago to parse fonts and layout glyphs, to measure the width of the heading at build time in the "em" unit. width = font.layout('DateRangePicker').advanceWidth / font.unitsPerEm This is a size independent measurement using the font's internal metrics. When multiplied by any font size, you get the pixel width of the text. To calculate the font size, set this as a CSS variable and divide the target width (100vw minus padding). Clamp to make sure it doesn't get too big or small. font-size: clamp(35px, (100vw - 32px) / var(--text-width), 55px) And tada! You have perfectly scaling text no matter the viewport size. 🎉

Seems like a good opportunity to share a trick I used on the React Aria website to make headings scale to fit the viewport on mobile, even with SSR. I used fontkit, a library I wrote 10 years ago to parse fonts and layout glyphs, to measure the width of the heading at build time in the "em" unit. width = font.layout('DateRangePicker').advanceWidth / font.unitsPerEm This is a size independent measurement using the font's internal metrics. When multiplied by any font size, you get the pixel width of the text. To calculate the font size, set this as a CSS variable and divide the target width (100vw minus padding). Clamp to make sure it doesn't get too big or small. font-size: clamp(35px, (100vw - 32px) / var(--text-width), 55px) And tada! You have perfectly scaling text no matter the viewport size. 🎉

48,052 просмотров

React Aria has built-in support for drag and drop. This kanban board is only ~100 lines, and even supports keyboard accessibility with no additional code needed! 🙂

React Aria has built-in support for drag and drop. This kanban board is only ~100 lines, and even supports keyboard accessibility with no additional code needed! 🙂

54,731 просмотров

Pretty amazing that we can now implement swipeable Tabs with native CSS. Updating the React Aria demo I made a few years ago to use native scroll snapping, scroll timeline, and anchor positioning instead of Framer Motion. Feels smooooooth! 🎉

Pretty amazing that we can now implement swipeable Tabs with native CSS. Updating the React Aria demo I made a few years ago to use native scroll snapping, scroll timeline, and anchor positioning instead of Framer Motion. Feels smooooooth! 🎉

83,922 просмотров

Along with automatic skeletons, another thing I worked on recently was coordinated image loading. You can wrap any group of images with an <ImageCoordinator>, and all the images under it will fade in together rather than popcorning. Makes for a much more pleasant experience! 😀

Along with automatic skeletons, another thing I worked on recently was coordinated image loading. You can wrap any group of images with an <ImageCoordinator>, and all the images under it will fade in together rather than popcorning. Makes for a much more pleasant experience! 😀

122,874 просмотров

I fixed the most upvoted React Aria issue of all time: in the next release, you can enter "invalid" dates like February 31st, and they'll be constrained on blur instead of as you type. This is helpful for transient states, e.g. editing the day before the month. It also enabled entering other temporary values like leading zeros. As you can see in the video, previously if the month was February you couldn't change the day to anything above 28. You'd first have to change the month and then go back to the day. Now the temporary invalid state is allowed. This might seem like such a simple issue, but it was actually pretty complicated to fix. It required entirely changing the way the state is stored. JS Date and Intl.DateTimeFormat cannot store or format dates that don't exist, so we had to reimplement it from scratch. Now we use Intl.DateTimeFormat to get the order of the fields for each locale, but format the value of each segment individually with Intl.NumberFormat. Lots of edge cases to handle as well, like daylight saving time, 12/24 hour time, different calendar and numbering systems, etc. Really glad to finally fix this one though!

I fixed the most upvoted React Aria issue of all time: in the next release, you can enter "invalid" dates like February 31st, and they'll be constrained on blur instead of as you type. This is helpful for transient states, e.g. editing the day before the month. It also enabled entering other temporary values like leading zeros. As you can see in the video, previously if the month was February you couldn't change the day to anything above 28. You'd first have to change the month and then go back to the day. Now the temporary invalid state is allowed. This might seem like such a simple issue, but it was actually pretty complicated to fix. It required entirely changing the way the state is stored. JS Date and Intl.DateTimeFormat cannot store or format dates that don't exist, so we had to reimplement it from scratch. Now we use Intl.DateTimeFormat to get the order of the fields for each locale, but format the value of each segment individually with Intl.NumberFormat. Lots of edge cases to handle as well, like daylight saving time, 12/24 hour time, different calendar and numbering systems, etc. Really glad to finally fix this one though!

28,897 просмотров

Built a React Aria Calendar with swipe gestures to navigate between months! Uses CSS scroll snap for native 120fps animations, with a neat trick to enable infinite scrolling in both directions. 👇

Built a React Aria Calendar with swipe gestures to navigate between months! Uses CSS scroll snap for native 120fps animations, with a neat trick to enable infinite scrolling in both directions. 👇

41,687 просмотров

New React Aria release! ✅ Multi-select ComboBox with customizable selection rendering (e.g. TagGroup) 🏝️ Tree sections – create labeled groups of items 💯 Better NumberField paste handling 📆 Improved Calendar month and year dropdown behavior 🐞 Lots of bug fixes!

New React Aria release! ✅ Multi-select ComboBox with customizable selection rendering (e.g. TagGroup) 🏝️ Tree sections – create labeled groups of items 💯 Better NumberField paste handling 📆 Improved Calendar month and year dropdown behavior 🐞 Lots of bug fixes!

18,890 просмотров

Animating React Aria Tabs, ToggleButtonGroup, etc. is about to be super easy with the new SelectionIndicator component. 🥳 • Native CSS transitions, no animation library needed. • Works with SSR with no flicker before JS runs. • No ResizeObserver. • Enter + exit animations.

Animating React Aria Tabs, ToggleButtonGroup, etc. is about to be super easy with the new SelectionIndicator component. 🥳 • Native CSS transitions, no animation library needed. • Works with SSR with no flicker before JS runs. • No ResizeObserver. • Enter + exit animations.

22,905 просмотров

New React Aria release! 🎁 🔎 Autocomplete alpha 📽️ CSS transition support in addition to keyframes 📆 Custom Calendar first day of week 🧪 Unit test utility package for ARIA patterns 🎯 Removed custom hit testing in usePress 🐞 and plenty of bug fixes!

New React Aria release! 🎁 🔎 Autocomplete alpha 📽️ CSS transition support in addition to keyframes 📆 Custom Calendar first day of week 🧪 Unit test utility package for ARIA patterns 🎯 Removed custom hit testing in usePress 🐞 and plenty of bug fixes!

35,054 просмотров

The React Aria team is cooking up a Command Palette example combining our Dialog, Autocomplete, and Menu components with Tailwind styles. 🧑‍🍳

The React Aria team is cooking up a Command Palette example combining our Dialog, Autocomplete, and Menu components with Tailwind styles. 🧑‍🍳

18,246 просмотров

Just implemented an "auto" variant for our button component with this technique. 🪄

Just implemented an "auto" variant for our button component with this technique. 🪄

20,045 просмотров

Live example with a color picker you can play with:

Live example with a color picker you can play with:

14,651 просмотров

A cool feature of the Disclosure component is that it uses the hidden=until-found attribute so you can still search the content while it is closed with ctrl+F (currently supported in Chrome). The disclosure will automatically open when content is found inside! 😲

A cool feature of the Disclosure component is that it uses the hidden=until-found attribute so you can still search the content while it is closed with ctrl+F (currently supported in Chrome). The disclosure will automatically open when content is found inside! 😲

10,687 просмотров

Videos

Больше нет контента для загрузки