-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:basic layout component and react PWA setup
- Loading branch information
1 parent
857ad15
commit eb43512
Showing
32 changed files
with
11,531 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"arrowParens": "avoid", | ||
"trailingComma": "es5", | ||
"singleQuote": true, | ||
"semi": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "my-app", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"@chakra-ui/icons": "^2.0.17", | ||
"@chakra-ui/react": "^2.4.9", | ||
"@emotion/react": "^11.0.0", | ||
"@emotion/styled": "^11.0.0", | ||
"@testing-library/jest-dom": "^5.16.4", | ||
"@testing-library/react": "^13.0.1", | ||
"@testing-library/user-event": "^14.1.0", | ||
"framer-motion": "^6.2.9", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-icons": "^3.0.0", | ||
"react-mic": "^12.4.6", | ||
"react-router-dom": "^6.7.0", | ||
"react-scripts": "5.0.1", | ||
"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" | ||
}, | ||
"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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!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 style="background-color: rgb(248, 248, 249)"> | ||
<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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# https://www.robotstxt.org/robotstxt.html | ||
User-agent: * | ||
Disallow: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import { BrowserRouter, Routes, Route } from 'react-router-dom'; | ||
import About from './pages/About'; | ||
import Contact from './pages/Contact'; | ||
import Home from './pages/Home'; | ||
import NotFound from './pages/NotFound'; | ||
|
||
function App() { | ||
return ( | ||
<BrowserRouter> | ||
<Routes> | ||
<Route path="/" element={<Home />} /> | ||
<Route path="/about" element={<About />} /> | ||
<Route path="/contact" element={<Contact />} /> | ||
<Route path="*" element={<NotFound />} /> | ||
</Routes> | ||
</BrowserRouter> | ||
); | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import { screen } from '@testing-library/react'; | ||
import { render } from './test-utils'; | ||
import App from './App'; | ||
|
||
test('renders learn react link', () => { | ||
render(<App />); | ||
const linkElement = screen.getByText(/learn chakra/i); | ||
expect(linkElement).toBeInTheDocument(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import { useColorMode, useColorModeValue, IconButton } from '@chakra-ui/react'; | ||
import { FaMoon, FaSun } from 'react-icons/fa'; | ||
|
||
export const ColorModeSwitcher = props => { | ||
const { toggleColorMode } = useColorMode(); | ||
const text = useColorModeValue('dark', 'light'); | ||
const SwitchIcon = useColorModeValue(FaMoon, FaSun); | ||
|
||
return ( | ||
<IconButton | ||
size="md" | ||
fontSize="lg" | ||
aria-label={`Switch to ${text} mode`} | ||
variant="ghost" | ||
color="current" | ||
marginLeft="2" | ||
onClick={toggleColorMode} | ||
icon={<SwitchIcon />} | ||
{...props} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import { Image, keyframes, usePrefersReducedMotion } from '@chakra-ui/react'; | ||
import logo from './logo.svg'; | ||
|
||
const spin = keyframes` | ||
from { transform: rotate(0deg); } | ||
to { transform: rotate(360deg); } | ||
`; | ||
|
||
export const Logo = props => { | ||
const prefersReducedMotion = usePrefersReducedMotion(); | ||
|
||
const animation = prefersReducedMotion | ||
? undefined | ||
: `${spin} infinite 20s linear`; | ||
|
||
return <Image animation={animation} src={logo} {...props} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Flex, Heading, Stack, useColorModeValue } from '@chakra-ui/react'; | ||
import React from 'react'; | ||
|
||
export default function CenterCard({ title, _box, _card, children }) { | ||
return ( | ||
<Flex | ||
minH={'90vh'} | ||
align={'center'} | ||
justify={'center'} | ||
bg={useColorModeValue('gray.50', 'gray.800')} | ||
{..._box} | ||
> | ||
<Stack | ||
spacing={4} | ||
w={'full'} | ||
maxW={'md'} | ||
bg={useColorModeValue('white', 'gray.700')} | ||
rounded={'xl'} | ||
boxShadow={'lg'} | ||
p={6} | ||
my={12} | ||
{..._card} | ||
> | ||
{title ? ( | ||
<Heading lineHeight={1.1} fontSize={{ base: '1xl', sm: '2xl' }}> | ||
{title} | ||
</Heading> | ||
) : ( | ||
<React.Fragment /> | ||
)} | ||
{children} | ||
</Stack> | ||
</Flex> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Card, CardBody, HStack, Text, VStack } from '@chakra-ui/react'; | ||
import React from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export default function Menus({ menus, _vstack, _body, _card }) { | ||
const navigate = useNavigate(); | ||
return ( | ||
<VStack spacing={4} {..._vstack}> | ||
{menus.map((item, key) => ( | ||
<Card | ||
key={key} | ||
width={'100%'} | ||
cursor="pointer" | ||
onClick={e => | ||
item?.link ? navigate(item?.link) : console.log('not link') | ||
} | ||
{..._card} | ||
> | ||
<CardBody {..._body}> | ||
<HStack justifyContent={'space-between'}> | ||
<Text>{item?.title}</Text> | ||
{item?.icon} | ||
</HStack> | ||
</CardBody> | ||
</Card> | ||
))} | ||
</VStack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { | ||
Button, | ||
HStack, | ||
IconButton, | ||
useColorModeValue, | ||
VStack, | ||
} from '@chakra-ui/react'; | ||
import React from 'react'; | ||
import { FaMicrophone, FaMicrophoneSlash } from 'react-icons/fa'; | ||
import { ReactMic } from 'react-mic'; | ||
|
||
export default function Mic({ onStop }) { | ||
const [record, setRecord] = React.useState(false); | ||
|
||
const onData = recordedBlob => { | ||
// console.log('chunk of real-time data is: ', recordedBlob); | ||
}; | ||
|
||
const onPlayStop = recordedBlob => { | ||
// console.log('recordedBlob is: ', recordedBlob); | ||
onStop(recordedBlob); | ||
}; | ||
|
||
return ( | ||
<VStack spacing={4} overflow="hidden"> | ||
<ReactMic | ||
record={record} | ||
onStop={onPlayStop} | ||
onData={onData} | ||
strokeColor="#fff" | ||
backgroundColor="#FF4081" | ||
mimeType="audio/webm" | ||
/> | ||
<HStack justifyContent="center"> | ||
<IconButton | ||
size="md" | ||
fontSize="lg" | ||
variant="ghost" | ||
color="current" | ||
marginLeft="2" | ||
onClick={e => setRecord(!record)} | ||
icon={record ? <FaMicrophone /> : <FaMicrophoneSlash />} | ||
/> | ||
</HStack> | ||
</VStack> | ||
); | ||
} |
Oops, something went wrong.