chat, links: componentise tabBar

This commit is contained in:
Matilde Park 2020-08-19 21:37:20 -04:00
parent 0dbd879443
commit 1fd147f6cb
4 changed files with 42 additions and 81 deletions

View File

@ -1,58 +1,61 @@
import React, { Component, Fragment } from "react"; import React, { Fragment } from 'react';
import { Link } from "react-router-dom"; import { Link } from 'react-router-dom';
import { ChatTabBar } from "./chat-tabbar";
import { SidebarSwitcher } from "~/views/components/SidebarSwitch";
import { deSig } from "~/logic/lib/util";
import { TabBar } from '~/views/components/chat-link-tabbar';
import { SidebarSwitcher } from '~/views/components/SidebarSwitch';
import { deSig } from '~/logic/lib/util';
export const ChatHeader = (props) => { export const ChatHeader = (props) => {
const isInPopout = props.popout ? "popout/" : ""; const isInPopout = props.popout ? 'popout/' : '';
const group = Array.from(props.group.members); const group = Array.from(props.group.members);
let title = props.station.substr(1); let title = props.station.substr(1);
if (props.association && if (props.association &&
"metadata" in props.association && 'metadata' in props.association &&
props.association.metadata.tile !== "") { props.association.metadata.tile !== '') {
title = props.association.metadata.title title = props.association.metadata.title;
} }
return ( return (
<Fragment> <Fragment>
<div <div
className="w-100 dn-m dn-l dn-xl inter pt4 pb6 pl3 f8" className="w-100 dn-m dn-l dn-xl inter pt4 pb6 pl3 f8"
style={{ height: "1rem" }}> style={{ height: '1rem' }}
<Link to="/~chat/">{"⟵ All Chats"}</Link> >
<Link to="/~chat/">{'⟵ All Chats'}</Link>
</div> </div>
<div <div
className={ className={
"pl4 pt2 bb b--gray4 b--gray1-d bg-gray0-d flex relative " + 'pl4 pt2 bb b--gray4 b--gray1-d bg-gray0-d flex relative ' +
"overflow-x-auto overflow-y-hidden flex-shrink-0 " 'overflow-x-auto overflow-y-hidden flex-shrink-0 '
} }
style={{ height: 48 }}> style={{ height: 48 }}
>
<SidebarSwitcher <SidebarSwitcher
sidebarShown={props.sidebarShown} sidebarShown={props.sidebarShown}
popout={props.popout} popout={props.popout}
api={props.api} api={props.api}
/> />
<Link <Link
to={"/~chat/" + isInPopout + "room" + props.station} to={'/~chat/' + isInPopout + 'room' + props.station}
className="pt2 white-d"> className="pt2 white-d"
>
<h2 <h2
className={ className={
"dib f9 fw4 lh-solid v-top " + 'dib f9 fw4 lh-solid v-top ' +
(title === props.station.substr(1) ? "mono" : "") (title === props.station.substr(1) ? 'mono' : '')
} }
style={{ width: "max-content" }}> style={{ width: 'max-content' }}
>
{title} {title}
</h2> </h2>
</Link> </Link>
<ChatTabBar <TabBar
location={props.location} location={props.location}
station={props.station} popoutHref={`/~chat/popout/room${props.station}`}
isOwner={deSig(props.match.params.ship) === window.ship} settings={`/~chat/${isInPopout}settings${props.station}`}
popout={props.popout} popout={props.popout}
/> />
</div> </div>
</Fragment> </Fragment>
); );
} };

View File

@ -1,48 +0,0 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { makeRoutePath } from '~/logic/lib/util';
export class LinksTabBar extends Component {
render() {
const props = this.props;
let setColor = '';
if (props.location.pathname.includes('/settings')) {
setColor = 'black white-d';
} else {
setColor = 'gray3';
}
const hidePopoutIcon = (props.popout)
? 'dn-m dn-l dn-xl'
: 'dib-m dib-l dib-xl';
return (
<div className="dib flex-shrink-0 flex-grow-1">
<div className={'dib pt2 f9 pl6 pr6 lh-solid'}>
<Link
className={'no-underline ' + setColor}
to={makeRoutePath(props.resourcePath, props.popout) + '/settings'}
>
Settings
</Link>
</div>
<a href={makeRoutePath(props.resourcePath, true, props.page)}
target="_blank"
rel="noopener noreferrer"
className="dib fr pt2 pr1"
>
<img
className={'flex-shrink-0 pr3 dn ' + hidePopoutIcon}
src="/~link/img/popout.png"
height="16"
width="16"
/>
</a>
</div>
);
}
}
export default LinksTabBar;

View File

@ -1,5 +1,5 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { LinksTabBar } from './lib/links-tabbar'; import { TabBar } from '~/views/components/chat-link-tabbar';
import { LinkPreview } from './lib/link-detail-preview'; import { LinkPreview } from './lib/link-detail-preview';
import { SidebarSwitcher } from '~/views/components/SidebarSwitch'; import { SidebarSwitcher } from '~/views/components/SidebarSwitch';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
@ -147,7 +147,12 @@ export class LinkDetail extends Component {
> >
{`<- ${props.resource.metadata.title}`} {`<- ${props.resource.metadata.title}`}
</Link> </Link>
<LinksTabBar {...props} popout={props.popout} resourcePath={props.resourcePath} /> <TabBar
location={props.location}
popout={props.popout}
popoutHref={makeRoutePath(props.resourcePath, true, props.page)}
settings={makeRoutePath(props.resourcePath, props.popout) + '/settings'}
/>
</div> </div>
<div className="w-100 mt2 flex justify-center overflow-y-scroll ph4 pb4"> <div className="w-100 mt2 flex justify-center overflow-y-scroll ph4 pb4">
<div className="w-100 mw7"> <div className="w-100 mw7">

View File

@ -1,10 +1,11 @@
import React, { Component } from 'react'; import React from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
export const ChatTabBar = (props) => { export const TabBar = (props) => {
const { const {
location, location,
station settings,
popoutHref
} = props; } = props;
let setColor = '', popout = ''; let setColor = '', popout = '';
@ -22,11 +23,11 @@ export const ChatTabBar = (props) => {
<div className={'dib pt2 f9 pl6 pr6 lh-solid'}> <div className={'dib pt2 f9 pl6 pr6 lh-solid'}>
<Link <Link
className={'no-underline ' + setColor} className={'no-underline ' + setColor}
to={'/~chat/' + popout + 'settings' + station}> to={settings}>
Settings Settings
</Link> </Link>
</div> </div>
<a href={'/~chat/popout/room' + station} rel="noopener noreferrer" <a href={popoutHref} rel="noopener noreferrer"
target="_blank" target="_blank"
className="dib fr pr1" className="dib fr pr1"
style={{ paddingTop: '8px' }}> style={{ paddingTop: '8px' }}>
@ -38,4 +39,4 @@ export const ChatTabBar = (props) => {
</a> </a>
</div> </div>
); );
} };