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

Adding Typescript and Mantine example #36294

Merged
merged 23 commits into from Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8442eba
Adding Typescript and Mantine example
triyanox Apr 20, 2022
3e4af90
Update examples/with-typescript-mantine/README.md
triyanox Apr 22, 2022
36c3bf1
Update examples/with-typescript-mantine/README.md
triyanox Apr 22, 2022
29e9ac9
Update examples/with-typescript-mantine/package.json
triyanox Apr 22, 2022
af84942
Delete hello.ts
triyanox Apr 22, 2022
cafa366
Merge branch 'vercel:canary' into canary
triyanox Apr 22, 2022
09d58f6
Renaming the exmaple to with-mantine
triyanox Apr 22, 2022
8be68d6
Update README.md
triyanox Apr 23, 2022
a179cd0
Merge branch 'vercel:canary' into canary
triyanox Apr 23, 2022
0ef7cc4
Merge branch 'canary' into canary
balazsorban44 Apr 25, 2022
8ff74ea
Merge branch 'canary' into canary
kodiakhq[bot] Apr 25, 2022
151d34a
Merge branch 'canary' into canary
triyanox Apr 25, 2022
dd831b9
Merge branch 'canary' into canary
kodiakhq[bot] Apr 25, 2022
5bac3e5
Merge branch 'canary' into canary
triyanox Apr 26, 2022
82dba61
Merge branch 'canary' into canary
triyanox Apr 26, 2022
efe0516
Merge branch 'canary' into canary
kodiakhq[bot] Apr 26, 2022
5885c30
Merge branch 'canary' into canary
triyanox Apr 26, 2022
266dbce
prettier config added and .eslintrc.json removed
triyanox Apr 26, 2022
e01a5a5
Merge branch 'canary' into canary
triyanox Apr 26, 2022
ddc2d27
Merge branch 'canary' into canary
triyanox Apr 26, 2022
5f5eb5c
Merge branch 'canary' into canary
triyanox Apr 26, 2022
c8417cd
Merge branch 'canary' into canary
kodiakhq[bot] Apr 27, 2022
e8d18ca
Merge branch 'canary' into canary
kodiakhq[bot] Apr 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/with-mantine/.eslintrc.json
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
35 changes: 35 additions & 0 deletions examples/with-mantine/.gitignore
@@ -0,0 +1,35 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

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

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
23 changes: 23 additions & 0 deletions examples/with-mantine/README.md
@@ -0,0 +1,23 @@
# TypeScript & Mantine Next.js example

This is a simple project that shows the usage of Next.js with TypeScript and Mantine.

## Deploy your own

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/with-typescript-mantine)

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-typescript-mantine&project-name=with-typescript-mantine&repository-name=with-typescript-mantine)

## How to use it?

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:

```bash
npx create-next-app --example with-mantine with-mantine-app
# or
yarn create next-app --example with-mantine with-mantine-app
# or
pnpm create next-app -- --example with-mantine with-mantine-app
```

Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
52 changes: 52 additions & 0 deletions examples/with-mantine/components/Card.tsx
@@ -0,0 +1,52 @@
import { Anchor, Text } from "@mantine/core";

type Props = {
title: string;
description: string;
link: string;
};

const Card = (props: Props) => {
return (
<Anchor
href={props.link}
target="_blank"
sx={{
border: "1px solid #eaeaea",
margin: "1rem",
padding: "1.5rem",
borderRadius: "10px",
textAlign: "left",
color: "black",
maxWidth: "300px",
transition: "all 0.3s ease-in-out",
"&:hover": {
borderColor: "#0070f3",
color: "#0070f3",
},
}}
>
<Text
component="h2"
sx={{
fontSize: "1.5rem",
fontWeight: "bold",
textAlign: "left",
}}
>
{props.title}
</Text>
<Text
component="p"
sx={{
fontSize: "1rem",
textAlign: "left",
}}
>
{props.description}
</Text>
</Anchor>
);
};

export default Card;
28 changes: 28 additions & 0 deletions examples/with-mantine/components/Grid.tsx
@@ -0,0 +1,28 @@
import { Box } from "@mantine/core";
import { ReactNode } from "react";

type Props = {
children: ReactNode;
};

const Grid = (props: Props) => {
return (
<Box
sx={{
display: "grid",
gridTemplateColumns: "repeat(2, minmax(200px, 1fr))",
gridGap: "1rem",
justifyContent: "center",
alignItems: "center",
"@media (max-width: 800px)": {
gridTemplateColumns: "repeat(1, minmax(200px, 1fr))",
gridGap: "0.2rem",
},
}}
>
{props.children}
</Box>
);
};

export default Grid;
5 changes: 5 additions & 0 deletions examples/with-mantine/next-env.d.ts
@@ -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.
6 changes: 6 additions & 0 deletions examples/with-mantine/next.config.js
@@ -0,0 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}

module.exports = nextConfig
25 changes: 25 additions & 0 deletions examples/with-mantine/package.json
@@ -0,0 +1,25 @@
{
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@mantine/core": "^4.1.4",
"@mantine/hooks": "^4.1.4",
"@mantine/next": "^4.1.4",
"next": "latest",
"react": "18.0.0",
"react-dom": "18.0.0"
},
"devDependencies": {
"@types/node": "17.0.25",
"@types/react": "18.0.5",
"@types/react-dom": "18.0.1",
"eslint": "8.13.0",
"eslint-config-next": "12.1.5",
"typescript": "4.6.3"
}
}
26 changes: 26 additions & 0 deletions examples/with-mantine/pages/_app.tsx
@@ -0,0 +1,26 @@
import "../styles/globals.css";
import type { AppProps } from "next/app";
import { MantineProvider } from "@mantine/core";

function MyApp({ Component, pageProps }: AppProps) {
return (
<MantineProvider
withGlobalStyles
withNormalizeCSS
theme={{
colorScheme: "light",
breakpoints: {
xs: 500,
sm: 800,
md: 1000,
lg: 1200,
xl: 1400,
},
}}
>
<Component {...pageProps} />
</MantineProvider>
);
}

export default MyApp;
20 changes: 20 additions & 0 deletions examples/with-mantine/pages/_document.tsx
@@ -0,0 +1,20 @@
import { createGetInitialProps } from "@mantine/next";
import Document, { Head, Html, Main, NextScript } from "next/document";

const getInitialProps = createGetInitialProps();

export default class _Document extends Document {
static getInitialProps = getInitialProps;

render() {
return (
<Html>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}
123 changes: 123 additions & 0 deletions examples/with-mantine/pages/index.tsx
@@ -0,0 +1,123 @@
import type { NextPage } from "next";
import Head from "next/head";
import Image from "next/image";
import { Box, Code, Text } from "@mantine/core";
import Card from "../components/Card";
import Grid from "../components/Grid";

const Home: NextPage = () => {
return (
<Box
component="main"
sx={{
paddingLeft: "2rem",
paddingRight: "2rem",
}}
>
<Head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>

<Box
component="main"
sx={{
minHeight: "100vh",
display: "flex",
paddingTop: "2rem",
paddingBottom: "2rem",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
}}
>
<Text
sx={{
color: "#0070f3",
fontSize: "2rem",
"@media (min-width: 800px)": {
fontSize: "3rem",
},
fontWeight: "bold",
textAlign: "center",
}}
>
Welcome to <a href="https://nextjs.org">Next.js!</a>
</Text>

<Text
sx={{
color: "black",
fontSize: "0.9rem",
"@media (min-width: 700px)": {
fontSize: "1.2rem",
},
padding: "1rem",
textAlign: "center",
}}
>
Get started by editing{" "}
<Code
sx={{
color: "black",
fontSize: "0.8rem",
textAlign: "center",
}}
>
pages/index.tsx
</Code>
</Text>

<Grid>
<Card
title="Documentation &rarr;"
description="Find in-depth information about Next.js features and API."
link="https://nextjs.org/docs"
/>
<Card
title="Learn &rarr;"
description="Learn about Next.js in an interactive course with quizzes!"
link="https://nextjs.org/learn"
/>
<Card
title="Examples &rarr;"
description="Discover and deploy boilerplate example Next.js projects."
link="https://nextjs.org/examples"
/>
<Card
title="Deploy &rarr;"
description="Instantly deploy your Next.js site to a public URL with Vercel."
link="https://vercel.com/import?filter=next.js&utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
/>
</Grid>
</Box>

<Box
component="footer"
sx={{
display: "flex",
flex: "1",
paddingTop: "2rem",
paddingBottom: "2rem",
borderTop: "1px solid #eaeaea",
justifyContent: "center",
alignItems: "center",
}}
>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Powered by{" "}
<Box component="span" sx={{ height: "1rem", marginLeft: "1.5rem" }}>
<Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />
</Box>
</a>
</Box>
</Box>
);
};

export default Home;
Binary file added examples/with-mantine/public/favicon.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions examples/with-mantine/public/vercel.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions examples/with-mantine/styles/globals.css
@@ -0,0 +1,16 @@
html,
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
}

a {
color: inherit;
text-decoration: none;
}

* {
box-sizing: border-box;
}