Files
outline/app/scenes/Document/components/ReferenceListItem.tsx
Tom Moor b9bf2e58cb feat: Add cursor style user preference (#4199)
* feat: Add cursor style user preference

* Remove headings for now
2022-10-01 04:39:45 -07:00

94 lines
2.2 KiB
TypeScript

import { observer } from "mobx-react";
import { DocumentIcon } from "outline-icons";
import * as React from "react";
import { Link } from "react-router-dom";
import styled from "styled-components";
import parseTitle from "@shared/utils/parseTitle";
import Document from "~/models/Document";
import EmojiIcon from "~/components/EmojiIcon";
import Flex from "~/components/Flex";
import { hover } from "~/styles";
import { NavigationNode } from "~/types";
import { sharedDocumentPath } from "~/utils/routeHelpers";
type Props = {
shareId?: string;
document: Document | NavigationNode;
anchor?: string;
showCollection?: boolean;
};
const DocumentLink = styled(Link)`
display: block;
margin: 2px -8px;
padding: 6px 8px;
border-radius: 8px;
max-height: 50vh;
min-width: 100%;
overflow: hidden;
position: relative;
cursor: var(--pointer);
&:${hover},
&:active,
&:focus {
background: ${(props) => props.theme.listItemHoverBackground};
}
`;
const Content = styled(Flex)`
color: ${(props) => props.theme.textSecondary};
margin-left: -4px;
`;
const Title = styled.div`
overflow: hidden;
text-overflow: ellipsis;
font-size: 14px;
font-weight: 500;
line-height: 1.25;
padding-top: 3px;
white-space: nowrap;
color: ${(props) => props.theme.text};
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
`;
function ReferenceListItem({
document,
showCollection,
anchor,
shareId,
...rest
}: Props) {
const { emoji } = parseTitle(document.title);
return (
<DocumentLink
to={{
pathname: shareId
? sharedDocumentPath(shareId, document.url)
: document.url,
hash: anchor ? `d-${anchor}` : undefined,
state: {
title: document.title,
},
}}
{...rest}
>
<Content gap={4} dir="auto">
{emoji ? (
<EmojiIcon emoji={emoji} />
) : (
<DocumentIcon color="currentColor" />
)}
<Title>
{emoji ? document.title.replace(emoji, "") : document.title}
</Title>
</Content>
</DocumentLink>
);
}
export default observer(ReferenceListItem);