2020-07-08 19:36:36 +02:00
|
|
|
import styled from "styled-components";
|
2021-06-14 11:29:03 +02:00
|
|
|
import {
|
|
|
|
Headline,
|
|
|
|
Item,
|
|
|
|
ItemList,
|
|
|
|
ListContainer,
|
|
|
|
SubHeadline,
|
|
|
|
} from "./elements";
|
2020-07-08 19:36:36 +02:00
|
|
|
|
|
|
|
const GroupContainer = styled.div`
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
flex: 2 1 auto;
|
|
|
|
padding: 1rem 0;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const Bookmark = styled.a`
|
|
|
|
font-weight: 400;
|
|
|
|
text-decoration: none;
|
2021-07-10 23:57:08 +02:00
|
|
|
color: ${(props) => props.theme.accentColor};
|
2020-07-08 19:36:36 +02:00
|
|
|
padding-top: 0.75rem;
|
|
|
|
font-size: 0.9rem;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
text-decoration: underline;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2021-03-05 22:00:32 +01:00
|
|
|
export interface IBookmarkProps {
|
2020-07-08 19:36:36 +02:00
|
|
|
name: string;
|
|
|
|
url: string;
|
|
|
|
}
|
|
|
|
|
2021-03-05 22:00:32 +01:00
|
|
|
export interface IBookmarkGroupProps {
|
2021-03-21 20:19:44 +01:00
|
|
|
name: string;
|
2021-03-05 22:00:32 +01:00
|
|
|
items: Array<IBookmarkProps>;
|
2020-07-08 19:36:36 +02:00
|
|
|
}
|
|
|
|
|
2021-06-14 11:29:03 +02:00
|
|
|
export interface IBookmarkListProps {
|
|
|
|
groups: Array<IBookmarkGroupProps>;
|
|
|
|
}
|
|
|
|
|
2021-03-21 19:59:18 +01:00
|
|
|
/**
|
|
|
|
* Renders a given bookmark group
|
2021-06-14 11:29:03 +02:00
|
|
|
* @param {IBookmarkGroupProps} props given props of the bookmark group
|
|
|
|
* @returns {React.ReactNode} the bookmark group component
|
2021-03-21 19:59:18 +01:00
|
|
|
*/
|
2021-03-21 20:19:44 +01:00
|
|
|
export const BookmarkGroup = ({ name, items }: IBookmarkGroupProps) => (
|
2020-07-08 19:36:36 +02:00
|
|
|
<Item>
|
|
|
|
<GroupContainer>
|
2021-03-21 20:19:44 +01:00
|
|
|
<SubHeadline>{name}</SubHeadline>
|
2021-06-30 00:56:01 +02:00
|
|
|
{items.map(({ name, url }, index) => (
|
|
|
|
<Bookmark key={[name, index].join("")} href={url}>
|
2020-07-08 19:36:36 +02:00
|
|
|
{name}
|
|
|
|
</Bookmark>
|
|
|
|
))}
|
|
|
|
</GroupContainer>
|
|
|
|
</Item>
|
|
|
|
);
|
2021-06-14 11:29:03 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders a given list of categorized bookmarks
|
|
|
|
* @param {IBookmarkListProps} props props of the given bookmark list
|
|
|
|
* @returns {React.ReactNode} the bookmark list component
|
|
|
|
*/
|
|
|
|
const BookmarkList = ({ groups }: IBookmarkListProps) => (
|
|
|
|
<ListContainer>
|
|
|
|
<Headline>Bookmarks</Headline>
|
|
|
|
<ItemList>
|
2021-06-30 00:56:01 +02:00
|
|
|
{groups.map(({ name, items }, index) => (
|
|
|
|
<BookmarkGroup key={[name, index].join("")} name={name} items={items} />
|
2021-06-14 11:29:03 +02:00
|
|
|
))}
|
|
|
|
</ItemList>
|
|
|
|
</ListContainer>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default BookmarkList;
|