Skip to content

Commit fc82036

Browse files
Add header component
1 parent 71dab30 commit fc82036

13 files changed

+135
-13
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
node_modules

Diff for: package-lock.json

+6-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+3
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,8 @@
3434
"last 1 firefox version",
3535
"last 1 safari version"
3636
]
37+
},
38+
"devDependencies": {
39+
"tailwindcss": "^3.4.14"
3740
}
3841
}

Diff for: public/img/icons/cart.svg

+3
Loading

Diff for: public/img/icons/dropdown.svg

+3
Loading

Diff for: public/img/icons/favorite.svg

+3
Loading

Diff for: public/img/icons/phone.svg

+3
Loading

Diff for: src/App.js

-7
This file was deleted.

Diff for: src/App.jsx

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import './App.css';
2+
import Header from './components/Header/Header';
3+
4+
function App() {
5+
return (
6+
<div className="App">
7+
<Header></Header>
8+
</div>
9+
);
10+
}
11+
12+
export default App;

Diff for: src/components/Header/Header.jsx

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import PhoneSelector from './PhoneSelector';
2+
function Header() {
3+
return (
4+
<header>
5+
<div className="flex max-w-[1100px] p-[10px] items-center w-full justify-between mx-auto">
6+
<div className="flex justify-between items-center gap-[75px]">
7+
<div className="font-bold text-[25px]">QPICK</div>
8+
<PhoneSelector />
9+
</div>
10+
<div>
11+
<div className="flex items-center gap-[25px]">
12+
<div className="relative cursor-pointer ">
13+
<img src="/img/icons/favorite.svg" alt="" />
14+
<span className=" absolute top-[-10px] right-[-10px] font-medium bg-[#FFA542] text-[15px] text-white rounded-full w-[17px] h-[17px] flex items-center justify-center ">
15+
0
16+
</span>
17+
</div>
18+
<div className="relative cursor-pointer ">
19+
<img src="/img/icons/cart.svg" alt="" />
20+
<span className=" absolute top-[-10px] right-[-10px] font-medium bg-[#FFA542] text-[15px] text-white rounded-full w-[17px] h-[17px] flex items-center justify-center ">
21+
0
22+
</span>
23+
</div>
24+
</div>
25+
</div>
26+
</div>
27+
</header>
28+
);
29+
}
30+
31+
export default Header;

Diff for: src/components/Header/PhoneSelector.jsx

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import React, { useState } from 'react';
2+
3+
function PhoneSelector() {
4+
const [isOpen, setIsOpen] = useState(false);
5+
const [selectedPhone, setSelectedPhone] = useState();
6+
7+
const toggleDropdown = () => {
8+
setIsOpen(!isOpen);
9+
};
10+
11+
const handleSelect = (phone) => {
12+
setSelectedPhone(phone);
13+
setIsOpen(false);
14+
};
15+
16+
return (
17+
<div className="flex items-center gap-[10px]">
18+
<div>
19+
<img src="/img/icons/phone.svg" alt="phone icon" />
20+
</div>
21+
<div className="relative" onClick={toggleDropdown}>
22+
<div className="flex items-center gap-[8px] w-full bg-transparent border-none cursor-pointer p-2">
23+
<span className="block min-w-[150px] max-w-[200px] w-full truncate">
24+
{selectedPhone || 'Choose a phone model'}
25+
</span>
26+
<img src="/img/icons/dropdown.svg" alt="dropdown icon" />
27+
</div>
28+
<ul
29+
className={`absolute left-0 w-full bg-white border border-gray-300 flex flex-col rounded mt-1 ${
30+
isOpen ? '' : 'hidden'
31+
}`}
32+
>
33+
{[
34+
'iPhone 12',
35+
'iPhone 12 Max',
36+
'iPhone 13',
37+
'iPhone 13 Max',
38+
'iPhone 13 Pro Max',
39+
'iPhone 14',
40+
].map((phone) => (
41+
<li
42+
key={phone}
43+
className="p-2 text-start hover:bg-gray-200 cursor-pointer"
44+
onClick={() => handleSelect(phone)}
45+
>
46+
{phone}
47+
</li>
48+
))}
49+
</ul>
50+
</div>
51+
</div>
52+
);
53+
}
54+
55+
export default PhoneSelector;

Diff for: src/index.css

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&family=Rubik:wght@500&display=swap');
5+
16
* {
27
margin: 0;
38
padding: 0;
49
}
510

611
body {
7-
font-family: 'Segoe UI', 'Roboto', 'Oxygen',
8-
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
9-
sans-serif;
12+
font-family: "Montserrat", sans-serif;
1013
}

Diff for: tailwind.config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('tailwindcss').Config} */
2+
module.exports = {
3+
content: ['./src/**/*.{js,jsx,ts,tsx}'],
4+
theme: {
5+
extend: {},
6+
},
7+
plugins: [],
8+
};

0 commit comments

Comments
 (0)