Skip to content

Commit 6990d69

Browse files
Merge branch 'main' of https://github.com/boutahlilsoufiane/react-spectrum into constrain-date
2 parents 18967fc + c22d474 commit 6990d69

File tree

1,558 files changed

+56126
-16041
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,558 files changed

+56126
-16041
lines changed

.chromatic/preview-head.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@
138138
<!--
139139
Load S2 adobe clean VF
140140
-->
141-
<link rel="preload" href="https://use.typekit.net/af/5e77d8/00000000000000007754d3a5/30/l?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=n1&v=3" as="font" crossorigin="anonymous" />
142-
<link rel="stylesheet" href="https://use.typekit.net/yuq6kxz.css">
141+
<link rel="preload" href="https://use.typekit.net/af/b1226a/0000000000000000775c0485/31/l?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=n1&v=3" as="font" crossorigin="anonymous" />
143142

144143
<!--
145144
This web project loads adobe clean, adobe clean serif, myriad-arabic, myriad-hebrew, adobe-clean-han-japanese,

.circleci/comment.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async function run() {
6060
[Publish stats](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/publish-stats/publish.json)
6161
[Size diff since last release](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/publish-stats/size-diff.txt)
6262
[Docs](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/docs/index.html)
63-
[Storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook/index.html)
63+
[Storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook/index.html?path=/story/accordion--default)
6464
[S2 Storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook-s2/index.html)`
6565
});
6666
}
@@ -79,9 +79,10 @@ async function run() {
7979
issue_number: pr,
8080
body: `Build successful! 🎉
8181
82-
* [View the storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook/index.html)
82+
* [View the storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook/index.html?path=/story/accordion--default)
8383
* [View the S2 storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook-s2/index.html)
84-
* [View the documentation](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/docs/index.html)`
84+
* [View the documentation](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/docs/index.html)
85+
* [View the S2 docs](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/s2-docs/index.html)`
8586
});
8687
} catch (err) {
8788
console.error(err)

.circleci/config.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ executors:
3737
CACHE_VERSION: v1
3838
working_directory: ~/react-spectrum
3939

40+
rsp-2xlarge:
41+
docker:
42+
- image: cimg/node:22.13.1
43+
resource_class: 2xlarge
44+
environment:
45+
CACHE_VERSION: v1
46+
working_directory: ~/react-spectrum
47+
4048
jobs:
4149
install:
4250
executor: rsp-large
@@ -325,7 +333,7 @@ jobs:
325333
path: ~/junit
326334

327335
test-esm:
328-
executor: rsp-xlarge
336+
executor: rsp-2xlarge
329337
steps:
330338
- restore_cache:
331339
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
@@ -470,6 +478,21 @@ jobs:
470478
paths:
471479
- '*/docs/'
472480

481+
s2-docs:
482+
executor: rsp-xlarge
483+
steps:
484+
- restore_cache:
485+
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
486+
487+
- run:
488+
name: build s2 docs
489+
command: make s2-docs
490+
491+
- persist_to_workspace:
492+
root: dist
493+
paths:
494+
- '*/s2-docs/'
495+
473496
verdaccio:
474497
executor: rsp-xlarge
475498
steps:
@@ -493,7 +516,7 @@ jobs:
493516
- storage
494517

495518
v-docs:
496-
executor: rsp-xlarge
519+
executor: rsp-2xlarge
497520
steps:
498521
- restore_cache:
499522
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
@@ -509,6 +532,15 @@ jobs:
509532
environment:
510533
VERDACCIO_STORAGE_PATH: /tmp/verdaccio-workspace/storage
511534

535+
- run:
536+
name: build docs off verdaccio retry
537+
command: |
538+
./scripts/verdaccio-ci.sh
539+
./scripts/verdaccio-build.sh
540+
environment:
541+
VERDACCIO_STORAGE_PATH: /tmp/verdaccio-workspace/storage
542+
when: on_fail
543+
512544
- persist_to_workspace:
513545
root: verdaccio_dist
514546
paths:
@@ -874,6 +906,9 @@ workflows:
874906
- docs:
875907
requires:
876908
- install
909+
- s2-docs:
910+
requires:
911+
- install
877912
- verdaccio:
878913
filters:
879914
branches:
@@ -928,6 +963,7 @@ workflows:
928963
- storybook
929964
- storybook-s2
930965
- docs
966+
- s2-docs
931967
- deploy-verdaccio:
932968
requires:
933969
- v-docs

.github/labeler.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
needs translations:
2+
- changed-files:
3+
- any-glob-to-any-file: ['**/intl/*.json']

.github/workflows/labeler.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: "Pull Request Labeler"
2+
on:
3+
- pull_request_target
4+
5+
jobs:
6+
labeler:
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/labeler@v5
13+
with:
14+
sync-labels: true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ test-reports.xml
1717
storage
1818
packages/dev/storybook-builder-parcel/iframe.html
1919
packages/dev/storybook-builder-parcel/preview.js
20+
starters/docs/registry
21+
starters/tailwind/registry

.storybook-s2/custom-addons/provider/index.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
import React, {useEffect, useState} from 'react';
22
import {addons} from '@storybook/preview-api';
33
import {makeDecorator} from '@storybook/preview-api';
4-
import {getQueryParams} from '@storybook/preview-api';
54
// Importing from src so that HMR works.
6-
// Without this, all HMR updates will bubble through the index.ts and up
5+
// Without this, all HMR updates will bubble through the index.ts and up
76
// to the root instead of stopping at the story files.
87
import {Provider} from '../../../packages/@react-spectrum/s2/src/Provider';
98

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

12-
const providerValuesFromUrl = Object.entries(getQueryParams()).reduce((acc, [k, v]) => {
13-
if (k.includes('providerSwitcher-')) {
14-
return { ...acc, [k.replace('providerSwitcher-', '')]: v };
15-
}
16-
return acc;
17-
}, {});
18-
1911
function ProviderUpdater(props) {
20-
let [localeValue, setLocale] = useState(providerValuesFromUrl.locale || undefined);
12+
let params = new URLSearchParams(document.location.search);
13+
let localeParam = params.get('providerSwitcher-locale') || undefined;
14+
let [localeValue, setLocale] = useState(localeParam);
2115

2216
useEffect(() => {
2317
let channel = addons.getChannel();

.storybook-s2/custom-addons/provider/register.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11

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

7-
const providerValuesFromUrl = Object.entries(getQueryParams()).reduce((acc, [k, v]) => {
8-
if (k.includes('providerSwitcher-')) {
9-
return { ...acc, [k.replace('providerSwitcher-', '')]: v };
10-
}
11-
return acc;
12-
}, {});
13-
146
function ProviderFieldSetter({api}) {
15-
let [values, setValues] = useState({locale: providerValuesFromUrl.locale || undefined});
7+
let localeParam = api.getQueryParam('providerSwitcher-locale') || undefined;
8+
let [values, setValues] = useState({locale: localeParam});
169
let channel = addons.getChannel();
1710
let onLocaleChange = (e) => {
1811
let newValue = e.target.value || undefined;

.storybook-s2/docs/Icons.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import icons from '@react-spectrum/s2/s2wf-icons/*.svg';
1+
import icons from '../../packages/@react-spectrum/s2/s2wf-icons/*.svg';
22
import { style } from '../../packages/@react-spectrum/s2/style/spectrum-theme' with {type: 'macro'};
33
import {ActionButton, Text} from '@react-spectrum/s2';
44
import {H2, H3, P, Code, Pre, Link} from './typography';

.storybook-s2/docs/Intro.jsx

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -140,41 +140,64 @@ export function Docs() {
140140
<P>You may also need to configure other tools such as TypeScript, Babel, ESLint, and Jest to support parsing import attributes. See <Link href="https://parceljs.org/features/macros/#usage-with-other-tools" target="_blank">these docs</Link> for details.</P>
141141
<P>See the <Link href="https://github.com/adobe/react-spectrum/tree/main/examples" target="_blank">examples folder</Link> in our repo for working setups with various build tools. For details on optimizing the output CSS, see the <Link href="?path=/docs/style-macro--docs#css-optimization" target="_top">style macro docs</Link>.</P>
142142
<H2>Setting up your app</H2>
143-
<P>Unlike React Spectrum v3, a <Code>Provider</Code> is not required. Instead, import <Code>@react-spectrum/s2/page.css</Code> in the entry component of your app to apply the background color and color scheme to the <Code>{'<html>'}</Code> element. This ensures that the entire page has the proper styles even before your JavaScript runs.</P>
144-
<Pre>{highlight(`import '@react-spectrum/s2/page.css';
145-
import {Button} from '@react-spectrum/s2';
143+
<P>Wrap your app in an S2 <Code>{'<Provider>'}</Code> component to load Spectrum 2 fonts for the user's locale and apply the appropriate Spectrum background layer for your app. When using S2 together with other versions of Spectrum, ensure that the S2 provider is the inner-most provider.</P>
144+
<Pre>{highlight(`import {Provider, Button} from '@react-spectrum/s2';
146145
147146
function App() {
148147
return (
149-
<Button
150-
variant="accent"
151-
onPress={() => alert('Hey there!')}>
152-
Hello Spectrum 2!
153-
</Button>
148+
// Wrap app in a <Provider> to load fonts, set background, set locale, etc.
149+
<Provider background="base">
150+
<Button
151+
variant="accent"
152+
onPress={() => alert('Hey there!')}>
153+
Hello Spectrum 2!
154+
</Button>
155+
</Provider>
154156
);
155157
}`)}</Pre>
156158
<Example>
157159
<Button variant="accent" onPress={() => alert('Hey there!')}>Hello Spectrum 2!</Button>
158160
</Example>
159-
<P><Strong>Note</Strong>: If you’re embedding Spectrum 2 as a section of a larger page rather than taking over the whole window, follow the <Link href="#embedded-sections" target="_self">directions below</Link> instead of using <Code>page.css</Code>.</P>
161+
<H3>Optimizing full-page apps</H3>
162+
<P>When building a full page S2 app that's not embedded within a larger page, import <Code>@react-spectrum/s2/page.css</Code> to apply the background color and color scheme to the <Code>{'<html>'}</Code> element instead of the <Code>{'<Provider>'}</Code>. This ensures that the page has styles even before your JavaScript loads. A <Code>{'<Provider>'}</Code> is still necessary in addition to <Code>page.css</Code> in order to include the fonts, set the locale, etc.</P>
163+
<Pre>{highlight(`// Apply S2 background to the <html> element
164+
import '@react-spectrum/s2/page.css';
165+
166+
function App() {
167+
return (
168+
<Provider>
169+
{/* ... */}
170+
</Provider>
171+
);
172+
}`)}</Pre>
173+
<P>By default, this uses the <Code>base</Code> background layer. This can be customized by setting the <Code>data-background</Code> attribute on the <Code>{'<html>'}</Code> element.</P>
174+
<Pre>{highlight(`<html data-background="layer-1">
175+
<!-- ... -->
176+
</html>`)}</Pre>
160177
<H3>Overriding the color scheme</H3>
161-
<P>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 <Code>base</Code> Spectrum background layer by default. This can be configured by setting the <Code>data-color-scheme</Code> and <Code>data-background</Code> attributes on the <Code>{'<html>'}</Code> element. For example, to force the application to only render in light mode, set <Code>data-color-scheme="light"</Code>.</P>
178+
<P>By default, React Spectrum follows the operating system color scheme setting, supporting both light and dark mode. The <Code>colorScheme</Code> prop can be set on <Code>{'<Provider>'}</Code> to force the app to always render in a certain color scheme.</P>
179+
<Pre>{highlight(`import {Provider} from '@react-spectrum/s2';
180+
181+
<Provider colorScheme="light">
182+
{/* your app */}
183+
</Provider>`)}</Pre>
184+
<P>When using <Code>page.css</Code>, set the <Code>data-color-scheme</Code> attribute on the <Code>{'<html>'}</Code> element.</P>
162185
<Pre>{highlight(`<html data-color-scheme="light">
163186
<!-- ... -->
164187
</html>`)}</Pre>
165188
<H3>Overriding the locale</H3>
166-
<P>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 <Code>{'<Provider>'}</Code> component at the root of your app, and setting the <Code>locale</Code> prop.</P>
189+
<P>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 setting the <Code>locale</Code> prop on the <Code>{'<Provider>'}</Code>.</P>
167190
<Pre>{highlight(`import {Provider} from '@react-spectrum/s2';
168191
169192
<Provider locale="en-US">
170193
{/* your app */}
171194
</Provider>`)}</Pre>
172-
<H3>Embedded sections</H3>
173-
<P>If you’re building an embedded section of a larger page using Spectrum 2, use the <Code>{'<Provider>'}</Code> component to set the background instead of importing <Code>page.css</Code>. The <Code>background</Code> prop should be set to the Spectrum background layer appropriate for your app, and the <Code>colorScheme</Code> can be overridden as well.</P>
174-
<Pre>{highlight(`import {Provider} from '@react-spectrum/s2';
175-
176-
<Provider background="base">
177-
{/* your app */}
195+
<H3>Server-side rendering</H3>
196+
<P>When using SSR, the <Code>{'<Provider>'}</Code> component can be rendered as the root <Code>{'<html>'}</Code> element. The <Code>locale</Code> prop should always be specified to avoid hydration errors. <Code>page.css</Code> is not needed in this case.</P>
197+
<Pre>{highlight(`<Provider elementType="html" locale="en-US">
198+
<body>
199+
{/* ... */}
200+
</body>
178201
</Provider>`)}</Pre>
179202
<H3>Usage with older React Spectrum versions</H3>
180203
<P>See Adobe internal documentation.</P>

0 commit comments

Comments
 (0)