From cfb29f831d24bdeef78d4f1283979ffd01d29523 Mon Sep 17 00:00:00 2001 From: Andy Hook Date: Wed, 13 Apr 2022 12:46:06 +0100 Subject: [PATCH 01/11] Upgrade Stitches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Benoît Grélard --- .yarn/versions/c8114ce3.yml | 2 + package.json | 2 +- .../react/accordion/src/Accordion.stories.tsx | 740 +++++----- .../alert-dialog/src/AlertDialog.stories.tsx | 350 ++--- .../react/announce/src/Announce.stories.tsx | 2 +- .../aspect-ratio/src/AspectRatio.stories.tsx | 6 +- packages/react/avatar/src/Avatar.stories.tsx | 56 +- .../react/checkbox/src/Checkbox.stories.tsx | 151 +- .../collapsible/src/Collapsible.stories.tsx | 126 +- .../context-menu/src/ContextMenu.stories.tsx | 696 ++++----- packages/react/dialog/src/Dialog.stories.tsx | 576 ++++---- .../src/DismissableLayer.stories.tsx | 16 +- .../src/DropdownMenu.stories.tsx | 1297 +++++++++-------- .../hover-card/src/HoverCard.stories.tsx | 490 ++++--- packages/react/label/src/Label.stories.tsx | 36 +- packages/react/menu/src/Menu.stories.tsx | 259 ++-- .../src/NavigationMenu.stories.tsx | 120 +- .../react/popover/src/Popover.stories.tsx | 495 +++---- packages/react/popper/src/Popper.stories.tsx | 72 +- .../react/presence/src/Presence.stories.tsx | 24 +- .../react/progress/src/Progress.stories.tsx | 52 +- .../radio-group/src/RadioGroup.stories.tsx | 438 +++--- .../scroll-area/src/ScrollArea.stories.tsx | 16 +- packages/react/select/src/Select.stories.tsx | 160 +- .../react/separator/src/Separator.stories.tsx | 10 +- packages/react/slider/src/Slider.stories.tsx | 444 +++--- packages/react/switch/src/Switch.stories.tsx | 95 +- packages/react/tabs/src/Tabs.stories.tsx | 268 ++-- packages/react/toast/src/Toast.stories.tsx | 300 ++-- .../toggle-group/src/ToggleGroup.stories.tsx | 307 ++-- packages/react/toggle/src/Toggle.stories.tsx | 22 +- .../react/toolbar/src/Toolbar.stories.tsx | 85 +- .../react/tooltip/src/Tooltip.stories.tsx | 905 ++++++------ stitches.config.ts | 26 +- yarn.lock | 21 +- 35 files changed, 4386 insertions(+), 4279 deletions(-) create mode 100644 .yarn/versions/c8114ce3.yml diff --git a/.yarn/versions/c8114ce3.yml b/.yarn/versions/c8114ce3.yml new file mode 100644 index 0000000000..e03b86dd57 --- /dev/null +++ b/.yarn/versions/c8114ce3.yml @@ -0,0 +1,2 @@ +declined: + - primitives diff --git a/package.json b/package.json index f37e5172f9..100abd90ef 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@babel/template": "^7.12.13", "@parcel/babel-plugin-transform-runtime": "^2.0.0-nightly.1823", "@parcel/babel-preset-env": "^2.0.0-alpha.3", - "@stitches/react": "0.0.3-canary.4", + "@stitches/core": "^1.2.7", "@storybook/addon-storysource": "6.1.0-beta.4", "@storybook/react": "6.1.0-beta.4", "@testing-library/cypress": "^7.0.6", diff --git a/packages/react/accordion/src/Accordion.stories.tsx b/packages/react/accordion/src/Accordion.stories.tsx index 122c04d63c..ba21e405c5 100644 --- a/packages/react/accordion/src/Accordion.stories.tsx +++ b/packages/react/accordion/src/Accordion.stories.tsx @@ -1,13 +1,7 @@ /* eslint-disable jsx-a11y/anchor-is-valid */ import * as React from 'react'; -import { css } from '../../../../stitches.config'; -import { - Accordion, - AccordionItem, - AccordionHeader, - AccordionTrigger, - AccordionContent, -} from './Accordion'; +import { css, keyframes } from '../../../../stitches.config'; +import * as Accordion from './Accordion'; export default { title: 'Components/Accordion' }; @@ -17,130 +11,135 @@ export const Single = () => { return ( <>

Uncontrolled

- - - - One - - + + + + One + + Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - - - - Two - - + + + + + Two + + Cursus sed mattis commodo fermentum conubia ipsum pulvinar sagittis, diam eget bibendum porta nascetur ac dictum, leo tellus dis integer platea ultrices mi. - - - - - Three (disabled) - - + + + + + Three (disabled) + + Sociis hac sapien turpis conubia sagittis justo dui, inceptos penatibus feugiat himenaeos euismod magna, nec tempor pulvinar eu etiam mattis. - - - - - Four - - + + + + + Four + + Odio placerat quisque sapien sagittis non sociis ligula penatibus dignissim vitae, enim vulputate nullam semper potenti etiam volutpat libero. - - - + + +

Controlled

- - - - One - - + + + + One + + Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - - - - Two - - + + + + + Two + + Cursus sed mattis commodo fermentum conubia ipsum pulvinar sagittis, diam eget bibendum porta nascetur ac dictum, leo tellus dis integer platea ultrices mi. - - - - - Three (disabled) - - + + + + + Three (disabled) + + Sociis hac sapien turpis conubia sagittis justo dui, inceptos penatibus feugiat himenaeos euismod magna, nec tempor pulvinar eu etiam mattis. - - - - - Four - - + + + + + Four + + Odio placerat quisque sapien sagittis non sociis ligula penatibus dignissim vitae, enim vulputate nullam semper potenti etiam volutpat libero. - - - + + +

Collapsible

- - - - One - - + + + + One + + Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - - - - Two - - + + + + + Two + + Cursus sed mattis commodo fermentum conubia ipsum pulvinar sagittis, diam eget bibendum porta nascetur ac dictum, leo tellus dis integer platea ultrices mi. - - - - - Three (disabled) - - + + + + + Three (disabled) + + Sociis hac sapien turpis conubia sagittis justo dui, inceptos penatibus feugiat himenaeos euismod magna, nec tempor pulvinar eu etiam mattis. - - - - - Four - - + + + + + Four + + Odio placerat quisque sapien sagittis non sociis ligula penatibus dignissim vitae, enim vulputate nullam semper potenti etiam volutpat libero. - - - + + + ); }; @@ -151,88 +150,93 @@ export const Multiple = () => { return ( <>

Uncontrolled

- - - - One - - + + + + One + + Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - - - - Two - - + + + + + Two + + Cursus sed mattis commodo fermentum conubia ipsum pulvinar sagittis, diam eget bibendum porta nascetur ac dictum, leo tellus dis integer platea ultrices mi. - - - - - Three (disabled) - - + + + + + Three (disabled) + + Sociis hac sapien turpis conubia sagittis justo dui, inceptos penatibus feugiat himenaeos euismod magna, nec tempor pulvinar eu etiam mattis. - - - - - Four - - + + + + + Four + + Odio placerat quisque sapien sagittis non sociis ligula penatibus dignissim vitae, enim vulputate nullam semper potenti etiam volutpat libero. - - - + + +

Controlled

- - - - One - - + + + + One + + Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - - - - Two - - + + + + + Two + + Cursus sed mattis commodo fermentum conubia ipsum pulvinar sagittis, diam eget bibendum porta nascetur ac dictum, leo tellus dis integer platea ultrices mi. - - - - - Three (disabled) - - + + + + + Three (disabled) + + Sociis hac sapien turpis conubia sagittis justo dui, inceptos penatibus feugiat himenaeos euismod magna, nec tempor pulvinar eu etiam mattis. - - - - - Four - - + + + + + Four + + Odio placerat quisque sapien sagittis non sociis ligula penatibus dignissim vitae, enim vulputate nullam semper potenti etiam volutpat libero. - - - + + + ); }; @@ -275,13 +279,13 @@ export const Animated = () => {

Closed by default

- + {values.map((value) => ( - - - {value} - - + + + {value} + + {[...Array(count)].map((_, index) => (
Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate @@ -289,19 +293,19 @@ export const Animated = () => { quam suscipit habitant sed.
))} -
-
+ + ))} -
+

Open by default

- + {values.map((value) => ( - - - {value} - - + + + {value} + + {[...Array(count)].map((_, index) => (
Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate @@ -309,10 +313,10 @@ export const Animated = () => { quam suscipit habitant sed.
))} -
-
+ + ))} -
+ ); }; @@ -322,13 +326,13 @@ export const Animated2D = () => { return ( <> - + {values.map((value) => ( - - - {value} - - + + + {value} + +
Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate @@ -336,10 +340,10 @@ export const Animated2D = () => { quam suscipit habitant sed.
-
-
+ + ))} -
+ ); }; @@ -347,46 +351,46 @@ export const Animated2D = () => { export const AnimatedControlled = () => { const [value, setValue] = React.useState(['one', 'two', 'three', 'four']); return ( - - - - One - - + + + + One + + Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - - - - Two - - + + + + + Two + + Cursus sed mattis commodo fermentum conubia ipsum pulvinar sagittis, diam eget bibendum porta nascetur ac dictum, leo tellus dis integer platea ultrices mi. - - - - - Three - - + + + + + Three + + Sociis hac sapien turpis conubia sagittis justo dui, inceptos penatibus feugiat himenaeos euismod magna, nec tempor pulvinar eu etiam mattis. - - - - - Four - - + + + + + Four + + Odio placerat quisque sapien sagittis non sociis ligula penatibus dignissim vitae, enim vulputate nullam semper potenti etiam volutpat libero. - - - + + + ); }; @@ -398,46 +402,46 @@ export const OutsideViewport = () => ( When accordion buttons are focused and the user is navigating via keyboard, the page should not scroll unless the next tab is entering the viewport.

- - - - One - - + + + + One + + Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - - - - Two - - + + + + + Two + + Cursus sed mattis commodo fermentum conubia ipsum pulvinar sagittis, diam eget bibendum porta nascetur ac dictum, leo tellus dis integer platea ultrices mi. - - - - - Three (disabled) - - + + + + + Three (disabled) + + Sociis hac sapien turpis conubia sagittis justo dui, inceptos penatibus feugiat himenaeos euismod magna, nec tempor pulvinar eu etiam mattis. - - - - - Four - - + + + + + Four + + Odio placerat quisque sapien sagittis non sociis ligula penatibus dignissim vitae, enim vulputate nullam semper potenti etiam volutpat libero. - - - + + +
); @@ -448,225 +452,225 @@ export const Chromatic = () => { <>

Uncontrolled

Single closed

- + {items.map((item) => ( - - - {item} - - + + + {item} + + {item}: Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - + + ))} - +

Single open

- + {items.map((item) => ( - - - {item} - - + + + {item} + + {item}: Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - + + ))} - +

Multiple closed

- + {items.map((item) => ( - - - {item} - - + + + {item} + + {item}: Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - + + ))} - +

Multiple open

- + {items.map((item) => ( - - - {item} - - + + + {item} + + {item}: Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - + + ))} - +

Controlled

Single open

- + {items.map((item) => ( - - - {item} - - + + + {item} + + {item}: Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - + + ))} - +

Multiple open

- + {items.map((item) => ( - - - {item} - - + + + {item} + + {item}: Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - + + ))} - +

Disabled (whole)

- + {items.map((item) => ( - - - {item} - - + + + {item} + + {item}: Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - + + ))} - +

Disabled (item)

Just item

- + {items.map((item) => ( - - - {item} - - + + + {item} + + {item}: Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - + + ))} - +

with `disabled=false` on top-level

- + {items.map((item) => ( - - - {item} - - + + + {item} + + {item}: Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - + + ))} - +

Force mounted contents

- + {items.map((item) => ( - - - {item} - - + + + {item} + + {item}: Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - + + ))} - +

State attributes

Accordion disabled

- + {items.map((item) => ( - - - {item} - - + + + {item} + + {item}: Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - + + ))} - +

Accordion enabled with item override

- + {items.map((item) => ( - - - {item} - - + + {item} + + {item}: Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - + + ))} - +

Accordion disabled with item override

- + {items.map((item) => ( - - - {item} - - + + {item} + + {item}: Per erat orci nostra luctus sociosqu mus risus penatibus, duis elit vulputate viverra integer ullamcorper congue curabitur sociis, nisi malesuada scelerisque quam suscipit habitant sed. - - + + ))} - + ); }; @@ -731,17 +735,17 @@ const contentClass = css({ lineHeight: 1.5, }); -const slideDown = css.keyframes({ +const slideDown = keyframes({ from: { height: 0 }, to: { height: 'var(--radix-accordion-content-height)' }, }); -const slideUp = css.keyframes({ +const slideUp = keyframes({ from: { height: 'var(--radix-accordion-content-height)' }, to: { height: 0 }, }); -const open2D = css.keyframes({ +const open2D = keyframes({ from: { width: 0, height: 0, @@ -752,7 +756,7 @@ const open2D = css.keyframes({ }, }); -const close2D = css.keyframes({ +const close2D = keyframes({ from: { width: 'var(--radix-accordion-content-width)', height: 'var(--radix-accordion-content-height)', diff --git a/packages/react/alert-dialog/src/AlertDialog.stories.tsx b/packages/react/alert-dialog/src/AlertDialog.stories.tsx index 61664b5ea9..7298147eb6 100644 --- a/packages/react/alert-dialog/src/AlertDialog.stories.tsx +++ b/packages/react/alert-dialog/src/AlertDialog.stories.tsx @@ -1,34 +1,24 @@ import * as React from 'react'; -import { - AlertDialog, - AlertDialogTrigger, - AlertDialogPortal, - AlertDialogOverlay, - AlertDialogContent, - AlertDialogTitle, - AlertDialogDescription, - AlertDialogAction, - AlertDialogCancel, -} from './AlertDialog'; import { css } from '../../../../stitches.config'; +import * as AlertDialog from './AlertDialog'; export default { title: 'Components/AlertDialog' }; export const Styled = () => ( - - delete everything - - - - Are you sure? - + + delete everything + + + + Are you sure? + This will do a very dangerous thing. Thar be dragons! - - yolo, do it - maybe not - - - + + yolo, do it + maybe not + + + ); export const Controlled = () => { @@ -40,8 +30,8 @@ export const Controlled = () => {
a large white house with a red roof
- - + { if (housePurchased) { e.preventDefault(); @@ -50,24 +40,24 @@ export const Controlled = () => { }} > {housePurchased ? 'You bought the house! Sell it!' : 'Buy this house'} - - - - - Are you sure? - + + + + + Are you sure? + Houses are very expensive and it looks like you only have €20 in the bank. Maybe consult with a financial advisor? - - setHousePurchased(true)}> + + setHousePurchased(true)}> buy it anyway - - + + good point, I'll reconsider - - - - + + + +
); }; @@ -84,188 +74,200 @@ export const Chromatic = () => (

Uncontrolled

Closed

- - delete everything - - - - Title - + + delete everything + + + + Title + Description - - Confirm - Cancel - - - + + Confirm + Cancel + + +

Open

- - delete everything - - + delete everything + + - - Title - + + Title + Description - - Confirm - Cancel - - - + + Confirm + Cancel + + +

Uncontrolled with reordered parts

Closed

- - - - - Title - + + + + + Title + Description - - Confirm - Cancel - - - delete everything - + + Confirm + Cancel + + + delete everything +

Open

- - - + + - - Title - + + Title + Description - - Confirm - Cancel - - - delete everything - + + Confirm + Cancel + + + delete everything +

Controlled

Closed

- - delete everything - - - - Title - + + delete everything + + + + Title + Description - - Confirm - Cancel - - - + + Confirm + Cancel + + +

Open

- - delete everything - - + delete everything + + - - Title - + + Title + Description - - Confirm - Cancel - - - + + Confirm + Cancel + + +

Controlled with reordered parts

Closed

- - - - - Title - + + + + + Title + Description - - Confirm - Cancel - - - delete everything - + + Confirm + Cancel + + + delete everything +

Open

- - - + + - - Title - + + Title + Description - - Confirm - Cancel - - - delete everything - + + Confirm + Cancel + + + delete everything +

State attributes

Closed

- - delete everything - - - - Title - + + delete everything + + + + Title + Description - - Confirm - Cancel - - - + + Confirm + Cancel + + +

Open

- - delete everything - - - - Title - + + delete everything + + + + Title + Description - - Confirm - Cancel - - - + + Confirm + Cancel + + +
); diff --git a/packages/react/announce/src/Announce.stories.tsx b/packages/react/announce/src/Announce.stories.tsx index 98cc6a4c68..a20a6b1698 100644 --- a/packages/react/announce/src/Announce.stories.tsx +++ b/packages/react/announce/src/Announce.stories.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import { Announce } from './Announce'; import { VisuallyHidden } from '@radix-ui/react-visually-hidden'; +import { Announce } from './Announce'; export default { title: 'Components/Announce' }; diff --git a/packages/react/aspect-ratio/src/AspectRatio.stories.tsx b/packages/react/aspect-ratio/src/AspectRatio.stories.tsx index 4660c302a8..c1ec5d700d 100644 --- a/packages/react/aspect-ratio/src/AspectRatio.stories.tsx +++ b/packages/react/aspect-ratio/src/AspectRatio.stories.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import { AspectRatio } from './AspectRatio'; import { css } from '../../../../stitches.config'; +import { AspectRatio } from './AspectRatio'; export default { title: 'Components/AspectRatio' }; @@ -14,7 +14,7 @@ const image = ( export const Styled = () => (
- +

Default ratio (1/1)

@@ -43,7 +43,7 @@ export const Chromatic = () => ( <>

Default ratio

- +

Default ratio (1/1)

diff --git a/packages/react/avatar/src/Avatar.stories.tsx b/packages/react/avatar/src/Avatar.stories.tsx index 7a6580bf53..70f01ade13 100644 --- a/packages/react/avatar/src/Avatar.stories.tsx +++ b/packages/react/avatar/src/Avatar.stories.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import { Avatar, AvatarImage, AvatarFallback } from './Avatar'; import { css } from '../../../../stitches.config'; +import * as Avatar from './Avatar'; export default { title: 'Components/Avatar' }; @@ -10,55 +10,55 @@ const srcBroken = 'https://broken.link.com/broken-pic.jpg'; export const Styled = () => ( <>

Without image & with fallback

- - JS - + + JS +

With image & with fallback

- - - + + + JS - - + +

With image & with fallback (but broken src)

- - + - + - - + + ); export const Chromatic = () => ( <>

Without image & with fallback

- - JS - + + JS +

With image & with fallback

- - - + + + JS - - + +

With image & with fallback (but broken src)

- - - + + + - - + + ); Chromatic.parameters = { chromatic: { disable: false, delay: 1000 } }; diff --git a/packages/react/checkbox/src/Checkbox.stories.tsx b/packages/react/checkbox/src/Checkbox.stories.tsx index ebc3f219f7..6c8a22a553 100644 --- a/packages/react/checkbox/src/Checkbox.stories.tsx +++ b/packages/react/checkbox/src/Checkbox.stories.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; +import { css, keyframes } from '../../../../stitches.config'; import { Label as LabelPrimitive } from '@radix-ui/react-label'; -import { Checkbox, CheckboxIndicator } from './Checkbox'; -import { css } from '../../../../stitches.config'; import { RECOMMENDED_CSS__LABEL__ROOT } from '../../label/src/Label.stories'; +import * as Checkbox from './Checkbox'; export default { title: 'Components/Checkbox' }; @@ -13,9 +13,9 @@ export const Styled = () => (

Custom label


@@ -24,9 +24,9 @@ export const Styled = () => (

Native label

Native label + native checkbox

@@ -36,18 +36,18 @@ export const Styled = () => (

Custom label + htmlFor

- - - + + +

Native label + htmlFor

- - - + + +

Native label + native checkbox

@@ -62,9 +62,14 @@ export const Controlled = () => { <>

This checkbox is placed adjacent to its label. The state is controlled.

{' '} - - - + + + ); }; @@ -75,9 +80,9 @@ export const Indeterminate = () => { return ( <>

- - - + + +