Skip to content

Commit 61eb69a

Browse files
committed
add default layout (#490)
1 parent 33abc12 commit 61eb69a

File tree

1 file changed

+41
-39
lines changed

1 file changed

+41
-39
lines changed

frontend/src/views/HomeView.tsx

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default function HomeView() {
4949
const footerText = useSelector(getFooterText);
5050
const [searchNotebook, setSetNotebook] = useState("");
5151
const [notebooksLook, setNotebooksLook] = useState(
52-
localStorage.getItem("layout")
52+
localStorage.getItem("layout") || "grid"
5353
);
5454

5555
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
@@ -311,45 +311,47 @@ export default function HomeView() {
311311
</ReactMarkdown>
312312
</div>
313313
)}
314-
<div
315-
style={{
316-
display: "flex",
317-
justifyContent: "flex-end",
318-
gap: "5px",
319-
marginBottom: "15px",
320-
}}
321-
>
322-
<input
323-
className="search-bar"
324-
type="text"
325-
maxLength={30}
326-
placeholder="Search Notebooks... "
327-
value={searchNotebook}
328-
onChange={handleInputChange}
329-
/>
330-
<button
331-
className={`btn ${
332-
notebooksLook === "list"
333-
? `selected-button`
334-
: `btn-outline-primary`
335-
}`}
336-
onClick={() => handleChangeLook("list")}
337-
title="Show list"
338-
>
339-
<i className="fa fa-list"></i>
340-
</button>
341-
<button
342-
className={`btn ${
343-
notebooksLook === "grid"
344-
? `selected-button`
345-
: `btn-outline-primary`
346-
}`}
347-
onClick={() => handleChangeLook("grid")}
348-
title="Show grid"
314+
{notebooks.length > 0 && (
315+
<div
316+
style={{
317+
display: "flex",
318+
justifyContent: "flex-end",
319+
gap: "5px",
320+
marginBottom: "15px",
321+
}}
349322
>
350-
<i className="fa fa-th-large"></i>
351-
</button>
352-
</div>
323+
<input
324+
className="search-bar"
325+
type="text"
326+
maxLength={30}
327+
placeholder="Search Notebooks... "
328+
value={searchNotebook}
329+
onChange={handleInputChange}
330+
/>
331+
<button
332+
className={`btn ${
333+
notebooksLook === "list"
334+
? `selected-button`
335+
: `btn-outline-primary`
336+
}`}
337+
onClick={() => handleChangeLook("list")}
338+
title="Show list"
339+
>
340+
<i className="fa fa-list"></i>
341+
</button>
342+
<button
343+
className={`btn ${
344+
notebooksLook === "grid"
345+
? `selected-button`
346+
: `btn-outline-primary`
347+
}`}
348+
onClick={() => handleChangeLook("grid")}
349+
title="Show grid"
350+
>
351+
<i className="fa fa-th-large"></i>
352+
</button>
353+
</div>
354+
)}
353355
<div className="row">
354356
{loadingState === "loading" && (
355357
<p>Loading notebooks. Please wait ...</p>

0 commit comments

Comments
 (0)