Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Add and revise Base UI + Create React App examples #36825

Merged
merged 19 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"/examples/material-cra",
"/examples/material-cra-ts",
"/examples/joy-cra-ts",
"/examples/base-cra",
"/examples/base-cra-ts"
],
"silent": true
Expand Down
File renamed without changes.
35 changes: 35 additions & 0 deletions examples/base-cra-system-ts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Base UI - Create React App example with MUI System in TypeScript

[Base UI](https://mui.com/base/getting-started/overview/) is a library of unstyled React UI components which includes prebuilt components with production-ready functionality, along with low-level hooks for transferring that functionality to other components.

[Create React App](https://create-react-app.dev/) is a framework for quickly creating a new React project without the need to configure complex build tools or development environments.

[MUI System](https://mui.com/system/getting-started/overview/) is a set of CSS utilities for building custom designs more efficiently when working with MUI component libraries.
(Note: MUI System, in turn, relies on [Emotion](https://emotion.sh/docs/introduction).
You can uninstall `@mui/system`, `@emotion/react`, and `@emotion/styled` if you plan to use a different styling solution.)

## How to use

Download the example [or clone the repo](https://github.com/mui/material-ui):

<!-- #default-branch-switch -->

```sh
curl https://codeload.github.com/mui/material-ui/tar.gz/master | tar -xz --strip=2 material-ui-master/examples/base-cra-system-ts
cd base-cra-system-ts
```

Install it and run:

```sh
npm install
npm start
```

or:

<!-- #default-branch-switch -->

[![Edit on StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/mui/material-ui/tree/master/examples/base-cra-system-ts)

[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/mui/material-ui/tree/master/examples/base-cra-system-ts)
35 changes: 35 additions & 0 deletions examples/base-cra-system-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "base-cra-system-ts",
"version": "5.0.0",
"private": true,
"dependencies": {
"@emotion/react": "latest",
"@emotion/styled": "latest",
"@mui/base": "latest",
"@mui/system": "latest",
"@types/react": "latest",
"@types/react-dom": "latest",
"react": "latest",
"react-dom": "latest",
"react-scripts": "latest",
"typescript": "latest"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added examples/base-cra-system-ts/public/favicon.ico
Binary file not shown.
38 changes: 38 additions & 0 deletions examples/base-cra-system-ts/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="initial-scale=1, width=device-width" />
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added examples/base-cra-system-ts/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/base-cra-system-ts/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions examples/base-cra-system-ts/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"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"
}
3 changes: 3 additions & 0 deletions examples/base-cra-system-ts/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
50 changes: 50 additions & 0 deletions examples/base-cra-system-ts/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import * as React from 'react';
import { Box, Stack, styled } from '@mui/system';

const Item = styled('div')({
border: '1px solid #000000',
padding: '20px',
borderRadius: '4px',
});

export default function RowAndColumnSpacing() {
return (
<Box
sx={{
flexGrow: 1,
maxWidth: '800px',
margin: 'auto',
padding: '15px',
fontFamily: 'sans-serif',
lineHeight: '1.5',
}}
>
<div>
<h1>Base UI + CRA + MUI System scaffold (TypeScript)</h1>
</div>

<Stack spacing={2} sx={{ marginBottom: '20px' }}>
<Item>
<a href="https://mui.com/base/getting-started/overview/">Base UI</a> is a library of
unstyled React UI components which includes prebuilt components with production-ready
functionality, along with low-level hooks for transferring that functionality to other
components.
</Item>
<Item>
<a href="https://create-react-app.dev/">Create React App</a> is a framework for quickly
creating a new React project without the need to configure complex build tools or
development environments.
</Item>
<Item>
<a href="https://mui.com/system/getting-started/overview/">MUI System</a> is a set of CSS
utilities for building custom designs more efficiently when working with MUI component
libraries. This startup page uses the MUI System `styled()` and `sx` utilities. (Note: MUI
System, in turn, relies on <a href="https://emotion.sh/docs/introduction">Emotion</a>.)
</Item>
</Stack>
<span>
Created with 💙 by <a href="https://mui.com">MUI</a>.
</span>
</Box>
);
}
8 changes: 8 additions & 0 deletions examples/base-cra-system-ts/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom/client';
import App from './App';

const rootElement = document.getElementById('root');
const root = ReactDOM.createRoot(rootElement!);

root.render(<App />);
1 change: 1 addition & 0 deletions examples/base-cra-system-ts/src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
19 changes: 19 additions & 0 deletions examples/base-cra-system-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": ["src"]
}
23 changes: 23 additions & 0 deletions examples/base-cra-system/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
35 changes: 35 additions & 0 deletions examples/base-cra-system/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Base UI - Create React App example with MUI System in JavaScript

[Base UI](https://mui.com/base/getting-started/overview/) is a library of unstyled React UI components which includes prebuilt components with production-ready functionality, along with low-level hooks for transferring that functionality to other components.

[Create React App](https://create-react-app.dev/) is a framework for quickly creating a new React project without the need to configure complex build tools or development environments.

[MUI System](https://mui.com/system/getting-started/overview/) is a set of CSS utilities for building custom designs more efficiently when working with MUI component libraries.
(Note: MUI System, in turn, relies on [Emotion](https://emotion.sh/docs/introduction).
You can uninstall `@mui/system`, `@emotion/react`, and `@emotion/styled` if you plan to use a different styling solution.)

## How to use

Download the example [or clone the repo](https://github.com/mui/material-ui):

<!-- #default-branch-switch -->

```sh
curl https://codeload.github.com/mui/material-ui/tar.gz/master | tar -xz --strip=2 material-ui-master/examples/base-cra-system
cd base-cra-system
```

Install it and run:

```sh
npm install
npm start
```

or:

<!-- #default-branch-switch -->

[![Edit on StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/mui/material-ui/tree/master/examples/base-cra-system)

[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/mui/material-ui/tree/master/examples/base-cra-system)
32 changes: 32 additions & 0 deletions examples/base-cra-system/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "base-cra-system",
"version": "5.0.0",
"private": true,
"dependencies": {
"@emotion/react": "latest",
"@emotion/styled": "latest",
"@mui/base": "latest",
"@mui/system": "latest",
"react": "latest",
"react-dom": "latest",
"react-scripts": "latest"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added examples/base-cra-system/public/favicon.ico
Binary file not shown.
40 changes: 40 additions & 0 deletions examples/base-cra-system/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!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" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added examples/base-cra-system/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/base-cra-system/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions examples/base-cra-system/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"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"
}
3 changes: 3 additions & 0 deletions examples/base-cra-system/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
Loading