Skip to content

chore: Storybook 8 using parcel builder #8272

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

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a61591d
Starting point
snowystinger May 20, 2025
7814a35
install state with parcel-bundler-storybook local
snowystinger May 21, 2025
b6505be
renders v3 and s2
snowystinger May 21, 2025
9f2dd97
fix lint, multiple copies of storybook, paths
snowystinger May 21, 2025
ec7de9c
mostly fix the docs pages
snowystinger May 21, 2025
10eecc4
fix tests
snowystinger May 22, 2025
225c07b
fix docs build
snowystinger May 22, 2025
a420e84
turn on verdaccio
snowystinger May 22, 2025
655d749
preemptively fix verdaccio
snowystinger May 22, 2025
381686f
fix lint - largely undoable when everything moves back to the other repo
snowystinger May 22, 2025
18b33cf
Merge branch 'main' into upgrade-sb-8-2
snowystinger May 24, 2025
30472c3
Revert "fix docs build"
snowystinger May 26, 2025
fea968c
Merge branch 'main' into upgrade-sb-8-2
snowystinger May 26, 2025
a19bf93
fix date range picker test locally
snowystinger May 26, 2025
cad506e
fix icon rendering with context
snowystinger May 27, 2025
8959586
bump to latest release in effort to fix docs addon
snowystinger May 27, 2025
4df714b
partial revert to get icons in buttons working again
snowystinger May 27, 2025
920c60d
remove dead patch
snowystinger May 27, 2025
c4c2fb9
Merge branch 'main' into upgrade-sb-8-2
snowystinger May 27, 2025
d1bee3e
fix sb docs
snowystinger May 28, 2025
c59c680
remove accidental story
snowystinger May 28, 2025
4a9231b
fix tailwind starter
snowystinger May 28, 2025
4877e01
try fixing verdaccio
snowystinger May 28, 2025
f134c4d
fix docs example build
snowystinger May 28, 2025
a3ad057
fix version of plugin
snowystinger May 28, 2025
2dc390f
undo webpack plugin for vite app
snowystinger May 28, 2025
10fa86c
set a default path for storybook v3
snowystinger May 28, 2025
37f7962
Revert "turn on verdaccio"
snowystinger May 28, 2025
1e9a68a
fix a11y addon
snowystinger Jun 3, 2025
17375f5
Merge branch 'main' into upgrade-sb-8-2
snowystinger Jun 3, 2025
427f0c7
fix searchwithin stories
snowystinger Jun 3, 2025
771b1f4
fix lint
snowystinger Jun 3, 2025
576f0c4
Merge branch 'upgrade-sb-8-2' of github.com:adobe/react-spectrum into…
snowystinger Jun 3, 2025
bc5e9c9
Merge branch 'main' into upgrade-sb-8-2
snowystinger Jun 4, 2025
a004ac8
Merge branch 'main' into upgrade-sb-8-2
snowystinger Jun 16, 2025
26eb687
Reapply "turn on verdaccio"
snowystinger Jun 16, 2025
2657b0d
Revert "Reapply "turn on verdaccio""
snowystinger Jun 16, 2025
c5c8450
fix merge
snowystinger Jun 16, 2025
cbb470e
Reapply "turn on verdaccio"
snowystinger Jun 16, 2025
29ad394
Revert "Reapply "turn on verdaccio""
snowystinger Jun 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function run() {
[Publish stats](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/publish-stats/publish.json)
[Size diff since last release](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/publish-stats/size-diff.txt)
[Docs](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/docs/index.html)
[Storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook/index.html)
[Storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook/index.html?path=/story/accordion--default)
[S2 Storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook-s2/index.html)`
});
}
Expand All @@ -79,7 +79,7 @@ async function run() {
issue_number: pr,
body: `Build successful! 🎉

* [View the storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook/index.html)
* [View the storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook/index.html?path=/story/accordion--default)
* [View the S2 storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook-s2/index.html)
* [View the documentation](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/docs/index.html)`
});
Expand Down
14 changes: 4 additions & 10 deletions .storybook-s2/custom-addons/provider/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import React, {useEffect, useState} from 'react';
import {addons} from '@storybook/preview-api';
import {makeDecorator} from '@storybook/preview-api';
import {getQueryParams} from '@storybook/preview-api';
// Importing from src so that HMR works.
// Without this, all HMR updates will bubble through the index.ts and up
// Without this, all HMR updates will bubble through the index.ts and up
// to the root instead of stopping at the story files.
import {Provider} from '../../../packages/@react-spectrum/s2/src/Provider';

document.body.style.margin = '0';

const providerValuesFromUrl = Object.entries(getQueryParams()).reduce((acc, [k, v]) => {
if (k.includes('providerSwitcher-')) {
return { ...acc, [k.replace('providerSwitcher-', '')]: v };
}
return acc;
}, {});

function ProviderUpdater(props) {
let [localeValue, setLocale] = useState(providerValuesFromUrl.locale || undefined);
let params = new URLSearchParams(document.location.search);
let localeParam = params.get('providerSwitcher-locale') || undefined;
let [localeValue, setLocale] = useState(localeParam);

useEffect(() => {
let channel = addons.getChannel();
Expand Down
11 changes: 2 additions & 9 deletions .storybook-s2/custom-addons/provider/register.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@

import {addons, types} from '@storybook/manager-api';
import {getQueryParams} from '@storybook/preview-api';
import {locales} from '../../constants';
import React, {useEffect, useState} from 'react';

const providerValuesFromUrl = Object.entries(getQueryParams()).reduce((acc, [k, v]) => {
if (k.includes('providerSwitcher-')) {
return { ...acc, [k.replace('providerSwitcher-', '')]: v };
}
return acc;
}, {});

function ProviderFieldSetter({api}) {
let [values, setValues] = useState({locale: providerValuesFromUrl.locale || undefined});
let localeParam = api.getQueryParam('providerSwitcher-locale') || undefined;
let [values, setValues] = useState({locale: localeParam});
let channel = addons.getChannel();
let onLocaleChange = (e) => {
let newValue = e.target.value || undefined;
Expand Down
2 changes: 1 addition & 1 deletion .storybook-s2/docs/Icons.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import icons from '@react-spectrum/s2/s2wf-icons/*.svg';
import icons from '../../packages/@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 {H2, H3, P, Code, Pre, Link} from './typography';
Expand Down
3 changes: 3 additions & 0 deletions .storybook-s2/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const config: StorybookConfig = {
framework: {
name: "storybook-react-parcel",
options: {},
},
core: {
disableWhatsNewNotifications: true
}
// typescript: {
// reactDocgen: 'react-docgen-typescript',
Expand Down
8 changes: 3 additions & 5 deletions .storybook/custom-addons/descriptions/register.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

import {addons, types} from '@storybook/manager-api';
import {addons, types, useParameter} from '@storybook/manager-api';
import { AddonPanel } from '@storybook/components';
import React from 'react';
import { useParameter } from '@storybook/api';

const ADDON_ID = 'descriptionAddon';
const PANEL_ID = `${ADDON_ID}/panel`;
Expand All @@ -19,10 +17,10 @@ addons.register(ADDON_ID, (api) => {
addons.add(PANEL_ID, {
type: types.PANEL,
title: 'Description',
render: ({ active }) => (
render: ({active}) => (
<AddonPanel active={active}>
<MyPanel />
</AddonPanel>
),
)
});
});
24 changes: 12 additions & 12 deletions .storybook/custom-addons/provider/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import React, {useEffect, useState} from 'react';
import {addons} from '@storybook/preview-api';
import {makeDecorator} from '@storybook/preview-api';
import {getQueryParams} from '@storybook/preview-api';
import {Provider} from '@react-spectrum/provider';
import {expressThemes, themes, defaultTheme} from '../../constants';

document.body.style.margin = '0';

const providerValuesFromUrl = Object.entries(getQueryParams()).reduce((acc, [k, v]) => {
if (k.includes('providerSwitcher-')) {
return { ...acc, [k.replace('providerSwitcher-', '')]: v };
}
return acc;
}, {});

function ProviderUpdater(props) {
let [localeValue, setLocale] = useState(providerValuesFromUrl.locale || undefined);
let [themeValue, setTheme] = useState(providerValuesFromUrl.theme || undefined);
let [scaleValue, setScale] = useState(providerValuesFromUrl.scale || undefined);
let [expressValue, setExpress] = useState(providerValuesFromUrl.express === 'true');
let params = new URLSearchParams(document.location.search);
let localeParam = params.get("providerSwitcher-locale") || undefined;
let [localeValue, setLocale] = useState(localeParam);
let themeParam = params.get("providerSwitcher-theme") || undefined;
let [themeValue, setTheme] = useState(themeParam);
let scaleParam = params.get("providerSwitcher-scale") || undefined;
let [scaleValue, setScale] = useState(scaleParam);
let expressParam = params.get("providerSwitcher-express") || undefined;
let [expressValue, setExpress] = useState(expressParam === 'true');
let [storyReady, setStoryReady] = useState(window.parent === window || window.parent !== window.top); // reduce content flash because it takes a moment to get the provider details
// Typically themes are provided with both light + dark, and both scales.
// To build our selector to see all themes, we need to hack it a bit.
Expand All @@ -27,6 +24,7 @@ function ProviderUpdater(props) {
useEffect(() => {
let channel = addons.getChannel();
let providerUpdate = (event) => {
console.log('providerUpdate', event);
setLocale(event.locale);
setTheme(event.theme === 'Auto' ? undefined : event.theme);
setScale(event.scale === 'Auto' ? undefined : event.scale);
Expand All @@ -42,6 +40,7 @@ function ProviderUpdater(props) {
}, []);

if (props.options.mainElement == null) {
console.log('mainElement is null', storyReady);
return (
<Provider theme={theme} colorScheme={colorScheme} scale={scaleValue} locale={localeValue}>
<main>
Expand All @@ -50,6 +49,7 @@ function ProviderUpdater(props) {
</Provider>
);
} else {
console.log('mainElement is not null');
return (
<Provider theme={theme} colorScheme={colorScheme} scale={scaleValue} locale={localeValue}>
{storyReady && props.children}
Expand Down
22 changes: 13 additions & 9 deletions .storybook/custom-addons/provider/register.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@

import {addons, types} from '@storybook/manager-api';
import {getQueryParams} from '@storybook/preview-api';
import {locales} from '../../constants';
import React, {useEffect, useState} from 'react';

const providerValuesFromUrl = Object.entries(getQueryParams()).reduce((acc, [k, v]) => {
if (k.includes('providerSwitcher-')) {
return { ...acc, [k.replace('providerSwitcher-', '')]: v };
}
return acc;
}, {});

let THEMES = [
{label: 'Auto', value: ''},
Expand Down Expand Up @@ -37,7 +29,17 @@ let TOAST_POSITIONS = [
];

function ProviderFieldSetter({api}) {
let [values, setValues] = useState({locale: providerValuesFromUrl.locale || undefined, theme: providerValuesFromUrl.theme || undefined, scale: providerValuesFromUrl.scale || undefined, express: providerValuesFromUrl.express === 'true'});
let localeParam = api.getQueryParam('providerSwitcher-locale') || undefined;
let themeParam = api.getQueryParam('providerSwitcher-theme') || undefined;
let scaleParam = api.getQueryParam('providerSwitcher-scale') || undefined;
let expressParam = api.getQueryParam('providerSwitcher-express') || undefined;

let [values, setValues] = useState({
locale: localeParam,
theme: themeParam,
scale: scaleParam,
express: expressParam === 'true'
});
let channel = addons.getChannel();
let onLocaleChange = (e) => {
let newValue = e.target.value || undefined;
Expand Down Expand Up @@ -73,6 +75,7 @@ function ProviderFieldSetter({api}) {
};
useEffect(() => {
let storySwapped = () => {
console.log('storySwapped', values);
channel.emit('provider/updated', values);
};
channel.on('rsp/ready-for-update', storySwapped);
Expand Down Expand Up @@ -119,6 +122,7 @@ function ProviderFieldSetter({api}) {
}

addons.register('ProviderSwitcher', (api) => {
console.log('ProviderSwitcher registering');
addons.add('ProviderSwitcher', {
title: 'viewport',
type: types.TOOL,
Expand Down
5 changes: 3 additions & 2 deletions .storybook/custom-addons/scrolling/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {addons} from '@storybook/preview-api';
import clsx from 'clsx';
import {getQueryParams} from '@storybook/preview-api';
import React, {useEffect, useState} from 'react';

function ScrollingDecorator(props) {
let {children} = props;
let [isScrolling, setScrolling] = useState(getQueryParams()?.scrolling === 'true' || false);
let params = new URLSearchParams(document.location.search);
let scrolling = params.get('scrolling') || undefined;
let [isScrolling, setScrolling] = useState(scrolling === 'true' || false);

useEffect(() => {
let channel = addons.getChannel();
Expand Down
4 changes: 2 additions & 2 deletions .storybook/custom-addons/scrolling/register.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {addons, types} from '@storybook/manager-api';
import {getQueryParams} from '@storybook/preview-api';
import React, {useEffect, useState} from 'react';

const ScrollingToolbar = ({api}) => {
let channel = addons.getChannel();
let [isScrolling, setScrolling] = useState(getQueryParams()?.scrolling === 'true' || false);
let scrolling = api.getQueryParam('scrolling');
let [isScrolling, setScrolling] = useState(scrolling === 'true' || false);
let onChange = () => {
setScrolling((old) => {
channel.emit('scrolling/updated', !old);
Expand Down
5 changes: 3 additions & 2 deletions .storybook/custom-addons/strictmode/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {addons, makeDecorator} from '@storybook/preview-api';
import {getQueryParams} from '@storybook/preview-api';
import React, {StrictMode, useEffect, useState} from 'react';

function StrictModeDecorator(props) {
let {children} = props;
let [isStrict, setStrict] = useState(getQueryParams()?.strict !== 'false');
let params = new URLSearchParams(document.location.search);
let strictParam = params.get("strict") || undefined;
let [isStrict, setStrict] = useState(strictParam !== 'false');

useEffect(() => {
let channel = addons.getChannel();
Expand Down
6 changes: 3 additions & 3 deletions .storybook/custom-addons/strictmode/register.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {addons, types} from '@storybook/manager-api';
import {getQueryParams} from '@storybook/preview-api';
import React, {useEffect, useState} from 'react';

const StrictModeToolBar = ({api}) => {
let channel = addons.getChannel();
let [isStrict, setStrict] = useState(getQueryParams()?.strict !== 'false');
let strictParam = api.getQueryParam('strict');
let [isStrict, setStrict] = useState(strictParam !== 'false');
let onChange = () => {
setStrict((old) => {
channel.emit('strict/updated', !old);
return !old;
})
});
};

useEffect(() => {
Expand Down
14 changes: 9 additions & 5 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ module.exports = {
"@storybook/addon-a11y",
"@storybook/addon-controls",
"storybook-dark-mode",
'./custom-addons/provider/register',
'./custom-addons/descriptions/register',
'./custom-addons/theme/register',
'./custom-addons/strictmode/register',
'./custom-addons/scrolling/register'
'./custom-addons/provider/register.js',
'./custom-addons/descriptions/register.js',
'./custom-addons/theme/register.js',
'./custom-addons/strictmode/register.js',
'./custom-addons/scrolling/register.js'
],

typescript: {
Expand All @@ -26,5 +26,9 @@ module.exports = {
framework: {
name: "storybook-react-parcel",
options: {},
},

core: {
disableWhatsNewNotifications: true
}
};
10 changes: 0 additions & 10 deletions .yarn/patches/@storybook-addon-a11y-npm-7.6.19-04b470eae0.patch

This file was deleted.

Loading