Skip to content

Commit 806aeae

Browse files
authored
Merge pull request #435 from ianshulx/main-616
update
2 parents 918664a + 33582ab commit 806aeae

File tree

420 files changed

+145687
-27335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

420 files changed

+145687
-27335
lines changed

Asteroid_Dodger/src/components/AsteroidDodger.jsx

Lines changed: 504 additions & 330 deletions
Large diffs are not rendered by default.

BMI-Calculator/src/components/BMICalculator.jsx

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { useState, useEffect } from 'react';
33
import { useTranslate, T } from '@tolgee/react';
44

55
const BMICalculator = () => {
6+
const [unit, setUnit] = useState('metric'); // 'metric' or 'imperial'
67
const { t } = useTranslate();
78
const [height, setHeight] = useState('');
89
const [weight, setWeight] = useState('');
@@ -21,22 +22,31 @@ const BMICalculator = () => {
2122

2223
const calculateBMI = (e) => {
2324
e.preventDefault();
25+
if (!height || !weight || height <= 0 || weight <= 0) {
26+
alert("Please enter valid height and weight!");
27+
return;
28+
}
2429
if (height && weight) {
25-
const bmiValue = (weight / (height * height)).toFixed(2);
26-
setBMI(bmiValue);
30+
let bmiValue;
31+
if (unit === 'metric') {
32+
bmiValue = weight / (height * height);
33+
} else {
34+
bmiValue = (weight / (height * height)) * 703;
35+
}
36+
setBMI(bmiValue.toFixed(2));
2737
setIsCalculated(true);
2838

2939
if (bmiValue < 18.5) {
30-
setMessage(t('bmi-calculator-underweight'));
40+
setMessage(t('Underweight '));
3141
} else if (bmiValue < 24.9) {
32-
setMessage(t('bmi-calculator-normal-weight'));
42+
setMessage(t('normal weight'));
3343
} else if (bmiValue < 29.9) {
34-
setMessage(t('bmi-calculator-overweight'));
44+
setMessage(t('overweight'));
3545
} else {
36-
setMessage(t('bmi-calculator-obese'));
46+
setMessage(t('obese'));
3747
}
3848
} else {
39-
setMessage(t('bmi-calculator-invalid-input'));
49+
setMessage(t('invalid-input'));
4050
}
4151
};
4252

@@ -72,34 +82,46 @@ const BMICalculator = () => {
7282
<h1 className="text-2xl font-bold mb-4 transition-transform duration-300 hover:scale-105">
7383
<T keyName="bmi-calculator-title" />
7484
</h1>
85+
86+
<div className="mb-4 -ml-10 mr-5 mt-10">
87+
<label className="mr-2 font-medium -ml-20">Units:</label>
88+
<select
89+
value={unit}
90+
onChange={(e) => { setUnit(e.target.value); resetForm(); }}
91+
className="border rounded px-2 py-1"
92+
>
93+
<option value="metric">Metric (m, kg)</option>
94+
<option value="imperial">Imperial (in, lbs)</option>
95+
</select>
96+
</div>
7597

7698
<form onSubmit={calculateBMI} className="mb-4">
7799
<div className="mb-4 transition-all duration-300">
78100
<label className="block text-left font-medium text-gray-700 mb-1 transition-colors duration-300">
79-
<T keyName="bmi-calculator-height-label" />
101+
<T keyName="Height"/>
80102
</label>
81103
<input
82104
type="number"
83105
value={height}
84106
onChange={(e) => setHeight(e.target.value)}
85107
step="0.01"
86108
className="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all duration-300 hover:border-blue-300"
87-
placeholder={t('bmi-calculator-height-placeholder')}
109+
placeholder={t(`Enter height in ${unit==="metric"?"Meters":"Inches"}`)}
88110
required
89111
/>
90112
</div>
91113

92114
<div className="mb-6 transition-all duration-300">
93115
<label className="block text-left font-medium text-gray-700 mb-1 transition-colors duration-300">
94-
<T keyName="bmi-calculator-weight-label" />
116+
<T keyName="Weight" />
95117
</label>
96118
<input
97119
type="number"
98120
value={weight}
99121
onChange={(e) => setWeight(e.target.value)}
100122
step="0.1"
101123
className="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all duration-300 hover:border-blue-300"
102-
placeholder={t('bmi-calculator-weight-placeholder')}
124+
placeholder={t(`Enter weight in ${unit==="metric"?"Kgs":"Pounds"}`)}
103125
required
104126
/>
105127
</div>
@@ -108,7 +130,7 @@ const BMICalculator = () => {
108130
type="submit"
109131
className="w-full bg-blue-500 text-white py-2 px-4 rounded-lg hover:bg-blue-600 transition-all duration-300 transform hover:scale-105 active:scale-95 shadow-md hover:shadow-lg"
110132
>
111-
<T keyName="bmi-calculator-calculate-button" />
133+
<T keyName="Calculate-BMI" />
112134
</button>
113135
</form>
114136

@@ -119,15 +141,15 @@ const BMICalculator = () => {
119141
${isAnimating ? 'scale-110 opacity-90' : 'scale-100 opacity-100'}
120142
`}
121143
>
122-
<div className="bg-gradient-to-r from-blue-50 to-green-50 p-6 rounded-lg border-2 border-gray-100 shadow-inner">
144+
<div className="bg-linear-to-r from-blue-50 to-green-50 p-6 rounded-lg border-2 border-gray-100 shadow-inner">
123145
<div className="flex items-center justify-center mb-4">
124146
<div className={`text-4xl font-bold ${getBMIColor()} transition-all duration-500 transform hover:scale-110`}>
125147
{bmi}
126148
</div>
127149
</div>
128150

129151
<p className="text-lg font-semibold mb-2 transition-colors duration-300">
130-
<T keyName="bmi-calculator-your-bmi" params={{ bmi }} />
152+
<T keyName="is Your-Bmi" params={{ bmi }} />
131153
</p>
132154

133155
<div
@@ -159,7 +181,7 @@ const BMICalculator = () => {
159181
onClick={resetForm}
160182
className="mt-6 px-6 py-2 bg-gray-500 text-white rounded-lg hover:bg-gray-600 transition-all duration-300 transform hover:scale-105 active:scale-95 w-full"
161183
>
162-
<T keyName="bmi-calculator-reset-button" />
184+
<T keyName="Reset" />
163185
</button>
164186
</div>
165187
</div>

BMI-Calculator/src/main.jsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,21 @@ import { StrictMode } from 'react'
22
import { createRoot } from 'react-dom/client'
33
import './index.css'
44
import App from './App.jsx'
5+
import { TolgeeProvider } from "@tolgee/react";
6+
import { Tolgee, DevTools } from "@tolgee/web";
57

6-
createRoot(document.getElementById('root')).render(
8+
const tolgee = Tolgee()
9+
.use(DevTools())
10+
.init({
11+
apiUrl: "https://app.tolgee.io",
12+
language: "en",
13+
fallbackLanguage: "en",
14+
});
15+
16+
createRoot(document.getElementById("root")).render(
717
<StrictMode>
8-
<App />
9-
</StrictMode>,
10-
)
18+
<TolgeeProvider tolgee={tolgee}>
19+
<App />
20+
</TolgeeProvider>
21+
</StrictMode>
22+
);

Blinkit clone/src/App.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useState } from "react"
77
import Navbar from "./landing page/Navbar";
88
import Footer from "./landing page/Footer";
99
import Modal from "./components/Modal";
10+
import Category from "./pages/Category.jsx";
1011

1112

1213
function App() {
@@ -41,6 +42,7 @@ function App() {
4142
<Routes>
4243
<Route path="/" element={<Home />} />
4344
<Route path="/cart" element={<Cart />} />
45+
<Route path="/category/:slug" element={<Category />} />
4446
</Routes>
4547

4648
<Footer />

Blinkit clone/src/landing page/CategoryRow.jsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
import Card from "./Card.jsx"
2+
import { useNavigate } from "react-router-dom"
3+
4+
export default function CategoryRow({ category, items, onSeeAll }) {
5+
const navigate = useNavigate()
6+
7+
const handleSeeAll = () => {
8+
if (typeof onSeeAll === "function") return onSeeAll(category)
9+
const slug = encodeURIComponent(category.toLowerCase().replace(/\s+/g, "-"))
10+
// pass the items (and category) via navigation state so the Category page can render them vertically
11+
navigate(`/category/${slug}`, { state: { category, items } })
12+
}
213

3-
export default function CategoryRow({ category, items }) {
414
return (
515
<div className="mb-8 mx-12">
616
<div className="flex justify-between items-center mb-3">
717
<h2 className="text-lg font-bold">{category}</h2>
8-
<button className="text-green-600 text-sm font-medium hover:underline">see all</button>
18+
<button
19+
type="button"
20+
aria-label={`See all ${category}`}
21+
className="text-green-600 text-sm font-medium hover:underline"
22+
onClick={handleSeeAll}
23+
>
24+
see all
25+
</button>
926
</div>
1027

1128
<div className="flex space-x-4 overflow-x-auto scrollbar-hide">

Blinkit clone/src/landing page/Navbar.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ export default function Navbar({ handleModalOpen }) {
1717
<div className="nav-container justify-between flex border-b items-center px-6 fixed bg-white w-full top-0 z-10 h-20">
1818

1919
<NavLink to="/">
20-
<div className="h-full border-r items-center flex hover:bg-slate-100 pr-4">
20+
<div className="h-full border-r items-center flex pr-4">
2121
<Logo />
2222
</div>
2323
</NavLink>
2424

25-
<div className="item-container flex hover:bg-slate-100 gap-6 px-4 flex-grow">
25+
<div className="item-container flex gap-6 px-4 flex-grow">
2626
<div className="delivery text-xs">
2727
<h1 className='font-bold'>Deliver in 8 minutes</h1>
2828
<p className='w-45'>B62, Pocket B, South City I, Sector...<ArrowDropDownIcon /> </p>

0 commit comments

Comments
 (0)