Skip to content

Commit 08f759c

Browse files
Added spotlight search UI
1 parent 18cfaed commit 08f759c

File tree

4 files changed

+127
-14
lines changed

4 files changed

+127
-14
lines changed
+50-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,51 @@
1-
export default function SpotLightSearch(){
2-
return(
31

4-
<input>
5-
6-
</input>
7-
)
8-
}
2+
import { useState, useEffect } from "react";
3+
import SearchIcon from '../icons/SearchIcon';
4+
export default function SpotLightSearch()
5+
{
6+
// Control the visibility of the overlay
7+
const [isOpen, setIsOpen] = useState(true);
8+
9+
10+
11+
// Toggle the overlay when user presses Ctrl+Space
12+
useEffect(() => {
13+
const handleKeyDown = (e) => {
14+
// Check for Ctrl+Space
15+
if (e.ctrlKey && e.code === 'Space') {
16+
e.preventDefault();
17+
setIsOpen((prev) => !prev);
18+
}
19+
};
20+
window.addEventListener('keydown', handleKeyDown);
21+
return () => window.removeEventListener('keydown', handleKeyDown);
22+
}, []);
23+
24+
// Close the overlay and reset the search
25+
const handleClose = () => {
26+
setIsOpen(false);
27+
};
28+
29+
30+
return (
31+
<>
32+
{isOpen && (
33+
<div className="spotlight-overlay" onClick={handleClose}>
34+
<div className="spotlight-container" onClick={(e) => e.stopPropagation()}>
35+
<div className="spotlight-input-wrapper">
36+
<div className="spotlight-icon">
37+
<SearchIcon dimension="33px" />
38+
</div>
39+
<input
40+
type="text"
41+
className="spotlight-input"
42+
placeholder="Spotlight Search"
43+
autoFocus
44+
/>
45+
</div>
46+
</div>
47+
</div>
48+
)}
49+
</>
50+
);
51+
};

app/routes/homepage.tsx

+15-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import "app/routes/styles/ControlCenter.scss"
1515
import "app/routes/styles/SendAMessage.scss"
1616
import "app/routes/styles/Calculator.scss"
1717
import "app/routes/styles/Blog.scss"
18+
import "app/routes/styles/SpotLightSearch.scss"
1819
import Folder from './components/Folder'
1920
import Finder from './components/Finder'
2021
import AppleLogoMenu from './components/AppleLogoMenu'
@@ -23,6 +24,7 @@ import ControlCenter from './components/ControlCenter'
2324
import SendAMessage from './components/SendAMessage'
2425
import Calculator from './components/Calculator'
2526
import Blog from './components/Blog'
27+
import SpotLightSearch from './components/SpotLightSearch'
2628
import AppleLogoIcon from './icons/AppleLogoIcon'
2729
import BatteryIcon from './icons/BatteryIcon'
2830
import SearchIcon from './icons/SearchIcon'
@@ -49,6 +51,7 @@ export default function homepage(){
4951
const [currentTimeState, setCurrentTimeState] = useState("");
5052
const [appleButtonClicked,setAppleButtonClicked] = useState(false);
5153
const [batteryButtonClicked, setBatteryButtonClicked] = useState(false);
54+
const [searchButtonClicked, setSearchButtonClicked] = useState(false);
5255
const [controlCenterButtonClicked, setControlCenterButtonClicked] = useState(false);
5356

5457

@@ -85,7 +88,11 @@ export default function homepage(){
8588
const handleBatteryButtonClick = () =>{
8689

8790
setBatteryButtonClicked(!batteryButtonClicked);
88-
}
91+
}
92+
const handleSearchButtonClick = () =>{
93+
setSearchButtonClicked(!searchButtonClicked);
94+
console.log("search button clicked", searchButtonClicked)
95+
}
8996

9097
const handleControlButtonClick = () =>{
9198

@@ -273,6 +280,10 @@ useEffect(() => {
273280
<BatteryMenu />
274281
</div>
275282
})
283+
({
284+
searchButtonClicked &&
285+
<SpotLightSearch />
286+
})
276287
{( controlCenterButtonClicked &&
277288
<div className="controlcenter-container">
278289
{/* <FullScreenProvider> */}
@@ -379,9 +390,10 @@ useEffect(() => {
379390
<div className="overlay-topbar__wifi">
380391
<WifiIcon fill="rgba(0,0,0,1)" height="20px" width="20px"/>
381392
</div>
382-
<div
393+
<div
394+
onClick={handleSearchButtonClick}
383395
className="overlay-topbar__search">
384-
<SearchIcon />
396+
<SearchIcon dimension="18px" />
385397
</div>
386398
<div
387399
onClick={handleControlButtonClick}

app/routes/icons/SearchIcon.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
export default function SearchIcon(){
1+
export default function SearchIcon({dimension}){
22

33

44
return(
55

66
<svg
77
xmlns="http://www.w3.org/2000/svg"
8-
height="21px"
8+
height={dimension}
99
viewBox="0 -960 960 960"
10-
width="21px"
11-
fill="rgba(28,28,28)">
10+
width={dimension}
11+
fill="rgb(47, 46, 46)">
1212
<path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l170 170-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"
1313
/>
1414
</svg>
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* Overlay that covers the entire screen */
2+
.spotlight-overlay {
3+
display: flex;
4+
position: absolute;
5+
top: 6rem;
6+
left: 40%;
7+
width: 100%;
8+
z-index: 9999;
9+
}
10+
11+
/* The container for the search bar and results */
12+
.spotlight-container {
13+
background-color: rgba(198, 198, 199, 0.5);
14+
;
15+
width: 30%;
16+
max-width: 500px;
17+
border-radius: 15px;
18+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
19+
mix-blend-mode: screen;
20+
21+
}
22+
23+
/* The input field */
24+
.spotlight-input {
25+
width: 100%;
26+
font-size: 1.5rem;
27+
font-family: "SF-Pro Medium",-apple-system, BlinkMacSystemFont;
28+
font-weight: 100;
29+
padding: 1px 1px;
30+
// border: 1px solid #ccc;
31+
border-radius: 15px;
32+
outline: none;
33+
box-sizing: border-box;
34+
35+
36+
}
37+
38+
.spotlight-input-wrapper {
39+
display: flex;
40+
align-items: center;
41+
justify-content: center;
42+
align-content: center;
43+
background-color: #fefefe;
44+
border: 1px solid #ccc;
45+
border-radius: 15px;
46+
padding: 4px 8px;
47+
mix-blend-mode: screen;
48+
}
49+
.spotlight-icon{
50+
margin-top: 0.2rem;
51+
}
52+
.text{
53+
font-family: "SF-Pro Medium",-apple-system, BlinkMacSystemFont;
54+
color:rgb(47, 46, 46,1);
55+
font-weight: 500;
56+
font-size: 1.6rem;
57+
}
58+

0 commit comments

Comments
 (0)