Various optimizations, mainly removing unused code and adding comments.

This commit is contained in:
Ray 2024-01-04 17:29:04 +11:00
parent 96a980bc07
commit be2649cd9c
5 changed files with 8 additions and 82 deletions

View File

@ -1,70 +1,3 @@
# Getting Started with Create React App # TomHodges.github.io
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). This is a webstie which simply displays a countdown timer to my retirement.
## 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 your browser.
The page will reload when you make changes.\
You may 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/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

View File

@ -1,8 +0,0 @@
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

View File

@ -13,18 +13,19 @@ import Button from 'react-bootstrap/Button';
const CountdownTimer = ({ targetDate }) => { const CountdownTimer = ({ targetDate }) => {
const [days, hours, minutes, seconds] = useCountdown(targetDate); const [days, hours, minutes, seconds] = useCountdown(targetDate);
// Return the JSX to display the countdown timer // Return the JSX to display the countdown timer, this function will return the ExpiredNotice component if the countdown has finished,
// otherwise it will return the ShowCounter component
// The component below display's the simple text stating the purpose of the timer, and the countdown box itself.
return ( return (
<Container fluid className="countdown-container"> <Container fluid className="countdown-container">
<Row className="justify-content-center align-items-center"> <Row className="justify-content-center align-items-center">
<Col xs={12} sm={8} md={6}> <Col xs={12} sm={8} md={6}>
<h1 className="title">Countdown to Retirement</h1> <h1 className="title">Countdown to Tom's Retirement</h1>
<Card className="border-0 shadow-lg mt-4"> <Card className="border-0 shadow-lg mt-4">
{days + hours + minutes + seconds <= 0 ? ( {days + hours + minutes + seconds <= 0 ? (
<Card.Body className="d-flex flex-column justify-content-center align-items-center"> <Card.Body className="d-flex flex-column justify-content-center align-items-center">
<ExpiredNotice /> <ExpiredNotice />
<Button variant="primary" size="lg" onClick={() => console.log('Button clicked')}>Reset Countdown</Button>
</Card.Body> </Card.Body>
) : ( ) : (
<Card.Body className="d-flex flex-column justify-content-center align-items-center"> <Card.Body className="d-flex flex-column justify-content-center align-items-center">

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
// ExpiredNotice component // ExpiredNotice component - simply displays a message that the countdown has finished
const ExpiredNotice = () => <div>Time's up!</div>; const ExpiredNotice = () => <div>Time's up!</div>;
export default ExpiredNotice; export default ExpiredNotice;

View File

@ -1,4 +1,4 @@
// This file contains the ShowCounter component which is used to display the countdown timer. // This file contains the ShowCounter component which is used to display the countdown timer on the website
import React from 'react'; import React from 'react';