index
int64 0
0
| repo_id
stringlengths 16
181
| file_path
stringlengths 28
270
| content
stringlengths 1
11.6M
| __index_level_0__
int64 0
10k
|
|---|---|---|---|---|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router/pages/_app.js
|
import * as React from 'react';
import PropTypes from 'prop-types';
import Head from 'next/head';
import { ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import { CacheProvider } from '@emotion/react';
import theme from '../src/theme';
import createEmotionCache from '../src/createEmotionCache';
// Client-side cache, shared for the whole session of the user in the browser.
const clientSideEmotionCache = createEmotionCache();
export default function MyApp(props) {
const { Component, emotionCache = clientSideEmotionCache, pageProps } = props;
return (
<CacheProvider value={emotionCache}>
<Head>
<meta name="viewport" content="initial-scale=1, width=device-width" />
</Head>
<ThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
<Component {...pageProps} />
</ThemeProvider>
</CacheProvider>
);
}
MyApp.propTypes = {
Component: PropTypes.elementType.isRequired,
emotionCache: PropTypes.object,
pageProps: PropTypes.object.isRequired,
};
| 5,900
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router/pages/_document.js
|
import * as React from 'react';
import PropTypes from 'prop-types';
import Document, { Html, Head, Main, NextScript } from 'next/document';
import createEmotionServer from '@emotion/server/create-instance';
import theme from '../src/theme';
import createEmotionCache from '../src/createEmotionCache';
export default function MyDocument(props) {
const { emotionStyleTags } = props;
return (
<Html lang="en">
<Head>
{/* PWA primary color */}
<meta name="theme-color" content={theme.palette.primary.main} />
<link rel="shortcut icon" href="/favicon.ico" />
<meta name="emotion-insertion-point" content="" />
{emotionStyleTags}
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
// `getInitialProps` belongs to `_document` (instead of `_app`),
// it's compatible with static-site generation (SSG).
MyDocument.getInitialProps = async (ctx) => {
// Resolution order
//
// On the server:
// 1. app.getInitialProps
// 2. page.getInitialProps
// 3. document.getInitialProps
// 4. app.render
// 5. page.render
// 6. document.render
//
// On the server with error:
// 1. document.getInitialProps
// 2. app.render
// 3. page.render
// 4. document.render
//
// On the client
// 1. app.getInitialProps
// 2. page.getInitialProps
// 3. app.render
// 4. page.render
const originalRenderPage = ctx.renderPage;
// You can consider sharing the same Emotion cache between all the SSR requests to speed up performance.
// However, be aware that it can have global side effects.
const cache = createEmotionCache();
const { extractCriticalToChunks } = createEmotionServer(cache);
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: (App) =>
function EnhanceApp(props) {
return <App emotionCache={cache} {...props} />;
},
});
const initialProps = await Document.getInitialProps(ctx);
// This is important. It prevents Emotion to render invalid HTML.
// See https://github.com/mui/material-ui/issues/26561#issuecomment-855286153
const emotionStyles = extractCriticalToChunks(initialProps.html);
const emotionStyleTags = emotionStyles.styles.map((style) => (
<style
data-emotion={`${style.key} ${style.ids.join(' ')}`}
key={style.key}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: style.css }}
/>
));
return {
...initialProps,
emotionStyleTags,
};
};
MyDocument.propTypes = {
emotionStyleTags: PropTypes.array.isRequired,
};
| 5,901
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router/pages/about.js
|
import * as React from 'react';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
import ProTip from '../src/ProTip';
import Link from '../src/Link';
import Copyright from '../src/Copyright';
export default function About() {
return (
<Container maxWidth="sm">
<Box sx={{ my: 4 }}>
<Typography variant="h4" component="h1" gutterBottom>
Material UI - Next.js example
</Typography>
<Button variant="contained" component={Link} noLinkStyle href="/">
Go to the main page
</Button>
<ProTip />
<Copyright />
</Box>
</Container>
);
}
| 5,902
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router/pages/index.js
|
import * as React from 'react';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
import ProTip from '../src/ProTip';
import Link from '../src/Link';
import Copyright from '../src/Copyright';
export default function Index() {
return (
<Container maxWidth="sm">
<Box sx={{ my: 4 }}>
<Typography variant="h4" component="h1" gutterBottom>
Material UI - Next.js example
</Typography>
<Link href="/about" color="secondary">
Go to the about page
</Link>
<ProTip />
<Copyright />
</Box>
</Container>
);
}
| 5,903
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router/src/Copyright.js
|
import * as React from 'react';
import Typography from '@mui/material/Typography';
import MuiLink from '@mui/material/Link';
export default function Copyright() {
return (
<Typography variant="body2" color="text.secondary" align="center">
{'Copyright © '}
<MuiLink color="inherit" href="https://mui.com/">
Your Website
</MuiLink>{' '}
{new Date().getFullYear()}.
</Typography>
);
}
| 5,904
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router/src/Link.js
|
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { useRouter } from 'next/router';
import NextLink from 'next/link';
import MuiLink from '@mui/material/Link';
import { styled } from '@mui/material/styles';
// Add support for the sx prop for consistency with the other branches.
const Anchor = styled('a')({});
export const NextLinkComposed = React.forwardRef(function NextLinkComposed(props, ref) {
const {
to,
linkAs,
replace,
scroll,
shallow,
prefetch,
legacyBehavior = true,
locale,
...other
} = props;
return (
<NextLink
href={to}
prefetch={prefetch}
as={linkAs}
replace={replace}
scroll={scroll}
shallow={shallow}
passHref
legacyBehavior={legacyBehavior}
locale={locale}
>
<Anchor ref={ref} {...other} />
</NextLink>
);
});
NextLinkComposed.propTypes = {
href: PropTypes.any,
legacyBehavior: PropTypes.bool,
linkAs: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
locale: PropTypes.string,
passHref: PropTypes.bool,
prefetch: PropTypes.bool,
replace: PropTypes.bool,
scroll: PropTypes.bool,
shallow: PropTypes.bool,
to: PropTypes.oneOfType([PropTypes.object, PropTypes.string]).isRequired,
};
// A styled version of the Next.js Link component:
// https://nextjs.org/docs/pages/api-reference/components/link
const Link = React.forwardRef(function Link(props, ref) {
const {
activeClassName = 'active',
as,
className: classNameProps,
href,
legacyBehavior,
linkAs: linkAsProp,
locale,
noLinkStyle,
prefetch,
replace,
role, // Link don't have roles.
scroll,
shallow,
...other
} = props;
const router = useRouter();
const pathname = typeof href === 'string' ? href : href.pathname;
const className = clsx(classNameProps, {
[activeClassName]: router.pathname === pathname && activeClassName,
});
const isExternal =
typeof href === 'string' && (href.indexOf('http') === 0 || href.indexOf('mailto:') === 0);
if (isExternal) {
if (noLinkStyle) {
return <Anchor className={className} href={href} ref={ref} {...other} />;
}
return <MuiLink className={className} href={href} ref={ref} {...other} />;
}
const linkAs = linkAsProp || as;
const nextjsProps = {
to: href,
linkAs,
replace,
scroll,
shallow,
prefetch,
legacyBehavior,
locale,
};
if (noLinkStyle) {
return <NextLinkComposed className={className} ref={ref} {...nextjsProps} {...other} />;
}
return (
<MuiLink
component={NextLinkComposed}
className={className}
ref={ref}
{...nextjsProps}
{...other}
/>
);
});
Link.propTypes = {
activeClassName: PropTypes.string,
as: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
className: PropTypes.string,
href: PropTypes.any,
legacyBehavior: PropTypes.bool,
linkAs: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
locale: PropTypes.string,
noLinkStyle: PropTypes.bool,
prefetch: PropTypes.bool,
replace: PropTypes.bool,
role: PropTypes.string,
scroll: PropTypes.bool,
shallow: PropTypes.bool,
};
export default Link;
| 5,905
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router/src/ProTip.js
|
import * as React from 'react';
import Link from '@mui/material/Link';
import SvgIcon from '@mui/material/SvgIcon';
import Typography from '@mui/material/Typography';
function LightBulbIcon(props) {
return (
<SvgIcon {...props}>
<path d="M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7zm2.85 11.1l-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1z" />
</SvgIcon>
);
}
export default function ProTip() {
return (
<Typography sx={{ mt: 6, mb: 3 }} color="text.secondary">
<LightBulbIcon sx={{ mr: 1, verticalAlign: 'middle' }} />
{'Pro tip: See more '}
<Link href="https://mui.com/material-ui/getting-started/templates/">templates</Link>
{' in the Material UI documentation.'}
</Typography>
);
}
| 5,906
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router/src/createEmotionCache.js
|
import createCache from '@emotion/cache';
const isBrowser = typeof document !== 'undefined';
// On the client side, Create a meta tag at the top of the <head> and set it as insertionPoint.
// This assures that MUI styles are loaded first.
// It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
export default function createEmotionCache() {
let insertionPoint;
if (isBrowser) {
const emotionInsertionPoint = document.querySelector('meta[name="emotion-insertion-point"]');
insertionPoint = emotionInsertionPoint ?? undefined;
}
return createCache({ key: 'mui-style', insertionPoint });
}
| 5,907
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-pages-router/src/theme.js
|
import { Roboto } from 'next/font/google';
import { createTheme } from '@mui/material/styles';
import { red } from '@mui/material/colors';
const roboto = Roboto({
weight: ['300', '400', '500', '700'],
subsets: ['latin'],
display: 'swap',
});
// Create a theme instance.
const theme = createTheme({
palette: {
primary: {
main: '#556cd6',
},
secondary: {
main: '#19857b',
},
error: {
main: red.A400,
},
},
typography: {
fontFamily: roboto.style.fontFamily,
},
});
export default theme;
| 5,908
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration/README.md
|
# Material UI v5 and Next.js example with @mui/styles (in TypeScript)
## How to use
Download the example [or clone the repo](https://github.com/mui/material-ui):
<!-- #default-branch-switch -->
```bash
curl https://codeload.github.com/mui/material-ui/tar.gz/master | tar -xz --strip=2 material-ui-master/examples/material-ui-nextjs-ts-v4-v5-migration
cd material-ui-nextjs-ts-v4-v5-migration
```
Install it and run:
```bash
npm install
npm run dev
```
or:
<!-- #default-branch-switch -->
[](https://stackblitz.com/github/mui/material-ui/tree/master/examples/material-ui-nextjs-ts-v4-v5-migration)
[](https://codesandbox.io/s/github/mui/material-ui/tree/master/examples/material-ui-nextjs-ts-v4-v5-migration)
## The idea behind the example
The project uses [Next.js](https://github.com/vercel/next.js), which is a framework for server-rendered React apps.
It includes `@mui/material` and its peer dependencies, including [Emotion](https://emotion.sh/docs/introduction), the default style engine in Material UI v5. If you prefer, you can [use styled-components instead](https://mui.com/material-ui/guides/interoperability/#styled-components).
It also includes `@mui/styles`, the legacy styling solution that uses JSS as an engine.
It provides all the necessary config for working with both Emotion and JSS for server-side rendering.
The project is intended as a basic starter for migrating your application from v4 to v5, as it lets the JSS style overrides take precedence over the default styles passed to the components by Emotion.
It demonstrates what results after handling v5's breaking changes to the [theme](https://mui.com/material-ui/migration/v5-style-changes/) and [components](https://mui.com/material-ui/migration/v5-component-changes/).
## The Link component
Next.js Pages Router has [a custom Link component](https://nextjs.org/docs/pages/api-reference/components/link).
The example folder provides adapters for usage with Material UI.
You can find more information [in the documentation](https://mui.com/material-ui/guides/routing/#next-js-pages-router).
| 5,909
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration/next.config.js
|
/** @type {import('next').NextConfig} */
module.exports = {
reactStrictMode: true,
};
| 5,910
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration/package.json
|
{
"name": "material-ui-nextjs-ts-v4-v5-migration",
"version": "5.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"post-update": "echo \"codesandbox preview only, need an update\" && yarn upgrade --latest"
},
"dependencies": {
"@emotion/cache": "latest",
"@emotion/react": "latest",
"@emotion/server": "latest",
"@emotion/styled": "latest",
"@mui/icons-material": "latest",
"@mui/material": "latest",
"@mui/styles": "latest",
"autoprefixer": "latest",
"clean-css": "latest",
"next": "latest",
"postcss": "latest",
"react": "latest",
"react-dom": "latest"
},
"devDependencies": {
"@types/node": "latest",
"@types/react": "latest",
"eslint": "latest",
"eslint-config-next": "latest",
"typescript": "latest"
}
}
| 5,911
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration/tsconfig.json
|
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"jsxImportSource": "@emotion/react",
"incremental": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
| 5,912
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration/pages/_app.tsx
|
import * as React from 'react';
import Head from 'next/head';
import { AppProps } from 'next/app';
import { ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import { CacheProvider, EmotionCache } from '@emotion/react';
import theme from '../src/theme';
import createEmotionCache from '../src/createEmotionCache';
// Client-side cache, shared for the whole session of the user in the browser.
const clientSideEmotionCache = createEmotionCache();
export interface MyAppProps extends AppProps {
emotionCache?: EmotionCache;
}
export default function MyApp(props: MyAppProps) {
const { Component, emotionCache = clientSideEmotionCache, pageProps } = props;
React.useEffect(() => {
// Remove the server-side injected CSS.
const jssStyles = document.querySelector('#jss-server-side');
if (jssStyles) {
jssStyles?.parentElement?.removeChild(jssStyles);
}
}, []);
return (
<CacheProvider value={emotionCache}>
<Head>
<meta name="viewport" content="initial-scale=1, width=device-width" />
</Head>
<ThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
<Component {...pageProps} />
</ThemeProvider>
</CacheProvider>
);
}
| 5,913
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration/pages/_document.tsx
|
import * as React from 'react';
import Document, {
Html,
Head,
Main,
NextScript,
DocumentProps,
DocumentContext,
} from 'next/document';
import createEmotionServer from '@emotion/server/create-instance';
import { AppType } from 'next/app';
import { ServerStyleSheets as JSSServerStyleSheets } from '@mui/styles';
import theme from '../src/theme';
import createEmotionCache from '../src/createEmotionCache';
import { MyAppProps } from './_app';
interface MyDocumentProps extends DocumentProps {
emotionStyleTags: JSX.Element[];
}
export default function MyDocument({ emotionStyleTags }: MyDocumentProps) {
return (
<Html lang="en">
<Head>
{/* PWA primary color */}
<meta name="theme-color" content={theme.palette.primary.main} />
<link rel="shortcut icon" href="/favicon.ico" />
{/* Inject MUI styles first to match with the prepend: true configuration. */}
{emotionStyleTags}
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
// You can find a benchmark of the available CSS minifiers under
// https://github.com/GoalSmashers/css-minification-benchmark
// We have found that clean-css is faster than cssnano but the output is larger.
// Waiting for https://github.com/cssinjs/jss/issues/279
// 4% slower but 12% smaller output than doing it in a single step.
//
// It's using .browserslistrc
let prefixer: any;
let cleanCSS: any;
if (process.env.NODE_ENV === 'production') {
/* eslint-disable global-require */
const postcss = require('postcss');
const autoprefixer = require('autoprefixer');
const CleanCSS = require('clean-css');
/* eslint-enable global-require */
prefixer = postcss([autoprefixer]);
cleanCSS = new CleanCSS();
}
// `getInitialProps` belongs to `_document` (instead of `_app`),
// it's compatible with static-site generation (SSG).
MyDocument.getInitialProps = async (ctx: DocumentContext) => {
// Resolution order
//
// On the server:
// 1. app.getInitialProps
// 2. page.getInitialProps
// 3. document.getInitialProps
// 4. app.render
// 5. page.render
// 6. document.render
//
// On the server with error:
// 1. document.getInitialProps
// 2. app.render
// 3. page.render
// 4. document.render
//
// On the client
// 1. app.getInitialProps
// 2. page.getInitialProps
// 3. app.render
// 4. page.render
const originalRenderPage = ctx.renderPage;
// You can consider sharing the same emotion cache between all the SSR requests to speed up performance.
// However, be aware that it can have global side effects.
const cache = createEmotionCache();
const { extractCriticalToChunks } = createEmotionServer(cache);
const jssSheets = new JSSServerStyleSheets();
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: (App: React.ComponentType<React.ComponentProps<AppType> & MyAppProps>) =>
function EnhanceApp(props) {
return jssSheets.collect(<App emotionCache={cache} {...props} />);
},
});
const initialProps = await Document.getInitialProps(ctx);
// Generate style tags for the styles coming from Emotion
// This is important. It prevents Emotion from rendering invalid HTML.
// See https://github.com/mui/material-ui/issues/26561#issuecomment-855286153
const emotionStyles = extractCriticalToChunks(initialProps.html);
const emotionStyleTags = emotionStyles.styles.map((style) => (
<style
data-emotion={`${style.key} ${style.ids.join(' ')}`}
key={style.key}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: style.css }}
/>
));
// Generate the css string for the styles coming from jss
let css = jssSheets.toString();
// It might be undefined, e.g. after an error.
if (css && process.env.NODE_ENV === 'production') {
const result1 = await prefixer.process(css, { from: undefined });
css = result1.css;
css = cleanCSS.minify(css).styles;
}
return {
...initialProps,
styles: [
...emotionStyleTags,
<style
id="jss-server-side"
key="jss-server-side"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: css }}
/>,
...React.Children.toArray(initialProps.styles),
],
};
};
| 5,914
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration/pages/about.tsx
|
import * as React from 'react';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
import { makeStyles } from '@mui/styles';
import Link from '../src/Link';
import ProTip from '../src/ProTip';
import Copyright from '../src/Copyright';
const useStyles = makeStyles((theme) => ({
main: {
marginTop: theme.spacing(4),
marginBottom: theme.spacing(4),
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
},
}));
export default function About() {
const classes = useStyles();
return (
<Container maxWidth="lg">
<div className={classes.main}>
<Typography variant="h4" component="h1" gutterBottom>
Material UI - Next.js example in TypeScript with legacy @mui/styles
</Typography>
<Box sx={{ maxWidth: 'sm' }}>
<Button variant="contained" component={Link} noLinkStyle href="/">
Go to the home page
</Button>
</Box>
<ProTip />
<Copyright />
</div>
</Container>
);
}
| 5,915
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration/pages/index.tsx
|
import * as React from 'react';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import { makeStyles } from '@mui/styles';
import Link from '../src/Link';
import ProTip from '../src/ProTip';
import Copyright from '../src/Copyright';
const useStyles = makeStyles((theme) => ({
main: {
marginTop: theme.spacing(4),
marginBottom: theme.spacing(4),
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
},
}));
export default function Home() {
const classes = useStyles();
return (
<Container maxWidth="lg">
<div className={classes.main}>
<Typography variant="h4" component="h1" gutterBottom>
Material UI - Next.js example in TypeScript with legacy @mui/styles
</Typography>
<Link href="/about" color="secondary">
Go to the about page
</Link>
<ProTip />
<Copyright />
</div>
</Container>
);
}
| 5,916
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration/src/Copyright.tsx
|
import * as React from 'react';
import Typography from '@mui/material/Typography';
import MuiLink from '@mui/material/Link';
export default function Copyright() {
return (
<Typography variant="body2" color="text.secondary" align="center">
{'Copyright © '}
<MuiLink color="inherit" href="https://mui.com/">
Your Website
</MuiLink>{' '}
{new Date().getFullYear()}.
</Typography>
);
}
| 5,917
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration/src/Link.tsx
|
import * as React from 'react';
import clsx from 'clsx';
import { useRouter } from 'next/router';
import NextLink, { LinkProps as NextLinkProps } from 'next/link';
import MuiLink, { LinkProps as MuiLinkProps } from '@mui/material/Link';
import { styled } from '@mui/material/styles';
// Add support for the sx prop for consistency with the other branches.
const Anchor = styled('a')({});
interface NextLinkComposedProps
extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>,
Omit<NextLinkProps, 'href' | 'as' | 'passHref' | 'onMouseEnter' | 'onClick' | 'onTouchStart'> {
to: NextLinkProps['href'];
linkAs?: NextLinkProps['as'];
}
export const NextLinkComposed = React.forwardRef<HTMLAnchorElement, NextLinkComposedProps>(
function NextLinkComposed(props, ref) {
const { to, linkAs, replace, scroll, shallow, prefetch, locale, ...other } = props;
return (
<NextLink
href={to}
prefetch={prefetch}
as={linkAs}
replace={replace}
scroll={scroll}
shallow={shallow}
passHref
locale={locale}
>
<Anchor ref={ref} {...other} />
</NextLink>
);
},
);
export type LinkProps = {
activeClassName?: string;
as?: NextLinkProps['as'];
href: NextLinkProps['href'];
linkAs?: NextLinkProps['as']; // Useful when the as prop is shallow by styled().
noLinkStyle?: boolean;
} & Omit<NextLinkComposedProps, 'to' | 'linkAs' | 'href'> &
Omit<MuiLinkProps, 'href'>;
// A styled version of the Next.js Link component:
// https://nextjs.org/docs/pages/api-reference/components/link
const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(function Link(props, ref) {
const {
activeClassName = 'active',
as,
className: classNameProps,
href,
linkAs: linkAsProp,
locale,
noLinkStyle,
prefetch,
replace,
role, // Link don't have roles.
scroll,
shallow,
...other
} = props;
const router = useRouter();
const pathname = typeof href === 'string' ? href : href.pathname;
const className = clsx(classNameProps, {
[activeClassName]: router.pathname === pathname && activeClassName,
});
const isExternal =
typeof href === 'string' && (href.indexOf('http') === 0 || href.indexOf('mailto:') === 0);
if (isExternal) {
if (noLinkStyle) {
return <Anchor className={className} href={href} ref={ref} {...other} />;
}
return <MuiLink className={className} href={href} ref={ref} {...other} />;
}
const linkAs = linkAsProp || as;
const nextjsProps = { to: href, linkAs, replace, scroll, shallow, prefetch, locale };
if (noLinkStyle) {
return <NextLinkComposed className={className} ref={ref} {...nextjsProps} {...other} />;
}
return (
<MuiLink
component={NextLinkComposed}
className={className}
ref={ref}
{...nextjsProps}
{...other}
/>
);
});
export default Link;
| 5,918
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration/src/ProTip.tsx
|
import * as React from 'react';
import Link from '@mui/material/Link';
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
import Typography from '@mui/material/Typography';
import { makeStyles } from '@mui/styles';
function LightBulbIcon(props: SvgIconProps) {
return (
<SvgIcon {...props}>
<path d="M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7zm2.85 11.1l-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1z" />
</SvgIcon>
);
}
const useStyles = makeStyles((theme) => ({
typography: {
marginTop: theme.spacing(6),
marginBottom: theme.spacing(3),
},
}));
export default function ProTip() {
const classes = useStyles();
return (
<Typography className={classes.typography} color="text.secondary">
<LightBulbIcon sx={{ mr: 1, verticalAlign: 'middle' }} />
{'Pro tip: See more '}
<Link href="https://mui.com/material-ui/getting-started/templates/">templates</Link> in the
{' in the Material UI documentation.'}
</Typography>
);
}
| 5,919
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration/src/createEmotionCache.ts
|
import createCache from '@emotion/cache';
// prepend: true moves MUI styles to the top of the <head> so they're loaded first.
// It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
export default function createEmotionCache() {
return createCache({ key: 'css', prepend: true });
}
| 5,920
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration/src/theme.ts
|
import { Roboto } from 'next/font/google';
import { createTheme } from '@mui/material/styles';
import { red } from '@mui/material/colors';
const roboto = Roboto({
weight: ['300', '400', '500', '700'],
subsets: ['latin'],
display: 'swap',
});
// Create a theme instance.
const theme = createTheme({
palette: {
primary: {
main: '#556cd6',
},
secondary: {
main: '#19857b',
},
error: {
main: red.A400,
},
},
typography: {
fontFamily: roboto.style.fontFamily,
},
});
export default theme;
| 5,921
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts-v4-v5-migration/types/mui-styles.d.ts
|
import { Theme } from '@mui/material/styles';
declare module '@mui/styles' {
interface DefaultTheme extends Theme {}
}
| 5,922
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/README.md
|
# Material UI - Next.js App Router example in TypeScript
This is a [Next.js](https://nextjs.org/) project bootstrapped using [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with Material UI installed.
## How to use
Download the example [or clone the repo](https://github.com/mui/material-ui):
<!-- #default-branch-switch -->
```bash
curl https://codeload.github.com/mui/material-ui/tar.gz/master | tar -xz --strip=2 material-ui-master/examples/material-ui-nextjs-ts
cd material-ui-nextjs-ts
```
Install it and run:
```bash
npm install
npm run dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
or:
<!-- #default-branch-switch -->
[](https://stackblitz.com/github/mui/material-ui/tree/master/examples/material-ui-nextjs-ts)
[](https://codesandbox.io/s/github/mui/material-ui/tree/master/examples/material-ui-nextjs-ts)
## Learn more
To learn more about this example:
- [Next.js documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Customizing Material UI](https://mui.com/material-ui/customization/how-to-customize/) - approaches to customizing Material UI.
## What's next?
<!-- #default-branch-switch -->
You now have a working example project.
You can head back to the documentation and continue by browsing the [templates](https://mui.com/material-ui/getting-started/templates/) section.
| 5,923
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/next-env.d.ts
|
/// <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.
| 5,924
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/next.config.js
|
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
modularizeImports: {
'@mui/icons-material': {
transform: '@mui/icons-material/{{member}}',
},
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'source.unsplash.com',
port: '',
pathname: '/random',
},
],
},
};
module.exports = nextConfig;
| 5,925
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/package.json
|
{
"name": "material-ui-nextjs-ts",
"version": "5.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"post-update": "echo \"codesandbox preview only, need an update\" && yarn upgrade --latest"
},
"dependencies": {
"@emotion/cache": "latest",
"@emotion/react": "latest",
"@emotion/styled": "latest",
"@mui/icons-material": "latest",
"@mui/material": "latest",
"next": "latest",
"react": "latest",
"react-dom": "latest"
},
"devDependencies": {
"@types/node": "latest",
"@types/react": "latest",
"@types/react-dom": "latest",
"eslint": "latest",
"eslint-config-next": "latest",
"typescript": "latest"
}
}
| 5,926
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/tsconfig.json
|
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
| 5,927
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src/app/layout.tsx
|
import * as React from 'react';
import Link from 'next/link';
import AppBar from '@mui/material/AppBar';
import Box from '@mui/material/Box';
import Drawer from '@mui/material/Drawer';
import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import Divider from '@mui/material/Divider';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import DashboardIcon from '@mui/icons-material/Dashboard';
import HomeIcon from '@mui/icons-material/Home';
import StarIcon from '@mui/icons-material/Star';
import ChecklistIcon from '@mui/icons-material/Checklist';
import SettingsIcon from '@mui/icons-material/Settings';
import SupportIcon from '@mui/icons-material/Support';
import LogoutIcon from '@mui/icons-material/Logout';
import ThemeRegistry from '@/components/ThemeRegistry/ThemeRegistry';
export const metadata = {
title: 'Next.js App Router + Material UI v5',
description: 'Next.js App Router + Material UI v5',
};
const DRAWER_WIDTH = 240;
const LINKS = [
{ text: 'Home', href: '/', icon: HomeIcon },
{ text: 'Starred', href: '/starred', icon: StarIcon },
{ text: 'Tasks', href: '/tasks', icon: ChecklistIcon },
];
const PLACEHOLDER_LINKS = [
{ text: 'Settings', icon: SettingsIcon },
{ text: 'Support', icon: SupportIcon },
{ text: 'Logout', icon: LogoutIcon },
];
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<ThemeRegistry>
<AppBar position="fixed" sx={{ zIndex: 2000 }}>
<Toolbar sx={{ backgroundColor: 'background.paper' }}>
<DashboardIcon sx={{ color: '#444', mr: 2, transform: 'translateY(-2px)' }} />
<Typography variant="h6" color="text.primary">
Next.js App Router
</Typography>
</Toolbar>
</AppBar>
<Drawer
sx={{
width: DRAWER_WIDTH,
flexShrink: 0,
'& .MuiDrawer-paper': {
width: DRAWER_WIDTH,
boxSizing: 'border-box',
top: ['48px', '56px', '64px'],
height: 'auto',
bottom: 0,
},
}}
variant="permanent"
anchor="left"
>
<Divider />
<List>
{LINKS.map(({ text, href, icon: Icon }) => (
<ListItem key={href} disablePadding>
<ListItemButton component={Link} href={href}>
<ListItemIcon>
<Icon />
</ListItemIcon>
<ListItemText primary={text} />
</ListItemButton>
</ListItem>
))}
</List>
<Divider sx={{ mt: 'auto' }} />
<List>
{PLACEHOLDER_LINKS.map(({ text, icon: Icon }) => (
<ListItem key={text} disablePadding>
<ListItemButton>
<ListItemIcon>
<Icon />
</ListItemIcon>
<ListItemText primary={text} />
</ListItemButton>
</ListItem>
))}
</List>
</Drawer>
<Box
component="main"
sx={{
flexGrow: 1,
bgcolor: 'background.default',
ml: `${DRAWER_WIDTH}px`,
mt: ['48px', '56px', '64px'],
p: 3,
}}
>
{children}
</Box>
</ThemeRegistry>
</body>
</html>
);
}
| 5,928
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src/app/page.tsx
|
import * as React from 'react';
import Box from '@mui/material/Box';
import Grid from '@mui/material/Unstable_Grid2';
import Drawer from '@mui/material/Drawer';
import Typography from '@mui/material/Typography';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import Alert from '@mui/material/Alert';
import AlertTitle from '@mui/material/AlertTitle';
import MediaCard from '@/components/MediaCard';
export default function HomePage() {
return (
<Box sx={{ display: 'flex' }}>
<div>
<Alert severity="info" sx={{ mt: 2, mb: 5 }}>
<AlertTitle>Hello 👋</AlertTitle>
This app uses the Next.js App Router and Material UI v5.
</Alert>
<Grid container rowSpacing={3} columnSpacing={3}>
<Grid xs={6}>
<MediaCard
heading="CMYK"
text="The CMYK color model (also known as process color, or four color) is a subtractive color model, based on the CMY color model, used in color printing, and is also used to describe the printing process itself."
/>
</Grid>
<Grid xs={6}>
<MediaCard
heading="HSL and HSV"
text="HSL (for hue, saturation, lightness) and HSV (for hue, saturation, value; also known as HSB, for hue, saturation, brightness) are alternative representations of the RGB color model, designed in the 1970s by computer graphics researchers."
/>
</Grid>
<Grid xs={6}>
<MediaCard
heading="RGB"
text="An RGB color space is any additive color space based on the RGB color model. RGB color spaces are commonly found describing the input signal to display devices such as television screens and computer monitors."
/>
</Grid>
<Grid xs={6}>
<MediaCard
heading="CIELAB"
text="The CIELAB color space, also referred to as L*a*b*, was intended as a perceptually uniform space, where a given numerical change corresponds to a similar perceived change in color."
/>
</Grid>
</Grid>
</div>
<Drawer
sx={{
width: 320,
flexShrink: 0,
'& .MuiDrawer-paper': {
width: 320,
boxSizing: 'border-box',
top: ['48px', '56px', '64px'],
height: 'auto',
bottom: 0,
},
}}
variant="permanent"
anchor="right"
>
<List sx={{ px: 2 }}>
<ListItem disablePadding>
<Typography variant="overline" sx={{ fontWeight: 500 }}>
On this page
</Typography>
</ListItem>
</List>
</Drawer>
</Box>
);
}
| 5,929
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src/app
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src/app/starred/page.tsx
|
import * as React from 'react';
import Container from '@mui/material/Container';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
export default function StarredPage() {
return (
<Container>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Typography variant="body1" gutterBottom>
Starred Page
</Typography>
</Box>
</Container>
);
}
| 5,930
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src/app
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src/app/tasks/page.tsx
|
import * as React from 'react';
import Container from '@mui/material/Container';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
export default function TasksPage() {
return (
<Container>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Typography variant="body1" gutterBottom>
Tasks Page
</Typography>
</Box>
</Container>
);
}
| 5,931
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src/components/MediaCard.tsx
|
import * as React from 'react';
import Image from 'next/image';
import Card from '@mui/material/Card';
import CardActions from '@mui/material/CardActions';
import CardContent from '@mui/material/CardContent';
import Button from '@mui/material/Button';
import Typography from '@mui/material/Typography';
export default function MediaCard({ heading, text }: { heading: string; text: string }) {
return (
<Card>
<Image
alt="Random image"
src="https://source.unsplash.com/random"
width={640}
height={480}
style={{
maxWidth: '100%',
height: '200px',
objectFit: 'cover',
}}
/>
<CardContent>
<Typography gutterBottom variant="h5" component="div">
{heading}
</Typography>
<Typography variant="body2" color="text.secondary">
{text}
</Typography>
</CardContent>
<CardActions>
<Button size="small">Share</Button>
<Button size="small">Learn More</Button>
</CardActions>
</Card>
);
}
| 5,932
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src/components
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src/components/ThemeRegistry/EmotionCache.tsx
|
'use client';
import * as React from 'react';
import createCache from '@emotion/cache';
import { useServerInsertedHTML } from 'next/navigation';
import { CacheProvider as DefaultCacheProvider } from '@emotion/react';
import type { EmotionCache, Options as OptionsOfCreateCache } from '@emotion/cache';
export type NextAppDirEmotionCacheProviderProps = {
/** This is the options passed to createCache() from 'import createCache from "@emotion/cache"' */
options: Omit<OptionsOfCreateCache, 'insertionPoint'>;
/** By default <CacheProvider /> from 'import { CacheProvider } from "@emotion/react"' */
CacheProvider?: (props: {
value: EmotionCache;
children: React.ReactNode;
}) => React.JSX.Element | null;
children: React.ReactNode;
};
// Adapted from https://github.com/garronej/tss-react/blob/main/src/next/appDir.tsx
export default function NextAppDirEmotionCacheProvider(props: NextAppDirEmotionCacheProviderProps) {
const { options, CacheProvider = DefaultCacheProvider, children } = props;
const [registry] = React.useState(() => {
const cache = createCache(options);
cache.compat = true;
const prevInsert = cache.insert;
let inserted: { name: string; isGlobal: boolean }[] = [];
cache.insert = (...args) => {
const [selector, serialized] = args;
if (cache.inserted[serialized.name] === undefined) {
inserted.push({
name: serialized.name,
isGlobal: !selector,
});
}
return prevInsert(...args);
};
const flush = () => {
const prevInserted = inserted;
inserted = [];
return prevInserted;
};
return { cache, flush };
});
useServerInsertedHTML(() => {
const inserted = registry.flush();
if (inserted.length === 0) {
return null;
}
let styles = '';
let dataEmotionAttribute = registry.cache.key;
const globals: {
name: string;
style: string;
}[] = [];
inserted.forEach(({ name, isGlobal }) => {
const style = registry.cache.inserted[name];
if (typeof style !== 'boolean') {
if (isGlobal) {
globals.push({ name, style });
} else {
styles += style;
dataEmotionAttribute += ` ${name}`;
}
}
});
return (
<React.Fragment>
{globals.map(({ name, style }) => (
<style
key={name}
data-emotion={`${registry.cache.key}-global ${name}`}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: style }}
/>
))}
{styles && (
<style
data-emotion={dataEmotionAttribute}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: styles }}
/>
)}
</React.Fragment>
);
});
return <CacheProvider value={registry.cache}>{children}</CacheProvider>;
}
| 5,933
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src/components
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src/components/ThemeRegistry/ThemeRegistry.tsx
|
'use client';
import * as React from 'react';
import { ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import NextAppDirEmotionCacheProvider from './EmotionCache';
import theme from './theme';
export default function ThemeRegistry({ children }: { children: React.ReactNode }) {
return (
<NextAppDirEmotionCacheProvider options={{ key: 'mui' }}>
<ThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
{children}
</ThemeProvider>
</NextAppDirEmotionCacheProvider>
);
}
| 5,934
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src/components
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs-ts/src/components/ThemeRegistry/theme.ts
|
import { Roboto } from 'next/font/google';
import { createTheme } from '@mui/material/styles';
const roboto = Roboto({
weight: ['300', '400', '500', '700'],
subsets: ['latin'],
display: 'swap',
});
const theme = createTheme({
palette: {
mode: 'light',
},
typography: {
fontFamily: roboto.style.fontFamily,
},
components: {
MuiAlert: {
styleOverrides: {
root: ({ ownerState }) => ({
...(ownerState.severity === 'info' && {
backgroundColor: '#60a5fa',
}),
}),
},
},
},
});
export default theme;
| 5,935
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/README.md
|
# Material UI - Next.js App Router example
This is a [Next.js](https://nextjs.org/) project bootstrapped using [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with Material UI installed.
## How to use
Download the example [or clone the repo](https://github.com/mui/material-ui):
<!-- #default-branch-switch -->
```bash
curl https://codeload.github.com/mui/material-ui/tar.gz/master | tar -xz --strip=2 material-ui-master/examples/material-ui-nextjs
cd material-ui-nextjs
```
Install it and run:
```bash
npm install
npm run dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
or:
<!-- #default-branch-switch -->
[](https://stackblitz.com/github/mui/material-ui/tree/master/examples/material-ui-nextjs)
[](https://codesandbox.io/s/github/mui/material-ui/tree/master/examples/material-ui-nextjs)
## Learn more
To learn more about this example:
- [Next.js documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Customizing Material UI](https://mui.com/material-ui/customization/how-to-customize/) - approaches to customizing Material UI.
## What's next?
<!-- #default-branch-switch -->
You now have a working example project.
You can head back to the documentation and continue by browsing the [templates](https://mui.com/material-ui/getting-started/templates/) section.
| 5,936
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/jsconfig.json
|
{
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
}
}
}
| 5,937
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/next.config.js
|
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
modularizeImports: {
'@mui/icons-material': {
transform: '@mui/icons-material/{{member}}',
},
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'source.unsplash.com',
port: '',
pathname: '/random',
},
],
},
};
module.exports = nextConfig;
| 5,938
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/package.json
|
{
"name": "material-ui-nextjs",
"version": "5.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@emotion/cache": "latest",
"@emotion/react": "latest",
"@emotion/styled": "latest",
"@mui/icons-material": "latest",
"@mui/material": "latest",
"eslint": "latest",
"eslint-config-next": "latest",
"next": "latest",
"react": "latest",
"react-dom": "latest"
}
}
| 5,939
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src/app/layout.js
|
import * as React from 'react';
import Link from 'next/link';
import AppBar from '@mui/material/AppBar';
import Box from '@mui/material/Box';
import Drawer from '@mui/material/Drawer';
import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import Divider from '@mui/material/Divider';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import DashboardIcon from '@mui/icons-material/Dashboard';
import HomeIcon from '@mui/icons-material/Home';
import StarIcon from '@mui/icons-material/Star';
import ChecklistIcon from '@mui/icons-material/Checklist';
import SettingsIcon from '@mui/icons-material/Settings';
import SupportIcon from '@mui/icons-material/Support';
import LogoutIcon from '@mui/icons-material/Logout';
import ThemeRegistry from '@/components/ThemeRegistry/ThemeRegistry';
export const metadata = {
title: 'Next.js App Router + Material UI v5',
description: 'Next.js App Router + Material UI v5',
};
const DRAWER_WIDTH = 240;
const LINKS = [
{ text: 'Home', href: '/', icon: HomeIcon },
{ text: 'Starred', href: '/starred', icon: StarIcon },
{ text: 'Tasks', href: '/tasks', icon: ChecklistIcon },
];
const PLACEHOLDER_LINKS = [
{ text: 'Settings', icon: SettingsIcon },
{ text: 'Support', icon: SupportIcon },
{ text: 'Logout', icon: LogoutIcon },
];
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
<ThemeRegistry>
<AppBar position="fixed" sx={{ zIndex: 2000 }}>
<Toolbar sx={{ backgroundColor: 'background.paper' }}>
<DashboardIcon sx={{ color: '#444', mr: 2, transform: 'translateY(-2px)' }} />
<Typography variant="h6" noWrap component="div" color="black">
Next.js App Router
</Typography>
</Toolbar>
</AppBar>
<Drawer
sx={{
width: DRAWER_WIDTH,
flexShrink: 0,
'& .MuiDrawer-paper': {
width: DRAWER_WIDTH,
boxSizing: 'border-box',
top: ['48px', '56px', '64px'],
height: 'auto',
bottom: 0,
},
}}
variant="permanent"
anchor="left"
>
<Divider />
<List>
{LINKS.map(({ text, href, icon: Icon }) => (
<ListItem key={href} disablePadding>
<ListItemButton component={Link} href={href}>
<ListItemIcon>
<Icon />
</ListItemIcon>
<ListItemText primary={text} />
</ListItemButton>
</ListItem>
))}
</List>
<Divider sx={{ mt: 'auto' }} />
<List>
{PLACEHOLDER_LINKS.map(({ text, icon: Icon }) => (
<ListItem key={text} disablePadding>
<ListItemButton>
<ListItemIcon>
<Icon />
</ListItemIcon>
<ListItemText primary={text} />
</ListItemButton>
</ListItem>
))}
</List>
</Drawer>
<Box
component="main"
sx={{
flexGrow: 1,
bgcolor: 'background.default',
ml: `${DRAWER_WIDTH}px`,
mt: ['48px', '56px', '64px'],
p: 3,
}}
>
{children}
</Box>
</ThemeRegistry>
</body>
</html>
);
}
| 5,940
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src/app/page.js
|
import * as React from 'react';
import Box from '@mui/material/Box';
import Grid from '@mui/material/Unstable_Grid2';
import Drawer from '@mui/material/Drawer';
import Typography from '@mui/material/Typography';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import Alert from '@mui/material/Alert';
import AlertTitle from '@mui/material/AlertTitle';
import MediaCard from '@/components/MediaCard';
export default function HomePage() {
return (
<Box sx={{ display: 'flex' }}>
<div>
<Alert severity="info" sx={{ mt: 2, mb: 5 }}>
<AlertTitle>Hello 👋</AlertTitle>
This app uses the Next.js App Router and Material UI v5.
</Alert>
<Grid container rowSpacing={3} columnSpacing={3}>
<Grid xs={6}>
<MediaCard
heading="CMYK"
text="The CMYK color model (also known as process color, or four color) is a subtractive color model, based on the CMY color model, used in color printing, and is also used to describe the printing process itself."
/>
</Grid>
<Grid xs={6}>
<MediaCard
heading="HSL and HSV"
text="HSL (for hue, saturation, lightness) and HSV (for hue, saturation, value; also known as HSB, for hue, saturation, brightness) are alternative representations of the RGB color model, designed in the 1970s by computer graphics researchers."
/>
</Grid>
<Grid xs={6}>
<MediaCard
heading="RGB"
text="An RGB color space is any additive color space based on the RGB color model. RGB color spaces are commonly found describing the input signal to display devices such as television screens and computer monitors."
/>
</Grid>
<Grid xs={6}>
<MediaCard
heading="CIELAB"
text="The CIELAB color space, also referred to as L*a*b*, was intended as a perceptually uniform space, where a given numerical change corresponds to a similar perceived change in color."
/>
</Grid>
</Grid>
</div>
<Drawer
sx={{
width: 320,
flexShrink: 0,
'& .MuiDrawer-paper': {
width: 320,
boxSizing: 'border-box',
top: ['48px', '56px', '64px'],
height: 'auto',
bottom: 0,
},
}}
variant="permanent"
anchor="right"
>
<List sx={{ px: 2 }}>
<ListItem disablePadding>
<Typography variant="overline" sx={{ fontWeight: 500 }}>
On this page
</Typography>
</ListItem>
</List>
</Drawer>
</Box>
);
}
| 5,941
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src/app
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src/app/starred/page.js
|
import * as React from 'react';
import Container from '@mui/material/Container';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
export default function StarredPage() {
return (
<Container>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Typography variant="body1" gutterBottom>
Starred Page
</Typography>
</Box>
</Container>
);
}
| 5,942
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src/app
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src/app/tasks/page.js
|
import * as React from 'react';
import Container from '@mui/material/Container';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
export default function TasksPage() {
return (
<Container>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Typography variant="body1" gutterBottom>
Tasks Page
</Typography>
</Box>
</Container>
);
}
| 5,943
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src/components/MediaCard.js
|
import * as React from 'react';
import Image from 'next/image';
import Card from '@mui/material/Card';
import CardActions from '@mui/material/CardActions';
import CardContent from '@mui/material/CardContent';
import Button from '@mui/material/Button';
import Typography from '@mui/material/Typography';
export default function MediaCard({ heading, text }) {
return (
<Card>
<Image
alt="Random image"
src="https://source.unsplash.com/random"
width={640}
height={480}
style={{
maxWidth: '100%',
height: '200px',
objectFit: 'cover',
}}
/>
<CardContent>
<Typography gutterBottom variant="h5" component="div">
{heading}
</Typography>
<Typography variant="body2" color="text.secondary">
{text}
</Typography>
</CardContent>
<CardActions>
<Button size="small">Share</Button>
<Button size="small">Learn More</Button>
</CardActions>
</Card>
);
}
| 5,944
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src/components
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src/components/ThemeRegistry/EmotionCache.js
|
'use client';
import * as React from 'react';
import createCache from '@emotion/cache';
import { useServerInsertedHTML } from 'next/navigation';
import { CacheProvider as DefaultCacheProvider } from '@emotion/react';
// Adapted from https://github.com/garronej/tss-react/blob/main/src/next/appDir.tsx
export default function NextAppDirEmotionCacheProvider(props) {
const { options, CacheProvider = DefaultCacheProvider, children } = props;
const [registry] = React.useState(() => {
const cache = createCache(options);
cache.compat = true;
const prevInsert = cache.insert;
let inserted = [];
cache.insert = (...args) => {
const [selector, serialized] = args;
if (cache.inserted[serialized.name] === undefined) {
inserted.push({
name: serialized.name,
isGlobal: !selector,
});
}
return prevInsert(...args);
};
const flush = () => {
const prevInserted = inserted;
inserted = [];
return prevInserted;
};
return { cache, flush };
});
useServerInsertedHTML(() => {
const inserted = registry.flush();
if (inserted.length === 0) {
return null;
}
let styles = '';
let dataEmotionAttribute = registry.cache.key;
const globals = [];
inserted.forEach(({ name, isGlobal }) => {
const style = registry.cache.inserted[name];
if (typeof style !== 'boolean') {
if (isGlobal) {
globals.push({ name, style });
} else {
styles += style;
dataEmotionAttribute += ` ${name}`;
}
}
});
return (
<React.Fragment>
{globals.map(({ name, style }) => (
<style
key={name}
data-emotion={`${registry.cache.key}-global ${name}`}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: style }}
/>
))}
{styles && (
<style
data-emotion={dataEmotionAttribute}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: styles }}
/>
)}
</React.Fragment>
);
});
return <CacheProvider value={registry.cache}>{children}</CacheProvider>;
}
| 5,945
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src/components
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src/components/ThemeRegistry/ThemeRegistry.js
|
'use client';
import * as React from 'react';
import { ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import NextAppDirEmotionCacheProvider from './EmotionCache';
import theme from './theme';
export default function ThemeRegistry({ children }) {
return (
<NextAppDirEmotionCacheProvider options={{ key: 'mui' }}>
<ThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
{children}
</ThemeProvider>
</NextAppDirEmotionCacheProvider>
);
}
| 5,946
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src/components
|
petrpan-code/mui/material-ui/examples/material-ui-nextjs/src/components/ThemeRegistry/theme.js
|
import { Roboto } from 'next/font/google';
import { createTheme } from '@mui/material/styles';
const roboto = Roboto({
weight: ['300', '400', '500', '700'],
subsets: ['latin'],
display: 'swap',
});
const theme = createTheme({
palette: {
mode: 'light',
},
typography: {
fontFamily: roboto.style.fontFamily,
},
components: {
MuiAlert: {
styleOverrides: {
root: ({ ownerState }) => ({
...(ownerState.severity === 'info' && {
backgroundColor: '#60a5fa',
}),
}),
},
},
},
});
export default theme;
| 5,947
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-preact/README.md
|
# Material UI - Preact example
## How to use
Download the example [or clone the repo](https://github.com/mui/material-ui):
<!-- #default-branch-switch -->
```bash
curl https://codeload.github.com/mui/material-ui/tar.gz/master | tar -xz --strip=2 material-ui-master/examples/material-ui-preact
cd material-ui-preact
```
Install it and run:
```bash
npm install
npm run start
```
## The idea behind the example
The project uses Material UI with [Preact](https://github.com/developit/preact), which is a lightweight (3 kB) alternative to React with the same modern API.
This example uses CRA with `react-app-rewired` for adding Webpack aliases for Preact.
It includes `@mui/material` and its peer dependencies, including [Emotion](https://emotion.sh/docs/introduction), the default style engine in Material UI v5.
<!-- #default-branch-switch -->
If you prefer, you can [use styled-components instead](https://mui.com/material-ui/guides/interoperability/#styled-components).
## What's next?
<!-- #default-branch-switch -->
You now have a working example project.
You can head back to the documentation and continue by browsing the [templates](https://mui.com/material-ui/getting-started/templates/) section.
| 5,948
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-preact/config-overrides.js
|
const { addWebpackAlias, override } = require('customize-cra');
module.exports = override(
addWebpackAlias({
react: 'preact/compat',
'react-dom': 'preact/compat',
}),
);
| 5,949
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-preact/package.json
|
{
"name": "material-ui-preact",
"version": "5.0.0",
"private": true,
"dependencies": {
"@babel/helper-builder-react-jsx": "latest",
"@emotion/react": "latest",
"@emotion/styled": "latest",
"@mui/material": "latest",
"@testing-library/jest-dom": "latest",
"@testing-library/react": "latest",
"@testing-library/user-event": "latest",
"preact": "latest",
"react-scripts": "^5.0.0"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"customize-cra": "latest",
"react-app-rewired": "latest"
}
}
| 5,950
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-preact
|
petrpan-code/mui/material-ui/examples/material-ui-preact/public/index.html
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Preact + Material UI</title>
<!-- Fonts to support Material Design -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700&display=swap"
/>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
| 5,951
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-preact
|
petrpan-code/mui/material-ui/examples/material-ui-preact/public/manifest.json
|
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
| 5,952
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-preact
|
petrpan-code/mui/material-ui/examples/material-ui-preact/src/App.js
|
import * as React from 'react';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
import ProTip from './ProTip';
import Copyright from './Copyright';
export default function App() {
return (
<Container maxWidth="sm">
<Box sx={{ my: 4 }}>
<Typography variant="h4" component="h1" gutterBottom>
Material UI Preact example
</Typography>
<ProTip />
<Copyright />
</Box>
</Container>
);
}
| 5,953
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-preact
|
petrpan-code/mui/material-ui/examples/material-ui-preact/src/Copyright.js
|
import * as React from 'react';
import Typography from '@mui/material/Typography';
import MuiLink from '@mui/material/Link';
export default function Copyright() {
return (
<Typography variant="body2" color="text.secondary" align="center">
{'Copyright © '}
<MuiLink color="inherit" href="https://mui.com/">
Your Website
</MuiLink>{' '}
{new Date().getFullYear()}.
</Typography>
);
}
| 5,954
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-preact
|
petrpan-code/mui/material-ui/examples/material-ui-preact/src/ProTip.js
|
import * as React from 'react';
import Link from '@mui/material/Link';
import SvgIcon from '@mui/material/SvgIcon';
import Typography from '@mui/material/Typography';
function LightBulbIcon(props) {
return (
<SvgIcon {...props}>
<path d="M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7zm2.85 11.1l-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1z" />
</SvgIcon>
);
}
export default function ProTip() {
return (
<Typography sx={{ mt: 6, mb: 3 }} color="text.secondary">
<LightBulbIcon sx={{ mr: 1, verticalAlign: 'middle' }} />
{'Pro tip: See more '}
<Link href="https://mui.com/material-ui/getting-started/templates/">templates</Link>
{' in the Material UI documentation.'}
</Typography>
);
}
| 5,955
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-preact
|
petrpan-code/mui/material-ui/examples/material-ui-preact/src/index.js
|
import * as React from 'react';
import * as ReactDOMClient from 'react-dom/client';
import App from './App';
const root = ReactDOMClient.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>,
);
| 5,956
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-preact
|
petrpan-code/mui/material-ui/examples/material-ui-preact/src/setupTests.js
|
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom/extend-expect';
| 5,957
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-preact
|
petrpan-code/mui/material-ui/examples/material-ui-preact/src/theme.js
|
import { createTheme } from '@mui/material/styles';
import { red } from '@mui/material/colors';
// Create a theme instance.
const theme = createTheme({
palette: {
primary: {
main: '#556cd6',
},
secondary: {
main: '#19857b',
},
error: {
main: red.A400,
},
},
});
export default theme;
| 5,958
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/.stackblitzrc
|
{
"startCommand": "npm run dev"
}
| 5,959
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/README.md
|
# Material UI - Remix example in TypeScript
## How to use
Download the example [or clone the repo](https://github.com/mui/material-ui):
<!-- #default-branch-switch -->
```bash
curl https://codeload.github.com/mui/material-ui/tar.gz/master | tar -xz --strip=2 material-ui-master/examples/material-ui-remix-ts
cd material-ui-remix-ts
```
Install it and run:
```bash
npm install
npm run dev
```
or:
<!-- #default-branch-switch -->
[](https://stackblitz.com/github/mui/material-ui/tree/master/examples/material-ui-remix-ts)
[](https://codesandbox.io/s/github/mui/material-ui/tree/master/examples/material-ui-remix-ts)
## The idea behind the example
The project uses [Remix](https://remix.run/), which is a full stack web framework.
It includes `@mui/material` and its peer dependencies, including [Emotion](https://emotion.sh/docs/introduction), the default style engine in Material UI v5.
If you prefer, you can [use styled-components instead](https://mui.com/material-ui/guides/interoperability/#styled-components).
## What's next?
<!-- #default-branch-switch -->
You now have a working example project.
You can head back to the documentation and continue by browsing the [templates](https://mui.com/material-ui/getting-started/templates/) section.
| 5,960
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/package.json
|
{
"name": "material-ui-remix-ts",
"version": "5.0.0",
"private": true,
"scripts": {
"build": "remix build",
"dev": "remix dev --manual",
"start": "remix-serve ./build/index.js",
"typecheck": "tsc"
},
"dependencies": {
"@emotion/cache": "latest",
"@emotion/react": "latest",
"@emotion/server": "latest",
"@emotion/styled": "latest",
"@mui/material": "latest",
"@remix-run/css-bundle": "latest",
"@remix-run/node": "latest",
"@remix-run/react": "latest",
"@remix-run/serve": "latest",
"@remix-run/server-runtime": "latest",
"react": "latest",
"react-dom": "latest"
},
"devDependencies": {
"@remix-run/dev": "latest",
"@types/react": "latest",
"@types/react-dom": "latest",
"typescript": "latest"
},
"engines": {
"node": ">=14"
},
"sideEffects": false
}
| 5,961
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/remix.config.js
|
/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
appDirectory: 'app',
browserBuildDirectory: 'public/build',
publicPath: '/build/',
serverBuildDirectory: 'build',
devServerPort: 8002,
// TODO: when mui has esm support, remove this (default is esm)
// check it https://github.com/mui/material-ui/issues/30671
serverModuleFormat: 'cjs',
};
| 5,962
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/remix.env.d.ts
|
/// <reference types="@remix-run/dev" />
/// <reference types="@remix-run/node/globals" />
| 5,963
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/tsconfig.json
|
{
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"isolatedModules": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"moduleResolution": "node",
"resolveJsonModule": true,
"target": "ES2022",
"strict": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"~/*": ["./app/*"]
},
// Remix takes care of building everything in `remix build`.
"noEmit": true
}
}
| 5,964
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app/entry.client.tsx
|
import * as React from 'react';
import * as ReactDOM from 'react-dom/client';
import { RemixBrowser } from '@remix-run/react';
import { CacheProvider } from '@emotion/react';
import { ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import ClientStyleContext from './src/ClientStyleContext';
import createEmotionCache from './src/createEmotionCache';
import theme from './src/theme';
interface ClientCacheProviderProps {
children: React.ReactNode;
}
function ClientCacheProvider({ children }: ClientCacheProviderProps) {
const [cache, setCache] = React.useState(createEmotionCache());
const clientStyleContextValue = React.useMemo(
() => ({
reset() {
setCache(createEmotionCache());
},
}),
[],
);
return (
<ClientStyleContext.Provider value={clientStyleContextValue}>
<CacheProvider value={cache}>{children}</CacheProvider>
</ClientStyleContext.Provider>
);
}
const hydrate = () => {
React.startTransition(() => {
ReactDOM.hydrateRoot(
document,
<ClientCacheProvider>
<ThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
<RemixBrowser />
</ThemeProvider>
</ClientCacheProvider>,
);
});
};
if (window.requestIdleCallback) {
window.requestIdleCallback(hydrate);
} else {
// Safari doesn't support requestIdleCallback
// https://caniuse.com/requestidlecallback
window.setTimeout(hydrate, 1);
}
| 5,965
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app/entry.server.tsx
|
import * as React from 'react';
import * as ReactDOMServer from 'react-dom/server';
import { RemixServer } from '@remix-run/react';
import type { EntryContext } from '@remix-run/node';
import createEmotionCache from './src/createEmotionCache';
import theme from './src/theme';
import CssBaseline from '@mui/material/CssBaseline';
import { ThemeProvider } from '@mui/material/styles';
import { CacheProvider } from '@emotion/react';
import createEmotionServer from '@emotion/server/create-instance';
export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
) {
const cache = createEmotionCache();
const { extractCriticalToChunks } = createEmotionServer(cache);
function MuiRemixServer() {
return (
<CacheProvider value={cache}>
<ThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
<RemixServer context={remixContext} url={request.url} />
</ThemeProvider>
</CacheProvider>
);
}
// Render the component to a string.
const html = ReactDOMServer.renderToString(<MuiRemixServer />);
// Grab the CSS from emotion
const { styles } = extractCriticalToChunks(html);
let stylesHTML = '';
styles.forEach(({ key, ids, css }) => {
const emotionKey = `${key} ${ids.join(' ')}`;
const newStyleTag = `<style data-emotion="${emotionKey}">${css}</style>`;
stylesHTML = `${stylesHTML}${newStyleTag}`;
});
// Add the Emotion style tags after the insertion point meta tag
const markup = html.replace(
/<meta(\s)*name="emotion-insertion-point"(\s)*content="emotion-insertion-point"(\s)*\/>/,
`<meta name="emotion-insertion-point" content="emotion-insertion-point"/>${stylesHTML}`,
);
responseHeaders.set('Content-Type', 'text/html');
return new Response(`<!DOCTYPE html>${markup}`, {
status: responseStatusCode,
headers: responseHeaders,
});
}
| 5,966
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app/root.tsx
|
import * as React from 'react';
import {
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
useRouteError,
isRouteErrorResponse,
} from '@remix-run/react';
import { withEmotionCache } from '@emotion/react';
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/material';
import theme from './src/theme';
import ClientStyleContext from './src/ClientStyleContext';
import Layout from './src/Layout';
interface DocumentProps {
children: React.ReactNode;
title?: string;
}
const Document = withEmotionCache(({ children, title }: DocumentProps, emotionCache) => {
const clientStyleData = React.useContext(ClientStyleContext);
// Only executed on client
useEnhancedEffect(() => {
// re-link sheet container
emotionCache.sheet.container = document.head;
// re-inject tags
const tags = emotionCache.sheet.tags;
emotionCache.sheet.flush();
tags.forEach((tag) => {
// eslint-disable-next-line no-underscore-dangle
(emotionCache.sheet as any)._insertTag(tag);
});
// reset cache to reapply global styles
clientStyleData.reset();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="theme-color" content={theme.palette.primary.main} />
{title ? <title>{title}</title> : null}
<Meta />
<Links />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700&display=swap"
/>
<meta name="emotion-insertion-point" content="emotion-insertion-point" />
</head>
<body>
{children}
<ScrollRestoration />
<Scripts />
<LiveReload />
</body>
</html>
);
});
// https://remix.run/docs/en/main/route/component
// https://remix.run/docs/en/main/file-conventions/routes
export default function App() {
return (
<Document>
<Layout>
<Outlet />
</Layout>
</Document>
);
}
// https://remix.run/docs/en/main/route/error-boundary
export function ErrorBoundary() {
const error = useRouteError();
if (isRouteErrorResponse(error)) {
let message;
switch (error.status) {
case 401:
message = <p>Oops! Looks like you tried to visit a page that you do not have access to.</p>;
break;
case 404:
message = <p>Oops! Looks like you tried to visit a page that does not exist.</p>;
break;
default:
throw new Error(error.data || error.statusText);
}
return (
<Document title={`${error.status} ${error.statusText}`}>
<Layout>
<h1>
{error.status}: {error.statusText}
</h1>
{message}
</Layout>
</Document>
);
}
if (error instanceof Error) {
console.error(error);
return (
<Document title="Error!">
<Layout>
<div>
<h1>There was an error</h1>
<p>{error.message}</p>
<hr />
<p>Hey, developer, you should replace this with what you want your users to see.</p>
</div>
</Layout>
</Document>
);
}
return <h1>Unknown Error</h1>;
}
| 5,967
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app/routes/_index.tsx
|
import * as React from 'react';
import type { MetaFunction } from '@remix-run/node';
import { Link as RemixLink } from '@remix-run/react';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
// https://remix.run/docs/en/main/route/meta
export const meta: MetaFunction = () => [
{ title: 'Remix Starter' },
{ name: 'description', content: 'Welcome to remix!' },
];
// https://remix.run/docs/en/main/file-conventions/routes#basic-routes
export default function Index() {
return (
<React.Fragment>
<Typography variant="h4" component="h1" gutterBottom>
Material UI Remix in TypeScript example
</Typography>
<Link to="/about" color="secondary" component={RemixLink}>
Go to the about page
</Link>
</React.Fragment>
);
}
| 5,968
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app/routes/about.tsx
|
import * as React from 'react';
import { Link } from '@remix-run/react';
import Typography from '@mui/material/Typography';
import Button from '@mui/material/Button';
export default function About() {
return (
<React.Fragment>
<Typography variant="h4" component="h1" gutterBottom>
Material UI Remix in TypeScript example
</Typography>
<Button variant="contained" component={Link} to="/">
Go to the main page
</Button>
</React.Fragment>
);
}
| 5,969
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app/src/ClientStyleContext.tsx
|
import * as React from 'react';
export interface ClientStyleContextData {
reset: () => void;
}
export default React.createContext<ClientStyleContextData>({
reset: () => {},
});
| 5,970
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app/src/Copyright.tsx
|
import * as React from 'react';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
export default function Copyright() {
return (
<Typography variant="body2" color="text.secondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}.
</Typography>
);
}
| 5,971
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app/src/Layout.tsx
|
import * as React from 'react';
import Container from '@mui/material/Container';
import Box from '@mui/material/Box';
import ProTip from './ProTip';
import Copyright from './Copyright';
export default function Layout({ children }: { children: React.ReactNode }) {
return (
<Container maxWidth="sm">
<Box sx={{ my: 4 }}>
{children}
<ProTip />
<Copyright />
</Box>
</Container>
);
}
| 5,972
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app/src/ProTip.tsx
|
import * as React from 'react';
import Link from '@mui/material/Link';
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
import Typography from '@mui/material/Typography';
function LightBulbIcon(props: SvgIconProps) {
return (
<SvgIcon {...props}>
<path d="M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7zm2.85 11.1l-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1z" />
</SvgIcon>
);
}
export default function ProTip() {
return (
<Typography sx={{ mt: 6, mb: 3 }} color="text.secondary">
<LightBulbIcon sx={{ mr: 1, verticalAlign: 'middle' }} />
{'Pro tip: See more '}
<Link href="https://mui.com/material-ui/getting-started/templates/">templates</Link>
{' in the Material UI documentation.'}
</Typography>
);
}
| 5,973
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app/src/createEmotionCache.ts
|
import createCache from '@emotion/cache';
export default function createEmotionCache() {
return createCache({ key: 'css' });
}
| 5,974
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app
|
petrpan-code/mui/material-ui/examples/material-ui-remix-ts/app/src/theme.ts
|
import { createTheme } from '@mui/material/styles';
import { red } from '@mui/material/colors';
// Create a theme instance.
const theme = createTheme({
palette: {
primary: {
main: '#556cd6',
},
secondary: {
main: '#19857b',
},
error: {
main: red.A400,
},
},
});
export default theme;
| 5,975
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-via-cdn/README.md
|
# Material UI - CDN example
## How to use
Download the example [or clone the repo](https://github.com/mui/material-ui):
```bash
curl https://codeload.github.com/mui/material-ui/tar.gz/master | tar -xz --strip=2 material-ui-master/examples/material-ui-via-cdn
cd material-ui-via-cdn
```
Run:
```bash
open index.html
```
## The idea behind the example
You can start using Material UI with minimal front-end infrastructure, which is great for prototyping.
We discourage using this approach in production, though.
The client has to download the entire library, regardless of which components are used, affecting performance and bandwidth usage.
<!-- #default-branch-switch -->
[The live preview.](https://rawcdn.githack.com/mui/material-ui/master/examples/material-ui-via-cdn/index.html)
## UMD releases
We are providing two Universal Module Definition (UMD) files:
- one for development: https://unpkg.com/@mui/material@latest/umd/material-ui.development.js
- one for production: https://unpkg.com/@mui/material@latest/umd/material-ui.production.min.js
<!-- #default-branch-switch -->
## What's next?
You now have a working example project.
You can head back to the documentation and continue by browsing the [templates](https://mui.com/material-ui/getting-started/templates/) section.
<!-- #default-branch-switch -->
| 5,976
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-via-cdn/index.html
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>My page</title>
<meta name="viewport" content="initial-scale=1, width=device-width" />
<script
src="https://unpkg.com/react@latest/umd/react.development.js"
crossorigin="anonymous"
></script>
<script src="https://unpkg.com/react-dom@latest/umd/react-dom.development.js"></script>
<script
src="https://unpkg.com/@mui/material@latest/umd/material-ui.development.js"
crossorigin="anonymous"
></script>
<script
src="https://unpkg.com/@babel/standalone@latest/babel.min.js"
crossorigin="anonymous"
></script>
<!-- Fonts to support Material Design -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700&display=swap"
/>
<!-- Icons to support Material Design -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
</head>
<body>
<div id="root"></div>
<script type="text/babel">
const {
colors,
CssBaseline,
ThemeProvider,
Typography,
Container,
createTheme,
Box,
SvgIcon,
Link,
} = MaterialUI;
// Create a theme instance.
const theme = createTheme({
palette: {
primary: {
main: '#556cd6',
},
secondary: {
main: '#19857b',
},
error: {
main: colors.red.A400,
},
},
});
function LightBulbIcon(props) {
return (
<SvgIcon {...props}>
<path d="M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7zm2.85 11.1l-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1z" />
</SvgIcon>
);
}
function ProTip() {
return (
<Typography sx={{ mt: 6, mb: 3 }} color="text.secondary">
<LightBulbIcon sx={{ mr: 1, verticalAlign: 'middle' }} />
{'Pro tip: See more '}
<Link href="https://mui.com/material-ui/getting-started/templates/">templates</Link>
{' in the Material UI documentation.'}
</Typography>
);
}
function Copyright() {
return (
<Typography variant="body2" color="text.secondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
function App() {
return (
<Container maxWidth="sm">
<Box sx={{ my: 4 }}>
<Typography variant="h4" component="h1" gutterBottom>
Material UI CDN example
</Typography>
<ProTip />
<Copyright />
</Box>
</Container>
);
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<ThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
<App />
</ThemeProvider>,
);
</script>
</body>
</html>
| 5,977
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-via-cdn/package.json
|
{
"name": "material-ui-via-cdn",
"version": "5.0.0",
"private": true,
"dependencies": {},
"scripts": {}
}
| 5,978
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts/README.md
|
# Material UI - Vite.js in TypeScript example
## How to use
Download the example [or clone the repo](https://github.com/mui/material-ui):
<!-- #default-branch-switch -->
```bash
curl https://codeload.github.com/mui/material-ui/tar.gz/master | tar -xz --strip=2 material-ui-master/examples/material-ui-vite-ts
cd material-ui-vite-ts
```
Install it and run:
```bash
npm install
npm run dev
```
or:
<!-- #default-branch-switch -->
[](https://stackblitz.com/github/mui/material-ui/tree/master/examples/material-ui-vite-ts)
[](https://codesandbox.io/s/github/mui/material-ui/tree/master/examples/material-ui-vite-ts)
## The idea behind the example
This example uses [Vite.js](https://github.com/vitejs/vite).
It includes `@mui/material` and its peer dependencies, including [Emotion](https://emotion.sh/docs/introduction), the default style engine in Material UI v5.
## What's next?
<!-- #default-branch-switch -->
You now have a working example project.
You can head back to the documentation and continue by browsing the [templates](https://mui.com/material-ui/getting-started/templates/) section.
| 5,979
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts/index.html
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="initial-scale=1, width=device-width" />
<!-- Fonts to support Material Design -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700&display=swap"
/>
<title>Vite + Material UI + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
| 5,980
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts/package.json
|
{
"name": "material-ui-vite-ts",
"private": true,
"version": "5.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@emotion/react": "latest",
"@emotion/styled": "latest",
"@mui/icons-material": "latest",
"@mui/material": "latest",
"react": "latest",
"react-dom": "latest"
},
"devDependencies": {
"@types/react": "latest",
"@types/react-dom": "latest",
"@vitejs/plugin-react": "latest",
"typescript": "latest",
"vite": "latest"
}
}
| 5,981
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts/tsconfig.json
|
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
| 5,982
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts/tsconfig.node.json
|
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
| 5,983
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts/vite.config.ts
|
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
});
| 5,984
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts/public/vite.svg
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
| 5,985
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts/src/App.tsx
|
import * as React from 'react';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
import Link from '@mui/material/Link';
import ProTip from './ProTip';
function Copyright() {
return (
<Typography variant="body2" color="text.secondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}.
</Typography>
);
}
export default function App() {
return (
<Container maxWidth="sm">
<Box sx={{ my: 4 }}>
<Typography variant="h4" component="h1" gutterBottom>
Material UI Vite.js example in TypeScript
</Typography>
<ProTip />
<Copyright />
</Box>
</Container>
);
}
| 5,986
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts/src/ProTip.tsx
|
import * as React from 'react';
import Link from '@mui/material/Link';
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
import Typography from '@mui/material/Typography';
function LightBulbIcon(props: SvgIconProps) {
return (
<SvgIcon {...props}>
<path d="M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7zm2.85 11.1l-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1z" />
</SvgIcon>
);
}
export default function ProTip() {
return (
<Typography sx={{ mt: 6, mb: 3 }} color="text.secondary">
<LightBulbIcon sx={{ mr: 1, verticalAlign: 'middle' }} />
{'Pro tip: See more '}
<Link href="https://mui.com/material-ui/getting-started/templates/">templates</Link>
{' in the Material UI documentation.'}
</Typography>
);
}
| 5,987
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts/src/main.tsx
|
import * as React from 'react';
import * as ReactDOM from 'react-dom/client';
import { ThemeProvider } from '@emotion/react';
import { CssBaseline } from '@mui/material';
import theme from './theme';
import App from './App';
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<ThemeProvider theme={theme}>
<CssBaseline />
<App />
</ThemeProvider>
</React.StrictMode>,
);
| 5,988
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts/src/theme.tsx
|
import { createTheme } from '@mui/material/styles';
import { red } from '@mui/material/colors';
// A custom theme for this app
const theme = createTheme({
palette: {
primary: {
main: '#556cd6',
},
secondary: {
main: '#19857b',
},
error: {
main: red.A400,
},
},
});
export default theme;
| 5,989
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts
|
petrpan-code/mui/material-ui/examples/material-ui-vite-ts/src/vite-env.d.ts
|
/// <reference types="vite/client" />
| 5,990
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-vite/README.md
|
# Material UI - Vite.js example
## How to use
Download the example [or clone the repo](https://github.com/mui/material-ui):
<!-- #default-branch-switch -->
```bash
curl https://codeload.github.com/mui/material-ui/tar.gz/master | tar -xz --strip=2 material-ui-master/examples/material-ui-vite
cd material-ui-vite
```
Install it and run:
```bash
npm install
npm run dev
```
or:
<!-- #default-branch-switch -->
[](https://stackblitz.com/github/mui/material-ui/tree/master/examples/material-ui-vite)
[](https://codesandbox.io/s/github/mui/material-ui/tree/master/examples/material-ui-vite)
## The idea behind the example
This example uses [Vite.js](https://github.com/vitejs/vite).
It includes `@mui/material` and its peer dependencies, including [Emotion](https://emotion.sh/docs/introduction), the default style engine in Material UI v5.
## What's next?
<!-- #default-branch-switch -->
You now have a working example project.
You can head back to the documentation and continue by browsing the [templates](https://mui.com/material-ui/getting-started/templates/) section.
| 5,991
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-vite/index.html
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="initial-scale=1, width=device-width" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700&display=swap"
/>
<title>Vite + Material UI + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
| 5,992
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-vite/package.json
|
{
"name": "material-ui-vite",
"version": "5.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"dependencies": {
"@emotion/react": "latest",
"@emotion/styled": "latest",
"@mui/material": "latest",
"react": "latest",
"react-dom": "latest"
},
"devDependencies": {
"@vitejs/plugin-react": "latest",
"vite": "latest"
}
}
| 5,993
|
0
|
petrpan-code/mui/material-ui/examples
|
petrpan-code/mui/material-ui/examples/material-ui-vite/vite.config.js
|
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
});
| 5,994
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-vite
|
petrpan-code/mui/material-ui/examples/material-ui-vite/public/vite.svg
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
| 5,995
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-vite
|
petrpan-code/mui/material-ui/examples/material-ui-vite/src/App.jsx
|
import * as React from 'react';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
import ProTip from './ProTip';
import Copyright from './Copyright';
export default function App() {
return (
<Container maxWidth="sm">
<Box sx={{ my: 4 }}>
<Typography variant="h4" component="h1" gutterBottom>
Material UI Vite.js example
</Typography>
<ProTip />
<Copyright />
</Box>
</Container>
);
}
| 5,996
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-vite
|
petrpan-code/mui/material-ui/examples/material-ui-vite/src/Copyright.jsx
|
import * as React from 'react';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
export default function Copyright() {
return (
<Typography variant="body2" color="text.secondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}.
</Typography>
);
}
| 5,997
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-vite
|
petrpan-code/mui/material-ui/examples/material-ui-vite/src/ProTip.jsx
|
import * as React from 'react';
import Link from '@mui/material/Link';
import SvgIcon from '@mui/material/SvgIcon';
import Typography from '@mui/material/Typography';
function LightBulbIcon(props) {
return (
<SvgIcon {...props}>
<path d="M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7zm2.85 11.1l-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1z" />
</SvgIcon>
);
}
export default function ProTip() {
return (
<Typography sx={{ mt: 6, mb: 3 }} color="text.secondary">
<LightBulbIcon sx={{ mr: 1, verticalAlign: 'middle' }} />
{'Pro tip: See more '}
<Link href="https://mui.com/material-ui/getting-started/templates/">templates</Link>
{' in the Material UI documentation.'}
</Typography>
);
}
| 5,998
|
0
|
petrpan-code/mui/material-ui/examples/material-ui-vite
|
petrpan-code/mui/material-ui/examples/material-ui-vite/src/main.jsx
|
import * as React from 'react';
import { createRoot } from 'react-dom/client';
import CssBaseline from '@mui/material/CssBaseline';
import { ThemeProvider } from '@mui/material/styles';
import App from './App';
import theme from './theme';
const rootElement = document.getElementById('root');
const root = createRoot(rootElement);
root.render(
<React.StrictMode>
<ThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
<App />
</ThemeProvider>
,
</React.StrictMode>,
);
| 5,999
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.