This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/app/scenes/Document/components/Backlink.js
Tom Moor 091e542406 feat: Backlinks (#979)
* feat: backlinks

* feat: add backlinkDocumentId to documents.list

* chore: refactor
fix: create and delete backlink handling

* fix: guard against self links

* feat: basic frontend
fix: race condition

* styling

* test: fix parse ids

* self review

* linting

* feat: Improved link styling

* fix: Increase clickable area at bottom of doc / between references

* perf: global styles are SLOW
2019-07-07 19:25:45 -07:00

69 lines
1.5 KiB
JavaScript

// @flow
import * as React from 'react';
import { observer } from 'mobx-react';
import { Link } from 'react-router-dom';
import styled from 'styled-components';
import PublishingInfo from 'components/PublishingInfo';
import Document from 'models/Document';
type Props = {
document: Document,
anchor: string,
showCollection?: boolean,
ref?: *,
};
const DocumentLink = styled(Link)`
display: block;
margin: 0 -8px;
padding: 6px 8px;
border-radius: 8px;
border: 2px solid transparent;
max-height: 50vh;
min-width: 100%;
overflow: hidden;
position: relative;
&:hover,
&:active,
&:focus {
background: ${props => props.theme.listItemHoverBackground};
outline: none;
}
`;
const Title = styled.h3`
max-width: 90%;
overflow: hidden;
text-overflow: ellipsis;
font-size: 14px;
margin-top: 0;
margin-bottom: 0.25em;
white-space: nowrap;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
`;
@observer
class Backlink extends React.Component<Props> {
render() {
const { document, showCollection, anchor, ...rest } = this.props;
return (
<DocumentLink
to={{
pathname: document.url,
hash: `d-${anchor}`,
state: { title: document.title },
}}
{...rest}
>
<Title>{document.title}</Title>
<PublishingInfo document={document} showCollection={showCollection} />
</DocumentLink>
);
}
}
export default Backlink;