Live demo: https://hasalawa.github.io/tip-calculator/
A clean, single-page tip calculator built with plain HTML, CSS and JavaScript. Enter a bill, pick a tip percentage, and see the tip and total update instantly. Built with Cursor for MLH Global Hack Week: Hacktoberfest (Challenge 1: Build a Mini App with Cursor).
- Live results: tip amount and total update as you type
- Quick tip presets: one-tap buttons for 10%, 15%, 18%, 20% and 25%, or enter any custom percentage
- Split the bill: divide the total between 2 to 50 people and see what each person pays
- Dark mode: toggle between light and dark themes; your choice is remembered, and it follows your system preference by default
- Responsive and accessible: works on desktop and mobile, with keyboard focus styles and ARIA labels
No build step or dependencies are needed.
- Clone the repository:
git clone https://github.com/Hasalawa/tip-calculator.git cd tip-calculator - Open
index.htmlin your browser (double-click it, or runopen index.htmlon macOS /start index.htmlon Windows).
- Type the bill amount.
- Choose a tip percentage with a preset button or type your own.
- (Optional) Click Split the bill and set the number of people.
- Read the tip amount, total, and per-person amount in the results panel.
- Use the sun/moon button in the top-right corner to switch themes.
- HTML5
- CSS3 (custom properties for theming)
- Vanilla JavaScript (no frameworks)
- Google Fonts: Fraunces and Outfit
tip-calculator/
├── .github/workflows/deploy.yml # CI/CD: lint + deploy to GitHub Pages
├── index.html # markup, styles and logic in a single file
├── LICENSE # MIT License
└── README.md
A GitHub Actions workflow (.github/workflows/deploy.yml) runs on every push and pull request to main:
- Test: lints
index.htmlwith HTMLHint - Deploy: if the lint passes on
main, the site is published to GitHub Pages automatically
Cursor generated the initial scaffold of the app from a short prompt and then helped me iterate: adding the dark mode toggle and the split-the-bill feature, and fixing issues along the way.
This project is licensed under the MIT License.
0 comments
log in to comment.