-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b68f246
commit 639b4d5
Showing
9 changed files
with
501 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,42 @@ | ||
import { ReactElement, useContext } from "react"; | ||
import { forwardRef, ReactElement, useContext } from "react"; | ||
import { AppContext } from "../App"; | ||
import BookmarkHistoryListItem from "./BookmarkHistoryListItem"; | ||
|
||
const BookmarkTab = (): ReactElement => { | ||
const { bookmarks, setBookmarks } = useContext(AppContext); | ||
const BookmarkTab = forwardRef( | ||
( | ||
{ bookmarkTabDisplay }: { bookmarkTabDisplay: boolean }, | ||
ref: React.ForwardedRef<HTMLDivElement> | ||
): ReactElement => { | ||
const { bookmarks, setBookmarks } = useContext(AppContext); | ||
|
||
return ( | ||
<div className="contTab listCont" id="bookmarksTab"> | ||
<h2>Bookmarks</h2> | ||
<div className="location-cont"> | ||
{bookmarks.length === 0 ? ( | ||
<p>No Bookmarks...</p> | ||
) : ( | ||
<ol> | ||
{bookmarks.map((e, i) => ( | ||
<BookmarkHistoryListItem | ||
isHistory={false} | ||
isBookmark={true} | ||
index={i} | ||
{...e} | ||
key={e.link} | ||
/> | ||
))} | ||
</ol> | ||
)} | ||
return ( | ||
<div | ||
className="contTab listCont" | ||
style={{ display: bookmarkTabDisplay ? "flex" : "none" }} | ||
id="bookmarksTab" | ||
ref={ref} | ||
> | ||
<h2>Bookmarks</h2> | ||
<div className="location-cont"> | ||
{bookmarks.length === 0 ? ( | ||
<p>No Bookmarks...</p> | ||
) : ( | ||
<ol> | ||
{bookmarks.map((e, i) => ( | ||
<BookmarkHistoryListItem | ||
isHistory={false} | ||
isBookmark={true} | ||
index={i} | ||
{...e} | ||
key={e.link} | ||
/> | ||
))} | ||
</ol> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
); | ||
} | ||
); | ||
|
||
export default BookmarkTab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,64 @@ | ||
import { faTrash } from "@fortawesome/free-solid-svg-icons"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { ReactElement, useContext } from "react"; | ||
import { forwardRef, ReactElement, useContext } from "react"; | ||
import { AppContext } from "../App"; | ||
import BookmarkHistoryListItem from "./BookmarkHistoryListItem"; | ||
|
||
const HistoryTab = (): ReactElement => { | ||
const { history, setHistory } = useContext(AppContext); | ||
return ( | ||
<div className="contTab listCont" id="historyTab"> | ||
<h2> | ||
History | ||
<button | ||
onFocus={(e) => e.currentTarget.blur()} | ||
onClick={() => { | ||
window.electron.dialog | ||
.showMessageBox(window.electron.getCurrentWindow(), { | ||
title: "Warning", | ||
type: "warning", | ||
message: "Are you sure you want to clear history", | ||
buttons: ["Yes", "No"], | ||
}) | ||
.then((res) => { | ||
if (res && res.response === 0) setHistory([]); | ||
}); | ||
}} | ||
tabIndex={-1} | ||
data-tooltip="Clear All" | ||
> | ||
<FontAwesomeIcon icon={faTrash} /> | ||
</button> | ||
</h2> | ||
<div className="location-cont"> | ||
{history.length === 0 ? ( | ||
<p>No History...</p> | ||
) : ( | ||
<ol> | ||
{history.map((e, i) => ( | ||
<BookmarkHistoryListItem | ||
isBookmark={false} | ||
isHistory={true} | ||
index={i} | ||
{...e} | ||
key={e.date} | ||
/> | ||
))} | ||
</ol> | ||
)} | ||
const HistoryTab = forwardRef( | ||
( | ||
{ historyTabDisplay }: { historyTabDisplay: boolean }, | ||
ref: React.ForwardedRef<HTMLDivElement> | ||
): ReactElement => { | ||
const { history, setHistory } = useContext(AppContext); | ||
return ( | ||
<div | ||
className="contTab listCont" | ||
style={{ display: historyTabDisplay ? "flex" : "none" }} | ||
id="historyTab" | ||
ref={ref} | ||
> | ||
<h2> | ||
History | ||
<button | ||
onFocus={(e) => e.currentTarget.blur()} | ||
onClick={() => { | ||
window.electron.dialog | ||
.showMessageBox(window.electron.getCurrentWindow(), { | ||
title: "Warning", | ||
type: "warning", | ||
message: "Are you sure you want to clear history", | ||
buttons: ["Yes", "No"], | ||
}) | ||
.then((res) => { | ||
if (res && res.response === 0) setHistory([]); | ||
}); | ||
}} | ||
tabIndex={-1} | ||
data-tooltip="Clear All" | ||
> | ||
<FontAwesomeIcon icon={faTrash} /> | ||
</button> | ||
</h2> | ||
<div className="location-cont"> | ||
{history.length === 0 ? ( | ||
<p>No History...</p> | ||
) : ( | ||
<ol> | ||
{history.map((e, i) => ( | ||
<BookmarkHistoryListItem | ||
isBookmark={false} | ||
isHistory={true} | ||
index={i} | ||
{...e} | ||
key={e.date} | ||
/> | ||
))} | ||
</ol> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
); | ||
} | ||
); | ||
|
||
export default HistoryTab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.