Pinned documents (#608)

* Migrations and API for pinned documents

* Documentation

* Add pin icon

* Fin.

* v0.2.0

* Remove pin from DocumentPreview, add general menu
Add Pinned documents header

* Tidy

* Fixed: Drafts appearing on collection home
This commit is contained in:
Tom Moor
2018-02-28 23:28:36 -08:00
committed by GitHub
parent 1722b3f3d9
commit 18b0338736
16 changed files with 399 additions and 101 deletions

View File

@ -14,6 +14,7 @@ type Props = {
onOpen?: () => void,
onClose?: () => void,
children?: React.Element<*>,
className?: string,
style?: Object,
};
@ -23,10 +24,9 @@ class DropdownMenu extends Component {
@observable top: number;
@observable right: number;
handleOpen = (openPortal: SyntheticEvent => void) => {
handleOpen = (openPortal: SyntheticEvent => *) => {
return (ev: SyntheticMouseEvent) => {
ev.preventDefault();
ev.stopPropagation();
const currentTarget = ev.currentTarget;
invariant(document.body, 'why you not here');
@ -41,30 +41,34 @@ class DropdownMenu extends Component {
};
render() {
const { className, label, children } = this.props;
return (
<div>
<div className={className}>
<PortalWithState
onOpen={this.props.onOpen}
onClose={this.props.onClose}
closeOnEsc
closeOnOutsideClick
closeOnEsc
>
{({ closePortal, openPortal, portal }) => [
<Label onClick={this.handleOpen(openPortal)} key="label">
{this.props.label}
</Label>,
portal(
<Menu
key="menu"
onClick={closePortal}
style={this.props.style}
top={this.top}
right={this.right}
>
{this.props.children}
</Menu>
),
]}
{({ closePortal, openPortal, portal }) => (
<React.Fragment>
<Label onClick={this.handleOpen(openPortal)}>{label}</Label>
{portal(
<Menu
onClick={ev => {
ev.stopPropagation();
closePortal();
}}
style={this.props.style}
top={this.top}
right={this.right}
>
{children}
</Menu>
)}
</React.Fragment>
)}
</PortalWithState>
</div>
);