Skip to content

Commit 7e19905

Browse files
committed
frontend fixes
1 parent ce9ef8d commit 7e19905

File tree

8 files changed

+141
-147
lines changed

8 files changed

+141
-147
lines changed

frontend/components/Navigation/Navigation.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const Banner = () => {
3131
}, [show]);
3232
return (
3333
show && (
34-
<div className={styles["banner"]}>
34+
<div className="flex items-center justify-between p-2 bg-offwhite-one">
3535
<div className={styles["banner-info"]}>
3636
<span
3737
className={[fontLight.className, styles["banner-text"]].join(" ")}
@@ -45,7 +45,7 @@ const Banner = () => {
4545
className={styles["banner-close"]}
4646
onClick={() => setShow(false)}
4747
>
48-
<CrossIcon className={styles["banner-icon"]} />
48+
<CrossIcon className="w-5 hover:text-black-three" />
4949
</button>
5050
</div>
5151
)
@@ -90,12 +90,13 @@ const Navigation = (props) => {
9090
return (
9191
<>
9292
<Bar />
93-
{/* <Banner /> */}
93+
<Banner />
9494
<nav className="z-50 flex justify-between w-full h-16 font-medium font-switzer bg-black-two">
9595
<section className="flex items-center h-full ml-4 w-fit">
9696
<Link href="/">
9797
<Logo className="h-6" />
9898
</Link>
99+
{/* {variant !== "home" && <Search />} */}
99100
</section>
100101
<button
101102
className="flex items-center justify-center mr-5 md:hidden"

frontend/components/Search/Button/Search.jsx

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import useSWR from "swr";
77
import Link from "next/link";
88
import { font } from "@fonts";
99

10+
import Input from "../Homepage/Search";
11+
import Results from "../Homepage/Search";
1012
import SearchIcon from "@/public/static/search.svg";
1113

1214
const server = process.env.NEXT_PUBLIC_SERVER;
@@ -28,6 +30,7 @@ const Search = () => {
2830
}
2931
);
3032
const [show, setShow] = useState(false);
33+
const inputRef = useRef(null);
3134

3235
const limit = 10;
3336
const { data } = useSWR(
@@ -50,6 +53,7 @@ const Search = () => {
5053
<>
5154
<button
5255
className={[
56+
"h-full",
5357
styles["search-button"],
5458
show ? styles["search-show"] : "",
5559
].join(" ")}
@@ -63,44 +67,17 @@ const Search = () => {
6367
className={styles["search-background"]}
6468
onClick={() => setShow(false)}
6569
/>
66-
<div className={styles["search"]}>
67-
<input
68-
type="text"
69-
className={[styles["search-input"], font.className].join(" ")}
70-
value={input.search}
71-
placeholder={input.focus ? "" : "Start Typing..."}
72-
onChange={(e) => setInput({ search: e.target.value })}
73-
onFocus={() => setInput({ focus: true })}
74-
onBlur={() => setInput({ focus: false })}
75-
autoFocus
76-
/>
77-
</div>
78-
{input.search && input.results.length ? (
79-
<ul className={styles["result-list"]}>
80-
{input.results.map((result) => {
81-
return (
82-
<li key={result.cik}>
83-
<Link
84-
href={`/filers/${result.cik}`}
85-
onClick={() => setShow(false)}
86-
>
87-
<div className={styles["result"]}>
88-
<span className={font.className}>
89-
{result.name.toUpperCase()}{" "}
90-
{result.tickers.length == 0
91-
? ""
92-
: `(${result.tickers.join(", ")})`}
93-
</span>
94-
<span className={font.className}>
95-
CIK{result.cik.padStart(10, "0")}
96-
</span>
97-
</div>
98-
</Link>
99-
</li>
100-
);
101-
})}
102-
</ul>
103-
) : null}
70+
<Input
71+
input={input}
72+
setInput={(...args) => setInput(...args)}
73+
inputRef={inputRef}
74+
className="z-[1500]"
75+
/>
76+
<Results
77+
input={input}
78+
setInput={(...args) => setInput(...args)}
79+
className="z-[1500]"
80+
/>
10481
</>
10582
) : null}
10683
</>

frontend/components/Search/Button/Search.module.css

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
cursor: pointer;
44

55
margin-left: 10px;
6-
height: 23px;
76

87
color: white;
98
transition: scale 0.2s ease;
@@ -32,7 +31,7 @@
3231
opacity: 0.8;
3332
width: 100vw;
3433
height: 100vh;
35-
z-index: 5;
34+
z-index: 1499;
3635

3736
background-color: var(--secondary);
3837
}
@@ -51,7 +50,7 @@
5150
padding: 5px;
5251
border-radius: 3px;
5352

54-
z-index: 10;
53+
z-index: 1500;
5554
opacity: 1;
5655

5756
border: solid var(--offwhite-dark) 3px;
@@ -89,7 +88,7 @@
8988
padding: 5px;
9089
border-radius: 3px;
9190

92-
z-index: 10;
91+
z-index: 1500;
9392
opacity: 1;
9493

9594
border: solid var(--offwhite-dark) 3px;

frontend/components/Search/Homepage/Example.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -918,15 +918,15 @@ function Example({
918918
return (
919919
<div
920920
className={cn(
921-
" md:w-full p-4 transition-all duration-300 mt-4 border-2 bg-black-one rounded-md text-white-one border-white-one",
921+
" w-full p-4 pb-2 transition-all duration-300 border-2 text-nowrap bg-black-one rounded-md text-white-one border-white-one",
922922
className
923923
)}
924924
>
925925
<div className="flex items-center justify-between w-full">
926926
<Link href={`/filers/${cik}/overview`}>
927-
<h3 className="text-lg font-bold text-wrap">{name}</h3>
927+
<h3 className="text-lg font-bold text-nowrap">{name}</h3>
928928
</Link>
929-
<span className="hidden text-sm md:block">{date}</span>
929+
<span className="hidden text-sm text-nowrap md:block">{date}</span>
930930
<Link href={`/filers/${cik}/overview`}>
931931
<span className="text-sm">{cik}</span>
932932
</Link>
@@ -936,11 +936,11 @@ function Example({
936936
<p className="text-sm">{tickers.length ? tickers.join(", ") : ""}</p>
937937
</div>
938938
<div className="flex justify-between px-4">
939-
<p className="text-sm text-wrap">${marketValue.toLocaleString()}</p>
939+
<p className="text-sm text-nowrap">${marketValue.toLocaleString()}</p>
940940
<p className="hidden text-sm md:block">{topHoldings.join(", ")}</p>
941941
</div>
942-
<div className="w-full mt-6 rounded">
943-
<table className="w-full overflow-x-auto border-none rounded-md bg-white-one">
942+
<div className="w-full mt-6 overflow-x-scroll rounded">
943+
<table className="w-full border-none rounded-md bg-white-one">
944944
<thead className="text-xs text-black-one">
945945
<tr>
946946
<th className="w-2/12 p-1 border-2 border-opacity-30 border-black-one">

frontend/components/Search/Homepage/Search.jsx

Lines changed: 100 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,7 @@ const fetcher = (url, query, limit) =>
1818
.then((res) => res.data)
1919
.catch((e) => console.error(e));
2020

21-
const Search = (props) => {
22-
const router = useRouter();
23-
const [input, setInput] = useReducer(
24-
(prev, next) => {
25-
return { ...prev, ...next };
26-
},
27-
{
28-
search: "",
29-
results: [],
30-
focus: false,
31-
}
32-
);
33-
const inputRef = useRef(null);
34-
// const input = props.state;
35-
// const setInput = props.dispatch;
36-
37-
const limit = 5;
38-
const { data } = useSWR(
39-
input.search ? [server + "/filers/search", input.search, limit] : null,
40-
([url, query, limit]) => fetcher(url, query, limit),
41-
{
42-
revalidateOnFocus: false,
43-
revalidateOnReconnect: false,
44-
}
45-
);
46-
47-
const handleSearch = (data) => {
48-
if (data) {
49-
setInput({ results: data.results });
50-
} else {
51-
setInput({ results: [] });
52-
}
53-
};
21+
const Input = ({ input, setInput, inputRef, className }) => {
5422
const handleChange = (e) => {
5523
setInput({ search: e.target.value });
5624
};
@@ -95,6 +63,24 @@ const Search = (props) => {
9563
break;
9664
}
9765
};
66+
return (
67+
<div className={cn(styles["search-box"], className)}>
68+
<input
69+
type="text"
70+
ref={inputRef}
71+
className={[styles["search-input"]].join(" ")}
72+
value={input.search}
73+
placeholder={input.focus ? "" : "Search..."}
74+
onChange={handleChange}
75+
onFocus={handleFocus}
76+
onBlur={handleBlur}
77+
onKeyDown={handleKey}
78+
/>
79+
</div>
80+
);
81+
};
82+
83+
const Results = ({ input, setInput, className }) => {
9884
const handleMouseEnter = (cik) => {
9985
setInput({
10086
results: input.results.map((result) =>
@@ -113,6 +99,81 @@ const Search = (props) => {
11399
),
114100
});
115101
};
102+
return (
103+
<div
104+
className={[
105+
styles["results"],
106+
input.focus && input.search.length ? styles["results-expand"] : "",
107+
className,
108+
].join(" ")}
109+
>
110+
{
111+
<ul className={styles["result-list"]}>
112+
{input.results.map((result) => {
113+
return (
114+
<li key={result.cik}>
115+
<Link href={`/filers/${result.cik}`}>
116+
<div
117+
className={cn(
118+
styles["result"],
119+
"hover:bg-white-two",
120+
result.hover && "bg-white-two"
121+
)}
122+
onMouseEnter={() => handleMouseEnter(result.cik)}
123+
onMouseLeave={() => handleMouseLeave(result.cik)}
124+
>
125+
<span className="font-semibold">
126+
{result.name.toUpperCase()}{" "}
127+
{result.tickers.length == 0
128+
? ""
129+
: `(${result.tickers.join(", ")})`}
130+
</span>
131+
<span className="font-semibold ">
132+
CIK{result.cik.padStart(10, "0")}
133+
</span>
134+
</div>
135+
</Link>
136+
</li>
137+
);
138+
})}
139+
</ul>
140+
}
141+
</div>
142+
);
143+
};
144+
145+
const Search = (props) => {
146+
const [input, setInput] = useReducer(
147+
(prev, next) => {
148+
return { ...prev, ...next };
149+
},
150+
{
151+
search: "",
152+
results: [],
153+
focus: false,
154+
}
155+
);
156+
const inputRef = useRef(null);
157+
// const input = props.state;
158+
// const setInput = props.dispatch;
159+
160+
const limit = 5;
161+
const { data } = useSWR(
162+
input.search ? [server + "/filers/search", input.search, limit] : null,
163+
([url, query, limit]) => fetcher(url, query, limit),
164+
{
165+
revalidateOnFocus: false,
166+
revalidateOnReconnect: false,
167+
}
168+
);
169+
170+
const handleSearch = (data) => {
171+
if (data) {
172+
setInput({ results: data.results });
173+
} else {
174+
setInput({ results: [] });
175+
}
176+
};
116177

117178
useEffect(() => {
118179
handleSearch(data);
@@ -126,57 +187,12 @@ const Search = (props) => {
126187
props.className,
127188
].join(" ")}
128189
>
129-
<div className={styles["search-box"]}>
130-
<input
131-
type="text"
132-
ref={inputRef}
133-
className={[styles["search-input"]].join(" ")}
134-
value={input.search}
135-
placeholder={input.focus ? "" : "Search..."}
136-
onChange={handleChange}
137-
onFocus={handleFocus}
138-
onBlur={handleBlur}
139-
onKeyDown={handleKey}
140-
/>
141-
</div>
142-
<div
143-
className={[
144-
styles["results"],
145-
input.focus && input.search.length ? styles["results-expand"] : "",
146-
].join(" ")}
147-
>
148-
{
149-
<ul className={styles["result-list"]}>
150-
{input.results.map((result) => {
151-
return (
152-
<li key={result.cik}>
153-
<Link href={`/filers/${result.cik}`}>
154-
<div
155-
className={cn(
156-
styles["result"],
157-
"hover:bg-white-two",
158-
result.hover && "bg-white-two"
159-
)}
160-
onMouseEnter={() => handleMouseEnter(result.cik)}
161-
onMouseLeave={() => handleMouseLeave(result.cik)}
162-
>
163-
<span className="font-semibold">
164-
{result.name.toUpperCase()}{" "}
165-
{result.tickers.length == 0
166-
? ""
167-
: `(${result.tickers.join(", ")})`}
168-
</span>
169-
<span className="font-semibold ">
170-
CIK{result.cik.padStart(10, "0")}
171-
</span>
172-
</div>
173-
</Link>
174-
</li>
175-
);
176-
})}
177-
</ul>
178-
}
179-
</div>
190+
<Input
191+
input={input}
192+
setInput={(...args) => setInput(...args)}
193+
inputRef={inputRef}
194+
/>
195+
<Results input={input} setInput={(...args) => setInput(...args)} />
180196
</div>
181197
);
182198
};

0 commit comments

Comments
 (0)