Repository: gopinav/React-MUI-Tutorials
Branch: master
Commit: 0c069c13b43e
Files: 53
Total size: 60.3 KB
Directory structure:
gitextract_erixtw6q/
└── react-mui-demo/
├── .gitignore
├── README.md
├── package.json
├── public/
│ ├── index.html
│ ├── manifest.json
│ └── robots.txt
├── src/
│ ├── App.css
│ ├── App.test.tsx
│ ├── App.tsx
│ ├── components/
│ │ ├── MuiAccordion.tsx
│ │ ├── MuiAlert.tsx
│ │ ├── MuiAutocomplete.tsx
│ │ ├── MuiAvatar.tsx
│ │ ├── MuiBadge.tsx
│ │ ├── MuiBottomNavigation.tsx
│ │ ├── MuiBreadcrumbs.tsx
│ │ ├── MuiButton.tsx
│ │ ├── MuiCard.tsx
│ │ ├── MuiCheckbox.tsx
│ │ ├── MuiChip.tsx
│ │ ├── MuiCustomTheme.tsx
│ │ ├── MuiDateRangePicker.tsx
│ │ ├── MuiDateTimePicker.tsx
│ │ ├── MuiDialog.tsx
│ │ ├── MuiDrawer.tsx
│ │ ├── MuiImageList.tsx
│ │ ├── MuiLayout.tsx
│ │ ├── MuiLink.tsx
│ │ ├── MuiList.tsx
│ │ ├── MuiLoadingButton.tsx
│ │ ├── MuiMasonry.tsx
│ │ ├── MuiNavbar.tsx
│ │ ├── MuiProgress.tsx
│ │ ├── MuiRadioButton.tsx
│ │ ├── MuiRating.tsx
│ │ ├── MuiSelect.tsx
│ │ ├── MuiSkeleton.tsx
│ │ ├── MuiSnackbar.tsx
│ │ ├── MuiSpeedDial.tsx
│ │ ├── MuiSwitch.tsx
│ │ ├── MuiTable.tsx
│ │ ├── MuiTabs.tsx
│ │ ├── MuiTextField.tsx
│ │ ├── MuiTimeline.tsx
│ │ ├── MuiTooltip.tsx
│ │ └── MuiTypography.tsx
│ ├── index.css
│ ├── index.tsx
│ ├── react-app-env.d.ts
│ ├── reportWebVitals.ts
│ ├── setupTests.ts
│ └── theme.d.ts
└── tsconfig.json
================================================
FILE CONTENTS
================================================
================================================
FILE: react-mui-demo/.gitignore
================================================
# 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*
================================================
FILE: react-mui-demo/README.md
================================================
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.\
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
================================================
FILE: react-mui-demo/package.json
================================================
{
"name": "react-mui-demo",
"version": "0.1.0",
"private": true,
"dependencies": {
"@date-io/date-fns": "^2.13.1",
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"@mui/icons-material": "^5.3.1",
"@mui/lab": "^5.0.0-alpha.67",
"@mui/material": "^5.3.1",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.4.0",
"@types/node": "^16.11.21",
"@types/react": "^17.0.38",
"@types/react-dom": "^17.0.11",
"date-fns": "^2.28.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"typescript": "^4.5.5",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
================================================
FILE: react-mui-demo/public/index.html
================================================
React App
You need to enable JavaScript to run this app.
================================================
FILE: react-mui-demo/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"
}
================================================
FILE: react-mui-demo/public/robots.txt
================================================
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
================================================
FILE: react-mui-demo/src/App.css
================================================
/* body {
background-color: #eeeeee;
} */
.App {
margin: 4rem;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
================================================
FILE: react-mui-demo/src/App.test.tsx
================================================
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render( );
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
================================================
FILE: react-mui-demo/src/App.tsx
================================================
import { createTheme, ThemeProvider, colors } from '@mui/material'
import AdapterDateFns from '@mui/lab/AdapterDateFns'
import { LocalizationProvider } from '@mui/lab'
import './App.css'
// import { MuiTable } from './components/MuiTable'
import { MuiCustomTheme } from './components/MuiCustomTheme'
// import { MuiTypography } from './components/MuiTypography'
// import { MuiButton } from './components/MuiButton'
// import { MuiTextField } from './components/MuiTextField'
// import { MuiSelect } from './components/MuiSelect'
// import { MuiRadioButton } from './components/MuiRadioButton'
// import { MuiCheckbox } from './components/MuiCheckbox'
// import { MuiSwitch } from './components/MuiSwitch'
// import { MuiRating } from './components/MuiRating'
// import { MuiAutocomplete } from './components/MuiAutocomplete'
// import { MuiLayout } from './components/MuiLayout'
// import { MuiCard } from './components/MuiCard'
// import { MuiAccordion } from './components/MuiAccordion'
// import { MuiImageList } from './components/MuiImageList'
// import { MuiNavbar } from './components/MuiNavbar'
// import { MuiLink } from './components/MuiLink'
// import { MuiBreadcrumbs } from './components/MuiBreadcrumbs'
// import { MuiDrawer } from './components/MuiDrawer'
// import { MuiTabs } from './components/MuiTabs'
// import { MuiSpeedDial } from './components/MuiSpeedDial'
// import { MuiBottomNavigation } from './components/MuiBottomNavigation'
// import { MuiAvatar } from './components/MuiAvatar'
// import { MuiBadge } from './components/MuiBadge'
// import { MuiList } from './components/MuiList'
// import { MuiChip } from './components/MuiChip'
// import { MuiTooltip } from './components/MuiTooltip'
// import { MuiAlert } from './components/MuiAlert'
// import { MuiSnackbar } from './components/MuiSnackbar'
// import { MuiDialog } from './components/MuiDialog'
// import { MuiSkeleton } from './components/MuiSkeleton'
// import { MuiProgress } from './components/MuiProgress'
// import { MuiLoadingButton } from './components/MuiLoadingButton'
// import { MuiDateTimePicker } from './components/MuiDateTimePicker'
// import { MuiDateRangePicker } from './components/MuiDateRangePicker'
// import { MuiTimeline } from './components/MuiTimeline'
// import { MuiMasonry } from './components/MuiMasonry'
const theme = createTheme({
status: {
danger: '#e53e3e'
},
palette: {
secondary: {
main: colors.orange[500]
},
neutral: {
main: colors.grey[500],
darker: colors.grey[700]
}
}
})
function App() {
return (
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
)
}
export default App
================================================
FILE: react-mui-demo/src/components/MuiAccordion.tsx
================================================
import {
Accordion,
AccordionSummary,
AccordionDetails,
Typography
} from '@mui/material'
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
import { useState } from 'react'
export const MuiAccordion = () => {
const [expanded, setExpanded] = useState(false)
const handleChange = (isExpanded: boolean, panel: string) => {
setExpanded(isExpanded ? panel : false)
}
return (
<>
handleChange(isExpanded, 'panel1')}>
}>
Accordion 1
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
malesuada lacus ex, sit amet blandit leo lobortis eget.
handleChange(isExpanded, 'panel2')}>
}>
Accordion 2
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
malesuada lacus ex, sit amet blandit leo lobortis eget.
handleChange(isExpanded, 'panel3')}>
}>
Accordion 3
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
malesuada lacus ex, sit amet blandit leo lobortis eget.
>
)
}
================================================
FILE: react-mui-demo/src/components/MuiAlert.tsx
================================================
import { Stack, Alert, AlertTitle, Button } from '@mui/material'
import CheckIcon from '@mui/icons-material/Check'
export const MuiAlert = () => {
return (
alert('Close alert')}>
Error This is an error alert
Warning This is a warning alert
Info This is an info alert
}
action={
UNDO
}>
Success This is a success alert
This is an outlined error alert
This is a outlined warning alert
This is an outlined info alert
This is a outlined success alert
This is an filled error alert
This is a filled warning alert
This is an filled info alert
This is a filled success alert
)
}
================================================
FILE: react-mui-demo/src/components/MuiAutocomplete.tsx
================================================
import { Stack, Autocomplete, TextField } from '@mui/material'
import { useState } from 'react'
type Skill = {
id: number
label: string
}
const skills = ['HTML', 'CSS', 'JavaScript', 'TypeScript', 'React']
const skillsOptions = skills.map((skill, index) => ({
id: index + 1,
label: skill
}))
export const MuiAutocomplete = () => {
const [value, setValue] = useState(null)
const [skill, setSkill] = useState(null)
console.log(skill)
return (
}
value={value}
onChange={(event: any, newValue: string | null) => {
setValue(newValue)
}}
/>
}
value={skill}
onChange={(_event: any, newValue: Skill | null) => {
setSkill(newValue)
}}
/>
)
}
================================================
FILE: react-mui-demo/src/components/MuiAvatar.tsx
================================================
import { Stack, Avatar, AvatarGroup } from '@mui/material'
export const MuiAvatar = () => {
return (
BW
CK
BW
CK
BW
CK
)
}
================================================
FILE: react-mui-demo/src/components/MuiBadge.tsx
================================================
import { Stack, Badge } from '@mui/material'
import MailIcon from '@mui/icons-material/Mail'
export const MuiBadge = () => {
return (
)
}
================================================
FILE: react-mui-demo/src/components/MuiBottomNavigation.tsx
================================================
import { BottomNavigation, BottomNavigationAction } from '@mui/material'
import HomeIcon from '@mui/icons-material/Home'
import FavoriteIcon from '@mui/icons-material/Favorite'
import PersonIcon from '@mui/icons-material/Person'
import { useState } from 'react'
export const MuiBottomNavigation = () => {
const [value, setValue] = useState(0)
return (
{
setValue(newValue)
}}>
} />
} />
} />
)
}
================================================
FILE: react-mui-demo/src/components/MuiBreadcrumbs.tsx
================================================
import { Box, Breadcrumbs, Link, Typography } from '@mui/material'
import NavigateNextIcon from '@mui/icons-material/NavigateNext'
export const MuiBreadcrumbs = () => {
return (
}
maxItems={3}
itemsAfterCollapse={2}
aria-label='breadcrumb'>
Home
Catalog
Accessories
New Collection
Shoes
)
}
================================================
FILE: react-mui-demo/src/components/MuiButton.tsx
================================================
import { useState } from 'react'
import {
Stack,
Button,
IconButton,
ButtonGroup,
ToggleButtonGroup,
ToggleButton
} from '@mui/material'
import SendIcon from '@mui/icons-material/Send'
import FormatBoldIcon from '@mui/icons-material/FormatBold'
import FormatItalicIcon from '@mui/icons-material/FormatItalic'
import FormatUnderlinedIcon from '@mui/icons-material/FormatUnderlined'
export const MuiButton = () => {
const [formats, setFormats] = useState([])
console.log(formats)
const handleFormatChange = (
_event: React.MouseEvent,
updatedFormats: string[]
) => {
setFormats(updatedFormats)
}
return (
Text
Contained
Outlined
Primary
Secondary
Error
Warning
Info
Success
Small
Medium
Large
}
disableRipple
onClick={() => alert('Clicked')}>
Send
} disableElevation>
Send
alert('Left clicked')}>Left
Center
Right
)
}
================================================
FILE: react-mui-demo/src/components/MuiCard.tsx
================================================
import {
Box,
Card,
CardContent,
CardActions,
Typography,
Button,
CardMedia
} from '@mui/material'
export const MuiCard = () => {
return (
React
React is a JavaScript library for building user interfaces. React
can be used as a base in the development of single-page or mobile
applications.
Share
Learn More
)
}
================================================
FILE: react-mui-demo/src/components/MuiCheckbox.tsx
================================================
import { useState } from 'react'
import {
Box,
FormControlLabel,
Checkbox,
FormControl,
FormLabel,
FormGroup
} from '@mui/material'
import BookmarkBorderIcon from '@mui/icons-material/BookmarkBorder'
import BookmarkIcon from '@mui/icons-material/Bookmark'
export const MuiCheckbox = () => {
const [acceptTnC, setAcceptTnC] = useState(false)
const [skills, setSkills] = useState([])
console.log(skills)
const handleChange = (event: React.ChangeEvent) => {
setAcceptTnC(event.target.checked)
}
const handleSkillChange = (event: React.ChangeEvent) => {
const index = skills.indexOf(event.target.value)
if (index === -1) {
setSkills([...skills, event.target.value])
} else {
setSkills(skills.filter(skill => skill !== event.target.value))
}
}
return (
}
label='Accept terms and conditions'
/>
}
checkedIcon={ }
checked={acceptTnC}
onChange={handleChange}
/>
Skills
}
label='HTML'
/>
}
label='CSS'
/>
}
label='JavaScript'
/>
)
}
================================================
FILE: react-mui-demo/src/components/MuiChip.tsx
================================================
import { Stack, Chip, Avatar } from '@mui/material'
import { useState } from 'react'
export const MuiChip = () => {
const [chips, setChips] = useState(['Chip 1', 'Chip 2', 'Chip 3'])
const handleDelete = (chipToDelete: string) => {
setChips(chips => chips.filter(chip => chip !== chipToDelete))
}
return (
V}
/>
alert('Clicked')} />
alert('Clicked')}
onDelete={() => alert('Delete')}
/>
{chips.map(chip => (
handleDelete(chip)} />
))}
)
}
================================================
FILE: react-mui-demo/src/components/MuiCustomTheme.tsx
================================================
import { Box, styled } from '@mui/material'
const StyledBox = styled(Box)(({ theme }) => ({
height: '250px',
width: '250px',
backgroundColor: theme.palette.neutral?.darker
}))
export const MuiCustomTheme = () => {
return (
<>
>
)
}
================================================
FILE: react-mui-demo/src/components/MuiDateRangePicker.tsx
================================================
import { Box, TextField } from '@mui/material'
import { DateRangePicker, DateRange } from '@mui/lab'
import { useState } from 'react'
export const MuiDateRangePicker = () => {
const [value, setValue] = useState>([null, null])
console.log('value', value)
return (
{
setValue(newValue)
}}
renderInput={(startProps, endProps) => (
<>
to
>
)}
/>
)
}
================================================
FILE: react-mui-demo/src/components/MuiDateTimePicker.tsx
================================================
import { Stack, TextField } from '@mui/material'
import { DatePicker, TimePicker, DateTimePicker } from '@mui/lab'
import { useState } from 'react'
export const MuiDateTimePicker = () => {
const [selectedDate, setSelectedDate] = useState(null)
const [selectedTime, setSelectedTime] = useState(null)
const [selectedDateTime, setSelectedDateTime] = useState(null)
console.log({
selectedDate,
selectedTime: selectedTime && selectedTime.toLocaleTimeString(),
selectedDateTime
})
return (
{
setSelectedDate(newValue)
}}
renderInput={params => }
/>
{
setSelectedTime(newValue)
}}
renderInput={params => }
/>
{
setSelectedDateTime(newValue)
}}
renderInput={params => }
/>
)
}
================================================
FILE: react-mui-demo/src/components/MuiDialog.tsx
================================================
import {
Button,
Dialog,
DialogTitle,
DialogContent,
DialogContentText,
DialogActions
} from '@mui/material'
import { useState } from 'react'
export const MuiDialog = () => {
const [open, setOpen] = useState(false)
return (
<>
setOpen(true)}>Open dialog
setOpen(false)}
aria-labelledby='dialog-title'
aria-describedby='dialog-description'>
Submit the test?
Are you sure you want to submit the test? You will not be able to
edit it after submitting.
setOpen(false)}>Cancel
setOpen(false)} autoFocus>
Submit
>
)
}
================================================
FILE: react-mui-demo/src/components/MuiDrawer.tsx
================================================
import { Drawer, Box, Typography, IconButton } from '@mui/material'
import { useState } from 'react'
import MenuIcon from '@mui/icons-material/Menu'
export const MuiDrawer = () => {
const [isDrawerOpen, setIsDrawerOpen] = useState(false)
return (
<>
setIsDrawerOpen(true)}
size='large'
edge='start'
color='inherit'
aria-label='logo'>
setIsDrawerOpen(false)}>
Side Panel
>
)
}
================================================
FILE: react-mui-demo/src/components/MuiImageList.tsx
================================================
import { Stack, ImageList, ImageListItem, Box } from '@mui/material'
export const MuiImageList = () => {
return (
{itemData.map(item => (
))}
{itemData2.map(item => (
))}
{itemData3.map(item => (
))}
)
}
const itemData = [
{
img: 'https://images.unsplash.com/photo-1551963831-b3b1ca40c98e',
title: 'Breakfast'
},
{
img: 'https://images.unsplash.com/photo-1551782450-a2132b4ba21d',
title: 'Burger'
},
{
img: 'https://images.unsplash.com/photo-1522770179533-24471fcdba45',
title: 'Camera'
},
{
img: 'https://images.unsplash.com/photo-1444418776041-9c7e33cc5a9c',
title: 'Coffee'
},
{
img: 'https://images.unsplash.com/photo-1533827432537-70133748f5c8',
title: 'Hats'
},
{
img: 'https://images.unsplash.com/photo-1558642452-9d2a7deb7f62',
title: 'Honey'
},
{
img: 'https://images.unsplash.com/photo-1516802273409-68526ee1bdd6',
title: 'Basketball'
},
{
img: 'https://images.unsplash.com/photo-1518756131217-31eb79b20e8f',
title: 'Fern'
},
{
img: 'https://images.unsplash.com/photo-1597645587822-e99fa5d45d25',
title: 'Mushrooms'
},
{
img: 'https://images.unsplash.com/photo-1567306301408-9b74779a11af',
title: 'Tomato basil'
},
{
img: 'https://images.unsplash.com/photo-1471357674240-e1a485acb3e1',
title: 'Sea star'
},
{
img: 'https://images.unsplash.com/photo-1589118949245-7d38baf380d6',
title: 'Bike'
}
]
const itemData2 = [
{
img: 'https://images.unsplash.com/photo-1549388604-817d15aa0110',
title: 'Bed'
},
{
img: 'https://images.unsplash.com/photo-1563298723-dcfebaa392e3',
title: 'Kitchen'
},
{
img: 'https://images.unsplash.com/photo-1523413651479-597eb2da0ad6',
title: 'Sink'
},
{
img: 'https://images.unsplash.com/photo-1525097487452-6278ff080c31',
title: 'Books'
},
{
img: 'https://images.unsplash.com/photo-1574180045827-681f8a1a9622',
title: 'Chairs'
},
{
img: 'https://images.unsplash.com/photo-1597262975002-c5c3b14bbd62',
title: 'Candle'
},
{
img: 'https://images.unsplash.com/photo-1530731141654-5993c3016c77',
title: 'Laptop'
},
{
img: 'https://images.unsplash.com/photo-1481277542470-605612bd2d61',
title: 'Doors'
},
{
img: 'https://images.unsplash.com/photo-1517487881594-2787fef5ebf7',
title: 'Coffee'
},
{
img: 'https://images.unsplash.com/photo-1516455207990-7a41ce80f7ee',
title: 'Storage'
},
{
img: 'https://images.unsplash.com/photo-1519710164239-da123dc03ef4',
title: 'Coffee table'
},
{
img: 'https://images.unsplash.com/photo-1588436706487-9d55d73a39e3',
title: 'Blinds'
}
]
const itemData3 = [
{
img: 'https://images.unsplash.com/photo-1549388604-817d15aa0110',
title: 'Bed'
},
{
img: 'https://images.unsplash.com/photo-1525097487452-6278ff080c31',
title: 'Books'
},
{
img: 'https://images.unsplash.com/photo-1523413651479-597eb2da0ad6',
title: 'Sink'
},
{
img: 'https://images.unsplash.com/photo-1563298723-dcfebaa392e3',
title: 'Kitchen'
},
{
img: 'https://images.unsplash.com/photo-1588436706487-9d55d73a39e3',
title: 'Blinds'
},
{
img: 'https://images.unsplash.com/photo-1574180045827-681f8a1a9622',
title: 'Chairs'
},
{
img: 'https://images.unsplash.com/photo-1530731141654-5993c3016c77',
title: 'Laptop'
},
{
img: 'https://images.unsplash.com/photo-1481277542470-605612bd2d61',
title: 'Doors'
},
{
img: 'https://images.unsplash.com/photo-1517487881594-2787fef5ebf7',
title: 'Coffee'
},
{
img: 'https://images.unsplash.com/photo-1516455207990-7a41ce80f7ee',
title: 'Storage'
},
{
img: 'https://images.unsplash.com/photo-1597262975002-c5c3b14bbd62',
title: 'Candle'
},
{
img: 'https://images.unsplash.com/photo-1519710164239-da123dc03ef4',
title: 'Coffee table'
}
]
================================================
FILE: react-mui-demo/src/components/MuiLayout.tsx
================================================
import { Box, Stack, Grid, Paper } from '@mui/material'
export const MuiLayout = () => {
return (
Codevolution
Item 1
Item 2
Item 3
Item 4
)
}
================================================
FILE: react-mui-demo/src/components/MuiLink.tsx
================================================
import { Stack, Link, Typography } from '@mui/material'
export const MuiLink = () => {
return (
Link
Secondary
Body 2 link
)
}
================================================
FILE: react-mui-demo/src/components/MuiList.tsx
================================================
import {
Box,
List,
ListItem,
ListItemText,
ListItemButton,
ListItemIcon,
Divider,
ListItemAvatar,
Avatar
} from '@mui/material'
import InboxIcon from '@mui/icons-material/Inbox'
export const MuiList = () => {
return (
)
}
================================================
FILE: react-mui-demo/src/components/MuiLoadingButton.tsx
================================================
import { Stack } from '@mui/material'
import { LoadingButton } from '@mui/lab'
import SaveIcon from '@mui/icons-material/Save'
export const MuiLoadingButton = () => {
return (
Submit
Submit
Fetch data
Fetch data
}
variant='outlined'>
Save
}
variant='outlined'>
Save
)
}
================================================
FILE: react-mui-demo/src/components/MuiMasonry.tsx
================================================
import { Masonry } from '@mui/lab'
import {
Box,
Paper,
Accordion,
AccordionSummary,
AccordionDetails,
Typography
} from '@mui/material'
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
const heights = [
150, 30, 90, 70, 110, 150, 130, 80, 50, 90, 100, 150, 30, 50, 80
]
export const MuiMasonry = () => {
return (
{heights.map((height, index) => (
}>
Accordion {index + 1}
Contents
))}
)
}
================================================
FILE: react-mui-demo/src/components/MuiNavbar.tsx
================================================
import {
AppBar,
Toolbar,
IconButton,
Typography,
Button,
Stack,
Menu,
MenuItem
} from '@mui/material'
import CatchingPokemonIcon from '@mui/icons-material/CatchingPokemon'
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'
import { useState } from 'react'
export const MuiNavbar = () => {
const [anchorEl, setAnchorEl] = useState(null)
const open = Boolean(anchorEl)
const handleClick = (event: React.MouseEvent) => {
setAnchorEl(event.currentTarget)
}
const handleClose = () => {
setAnchorEl(null)
}
return (
POKEMONAPP
Features
Pricing
About
}
onClick={handleClick}>
Resources
Login
)
}
================================================
FILE: react-mui-demo/src/components/MuiProgress.tsx
================================================
import { Stack, CircularProgress, LinearProgress } from '@mui/material'
export const MuiProgress = () => {
return (
)
}
================================================
FILE: react-mui-demo/src/components/MuiRadioButton.tsx
================================================
import { useState } from 'react'
import {
Box,
FormControl,
FormLabel,
FormControlLabel,
RadioGroup,
Radio
} from '@mui/material'
export const MuiRadioButton = () => {
const [value, setValue] = useState('')
console.log(value)
const handleChange = (event: React.ChangeEvent) => {
setValue(event.target.value)
}
return (
Years of experience
}
label='0-2 years'
/>
}
label='3-5 years'
/>
}
label='6-10 years'
/>
)
}
================================================
FILE: react-mui-demo/src/components/MuiRating.tsx
================================================
import { Stack, Rating } from '@mui/material'
import { useState } from 'react'
import FavoriteIcon from '@mui/icons-material/Favorite'
import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder'
export const MuiRating = () => {
const [value, setValue] = useState(3)
console.log(value)
const handleChange = (
_event: React.ChangeEvent<{}>,
newValue: number | null
) => {
setValue(newValue)
}
return (
}
emptyIcon={ }
readOnly
/>
)
}
================================================
FILE: react-mui-demo/src/components/MuiSelect.tsx
================================================
import { useState } from 'react'
import { Box, TextField, MenuItem } from '@mui/material'
export const MuiSelect = () => {
const [countries, setCountries] = useState([])
console.log(countries)
const handleChange = (event: React.ChangeEvent) => {
const value = event.target.value
setCountries(typeof value === 'string' ? value.split(',') : value)
}
return (
India
USA
Australia
)
}
================================================
FILE: react-mui-demo/src/components/MuiSkeleton.tsx
================================================
import { Avatar, Box, Skeleton, Stack, Typography } from '@mui/material'
import { useState, useEffect } from 'react'
export const MuiSkeleton = () => {
const [loading, setLoading] = useState(true)
useEffect(() => {
setTimeout(() => {
setLoading(false)
}, 3000)
}, [])
return (
{loading ? (
) : (
)}
{loading ? (
) : (
V
)}
{loading ? (
<>
>
) : (
<>
React MUI Tutorial
>
)}
)
}
================================================
FILE: react-mui-demo/src/components/MuiSnackbar.tsx
================================================
import { Snackbar, Button, Alert, AlertProps } from '@mui/material'
import { useState, forwardRef } from 'react'
const SnackbarAlert = forwardRef(
function SnackbarAlert(props, ref) {
return
}
)
export const MuiSnackbar = () => {
const [open, setOpen] = useState(false)
const handleClose = (
event?: React.SyntheticEvent | Event,
reason?: string
) => {
if (reason === 'clickaway') {
return
}
setOpen(false)
}
return (
<>
setOpen(true)}>Submit
Form submitted successfully!
>
)
}
================================================
FILE: react-mui-demo/src/components/MuiSpeedDial.tsx
================================================
import { SpeedDial, SpeedDialAction, SpeedDialIcon } from '@mui/material'
import CopyIcon from '@mui/icons-material/FileCopyOutlined'
import PrintIcon from '@mui/icons-material/Print'
import ShareIcon from '@mui/icons-material/Share'
import EditIcon from '@mui/icons-material/Edit'
export const MuiSpeedDial = () => {
return (
} />}>
} tooltipTitle='Copy' tooltipOpen />
} tooltipTitle='Print' tooltipOpen />
} tooltipTitle='Share' tooltipOpen />
)
}
================================================
FILE: react-mui-demo/src/components/MuiSwitch.tsx
================================================
import { Box, FormControlLabel, Switch } from '@mui/material'
import { useState } from 'react'
export const MuiSwitch = () => {
const [checked, setChecked] = useState(false)
console.log(checked)
const handleChange = (event: React.ChangeEvent) => {
setChecked(event.target.checked)
}
return (
}
label='Dark mode'
/>
)
}
================================================
FILE: react-mui-demo/src/components/MuiTable.tsx
================================================
import {
TableContainer,
Table,
TableHead,
TableBody,
TableRow,
TableCell,
Paper
} from '@mui/material'
export const MuiTable = () => {
return (
Id
First Name
Last Name
Email
{tableData.map(row => (
{row.id}
{row.first_name}
{row.last_name}
{row.email}
))}
)
}
const tableData = [
{
id: 1,
first_name: 'Beret',
last_name: 'Lennard',
email: 'blennard0@pcworld.com',
gender: 'Female',
ip_address: '213.196.192.52'
},
{
id: 2,
first_name: 'Tera',
last_name: 'Choke',
email: 'tchoke1@theatlantic.com',
gender: 'Male',
ip_address: '101.152.241.70'
},
{
id: 3,
first_name: 'Lyn',
last_name: 'Bowart',
email: 'lbowart2@odnoklassniki.ru',
gender: 'Male',
ip_address: '188.127.126.94'
},
{
id: 4,
first_name: 'Bert',
last_name: 'Huckett',
email: 'bhuckett3@tinypic.com',
gender: 'Female',
ip_address: '247.156.243.148'
},
{
id: 5,
first_name: 'Drew',
last_name: 'Jenicke',
email: 'djenicke4@businessinsider.com',
gender: 'Male',
ip_address: '0.185.35.172'
},
{
id: 6,
first_name: 'Deloria',
last_name: 'Pepperill',
email: 'dpepperill5@meetup.com',
gender: 'Non-binary',
ip_address: '101.44.39.120'
},
{
id: 7,
first_name: 'Spense',
last_name: 'Ivashnyov',
email: 'sivashnyov6@hexun.com',
gender: 'Female',
ip_address: '253.192.252.49'
},
{
id: 8,
first_name: 'Elden',
last_name: 'Chaucer',
email: 'echaucer7@mozilla.com',
gender: 'Agender',
ip_address: '60.70.120.186'
},
{
id: 9,
first_name: 'Sholom',
last_name: 'Deetch',
email: 'sdeetch8@so-net.ne.jp',
gender: 'Female',
ip_address: '218.36.95.147'
},
{
id: 10,
first_name: 'Genovera',
last_name: 'Colby',
email: 'gcolby9@dagondesign.com',
gender: 'Non-binary',
ip_address: '199.140.221.248'
}
]
================================================
FILE: react-mui-demo/src/components/MuiTabs.tsx
================================================
import { Box, Tab } from '@mui/material'
import { TabContext, TabList, TabPanel } from '@mui/lab'
import { useState } from 'react'
import FavoriteIcon from '@mui/icons-material/Favorite'
export const MuiTabs = () => {
const [value, setValue] = useState('1')
const handleChange = (event: React.SyntheticEvent, newValue: string) => {
setValue(newValue)
}
return (
}
iconPosition='start'
label='Tab One'
value='1'
/>
Item One
Item Two
Item Three
Item Four
Item Five
Item Six
)
}
================================================
FILE: react-mui-demo/src/components/MuiTextField.tsx
================================================
import { useState } from 'react'
import { Stack, TextField, InputAdornment } from '@mui/material'
export const MuiTextField = () => {
const [value, setValue] = useState('')
const handleChange = (event: React.ChangeEvent) => {
setValue(event.target.value)
}
return (
$
}}
/>
kg
}}
/>
)
}
================================================
FILE: react-mui-demo/src/components/MuiTimeline.tsx
================================================
import {
Timeline,
TimelineItem,
TimelineSeparator,
TimelineConnector,
TimelineContent,
TimelineDot,
TimelineOppositeContent
} from '@mui/lab'
export const MuiTimeline = () => {
return (
09:30 am
Eat
10:30 am
Code
10:30 am
Sleep
09:00 am
Repeat
)
}
================================================
FILE: react-mui-demo/src/components/MuiTooltip.tsx
================================================
import { Tooltip, IconButton } from '@mui/material'
import DeleteIcon from '@mui/icons-material/Delete'
export const MuiTooltip = () => {
return (
)
}
================================================
FILE: react-mui-demo/src/components/MuiTypography.tsx
================================================
import { Typography } from '@mui/material'
export const MuiTypography = () => {
return (
h1 Heading
h2 Heading
h3 Heading
h4 Heading
h5 Heading
h6 Heading
subtitle1
subtitle2
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nam saepe
magnam illo quas illum minus, aperiam, iusto optio quisquam veniam
obcaecati quasi libero aspernatur alias quia modi minima excepturi ad.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum, harum
quam deserunt optio atque illo iste! Qui ullam ut nisi. Porro adipisci
eius nesciunt excepturi id! Eius nemo asperiores natus?
)
}
================================================
FILE: react-mui-demo/src/index.css
================================================
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
================================================
FILE: react-mui-demo/src/index.tsx
================================================
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
ReactDOM.render(
,
document.getElementById('root')
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
================================================
FILE: react-mui-demo/src/react-app-env.d.ts
================================================
///
================================================
FILE: react-mui-demo/src/reportWebVitals.ts
================================================
import { ReportHandler } from 'web-vitals';
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;
================================================
FILE: react-mui-demo/src/setupTests.ts
================================================
// 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';
================================================
FILE: react-mui-demo/src/theme.d.ts
================================================
import { Theme, ThemeOptions } from '@mui/material/styles'
declare module '@mui/material/styles' {
interface Theme {
status: {
danger: string
}
}
interface ThemeOptions {
status: {
danger: React.CSSProperties['color']
}
}
interface Palette {
neutral?: PaletteColor
}
interface PaletteOptions {
neutral?: PaletteColorOptions
}
interface PaletteColor {
darker?: string
}
interface SimplePaletteColorOptions {
darker?: string
}
}
================================================
FILE: react-mui-demo/tsconfig.json
================================================
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}