Skip to content

Commit 91b7195

Browse files
authored
Add NextJS test app to CI (#3576)
* add NextJS example app * add NextJS build to CI * edit to run on this pr (will revert before merge) * add empty postCSS config to ignore RSP's * fix build output * add homepage to package.json * set basePath when building on verdaccio * update env variable * fix env variable * add commit hash to basePath * add leading slash * fix stats output * fix basePath again * cleanup script * bump versions in example * update next css config * add Badge and LabeledValue * add Date and Time components * cleanup examples * clean up example * formatting * fix build * fix build * Publish - @adobe/[email protected] - @adobe/[email protected] - @internationalized/[email protected] - @internationalized/[email protected] - @internationalized/[email protected] - @internationalized/[email protected] - @internationalized/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-aria/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-spectrum/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-stately/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @react-types/[email protected] - @spectrum-icons/[email protected] - @spectrum-icons/[email protected] - @spectrum-icons/[email protected] - @spectrum-icons/[email protected] - @spectrum-icons/[email protected] - [email protected] - @react-spectrum/[email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - [email protected] - @react-spectrum/[email protected] - [email protected] - [email protected] * Revert publish * Revert "Publish" This reverts commit 358877e. * update readme * add isIndeterminate examples * add DialogContainer * remove unused styles * use Grid for layout * formatting * add color examples * cleanup * update to run on main
1 parent aee2417 commit 91b7195

File tree

18 files changed

+4614
-10
lines changed

18 files changed

+4614
-10
lines changed

.circleci/comment.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ async function run() {
4747
repo: 'react-spectrum',
4848
commit_sha: process.env.CIRCLE_SHA1,
4949
body: `Verdaccio builds:
50-
[Test App](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/build/index.html)
51-
[Test App Size](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/publish-stats/build-stats.txt)
50+
[CRA Test App](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/build/index.html)
51+
[NextJS Test App](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/next/index.html)
52+
[CRA Test App Size](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/publish-stats/build-stats.txt)
53+
[NextJS App Size](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/publish-stats/next-build-stats.txt)
5254
[Publish stats](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/publish-stats/publish.json)
5355
[Size diff since last release](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/publish-stats/size-diff.txt)
5456
[Docs](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/docs/index.html)`

examples/rsp-next-ts/.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["next", "next/core-web-vitals"]
3+
}

examples/rsp-next-ts/.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel

examples/rsp-next-ts/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Next.js Typescript example with React Spectrum
2+
3+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) and [React Spectrum](https://react-spectrum.adobe.com/index.html).
4+
5+
## Getting Started
6+
7+
First, run the development server:
8+
9+
```bash
10+
npm run dev
11+
# or
12+
yarn dev
13+
```
14+
15+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
16+
17+
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
18+
19+
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.tsx`.
20+
21+
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { View, Heading, Divider } from "@adobe/react-spectrum";
2+
import React from "react";
3+
4+
interface SectionProps {
5+
title: string;
6+
children: JSX.Element | JSX.Element[];
7+
}
8+
9+
export default function Section(props: SectionProps) {
10+
let { title, children } = props;
11+
return (
12+
<View marginBottom="size-200">
13+
<Heading id={title.toLowerCase()} level={2}>
14+
{title}
15+
</Heading>
16+
<Divider marginBottom="size-100" />
17+
{children}
18+
</View>
19+
);
20+
}

examples/rsp-next-ts/next-env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.

examples/rsp-next-ts/next.config.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
const withTM = require("next-transpile-modules")([
2+
"@adobe/react-spectrum",
3+
"@react-spectrum/actiongroup",
4+
"@react-spectrum/badge",
5+
"@react-spectrum/breadcrumbs",
6+
"@react-spectrum/button",
7+
"@react-spectrum/buttongroup",
8+
"@react-spectrum/calendar",
9+
"@react-spectrum/checkbox",
10+
"@react-spectrum/color",
11+
"@react-spectrum/combobox",
12+
"@react-spectrum/contextualhelp",
13+
"@react-spectrum/datepicker",
14+
"@react-spectrum/dialog",
15+
"@react-spectrum/divider",
16+
"@react-spectrum/form",
17+
"@react-spectrum/icon",
18+
"@react-spectrum/illustratedmessage",
19+
"@react-spectrum/image",
20+
"@react-spectrum/label",
21+
"@react-spectrum/labeledvalue",
22+
"@react-spectrum/layout",
23+
"@react-spectrum/link",
24+
"@react-spectrum/list",
25+
"@react-spectrum/listbox",
26+
"@react-spectrum/menu",
27+
"@react-spectrum/meter",
28+
"@react-spectrum/numberfield",
29+
"@react-spectrum/overlays",
30+
"@react-spectrum/picker",
31+
"@react-spectrum/progress",
32+
"@react-spectrum/provider",
33+
"@react-spectrum/radio",
34+
"@react-spectrum/slider",
35+
"@react-spectrum/searchfield",
36+
"@react-spectrum/statuslight",
37+
"@react-spectrum/switch",
38+
"@react-spectrum/table",
39+
"@react-spectrum/tabs",
40+
"@react-spectrum/text",
41+
"@react-spectrum/textfield",
42+
"@react-spectrum/theme-dark",
43+
"@react-spectrum/theme-default",
44+
"@react-spectrum/theme-light",
45+
"@react-spectrum/tooltip",
46+
"@react-spectrum/view",
47+
"@react-spectrum/well",
48+
"@spectrum-icons/illustrations",
49+
"@spectrum-icons/ui",
50+
"@spectrum-icons/workflow",
51+
]);
52+
53+
module.exports = withTM({
54+
basePath:
55+
process.env.VERDACCIO && process.env.CIRCLE_SHA1
56+
? `/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/next`
57+
: "",
58+
});

examples/rsp-next-ts/package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "rsp-next-ts",
3+
"version": "0.1.0",
4+
"private": true,
5+
"homepage": ".",
6+
"scripts": {
7+
"dev": "next dev",
8+
"build": "next build",
9+
"export": "next export",
10+
"start": "next start",
11+
"lint": "next lint"
12+
},
13+
"dependencies": {
14+
"@adobe/react-spectrum": "^3.22.0",
15+
"@react-spectrum/color": "^3.0.0-beta.16",
16+
"@spectrum-icons/illustrations": "^3.5.0",
17+
"@spectrum-icons/workflow": "^4.0.3",
18+
"next": "^12.3.1",
19+
"next-transpile-modules": "^9.0.0",
20+
"react": "^18.2.0",
21+
"react-dom": "^18.2.0"
22+
},
23+
"devDependencies": {
24+
"@types/node": "^18.8.2",
25+
"@types/react": "^18.0.21",
26+
"eslint": "^8.24.0",
27+
"eslint-config-next": "^12.3.1",
28+
"typescript": "^4.8.4"
29+
}
30+
}

examples/rsp-next-ts/pages/_app.tsx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import "../styles/globals.css";
2+
import type { AppProps } from "next/app";
3+
import {
4+
SSRProvider,
5+
Provider,
6+
lightTheme,
7+
ActionButton,
8+
Flex,
9+
Grid,
10+
View,
11+
} from "@adobe/react-spectrum";
12+
import { ColorScheme } from "@react-types/provider";
13+
import { useState } from "react";
14+
import Moon from "@spectrum-icons/workflow/Moon";
15+
import Light from "@spectrum-icons/workflow/Light";
16+
17+
function MyApp({ Component, pageProps }: AppProps) {
18+
const [theme, setTheme] = useState<ColorScheme>("light");
19+
20+
let themeIcons = { dark: <Moon />, light: <Light /> };
21+
let otherTheme: ColorScheme = theme === "light" ? "dark" : "light";
22+
23+
return (
24+
<SSRProvider>
25+
<Provider theme={lightTheme} colorScheme={theme}>
26+
<Grid
27+
areas={["header", "content"]}
28+
columns={["1fr"]}
29+
rows={["size-200", "auto"]}
30+
gap="size-100"
31+
>
32+
<Flex
33+
direction="row"
34+
gap="size-100"
35+
justifyContent="end"
36+
margin="size-100"
37+
>
38+
<ActionButton
39+
aria-label={`Switch to ${otherTheme} mode.`}
40+
onPress={() => setTheme(otherTheme)}
41+
>
42+
{themeIcons[otherTheme]}
43+
</ActionButton>
44+
</Flex>
45+
<View>
46+
<Component {...pageProps} />
47+
</View>
48+
</Grid>
49+
</Provider>
50+
</SSRProvider>
51+
);
52+
}
53+
export default MyApp;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
2+
import type { NextApiRequest, NextApiResponse } from 'next'
3+
4+
type Data = {
5+
name: string
6+
}
7+
8+
export default function handler(
9+
req: NextApiRequest,
10+
res: NextApiResponse<Data>
11+
) {
12+
res.status(200).json({ name: 'John Doe' })
13+
}

0 commit comments

Comments
 (0)