Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#642 calculator styled #643

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 87 additions & 34 deletions src/components/rent/RentCalculator.css
Original file line number Diff line number Diff line change
@@ -1,58 +1,111 @@
.rent-calculator {
max-width: 400px;
margin: 0 auto;
padding: 20px;
.rent-calculator h1{
font-weight: 700;
font-size: 40px;
margin-bottom: 20px;
}
.rent-calculator {
display: flex;
font-family: Arial, sans-serif;
max-width: 80vw;
justify-content: space-between;
margin: 20px auto;
align-items: center;
}
.left{
max-width: 600px;
}
.left h1 span{
color: #ec154e;
font-size: 50px;
}
.left p{
max-width: 500px;
font-size: 20px;
}
.right{
width: 500px;
border: 1px solid #ddd;
border-radius: 8px;
background-color: #f9f9f9;
text-align: center;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
background-color: #f9f9f9;
padding: 20px;
}

.rent-calculator h1 {
color: #333;
.input-group {
margin-bottom: 20px;
font-size: 24px;
}

.input-group {
margin-bottom: 15px;

.slider-label {
display: flex;
justify-content: space-between;
font-weight: bold;
color: gray;
display: flex;
align-items: baseline;
}

.input-group label {
display: block;
font-size: 16px;
margin-bottom: 5px;
color: #555;
.slider-label span{
color: black;
background-color: #e0e0e0;
padding: 10px;
border-radius: 10px;
}

.input-group input {
.slider {
width: 100%;
padding: 10px;
font-size: 14px;
border: 1px solid #ddd;
border-radius: 5px;
-webkit-appearance: none;
appearance: none;
height: 6px;
background: #e0e0e0;
border-radius: 3px;
outline: none;
cursor: pointer;
}


.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 20px;
height: 20px;
border-radius: 50%;
background: #00b894;
cursor: pointer;
}

.slider::-moz-range-thumb {
width: 20px;
height: 20px;
border-radius: 50%;
background: #00b894;
cursor: pointer;
}

.calculate-btn {
width: 100%;
padding: 10px;
background-color: #2ec4b6;
padding: 10px 20px;
background-color: #00b894;
color: white;
font-size: 16px;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}

.calculate-btn:hover {
background-color: #238e8b;
background-color: #019970;
}

.result {
text-align: center;
margin-top: 20px;
font-size: 18px;
font-weight: bold;
color: #2ec4b6;
}
display: flex;
align-items: center;
justify-content: space-evenly;
}

.result span{
margin-left: 10px;
font-size: 20px;
font-weight: 900;
}

81 changes: 52 additions & 29 deletions src/components/rent/RentCalculator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,94 @@ import React, { useState } from 'react';
import './RentCalculator.css';

const RentCalculator = () => {
const [baseRent, setBaseRent] = useState('');
const [powerBill, setPowerBill] = useState('');
const [waterBill, setWaterBill] = useState('');
const [otherFees, setOtherFees] = useState('');
const [baseRent, setBaseRent] = useState(20000);
const [powerBill, setPowerBill] = useState(300);
const [waterBill, setWaterBill] = useState(50);
const [otherFees, setOtherFees] = useState(500);
const [totalRent, setTotalRent] = useState(null);

const calculateTotalRent = () => {
const rent = parseFloat(baseRent) || 0;
const power = parseFloat(powerBill) || 0;
const water = parseFloat(waterBill) || 0;
const other = parseFloat(otherFees) || 0;
const total = rent + power + water + other;
const total = baseRent + powerBill + waterBill + otherFees;
setTotalRent(total);
};

return (

<div id="RentCalculator" className="rent-calculator">
<h1>Monthly Rent Calculator</h1>
<div className='left'>
<h1>Monthly Rent <span>Calculator</span></h1>
<p className="description">Adjust the sliders below to input your rent, utilities, and other fees. The total rent will be calculated automatically!</p>
</div>


<div className='right'>
<div className="input-group">
<label>Base Rent ($):</label>
<label className="slider-label">Base Rent: <span>$ {baseRent}</span></label>
<input
type="number"
type="range"
min="1000"
max="50000"
step="50"
value={baseRent}
onChange={(e) => setBaseRent(e.target.value)}
placeholder="Enter base rent amount"
onChange={(e) => setBaseRent(parseInt(e.target.value, 10))}
className="slider"
style={{ background: `linear-gradient(to right, #1abc9c ${(baseRent - 1000) / 490}%, #e0e0e0 ${(baseRent - 1000) / 490}%)` }}
/>
</div>

<div className="input-group">
<label>Power Bill ($):</label>
<label className="slider-label">Power Bill : <span>$ {powerBill}</span></label>
<input
type="number"
type="range"
min="0"
max="500"
step="10"
value={powerBill}
onChange={(e) => setPowerBill(e.target.value)}
placeholder="Enter power bill amount"
onChange={(e) => setPowerBill(parseInt(e.target.value, 10))}
className="slider"
style={{ background: `linear-gradient(to right, #1abc9c ${powerBill / 5}%, #e0e0e0 ${powerBill / 5}%)` }}
/>
</div>

<div className="input-group">
<label>Water Bill ($):</label>
<label className="slider-label">Water Bill : <span>$ {waterBill}</span></label>
<input
type="number"
type="range"
min="0"
max="200"
step="10"
value={waterBill}
onChange={(e) => setWaterBill(e.target.value)}
placeholder="Enter water bill amount"
onChange={(e) => setWaterBill(parseInt(e.target.value, 10))}
className="slider"
style={{ background: `linear-gradient(to right, #1abc9c ${waterBill / 2}%, #e0e0e0 ${waterBill / 2}%)` }}
/>
</div>

<div className="input-group">
<label>Other Fees ($):</label>
<label className="slider-label">Other Fees : <span>$ {otherFees}</span></label>
<input
type="number"
type="range"
min="0"
max="1000"
step="10"
value={otherFees}
onChange={(e) => setOtherFees(e.target.value)}
placeholder="Enter other fees"
onChange={(e) => setOtherFees(parseInt(e.target.value, 10))}
className="slider"
style={{ background: `linear-gradient(to right, #1abc9c ${otherFees / 10}%, #e0e0e0 ${otherFees / 10}%)` }}
/>
</div>

<button onClick={calculateTotalRent} className="calculate-btn">
Calculate Total Rent
</button>

{totalRent !== null && (
<div className="result">
<h2>Total Monthly Rent: ${totalRent.toFixed(2)}</h2>
<h2>Total Monthly Rent: <span>${totalRent.toFixed(2)}</span></h2>
</div>
)}
</div>
</div>
);
};

export default RentCalculator;
export default RentCalculator;
Loading