-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b753d46
commit 648b84d
Showing
8 changed files
with
83 additions
and
41 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 |
---|---|---|
@@ -1,8 +1,20 @@ | ||
# React + Vite | ||
# Tip React Calculator | ||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
This application is a simple tip calculator built with React and Vite. It allows users to calculate the tip amount based on the bill and the service rating. | ||
|
||
Currently, two official plugins are available: | ||
## Main Components | ||
|
||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
- [`App`](src/App.jsx): This is the main component of the application. It maintains the state of the bill amount, the service rating, and the calculated tip. It also renders the other components and handles the reset functionality. | ||
|
||
- [`BillInput`](src/components/BillInput.jsx): This component allows users to input the bill amount. It accepts a number and ensures that the value is always positive. | ||
|
||
- [`ServiceInput`](src/components/ServiceInput.jsx): This component is used to rate the service. The rating affects the calculated tip. | ||
|
||
- [`Output`](src/components/Output.jsx): This component displays the calculated tip based on the bill amount and the service rating. | ||
|
||
## Running the Application | ||
|
||
To run the application, use the `dev` script in the [package.json](package.json) file: | ||
|
||
```sh | ||
npm run dev |
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
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 |
---|---|---|
|
@@ -24,3 +24,7 @@ | |
border-radius: 6px; | ||
padding: 0.5rem 0; | ||
} | ||
|
||
.btn-reset { | ||
margin-top: 1rem; | ||
} |
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
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
This file was deleted.
Oops, something went wrong.
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,12 @@ | ||
export default function Output({ bill, tip }) { | ||
return ( | ||
<div className="pay-box"> | ||
<p> | ||
Food: ${bill ? bill : 0} | Tips: ${tip} | ||
</p> | ||
<h3> | ||
<em>Total:</em> ${bill + tip} | ||
</h3> | ||
</div> | ||
); | ||
} |
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