Skip to content

Commit 9ef31cc

Browse files
committed
First commit
0 parents  commit 9ef31cc

24 files changed

+12882
-0
lines changed

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Base project for the Todo state manager series

package.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "todo-base",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@chakra-ui/react": "^1.0.0",
7+
"@emotion/react": "^11.0.0",
8+
"@emotion/styled": "^11.0.0",
9+
"@testing-library/jest-dom": "^5.9.0",
10+
"@testing-library/react": "^10.2.1",
11+
"@testing-library/user-event": "^12.0.2",
12+
"@types/jest": "^25.0.0",
13+
"@types/node": "^12.0.0",
14+
"@types/react": "^16.9.0",
15+
"@types/react-dom": "^16.9.0",
16+
"framer-motion": ">=3.0.0",
17+
"react": "^17.0.1",
18+
"react-dom": "^17.0.1",
19+
"react-icons": "^3.0.0",
20+
"react-scripts": "4.0.2",
21+
"typescript": "^3.9.5",
22+
"web-vitals": "^0.2.2"
23+
},
24+
"scripts": {
25+
"start": "react-scripts start",
26+
"build": "react-scripts build",
27+
"test": "react-scripts test",
28+
"eject": "react-scripts eject"
29+
},
30+
"eslintConfig": {
31+
"extends": "react-app"
32+
},
33+
"browserslist": {
34+
"production": [
35+
">0.2%",
36+
"not dead",
37+
"not op_mini all"
38+
],
39+
"development": [
40+
"last 1 chrome version",
41+
"last 1 firefox version",
42+
"last 1 safari version"
43+
]
44+
}
45+
}

public/favicon.ico

3.78 KB
Binary file not shown.

public/index.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
<meta
9+
name="description"
10+
content="Web site created using create-react-app"
11+
/>
12+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13+
<!--
14+
manifest.json provides metadata used when your web app is installed on a
15+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16+
-->
17+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18+
<!--
19+
Notice the use of %PUBLIC_URL% in the tags above.
20+
It will be replaced with the URL of the `public` folder during the build.
21+
Only files inside the `public` folder can be referenced from the HTML.
22+
23+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24+
work correctly both with client-side routing and a non-root public URL.
25+
Learn how to configure a non-root public URL by running `npm run build`.
26+
-->
27+
<title>Base Todo List</title>
28+
</head>
29+
<body>
30+
<noscript>You need to enable JavaScript to run this app.</noscript>
31+
<div id="root"></div>
32+
<!--
33+
This HTML file is a template.
34+
If you open it directly in the browser, you will see an empty page.
35+
36+
You can add webfonts, meta tags, or analytics to this file.
37+
The build step will place the bundled scripts into the <body> tag.
38+
39+
To begin the development, run `npm start` or `yarn start`.
40+
To create a production bundle, use `npm run build` or `yarn build`.
41+
-->
42+
</body>
43+
</html>

public/logo192.png

5.22 KB
Loading

public/logo512.png

9.44 KB
Loading

public/manifest.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
},
10+
{
11+
"src": "logo192.png",
12+
"type": "image/png",
13+
"sizes": "192x192"
14+
},
15+
{
16+
"src": "logo512.png",
17+
"type": "image/png",
18+
"sizes": "512x512"
19+
}
20+
],
21+
"start_url": ".",
22+
"display": "standalone",
23+
"theme_color": "#000000",
24+
"background_color": "#ffffff"
25+
}

public/robots.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://www.robotstxt.org/robotstxt.html
2+
User-agent: *
3+
Disallow:

src/App.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from "react"
2+
import { screen } from "@testing-library/react"
3+
import { render } from "./test-utils"
4+
import { App } from "./App"
5+
6+
test("renders learn react link", () => {
7+
render(<App />)
8+
const linkElement = screen.getByText(/learn chakra/i)
9+
expect(linkElement).toBeInTheDocument()
10+
})

src/App.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as React from "react";
2+
import { ChakraProvider, Box, theme } from "@chakra-ui/react";
3+
import TopBar from "./components/TopBar";
4+
import TodoList from "./components/TodoList";
5+
import TodoAdd from "./components/TodoAdd";
6+
7+
export function App() {
8+
return (
9+
<ChakraProvider theme={theme}>
10+
<Box maxWidth="8xl" margin="auto" p={5}>
11+
<TopBar />
12+
<TodoList />
13+
<TodoAdd />
14+
</Box>
15+
</ChakraProvider>
16+
);
17+
}

src/components/ColorModeSwitcher.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as React from "react"
2+
import {
3+
useColorMode,
4+
useColorModeValue,
5+
IconButton,
6+
IconButtonProps,
7+
} from "@chakra-ui/react"
8+
import { FaMoon, FaSun } from "react-icons/fa"
9+
10+
type ColorModeSwitcherProps = Omit<IconButtonProps, "aria-label">
11+
12+
export const ColorModeSwitcher: React.FC<ColorModeSwitcherProps> = (props) => {
13+
const { toggleColorMode } = useColorMode()
14+
const text = useColorModeValue("dark", "light")
15+
const SwitchIcon = useColorModeValue(FaMoon, FaSun)
16+
17+
return (
18+
<IconButton
19+
size="md"
20+
fontSize="lg"
21+
variant="ghost"
22+
color="current"
23+
marginLeft="2"
24+
onClick={toggleColorMode}
25+
icon={<SwitchIcon />}
26+
aria-label={`Switch to ${text} mode`}
27+
{...props}
28+
/>
29+
)
30+
}

src/components/TodoAdd.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as React from "react";
2+
import { Button, Input, Grid } from "@chakra-ui/react";
3+
4+
function TodoAdd() {
5+
return (
6+
<Grid pt={2} templateColumns="5fr 1fr" columnGap="3">
7+
<Input placeholder="New todo" />
8+
<Button>Add Todo</Button>
9+
</Grid>
10+
);
11+
}
12+
13+
export default TodoAdd;

src/components/TodoList.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as React from "react";
2+
import { Button, Input, Flex, Checkbox, Heading } from "@chakra-ui/react";
3+
4+
function TodoListItems() {
5+
return (
6+
<>
7+
{[].map((todo: { id: number; text: string }) => (
8+
<Flex pt={2} key={todo.id}>
9+
<Checkbox />
10+
<Input mx={2} value={todo.text} />
11+
<Button>Delete</Button>
12+
</Flex>
13+
))}
14+
</>
15+
);
16+
}
17+
18+
function TodoList() {
19+
return (
20+
<>
21+
<Heading>Todo List</Heading>
22+
<TodoListItems />
23+
</>
24+
);
25+
}
26+
27+
export default TodoList;

src/components/TopBar.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as React from "react";
2+
import { Button, Grid } from "@chakra-ui/react";
3+
import { ColorModeSwitcher } from "./ColorModeSwitcher";
4+
5+
/*
6+
JSON source: https://raw.githubusercontent.com/jherr/todos-four-ways/master/data/todos.json
7+
*/
8+
9+
function TopBar() {
10+
return (
11+
<Grid pt={2} templateColumns="1fr 1fr" columnGap="3">
12+
<ColorModeSwitcher />
13+
<Button>Load</Button>
14+
</Grid>
15+
);
16+
}
17+
18+
export default TopBar;

src/index.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ColorModeScript } from "@chakra-ui/react"
2+
import * as React from "react"
3+
import ReactDOM from "react-dom"
4+
import { App } from "./App"
5+
import reportWebVitals from "./reportWebVitals"
6+
import * as serviceWorker from "./serviceWorker"
7+
8+
ReactDOM.render(
9+
<React.StrictMode>
10+
<ColorModeScript />
11+
<App />
12+
</React.StrictMode>,
13+
document.getElementById("root"),
14+
)
15+
16+
// If you want your app to work offline and load faster, you can change
17+
// unregister() to register() below. Note this comes with some pitfalls.
18+
// Learn more about service workers: https://cra.link/PWA
19+
serviceWorker.unregister()
20+
21+
// If you want to start measuring performance in your app, pass a function
22+
// to log results (for example: reportWebVitals(console.log))
23+
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
24+
reportWebVitals()

src/react-app-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="react-scripts" />

src/reportWebVitals.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ReportHandler } from "web-vitals"
2+
3+
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
4+
if (onPerfEntry && onPerfEntry instanceof Function) {
5+
import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
6+
getCLS(onPerfEntry)
7+
getFID(onPerfEntry)
8+
getFCP(onPerfEntry)
9+
getLCP(onPerfEntry)
10+
getTTFB(onPerfEntry)
11+
})
12+
}
13+
}
14+
15+
export default reportWebVitals

0 commit comments

Comments
 (0)