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:
@ -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>
|
||||
);
|
||||
|
Reference in New Issue
Block a user