publish: sidebar switch + popout to notebook.js

This commit is contained in:
Matilde Park 2020-02-12 20:17:13 -05:00
parent 213ab1e0a9
commit 778ba9849d
9 changed files with 38 additions and 60 deletions

View File

@ -96,7 +96,7 @@ a {
.NewPost { .NewPost {
width: 100%; width: 100%;
height: calc(100% - 103px); height: calc(100% - 115px);
display: flex; display: flex;
padding-top: 8px; padding-top: 8px;
} }

View File

@ -1,16 +0,0 @@
import React, { Component } from 'react';
//TODO "About" subcomponent of Notebook.js
//Fill in with "description" from props.notebook
export class About extends Component {
render() {
return (
<p className="f8 lh-solid">
</p>
)
}
}
export default About

View File

@ -46,8 +46,9 @@ export class NewPost extends Component {
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
let notebook = this.props.notebooks[this.props.ship][this.props.book]; let notebook = this.props.notebooks[this.props.ship][this.props.book];
if (notebook.notes[this.state.awaiting]) { if (notebook.notes[this.state.awaiting]) {
let popout = (this.props.popout) ? "popout/" : "";
let redirect = let redirect =
`/~publish/note/${this.props.ship}/${this.props.book}/${this.state.awaiting}`; `/~publish/${popout}note/${this.props.ship}/${this.props.book}/${this.state.awaiting}`;
this.props.history.push(redirect); this.props.history.push(redirect);
} }
} }
@ -82,13 +83,12 @@ export class NewPost extends Component {
? { color: '#2AA779', cursor: "pointer" } ? { color: '#2AA779', cursor: "pointer" }
: { color: '#B1B2B3', cursor: "auto" }; : { color: '#B1B2B3', cursor: "auto" };
let publishHrefIndex = props.location.pathname.indexOf("/notebook/"); let hrefIndex = props.location.pathname.indexOf("/notebook/");
let publishsubStr = props.location.pathname.substr(publishHrefIndex) let publishsubStr = props.location.pathname.substr(hrefIndex)
let popoutHref = `/~publish/popout${publishsubStr}`; let popoutHref = `/~publish/popout${publishsubStr}`;
let hiddenOnPopout = (props.popout) let hiddenOnPopout = (props.popout)
? "" ? "" : "dib-m dib-l dib-xl";
: "dib-m dib-l dib-xl"
return ( return (
<div className="f9 h-100 relative"> <div className="f9 h-100 relative">

View File

@ -1,16 +0,0 @@
import React, { Component } from 'react'
//TODO render props from notebook.js as a div of individual notes in the
//notebook
export class NoteItem extends Component {
render() {
return (
<div>
</div>
)
}
}
export default NoteItem

View File

@ -1,15 +0,0 @@
import React, { Component } from 'react';
import { NoteItem } from './note-item';
//TODO map a list of NoteItems
export class NoteList extends Component {
render() {
return (
<div>
</div>
)
}
}
export default NoteList

View File

@ -55,7 +55,8 @@ export class NotebookPosts extends Component {
comment = `${note["num-comments"]} Comments`; comment = `${note["num-comments"]} Comments`;
} }
let date = moment(note["date-created"]).fromNow(); let date = moment(note["date-created"]).fromNow();
let url = `/~publish/note/${props.host}/${props.notebookName}/${noteId}` let popout = (props.popout) ? "popout/" : "";
let url = `/~publish/${popout}note/${props.host}/${props.notebookName}/${noteId}`
notes.push( notes.push(
<Link key={i} to={url}> <Link key={i} to={url}>

View File

@ -1,10 +1,10 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Link, Switch, Route } from 'react-router-dom'; import { Link, Switch, Route } from 'react-router-dom';
import { NoteList } from './note-list'; import { SidebarSwitcher } from './icons/icon-sidebar-switch';
import { NotebookPosts } from './notebook-posts'; import { NotebookPosts } from './notebook-posts';
import { About } from './about';
import { Subscribers } from './subscribers'; import { Subscribers } from './subscribers';
import { Settings } from './settings'; import { Settings } from './settings';
import Sidebar from './sidebar';
//TODO subcomponent logic for subscribers, settings //TODO subcomponent logic for subscribers, settings
@ -71,6 +71,13 @@ export class Notebook extends Component {
render() { render() {
const { props } = this; const { props } = this;
// popout logic
let hrefIndex = props.location.pathname.indexOf("/notebook/");
let publishsubStr = props.location.pathname.substr(hrefIndex);
let popoutHref = `/~publish/popout${publishsubStr}`;
let hiddenOnPopout = props.popout ? "" : "dib-m dib-l dib-xl";
let notebook = props.notebooks[props.ship][props.book]; let notebook = props.notebooks[props.ship][props.book];
let tabStyles = { let tabStyles = {
@ -87,6 +94,7 @@ export class Notebook extends Component {
let notesList = notebook["notes-by-date"] || []; let notesList = notebook["notes-by-date"] || [];
let notes = notebook.notes || null; let notes = notebook.notes || null;
inner = <NotebookPosts notes={notes} inner = <NotebookPosts notes={notes}
popout={props.popout}
list={notesList} list={notesList}
host={props.ship} host={props.ship}
notebookName={props.book} notebookName={props.book}
@ -106,6 +114,7 @@ export class Notebook extends Component {
break; break;
} }
// displaying nicknames, sigil colors for contacts
let contact = !!(props.ship.substr(1) in props.contacts) let contact = !!(props.ship.substr(1) in props.contacts)
? props.contacts[props.ship.substr(1)] : false; ? props.contacts[props.ship.substr(1)] : false;
let name = props.ship; let name = props.ship;
@ -114,7 +123,8 @@ export class Notebook extends Component {
? contact.nickname : props.ship; ? contact.nickname : props.ship;
} }
let base = `/~publish/notebook/${props.ship}/${props.book}`; let popout = (props.popout) ? "popout/" : "";
let base = `/~publish/${popout}notebook/${props.ship}/${props.book}`;
let about = base + '/about'; let about = base + '/about';
let subs = base + '/subscribers'; let subs = base + '/subscribers';
let settings = base + '/settings'; let settings = base + '/settings';
@ -142,6 +152,20 @@ export class Notebook extends Component {
<div <div
className="center mw6 f9 h-100" className="center mw6 f9 h-100"
style={{ paddingLeft: 16, paddingRight: 16 }}> style={{ paddingLeft: 16, paddingRight: 16 }}>
<SidebarSwitcher
popout={props.popout}
sidebarShown={props.sidebarShown}
/>
<Link
className={"dn absolute right-1 top-1 " + hiddenOnPopout}
to={popoutHref}
target="_blank"
>
<img src="/~publish/popout.png"
height={16}
width={16}
/>
</Link>
<div <div
className="h-100 overflow-container no-scrollbar" className="h-100 overflow-container no-scrollbar"
onScroll={this.onScroll} onScroll={this.onScroll}
@ -155,7 +179,7 @@ export class Notebook extends Component {
<div className="mb1">{notebook.title}</div> <div className="mb1">{notebook.title}</div>
<span> <span>
<span className="gray3 mr1">by</span> <span className="gray3 mr1">by</span>
<span className={(props.ship === name) ? "mono" : ""}> <span className={props.ship === name ? "mono" : ""}>
{name} {name}
</span> </span>
</span> </span>

View File

@ -126,7 +126,7 @@ export class Root extends Component {
else { else {
return ( return (
<Skeleton <Skeleton
popout={false} popout={popout}
active={"rightPanel"} active={"rightPanel"}
rightPanelHide={false} rightPanelHide={false}
sidebarShown={state.sidebarShown} sidebarShown={state.sidebarShown}

View File

@ -33,7 +33,7 @@ export class Skeleton extends Component {
path={props.path} path={props.path}
invites={props.invites} invites={props.invites}
/> />
<div className={"h-100 w-100 " + rightPanelHide} style={{ <div className={"h-100 w-100 relative " + rightPanelHide} style={{
flexGrow: 1, flexGrow: 1,
}}> }}>
{props.children} {props.children}