This commit is contained in:
Tyrel Souza 2022-09-21 16:21:26 -04:00
parent 652dd89fac
commit 3a29298624
No known key found for this signature in database
GPG Key ID: F6582CF1308A2360
21 changed files with 38778 additions and 0 deletions

View File

@ -0,0 +1 @@
[{"/Users/tyrel.souza/code/udemy/react-course/style-chapter/src/index.js":"1","/Users/tyrel.souza/code/udemy/react-course/style-chapter/src/App.js":"2","/Users/tyrel.souza/code/udemy/react-course/style-chapter/src/components/CourseGoals/CourseGoalList/CourseGoalList.js":"3","/Users/tyrel.souza/code/udemy/react-course/style-chapter/src/components/CourseGoals/CourseInput/CourseInput.js":"4","/Users/tyrel.souza/code/udemy/react-course/style-chapter/src/components/CourseGoals/CourseGoalItem/CourseGoalItem.js":"5","/Users/tyrel.souza/code/udemy/react-course/style-chapter/src/components/UI/Button/Button.js":"6"},{"size":206,"mtime":1648532578000,"results":"7","hashOfConfig":"8"},{"size":1533,"mtime":1616593574000,"results":"9","hashOfConfig":"8"},{"size":461,"mtime":1616593574000,"results":"10","hashOfConfig":"8"},{"size":983,"mtime":1663790519427,"results":"11","hashOfConfig":"8"},{"size":393,"mtime":1616593574000,"results":"12","hashOfConfig":"8"},{"size":259,"mtime":1663790037167,"results":"13","hashOfConfig":"8"},{"filePath":"14","messages":"15","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},"1u2q7ae",{"filePath":"17","messages":"18","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"19","messages":"20","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"21","messages":"22","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"23","messages":"24","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"25","messages":"26","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/tyrel.souza/code/udemy/react-course/style-chapter/src/index.js",[],["27","28"],"/Users/tyrel.souza/code/udemy/react-course/style-chapter/src/App.js",[],"/Users/tyrel.souza/code/udemy/react-course/style-chapter/src/components/CourseGoals/CourseGoalList/CourseGoalList.js",[],"/Users/tyrel.souza/code/udemy/react-course/style-chapter/src/components/CourseGoals/CourseInput/CourseInput.js",[],"/Users/tyrel.souza/code/udemy/react-course/style-chapter/src/components/CourseGoals/CourseGoalItem/CourseGoalItem.js",[],"/Users/tyrel.souza/code/udemy/react-course/style-chapter/src/components/UI/Button/Button.js",[],{"ruleId":"29","replacedBy":"30"},{"ruleId":"31","replacedBy":"32"},"no-native-reassign",["33"],"no-negated-in-lhs",["34"],"no-global-assign","no-unsafe-negation"]

38413
style-chapter/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
{
"name": "react-complete-guide",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^12.5.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-scripts": "4.0.1",
"styled-components": "^5.3.5",
"web-vitals": "^0.2.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"
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -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>
<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 not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -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"
}

View File

@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

14
style-chapter/src/App.css Normal file
View File

@ -0,0 +1,14 @@
#goals {
width: 35rem;
max-width: 90%;
margin: 3rem auto;
}
#goal-form {
width: 30rem;
max-width: 90%;
margin: 3rem auto;
padding: 2rem;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
border-radius: 10px;
}

57
style-chapter/src/App.js Normal file
View File

@ -0,0 +1,57 @@
import React, { useState } from 'react';
import CourseGoalList from './components/CourseGoals/CourseGoalList/CourseGoalList';
import CourseInput from './components/CourseGoals/CourseInput/CourseInput';
import './App.css';
const App = () => {
const [courseGoals, setCourseGoals] = useState([
{ text: 'Do all exercises!', id: 'g1' },
{ text: 'Finish the course!', id: 'g2' }
]);
const addGoalHandler = enteredText => {
setCourseGoals(prevGoals => {
const updatedGoals = [...prevGoals];
updatedGoals.unshift({ text: enteredText, id: Math.random().toString() });
return updatedGoals;
});
};
const deleteItemHandler = goalId => {
setCourseGoals(prevGoals => {
const updatedGoals = prevGoals.filter(goal => goal.id !== goalId);
return updatedGoals;
});
};
let content = (
<p style={{ textAlign: 'center' }}>No goals found. Maybe add one?</p>
);
if (courseGoals.length > 0) {
content = (
<CourseGoalList items={courseGoals} onDeleteItem={deleteItemHandler} />
);
}
return (
<div>
<section id="goal-form">
<CourseInput onAddGoal={addGoalHandler} />
</section>
<section id="goals">
{content}
{/* {courseGoals.length > 0 && (
<CourseGoalList
items={courseGoals}
onDeleteItem={deleteItemHandler}
/>
) // <p style={{ textAlign: 'center' }}>No goals found. Maybe add one?</p>
} */}
</section>
</div>
);
};
export default App;

View File

@ -0,0 +1,8 @@
.goal-item {
margin: 1rem 0;
background: #8b005d;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
color: white;
padding: 1rem 2rem;
cursor: pointer;
}

View File

@ -0,0 +1,20 @@
import React from 'react';
import './CourseGoalItem.css';
const CourseGoalItem = props => {
// const [deleteText, setDeleteText] = useState('');
const deleteHandler = () => {
// setDeleteText('(Deleted!)');
props.onDelete(props.id);
};
return (
<li className="goal-item" onClick={deleteHandler}>
{props.children}
</li>
);
};
export default CourseGoalItem;

View File

@ -0,0 +1,5 @@
.goal-list {
list-style: none;
margin: 0;
padding: 0;
}

View File

@ -0,0 +1,22 @@
import React from 'react';
import CourseGoalItem from '../CourseGoalItem/CourseGoalItem';
import './CourseGoalList.css';
const CourseGoalList = props => {
return (
<ul className="goal-list">
{props.items.map(goal => (
<CourseGoalItem
key={goal.id}
id={goal.id}
onDelete={props.onDeleteItem}
>
{goal.text}
</CourseGoalItem>
))}
</ul>
);
};
export default CourseGoalList;

View File

@ -0,0 +1,37 @@
import React, { useState } from "react";
import Button from "../../UI/Button/Button";
import styles from "./CourseInput.module.css";
const CourseInput = (props) => {
const [enteredValue, setEnteredValue] = useState("");
const [isValid, setIsValid] = useState(true);
const goalInputChangeHandler = (event) => {
if (event.target.value.trim().length > 0) {
setIsValid(true);
}
setEnteredValue(event.target.value);
};
const formSubmitHandler = (event) => {
event.preventDefault();
if (enteredValue.trim().length === 0) {
setIsValid(false);
return;
}
props.onAddGoal(enteredValue);
};
return (
<form onSubmit={formSubmitHandler}>
<div className={`${styles["form-control"]} ${!isValid && styles.invalid}`}>
<label>Course Goal</label>
<input type="text" onChange={goalInputChangeHandler} />
</div>
<Button type="submit">Add Goal</Button>
</form>
);
};
export default CourseInput;

View File

@ -0,0 +1,33 @@
.form-control {
margin: 0.5rem 0;
}
.form-control label {
font-weight: bold;
display: block;
margin-bottom: 0.5rem;
}
.form-control input {
display: block;
width: 100%;
border: 1px solid #ccc;
font: inherit;
line-height: 1.5rem;
padding: 0 0.25rem;
}
.form-control input:focus {
outline: none;
background: #fad0ec;
border-color: #8b005d;
}
.form-control.invalid input {
border-color: red;
background: salmon;
}
.form-control.invalid label {
color: red;
}

View File

@ -0,0 +1,12 @@
import React from "react";
import styles from "./Button.module.css";
const Button = (props) => {
return (
<button type={props.type} className={styles.button} onClick={props.onClick}>
{props.children}
</button>
);
};
export default Button;

View File

@ -0,0 +1,27 @@
.button {
width: 100%;
font: inherit;
padding: 0.5rem 1.5rem;
border: 1px solid #8b005d;
color: white;
background: #8b005d;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.26);
cursor: pointer;
}
.button:focus {
outline: none;
}
.button:hover,
.button:active {
background: #ac0e77;
border-color: #ac0e77;
box-shadow: 0 0 8px rgba(0, 0, 0, 0.26);
}
@media (min-width: 768px) {
.button {
width: auto;
}
}

View File

@ -0,0 +1,11 @@
* {
box-sizing: border-box;
}
html {
font-family: sans-serif;
}
body {
margin: 0;
}

View File

@ -0,0 +1,8 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);