Skip to content
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

Add Next.js app router Toolpad Core playground #3587

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
bebb82e
Improve bundling, try to fix MUI/Next integration bugs
apedroferreira Mar 28, 2024
03786bd
Fix import in template
apedroferreira Mar 28, 2024
fd68ff0
fix it more
apedroferreira Mar 28, 2024
4d04649
Re-add icon imports
apedroferreira Mar 28, 2024
8630f2a
Always clean or it gets messy
apedroferreira Mar 28, 2024
235116a
Basic layout - a start
apedroferreira Mar 29, 2024
1311f6f
Remove unused icon
apedroferreira Apr 1, 2024
8f6c9db
Basic header, sidebar in progress
apedroferreira Apr 2, 2024
e6d436b
Header with branding + navigation with nesting
apedroferreira Apr 3, 2024
4807db7
Grammar
apedroferreira Apr 3, 2024
926102f
Much better test
apedroferreira Apr 3, 2024
f0c6180
Update created app files
apedroferreira Apr 4, 2024
4175348
Scaffolding fixes
apedroferreira Apr 4, 2024
8f19dde
Add DashboardLayout tests
apedroferreira Apr 4, 2024
f44f5a0
Remove this thing I guess
apedroferreira Apr 4, 2024
d250929
Nevermind
apedroferreira Apr 4, 2024
06da40c
Fix dependencies if they're broken
apedroferreira Apr 4, 2024
f0a17e4
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira Apr 4, 2024
3dab0a8
Review fixes, make everything more generic, use playground folder
apedroferreira Apr 16, 2024
eb8a6f1
Build with babel, create development tools
apedroferreira Apr 18, 2024
b8fdf8d
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira Apr 18, 2024
229dffc
Update create-toolpad-app for core
apedroferreira Apr 18, 2024
1c777d3
Review suggestions and add DashboardLayout demo to docs
apedroferreira Apr 23, 2024
9efd2f5
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira Apr 23, 2024
c31fe20
Fix this example
apedroferreira Apr 23, 2024
7fd54d4
Dedupe
apedroferreira Apr 23, 2024
c6819a5
Use new navigation system
apedroferreira Apr 26, 2024
c4da025
Better component name
apedroferreira Apr 26, 2024
e105c15
DashboardLayout docs, missing API reference
apedroferreira Apr 30, 2024
0327c4f
Update
apedroferreira May 2, 2024
4b59fc0
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira May 2, 2024
cbc3045
Reuse theme in docs
apedroferreira May 2, 2024
6508899
Fix core publish
apedroferreira May 2, 2024
34e9255
Rerun install
apedroferreira May 2, 2024
fa9b64f
Fix tests and other errors
apedroferreira May 3, 2024
c21a36e
Set exports too
apedroferreira May 3, 2024
83e99e2
whoops
apedroferreira May 3, 2024
effcabf
Merge branch 'master' into add-layout-component
apedroferreira May 3, 2024
0de2030
Try Netlify deploy with imports from root
apedroferreira May 3, 2024
dd39264
Stupid VSCode setting
apedroferreira May 3, 2024
65acf1d
Linters
apedroferreira May 3, 2024
67f724b
Attempt to fix netlify build
apedroferreira May 6, 2024
4b033f7
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira May 6, 2024
6da38cb
Try to fix OOM in Circle CI
apedroferreira May 6, 2024
1c4f46b
Another attempt to fix OOM in CI
apedroferreira May 6, 2024
a154f6f
Add Toolpad Core contributing instructions
apedroferreira May 6, 2024
c939d98
Try Jan's changes and some other but keep playground
apedroferreira May 7, 2024
b56c288
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira May 7, 2024
69f2db0
Another attempt
apedroferreira May 7, 2024
661c6ad
More cleanup before trying to remove playground
apedroferreira May 7, 2024
291c78f
Update lockfile
apedroferreira May 7, 2024
c355188
Retry filter option to try to keep playground alive
apedroferreira May 7, 2024
701187e
Try with correct option
apedroferreira May 7, 2024
fef1864
Dedupe again
apedroferreira May 7, 2024
deb85ea
ugh
apedroferreira May 7, 2024
b3346b9
Maybe this
apedroferreira May 7, 2024
f7a9cbb
Revert last failed attempts
apedroferreira May 8, 2024
31a4af8
Try older pnpm patch version
apedroferreira May 8, 2024
1c996a7
Try latest pnpm minor version
apedroferreira May 8, 2024
631afc1
Try pnpm 9
apedroferreira May 8, 2024
5682085
Properly try previous minor version
apedroferreira May 8, 2024
ce8102e
Try latesg pnpm commit ( I think)
apedroferreira May 8, 2024
22cfa4f
gh
apedroferreira May 8, 2024
8fa6300
Fix mismatched packages
apedroferreira May 8, 2024
8ac56cb
Playing around with pnpm had somehow broken the lockfile permanently
apedroferreira May 8, 2024
09a4741
Final cleanup
apedroferreira May 8, 2024
4e7d81c
Many review improvements, provide some themes too
apedroferreira May 13, 2024
dbc0e1b
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira May 14, 2024
59e4121
Remove more leftovers
apedroferreira May 14, 2024
9e26e6e
Review fixes, prep to split into another PR
apedroferreira May 14, 2024
6277b31
Add TODO comments
apedroferreira May 14, 2024
3718162
Merge remote-tracking branch 'upstream/master' into add-layout-component
apedroferreira May 24, 2024
e6b3422
Update playground app
apedroferreira May 24, 2024
e77a9b7
More update
apedroferreira May 24, 2024
275b8a0
Add Next.js pages router playground app
apedroferreira May 24, 2024
6bcb187
Merge remote-tracking branch 'upstream/master' into add-next-js-app-r…
apedroferreira May 27, 2024
b84e32e
Prettier
apedroferreira May 27, 2024
1a016b6
Remove extra folder
apedroferreira May 27, 2024
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
34 changes: 31 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Local development

If you would like to hack on Toolpad Studio or want to run the latest version, you can follow these steps:
If you would like to hack on Toolpad or want to run the latest version, you can follow these steps:

_If you're looking into contributing to the docs, follow the [instructions](#building-and-running-the-documentation) down below_

Expand All @@ -11,7 +11,7 @@ _If you're looking into contributing to the docs, follow the [instructions](#bui
- git
- node.js

### Running apps inside the monorepo (recommended)
### Running Toolpad Studio apps inside the monorepo (recommended)

This uses the local version of Toolpad Studio as built in the mono-repository.
This is recommended when your app is in a folder inside of the mono-repository.
Expand Down Expand Up @@ -139,6 +139,34 @@ pnpm install

</details>

### Developing on Toolpad Core

This uses the local version of Toolpad Core as built in the mono-repository, and allows for quickly testing out changes and their results.

Some application examples for different JavaScript frameworks (such as Next.js, Vite…) are present in the `playground` folder that can be used to quickly develop on Toolpad Core on a live application.

1. Install dependencies:

```bash
pnpm install
```

2. Run the built-in watch mode

```bash
pnpm dev
```

3. Run any application in the `playground` folder in development mode, such as `toolpad-core-nextjs`

```bash
cd playground/toolpad-core-nextjs
```

```bash
pnpm dev
```

## Running integration tests

The playwright tests can be run in one of two modes:
Expand Down Expand Up @@ -198,7 +226,7 @@ Use the `--ui` flag to run the tests interactively.

## Using CodeSandbox CI

Each pull request is built on [CodeSandbox CI](https://codesandbox.io/docs/learn/sandboxes/ci). As a result of that we have a published Toolpad Studio package for ever pull request. To use the package from the pull request, take the following steps:
Each pull request is built on [CodeSandbox CI](https://codesandbox.io/docs/learn/sandboxes/ci). As a result of that we have a published Toolpad Studio package for every pull request. To use the package from the pull request, take the following steps:

1. In the GitHub PR checks, locate the ci/codesandbox check and make sure it has successfully finished building. Click on "details" to open the CodeSandbox CI user interface.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"markdownlint": "markdownlint-cli2 \"**/*.md\"",
"prettier": "pretty-quick --ignore-path .eslintignore",
"prettier:all": "prettier --write . --ignore-path .eslintignore",
"dev": "dotenv cross-env FORCE_COLOR=1 lerna -- run dev --stream --parallel --ignore docs",
"dev": "dotenv cross-env FORCE_COLOR=1 lerna -- run dev --stream --parallel --ignore docs --ignore toolpad-core-nextjs",
"docs:dev": "pnpm --filter docs dev",
"docs:build": "pnpm --filter docs build",
"docs:build:api:core": "tsx --tsconfig ./scripts/tsconfig.json ./scripts/docs/buildCoreApiDocs/index.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ function DashboardSidebarSubNavigation({
) : (
listItem
)}

{navigationItem.children ? (
<Collapse in={isNestedNavigationExpanded} timeout="auto" unmountOnExit>
<DashboardSidebarSubNavigation
Expand Down
34 changes: 34 additions & 0 deletions playground/toolpad-core-nextjs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Toolpad Core Playground - Next.js App Router

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).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
5 changes: 5 additions & 0 deletions playground/toolpad-core-nextjs/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
4 changes: 4 additions & 0 deletions playground/toolpad-core-nextjs/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};

export default nextConfig;
23 changes: 23 additions & 0 deletions playground/toolpad-core-nextjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "toolpad-core-nextjs",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"lint": "next lint"
},
"dependencies": {},
"devDependencies": {
"@emotion/react": "11.11.4",
"@emotion/styled": "11.11.5",
"@mui/icons-material": "5.15.18",
"@mui/material": "5.15.18",
"@toolpad/core": "workspace:*",
"@types/react": "18.3.1",
"@types/react-dom": "18.3.0",
"eslint-config-next": "14.1.3",
"next": "14.2.3",
"react": "18.2.0",
"react-dom": "18.2.0"
}
}
6 changes: 6 additions & 0 deletions playground/toolpad-core-nextjs/src/app/dashboard/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as React from 'react';
import { DashboardLayout } from '@toolpad/core/DashboardLayout';

export default function Layout(props: { children: React.ReactNode }) {
return <DashboardLayout>{props.children}</DashboardLayout>;
}
21 changes: 21 additions & 0 deletions playground/toolpad-core-nextjs/src/app/dashboard/orders/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';

export default function Orders() {
return (
<Box
sx={{
my: 4,
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Typography variant="h4" component="h1" sx={{ mb: 2 }}>
Welcome to the Toolpad orders!
</Typography>
</Box>
);
}
21 changes: 21 additions & 0 deletions playground/toolpad-core-nextjs/src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';

export default function Dashboard() {
return (
<Box
sx={{
my: 4,
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Typography variant="h4" component="h1" sx={{ mb: 2 }}>
Welcome to the Toolpad dashboard!
</Typography>
</Box>
);
}
32 changes: 32 additions & 0 deletions playground/toolpad-core-nextjs/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as React from 'react';
import { AppProvider } from '@toolpad/core/AppProvider';
import DashboardIcon from '@mui/icons-material/Dashboard';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import type { Navigation } from '@toolpad/core';

const NAVIGATION: Navigation = [
{
kind: 'header',
title: 'Main items',
},
{
slug: '/dashboard',
title: 'Dashboard',
icon: <DashboardIcon />,
},
{
slug: '/dashboard/orders',
title: 'Orders',
icon: <ShoppingCartIcon />,
},
];

export default function RootLayout(props: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<AppProvider navigation={NAVIGATION}>{props.children}</AppProvider>
</body>
</html>
);
}
21 changes: 21 additions & 0 deletions playground/toolpad-core-nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';

export default function Home() {
return (
<Box
sx={{
my: 4,
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Typography variant="h4" component="h1" sx={{ mb: 2 }}>
Welcome to Toolpad!
</Typography>
</Box>
);
}
26 changes: 26 additions & 0 deletions playground/toolpad-core-nextjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
Loading
Loading