diff --git a/.storybook-s2/.parcelrc b/.storybook-s2/.parcelrc index beac09e5269..f20d4c80269 100644 --- a/.storybook-s2/.parcelrc +++ b/.storybook-s2/.parcelrc @@ -6,12 +6,13 @@ "packages/@react-spectrum/s2/s2wf-icons/*.svg": ["parcel-transformer-icon"], "packages/*/*/intl/*.json": ["parcel-transformer-intl"], // Disable PostCSS from running over style macro output - "packages/@react-spectrum/s2/**/*.css": ["@parcel/transformer-css"], + "*.css": ["@parcel/transformer-css"], "*.{js,mjs,jsm,jsx,es6,cjs,ts,tsx}": [ "@parcel/transformer-js", "@parcel/transformer-react-refresh-wrap" ], "*.svg": ["@parcel/transformer-svg-react"], + "*.{mdx,md}": ["parcel-transformer-mdx-storybook"], "raw:*": ["@parcel/transformer-raw"] } } diff --git a/.storybook-s2/Intro.mdx b/.storybook-s2/Intro.mdx deleted file mode 100644 index a6198c51265..00000000000 --- a/.storybook-s2/Intro.mdx +++ /dev/null @@ -1,3 +0,0 @@ -import Readme from '../README.md'; - - diff --git a/.storybook-s2/docs/Icons.jsx b/.storybook-s2/docs/Icons.jsx new file mode 100644 index 00000000000..d1c6dc7019f --- /dev/null +++ b/.storybook-s2/docs/Icons.jsx @@ -0,0 +1,35 @@ +import icons from '@react-spectrum/s2/s2wf-icons/*.svg'; +import { style } from '../../packages/@react-spectrum/s2/style/spectrum-theme' with {type: 'macro'}; +import {ActionButton, Text} from '@react-spectrum/s2'; +import {P, Code, Pre} from './typography'; +import {highlight} from './highlight' with {type: 'macro'}; + +export function Icons() { + return ( +
+
+

+ Workflow icons +

+

Spectrum 2 offers a subset of the icons currently available in React Spectrum v3. These icons can be imported from @react-spectrum/s2/icons.

+
{highlight("import Add from '@react-spectrum/s2/icons/Add';")}
+

See below for a full list of available icons. Click to copy import statement.

+
+ {Object.keys(icons).map(icon => { + let Icon = icons[icon].default; + let name = icon.replace(/^S2_Icon_(.*?)_2.*/, '$1'); + let importName = name.replace(/^(\d)/, '_$1'); + return ( + navigator.clipboard.writeText(`import ${importName} from '@react-spectrum/s2/icons/${name}';`)}> + + {name} + + ); + })} +
+
+
+ ); +} diff --git a/.storybook-s2/docs/Intro.jsx b/.storybook-s2/docs/Intro.jsx new file mode 100644 index 00000000000..6e94c202e3f --- /dev/null +++ b/.storybook-s2/docs/Intro.jsx @@ -0,0 +1,269 @@ +import { style } from '../../packages/@react-spectrum/s2/style/spectrum-theme' with {type: 'macro'}; +import {Button, LinkButton, ButtonGroup, Checkbox, Content, Dialog, DialogTrigger, Footer, Header, Heading, Image, InlineAlert, Menu, MenuItem, MenuSection, MenuTrigger, SubmenuTrigger, Switch, Link, Text} from '@react-spectrum/s2'; +import NewIcon from '@react-spectrum/s2/s2wf-icons/S2_Icon_New_20_N.svg'; +import ImgIcon from '@react-spectrum/s2/s2wf-icons/S2_Icon_Image_20_N.svg'; +import CopyIcon from '@react-spectrum/s2/s2wf-icons/S2_Icon_Copy_20_N.svg'; +import CommentTextIcon from '@react-spectrum/s2/s2wf-icons/S2_Icon_CommentText_20_N.svg'; +import ClockPendingIcon from '@react-spectrum/s2/s2wf-icons/S2_Icon_ClockPending_20_N.svg'; +import CommunityIcon from '@react-spectrum/s2/s2wf-icons/S2_Icon_Community_20_N.svg'; +import DeviceTabletIcon from '@react-spectrum/s2/s2wf-icons/S2_Icon_DeviceTablet_20_N.svg'; +import DeviceDesktopIcon from '@react-spectrum/s2/s2wf-icons/S2_Icon_DeviceDesktop_20_N.svg'; +import {highlight} from './highlight' with {type: 'macro'}; +import {H2, H3, H4, P, Pre, Code} from './typography'; + +export function Docs() { + return ( +
+
+

+ Spectrum 2 in React Spectrum +

+
+
+

Introducing Spectrum 2 – a new update to Adobe's design system, now in pre-release! Designed to support our growing suite of products, Spectrum 2 aims to work seamlessly across experiences by balancing personality and function.

+

The React Spectrum team has been hard at work to bring the Spectrum 2 design to our components. Spectrum 2 in React Spectrum is built on React Aria Components and a new styling foundation powered by Spectrum Tokens. This gives you access to Spectrum design fundamentals such as colors, spacing, sizing, and typography in your own applications and custom components. Spectrum 2 also brings new features such as t-shirt sizing, improved form layout, dynamic new press interactions, and more.

+

Check out the new Button design, with fresh new colors and icons, a fun new press scaling interaction, and support for t-shirt sizes.

+ + + + + +

Spectrum 2 switches have a more accessible design, with a solid border and new animations.

+ + Wi-Fi + +

Dialogs have a refreshed design with more pronounced rounding, and improved layout.

+ + + + + {({close}) => ( + <> + + Dialog title +
Header
+ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in

+
+
Don't show this again
+ + + + + + )} +
+
+
+

Menus received a major design update, with new styles for sections, links, selection, focus rings, and submenus.

+ + + + + +
+ Publish and export + Social media, other formats +
+ + + Quick Export + Share a low-res snapshot. + + + + + Open a copy + Illustrator for iPad or desktop + + + +
+ Open a copy in +
+ + + Illustrator for iPad + + + + Illustrator for desktop + +
+
+
+
+ +
+ Menu section header + Menu section description +
+ + + Share link + Enable comments and downloads + + + + Preview Timelapse + + + + Livestream + Start streaming + +
+
+
+
+

Getting started

+

Installation

+

Spectrum 2 in React Spectrum can be installed from npm:

+
yarn add @react-spectrum/s2
+

Configuring your bundler

+

React Spectrum supports styling via macros, a new bundler feature that enables functions to run at build time. Currently, Parcel v2.12.0 and newer supports macros out of the box. When using other build tools, you can install a plugin to enable them.

+

See below to learn more about using the React Spectrum style macro.

+

Webpack, Next.js, Vite, Rollup, or ESBuild

+

First, install unplugin-parcel-macros using your package manager:

+
yarn add unplugin-parcel-macros --dev
+

Then, configure your bundler according to the steps documented in the readme. Note that plugin order is important: unplugin-parcel-macros must run before other plugins like Babel.

+

You may also need to configure other tools such as TypeScript, Babel, ESLint, and Jest to support parsing import attributes. See these docs for details.

+

See the examples folder in our repo for working setups with various build tools.

+

Setting up your app

+

Unlike React Spectrum v3, a Provider is not required. Instead, import @react-spectrum/s2/page.css in the entry component of your app to apply the background color and color scheme to the {''} element. This ensures that the entire page has the proper styles even before your JavaScript runs.

+
{highlight(`import '@react-spectrum/s2/page.css';
+import {Button} from '@react-spectrum/s2';
+
+function App() {
+  return (
+    
+  );
+}`)}
+ + + +

Note: If you’re embedding Spectrum 2 as a section of a larger page rather than taking over the whole window, follow the directions below instead of using page.css.

+

Overriding the color scheme

+

By default, the page follows the user’s operating system color scheme setting, supporting both light and dark mode. The page background is set to the base Spectrum background layer by default. This can be configured by setting the data-color-scheme and data-background attributes on the {''} element. For example, to force the application to only render in light mode, set data-color-scheme="light".

+
{highlight(`
+  
+`)}
+

Overriding the locale

+

By default, React Spectrum uses the browser/operating system language setting for localized strings, date and number formatting, and to determine the layout direction (left-to-right or right-to-left). This can be overridden by rendering a {''} component at the root of your app, and setting the locale prop.

+
{highlight(`import {Provider} from '@react-spectrum/s2';
+
+  {/* your app */}
+`)}
+

Embedded sections

+

If you’re building an embedded section of a larger page using Spectrum 2, use the {''} component to set the background instead of importing page.css. The background prop should be set to the Spectrum background layer appropriate for your app, and the colorScheme can be overridden as well.

+
{highlight(`import {Provider} from '@react-spectrum/s2';
+
+  {/* your app */}
+`)}
+

Styling

+

React Spectrum v3 supported a limited set of style props for layout and positioning using Spectrum-defined values. In Spectrum 2, we’re improving on this by offering a much more flexible style macro. This offers additional Spectrum tokens, improves performance by generating CSS at build time rather than runtime, and works with any DOM element for use in custom components.

+

Macros are a new bundler feature that enable functions to run at build time. The React Spectrum style macro uses this to generate CSS that can be applied to any DOM element or component. Import the style macro using the with {`{type: 'macro'}`} import attribute, and pass the result to the styles prop of any React Spectrum component to provide it with styles.

+
{highlight(`import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
+import {ActionButton} from '@react-spectrum/s2';
+
+
+  Edit
+`)}
+

The styles prop accepts a limited set of CSS properties, including layout, spacing, sizing, and positioning. Other styles such as colors and internal padding cannot be customized within Spectrum components.

+ + Learn more about styling + See the full docs to learn about using the style macro to build custom components. + +

Supported CSS properties on Spectrum components

+
    +
  • margin
  • +
  • marginStart
  • +
  • marginEnd
  • +
  • marginTop
  • +
  • marginBottom
  • +
  • marginX
  • +
  • marginY
  • +
  • width
  • +
  • minWidth
  • +
  • maxWidth
  • +
  • flex
  • +
  • flexGrow
  • +
  • flexShrink
  • +
  • flexBasis
  • +
  • justifySelf
  • +
  • alignSelf
  • +
  • order
  • +
  • gridArea
  • +
  • gridRow
  • +
  • gridRowStart
  • +
  • gridRowEnd
  • +
  • gridColumn
  • +
  • gridColumnStart
  • +
  • gridColumnEnd
  • +
  • position
  • +
  • zIndex
  • +
  • top
  • +
  • bottom
  • +
  • inset
  • +
  • insetX
  • +
  • insetY
  • +
  • insetStart
  • +
  • insetEnd
  • +
+

UNSAFE Style Overrides

+

We highly discourage overriding the styles of React Spectrum components because it may break at any time when we change our implementation, making it difficult for you to update in the future. Consider using React Aria Components with our style macro to build a custom component with Spectrum styles instead.

+

That said, just like in React Spectrum v3, the UNSAFE_className and UNSAFE_style props are supported on Spectrum 2 components as last-resort escape hatches. However, unlike in v3, UNSAFE_classNames must be placed in a special UNSAFE_overrides CSS cascade layer. This guarentees that your overrides will always win over other styles on the page, no matter the order or specificity of the selector.

+
{highlight(`/* YourComponent.tsx */
+import {Button} from '@react-spectrum/s2';
+import './YourComponent.css';
+
+function YourComponent() {
+  return ;
+}`)}
+
{highlight(`/* YourComponent.css */
+@layer UNSAFE_overrides {
+  /* Wrap all UNSAFE_className rules in this layer. */
+  .your-unsafe-class {
+    background: red;
+  }
+}`, 'CSS')}
+
+
+ ) +} + +function Example({children}) { + return ( +
+ {children} +
+ ); +} diff --git a/.storybook-s2/docs/Intro.mdx b/.storybook-s2/docs/Intro.mdx new file mode 100644 index 00000000000..fd03e950979 --- /dev/null +++ b/.storybook-s2/docs/Intro.mdx @@ -0,0 +1,3 @@ +import {Docs} from './Intro.jsx'; + + diff --git a/.storybook-s2/docs/Style Macro.mdx b/.storybook-s2/docs/Style Macro.mdx new file mode 100644 index 00000000000..39b171db10a --- /dev/null +++ b/.storybook-s2/docs/Style Macro.mdx @@ -0,0 +1,3 @@ +import {StyleMacro} from './StyleMacro.jsx'; + + diff --git a/.storybook-s2/docs/StyleMacro.jsx b/.storybook-s2/docs/StyleMacro.jsx new file mode 100644 index 00000000000..31a3e33fc10 --- /dev/null +++ b/.storybook-s2/docs/StyleMacro.jsx @@ -0,0 +1,132 @@ +import { style } from '../../packages/@react-spectrum/s2/style/spectrum-theme' with {type: 'macro'}; +import {Link, LinkButton} from '@react-spectrum/s2'; +import {highlight} from './highlight' with {type: 'macro'}; +import {H2, H3, H3, P, Pre, Code} from './typography'; + +export function StyleMacro() { + return ( +
+
+

+ Style Macro +

+
+
+

The React Spectrum style macro generates atomic CSS at build time, which can be applied to any DOM element or Spectrum component. Style properties use Spectrum tokens such as colors, spacing, sizing, and typography, helping you work more quickly with TypeScript autocomplete, reduce the design choices you need to make, and improve consistency between Adobe applications.

+
{highlight(`import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
+
+
+ {/* ... */} +
`)}
+

Atomic CSS scales as your application grows because it outputs a separate rule for each CSS property you write, ensuring there is no duplication across your whole app. The above example generates two CSS rules:

+
{highlight(`.bJ { background-color: #ffbcb4 }
+.ac { color: #fff }`, 'CSS')}
+

These rules are reused across your app wherever the same values are used, which keeps your bundle size small even as you add features. In addition, you only pay for the values you use – there’s no unnecessary CSS custom properties for colors and other tokens that aren’t used.

+

The style macro colocates your styles with your component code, rather than in separate CSS files. Colocation enables you to:

+
    +
  • Develop more efficiently – No need to switch between multiple files when working on a component, or spend time writing CSS selectors.
  • +
  • Refactor with confidence – Changing the styles in a component is guaranteed to never unintentionally affect any other parts of your application. When you delete a component, the corresponding styles are also removed, reducing technical debt.
  • +
+

Values

+

The style macro supports a constrained set of values for each CSS property, which conform to the Spectrum design system. For example, the backgroundColor property supports Spectrum colors, and does not allow arbitrary hex or rgb values by default. This helps make it easier to build consistent UIs that are maintainable over time.

+

Colors

+

The Spectrum 2 color palette is available across all color properties. The backgroundColor property also supports Spectrum’s background layers. In addition, semantic colors such as accent and negative are available across all properties, and automatically update according to states such as isHovered (see runtime conditions below).

+

Spacing and sizing

+

Spacing properties such as margin and padding, and sizing properties such as width and height support a limited set of values. The API is represented in pixels, however, only values conforming to a 4px grid are allowed. This helps ensure that spacing and sizing are visually consistent.

+

Internally, spacing and sizing values are converted from pixels to rems, which scale according to the user’s font size preference. In addition, sizing values are multiplied by 1.25x on touch screen devices to help increase the size of hit targets. Spacing values do not scale and remain fixed.

+

Conditional styles

+

The style macro also supports conditional styles, such as media queries, UI states such as hover and press, and component variants. Conditional values are defined as an object where each key is a condition. This keeps all values for each property together in one place so it is easy to see where overrides are coming from.

+

This example sets the padding of a div to 8px by default, and 32px at the large media query breakpoint (1024px) defined by Spectrum.

+
{highlight(`
`)}
+

Conditions are mutually exclusive, following object property order. The style macro uses CSS cascade layers to ensure that there are no specificity issues to worry about. The last matching condition always wins.

+

Runtime conditions

+

The style macro also supports conditions that are resolved in JavaScript at runtime, such as variant props and UI states. When a runtime condition is detected, the style macro returns a function that can be called at runtime to determine which styles to apply.

+

Runtime conditions can be named however you like, and values are defined as an object. This example changes the background color depending on a variant prop:

+
{highlight(`let styles = style({
+  backgroundColor: {
+    variant: {
+      primary: 'accent',
+      secondary: 'neutral'
+    }
+  }
+});
+function MyComponent({variant}) {
+  return 
+}`)}
+

Boolean conditions starting with is do not need to be nested in an object:

+
{highlight(`let styles = style({
+  backgroundColor: {
+    default: 'gray-100',
+    isSelected: 'gray-900'
+  }
+});
+
`)}
+

Runtime conditions also work well with the render props in React Aria Components. If you define your styles inline, you’ll even get autocomplete for all of the available conditions.

+
{highlight(`import {Checkbox} from 'react-aria-components';
+`)}
+

Nesting conditions

+

Conditions can be nested to apply styles when multiple conditions are true. Keep in mind that conditions at the same level are mutually exclusive, with the last matching condition winning. Since only one value can apply at a time, there are no specificity issues to worry about.

+
{highlight(`let styles = style({
+  backgroundColor: {
+    default: 'gray-25',
+    isSelected: {
+      default: 'neutral',
+      isEmphasized: 'accent',
+      forcedColors: 'Highlight',
+      isDisabled: {
+        default: 'gray-400',
+        forcedColors: 'GrayText'
+      }
+    }
+  }
+});
+
`)}
+

The above example has three runtime conditions (isSelected, isEmphasized, and isDisabled), and uses the forcedColors condition to apply styles for Windows High Contrast Mode (WHCM). The order of precedence follows the order the conditions are defined in the object, with the isSelected + isDisabled + forcedColors state having the highest priority.

+

Reusing styles

+

Styles can be reused by extracting common properties into objects, and spreading them into style calls. These must either be constants (declared with const) in the same file, or imported from another file as a macro ({"with {type: 'macro'}"}). Properties can be overridden just like normal JS objects – the last value always wins.

+
{highlight(`const horizontalStack = {
+  display: 'flex',
+  alignItems: 'center',
+  columnGap: 8
+};
+const styles = style({
+  ...horizontalStack,
+  columnGap: 4
+});`)}
+

You can also create custom utilities by defining your own macros. These are normal functions so you can do whatever computations you like to generate styles.

+
{highlight(`// style-utils.ts
+export function horizontalStack(gap: number) {
+  return {
+    display: 'flex',
+    alignItems: 'center',
+    columnGap: gap
+  };
+}`)}
+

Then, import your macro and use it in a component.

+
{highlight(`// component.tsx
+import {horizontalStack} from './style-utils' with {type: 'macro'};
+const styles = style({
+  ...horizontalStack(4),
+  backgroundColor: 'base'
+});`)}
+
+
+ ) +} diff --git a/.storybook-s2/docs/Workflow Icons.mdx b/.storybook-s2/docs/Workflow Icons.mdx new file mode 100644 index 00000000000..8703f29b549 --- /dev/null +++ b/.storybook-s2/docs/Workflow Icons.mdx @@ -0,0 +1,3 @@ +import {Icons} from './Icons.jsx'; + + diff --git a/.storybook-s2/docs/highlight.js b/.storybook-s2/docs/highlight.js new file mode 100644 index 00000000000..c74f3c33671 --- /dev/null +++ b/.storybook-s2/docs/highlight.js @@ -0,0 +1,38 @@ +const treeSitter = require('tree-sitter-highlight'); +const tokens = require('@adobe/spectrum-tokens/dist/json/variables.json'); + +function colorToken(name) { + let token = tokens[name]; + return `light-dark(${token.sets.light.value}, ${token.sets.dark.value})`; +} + +exports.highlight = function(code, lang = 'JSX') { + this.addAsset({ + type: 'css', + content: ` +.keyword { + color: ${colorToken('magenta-1000')} +} +.string { + color: ${colorToken('green-1000')} +} +.number { + color: ${colorToken('pink-1000')} +} +.property, .attribute { + color: ${colorToken('indigo-1000')} +} +.function, .tag, .constructor { + color: ${colorToken('red-1000')} +} +.comment { + color: ${colorToken('gray-700')} +} +.variable { + color: ${colorToken('fuchsia-1000')} +} +` + }); + + return treeSitter.highlight(code, treeSitter.Language[lang]); +} diff --git a/.storybook-s2/docs/typography.js b/.storybook-s2/docs/typography.js new file mode 100644 index 00000000000..8ec984c32e2 --- /dev/null +++ b/.storybook-s2/docs/typography.js @@ -0,0 +1,37 @@ +import { style } from '../../packages/@react-spectrum/s2/style/spectrum-theme' with {type: 'macro'}; +import {Link} from '@react-spectrum/s2'; + +export function H2({children}) { + let id = anchorId(children); + return

{children}

+} + +export function H3({children}) { + let id = anchorId(children); + return

{children}

+} + +export function H4({children}) { + let id = anchorId(children); + return

{children}

+} + +export function P({children}) { + return

{children}

+} + +export function Code({children}) { + return {children}; +} + +export function Pre({children}) { + return ( +
+      
+    
+ ); +} + +function anchorId(children) { + return children.replace(/\s/g, '-').replace(/[^a-zA-Z0-9-_]/g, '').toLowerCase(); +} diff --git a/.storybook-s2/docs/wallpaper_collaborative_S2_desktop.webp b/.storybook-s2/docs/wallpaper_collaborative_S2_desktop.webp new file mode 100644 index 00000000000..14a94ca9b04 Binary files /dev/null and b/.storybook-s2/docs/wallpaper_collaborative_S2_desktop.webp differ diff --git a/.storybook-s2/main.ts b/.storybook-s2/main.ts index 17d22d73f97..1ce3a845997 100644 --- a/.storybook-s2/main.ts +++ b/.storybook-s2/main.ts @@ -16,7 +16,7 @@ import type { StorybookConfig } from "@storybook/types"; const config: StorybookConfig = { stories: [ - // './Intro.mdx', + './docs/*.mdx', "../packages/@react-spectrum/s2/stories/*.stories.@(js|jsx|mjs|ts|tsx)", ], addons: [ diff --git a/.storybook-s2/preview-head.html b/.storybook-s2/preview-head.html index 1b947ace760..3901b66fd7c 100644 --- a/.storybook-s2/preview-head.html +++ b/.storybook-s2/preview-head.html @@ -13,3 +13,12 @@ h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s) })(document); + diff --git a/package.json b/package.json index f9622f5e7dc..83ee46648bd 100644 --- a/package.json +++ b/package.json @@ -250,7 +250,8 @@ "packages/@react-spectrum/style-macro-s1/**", "packages/@react-spectrum/tree/**", "packages/@react-spectrum/color/src/*.tsx", - "packages/@react-spectrum/s2/**" + "packages/@react-spectrum/s2/**", + ".storybook-s2/**" ] }, "drafts": { diff --git a/packages/@react-spectrum/s2/spectrum-illustrations/Cloud.svg b/packages/@react-spectrum/s2/spectrum-illustrations/Cloud.svg index d3b0277e1e6..afd9fa40f66 100644 --- a/packages/@react-spectrum/s2/spectrum-illustrations/Cloud.svg +++ b/packages/@react-spectrum/s2/spectrum-illustrations/Cloud.svg @@ -1,3 +1,3 @@ - - + + diff --git a/packages/@react-spectrum/s2/spectrum-illustrations/DropToUpload.svg b/packages/@react-spectrum/s2/spectrum-illustrations/DropToUpload.svg index 3b98dba8cc3..76824d0bd96 100644 --- a/packages/@react-spectrum/s2/spectrum-illustrations/DropToUpload.svg +++ b/packages/@react-spectrum/s2/spectrum-illustrations/DropToUpload.svg @@ -1,4 +1,3 @@ - - - + + diff --git a/packages/@react-spectrum/upgrade-cli/README.md b/packages/@react-spectrum/upgrade-cli/README.md index 70bec5306bc..fae0ec4a682 100644 --- a/packages/@react-spectrum/upgrade-cli/README.md +++ b/packages/@react-spectrum/upgrade-cli/README.md @@ -4,7 +4,7 @@ A CLI tool for upgrading React Spectrum components to Spectrum 2. ## Usage -Run `npx upgrade-react-spectrum` from the directory you want to upgrade. +Run `npx @react-spectrum/upgrade-cli` from the directory you want to upgrade. ### Options @@ -12,4 +12,4 @@ Run `npx upgrade-react-spectrum` from the directory you want to upgrade. ## How it works -The upgrade assistant use codemods written with [jscodeshift](https://github.com/facebook/jscodeshift). \ No newline at end of file +The upgrade assistant use codemods written with [jscodeshift](https://github.com/facebook/jscodeshift). diff --git a/packages/dev/parcel-transformer-mdx-storybook/StorybookMDXTransformer.mjs b/packages/dev/parcel-transformer-mdx-storybook/StorybookMDXTransformer.mjs new file mode 100644 index 00000000000..cfbc208a364 --- /dev/null +++ b/packages/dev/parcel-transformer-mdx-storybook/StorybookMDXTransformer.mjs @@ -0,0 +1,17 @@ +import {Transformer} from '@parcel/plugin'; +import {compile} from '@mdx-js/mdx'; + +export default (new Transformer({ + async transform({asset}) { + let code = await asset.getCode(); + let compiled = await compile(code, { + providerImportSource: '@mdx-js/react', + jsxRuntime: 'automatic' + }); + + asset.type = 'js'; + asset.setCode(compiled.value); + + return [asset]; + }, +})); diff --git a/packages/dev/parcel-transformer-mdx-storybook/package.json b/packages/dev/parcel-transformer-mdx-storybook/package.json new file mode 100644 index 00000000000..d9c5154d877 --- /dev/null +++ b/packages/dev/parcel-transformer-mdx-storybook/package.json @@ -0,0 +1,13 @@ +{ + "name": "parcel-transformer-mdx-storybook", + "version": "1.0.0", + "private": true, + "main": "StorybookMDXTransformer.mjs", + "engines": { + "parcel": "2.0.0-dev.1599" + }, + "dependencies": { + "@mdx-js/mdx": "next", + "@mdx-js/react": "next" + } +} diff --git a/yarn.lock b/yarn.lock index c6cecbbb2dd..d5bc4f89093 100644 --- a/yarn.lock +++ b/yarn.lock @@ -27010,6 +27010,15 @@ __metadata: languageName: unknown linkType: soft +"parcel-transformer-mdx-storybook@workspace:packages/dev/parcel-transformer-mdx-storybook": + version: 0.0.0-use.local + resolution: "parcel-transformer-mdx-storybook@workspace:packages/dev/parcel-transformer-mdx-storybook" + dependencies: + "@mdx-js/mdx": "npm:next" + "@mdx-js/react": "npm:next" + languageName: unknown + linkType: soft + "parcel-transformer-react-docgen-typescript@workspace:packages/dev/parcel-transformer-react-docgen-typescript": version: 0.0.0-use.local resolution: "parcel-transformer-react-docgen-typescript@workspace:packages/dev/parcel-transformer-react-docgen-typescript"