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

[docs] Add Toolpad core tutorial example #3617

Merged
merged 5 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions examples/core-tutorial/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
36 changes: 36 additions & 0 deletions examples/core-tutorial/.gitignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can make this terser, like the Next.js examples .gitignore?

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
6 changes: 6 additions & 0 deletions examples/core-tutorial/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>;
}
13 changes: 13 additions & 0 deletions examples/core-tutorial/app/(dashboard)/page/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Typography, Container } from '@mui/material';

export default function Home() {
return (
<main>
<Container sx={{ mx: 4 }}>
<Typography variant="h6" color="grey.800">
Dashboard content!
</Typography>
</Container>
</main>
);
}
Empty file.
Empty file.
28 changes: 28 additions & 0 deletions examples/core-tutorial/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { AppProvider } from '@toolpad/core/AppProvider';
import DashboardIcon from '@mui/icons-material/Dashboard';
import type { Navigation } from '@toolpad/core';
import theme from '../theme';

const NAVIGATION: Navigation = [
{
kind: 'header',
title: 'Main items',
},
{
slug: '/page',
title: 'Page',
icon: <DashboardIcon />,
},
];

export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
return (
<html lang="en">
<body>
<AppProvider theme={theme} navigation={NAVIGATION}>
{children}
</AppProvider>
</body>
</html>
);
}
26 changes: 26 additions & 0 deletions examples/core-tutorial/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Link from 'next/link';
import { Button, Container, Typography, Box } from '@mui/material';

export default function Home() {
return (
<Container>
<Box sx={{ my: 4 }}>
<Typography variant="h4" component="h1" gutterBottom>
Welcome to <Link href="https://mui.com/toolpad/core/introduction">Toolpad Core!</Link>
</Typography>

<Typography variant="body1">
Get started by editing <code>(dashboard)/page/page.tsx</code>
</Typography>

<Box sx={{ mt: 2 }}>
<Link href="/page">
<Button variant="contained" color="primary">
Go to Page
</Button>
</Link>
</Box>
</Box>
</Container>
);
}
5 changes: 5 additions & 0 deletions examples/core-tutorial/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.
3 changes: 3 additions & 0 deletions examples/core-tutorial/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
export default nextConfig;
29 changes: 29 additions & 0 deletions examples/core-tutorial/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "core-test",
"version": "0.1.0",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"react": "^18",
"react-dom": "^18",
"next": "^14",
"@toolpad/core": "latest",
"@mui/material": "^5",
"@mui/icons-material": "^5",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@emotion/cache": "^11"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "^14"
}
}
115 changes: 115 additions & 0 deletions examples/core-tutorial/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
'use client';
import { createTheme } from '@mui/material/styles';

const defaultTheme = createTheme();

const theme = createTheme(defaultTheme, {
palette: {
background: {
default: defaultTheme.palette.grey['50'],
},
},
typography: {
h6: {
fontWeight: '700',
},
},
components: {
MuiAppBar: {
styleOverrides: {
root: {
borderWidth: 0,
borderBottomWidth: 1,
borderStyle: 'solid',
borderColor: defaultTheme.palette.divider,
boxShadow: 'none',
},
},
},
MuiList: {
styleOverrides: {
root: {
padding: 0,
},
},
},
MuiIconButton: {
styleOverrides: {
root: {
color: defaultTheme.palette.primary.dark,
padding: 8,
},
},
},
MuiListSubheader: {
styleOverrides: {
root: {
color: defaultTheme.palette.grey['600'],
fontSize: 12,
fontWeight: '700',
height: 40,
paddingLeft: 32,
},
},
},
MuiListItem: {
styleOverrides: {
root: {
paddingTop: 0,
paddingBottom: 0,
},
},
},
MuiListItemButton: {
styleOverrides: {
root: {
borderRadius: 8,
'&.Mui-selected': {
'& .MuiListItemIcon-root': {
color: defaultTheme.palette.primary.dark,
},
'& .MuiTypography-root': {
color: defaultTheme.palette.primary.dark,
},
'& .MuiSvgIcon-root': {
color: defaultTheme.palette.primary.dark,
},
'& .MuiTouchRipple-child': {
backgroundColor: defaultTheme.palette.primary.dark,
},
},
'& .MuiSvgIcon-root': {
color: defaultTheme.palette.action.active,
},
},
},
},
MuiListItemText: {
styleOverrides: {
root: {
'& .MuiTypography-root': {
fontWeight: '500',
},
},
},
},
MuiListItemIcon: {
styleOverrides: {
root: {
minWidth: 34,
},
},
},
MuiDivider: {
styleOverrides: {
root: {
borderBottomWidth: 2,
marginLeft: '16px',
marginRight: '16px',
},
},
},
},
});

export default theme;
26 changes: 26 additions & 0 deletions examples/core-tutorial/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": {
"@/*": ["./*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
Loading