Last active
March 10, 2023 08:15
-
-
Save MariusBongarts/ff9dc92e165a06b7c0747fac7d1f352f to your computer and use it in GitHub Desktop.
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
import React from "react"; | |
import { truncateString, urlWithoutSchema } from "../services/helper"; | |
import { | |
StyledInfo, | |
StyledHistoryItem, | |
StyledItemLink, | |
StyledTitle, | |
StyledTime, | |
} from "./HistoryItem.styled"; | |
interface HistoryItemProps { | |
item: chrome.history.HistoryItem; | |
} | |
export const HistoryItem: React.FC<HistoryItemProps> = ({ item }) => { | |
const lastVisitDate = new Date(item.lastVisitTime ?? 0); | |
const time = lastVisitDate.toLocaleTimeString().substring(0, 5); | |
const url = urlWithoutSchema(item.url ?? ""); | |
return ( | |
<StyledHistoryItem> | |
<StyledInfo> | |
<StyledTitle title={item.title}> | |
{truncateString(item.title ?? "", 50)} | |
</StyledTitle> | |
<br /> | |
<StyledItemLink href={item.url} target="_blank" title={item.url}> | |
{truncateString(url, 30)} | |
</StyledItemLink> | |
</StyledInfo> | |
<StyledTime title={lastVisitDate.toTimeString()}>{time}</StyledTime> | |
</StyledHistoryItem> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment