StatusBar: update for profile + omnibox

This commit is contained in:
Liam Fitzgerald 2020-08-17 17:37:28 +10:00
parent e3d1293f6a
commit b13d2488a4
5 changed files with 79 additions and 61 deletions

View File

@ -145,6 +145,7 @@ class App extends React.Component {
api={this.api} api={this.api}
connection={this.state.connection} connection={this.state.connection}
subscription={this.subscription} subscription={this.subscription}
ship={this.ship}
/> />
<Omnibox <Omnibox
associations={state.associations} associations={state.associations}

View File

@ -8,7 +8,7 @@ const ReconnectButton = ({ connection, subscription }) => {
return ( return (
<> <>
<Box <Box
ml={4} ml={2}
px={2} px={2}
py={1} py={1}
display='inline-block' display='inline-block'
@ -26,7 +26,7 @@ const ReconnectButton = ({ connection, subscription }) => {
return ( return (
<> <>
<Box <Box
ml={4} ml={2}
px={2} px={2}
py={1} py={1}
lineHeight="min" lineHeight="min"

View File

@ -1,106 +1,79 @@
import React from 'react'; import React from 'react';
import { useLocation } from 'react-router-dom'; import { useLocation } from 'react-router-dom';
import { Box, Text, Icon } from '@tlon/indigo-react'; import { Box, Text, Row } from '@tlon/indigo-react';
import ReconnectButton from './ReconnectButton'; import ReconnectButton from './ReconnectButton';
import { StatusBarItem } from './StatusBarItem';
import { Sigil } from '../lib/sigil';
const StatusBar = (props) => { const StatusBar = (props) => {
const location = useLocation(); const location = useLocation();
const atHome = Boolean(location.pathname === '/'); const atHome = Boolean(location.pathname === '/');
const display = (!window.location.href.includes('popout/')) const display = (!window.location.href.includes('popout/'))
? 'db' : 'dn'; ? 'grid' : 'none';
const invites = (props.invites && props.invites['/contacts']) const invites = (props.invites && props.invites['/contacts'])
? props.invites['/contacts'] ? props.invites['/contacts']
: {}; : {};
const Notification = (Object.keys(invites).length > 0)
? <Icon size="22px" icon="Bullet"
fill="blue" position="absolute"
top={'-8px'} right={'7px'}
/>
: null;
const metaKey = (window.navigator.platform.includes('Mac')) ? '⌘' : 'Ctrl+'; const metaKey = (window.navigator.platform.includes('Mac')) ? '⌘' : 'Ctrl+';
const mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(
navigator.userAgent
);
return ( return (
<div <Box
className={ display={display}
'w-100 justify-between relative tc pt3 ' + display width="100%"
} gridTemplateRows="30px"
style={{ height: 45 }}> gridTemplateColumns="2fr 1fr"
<div className='absolute left-0 pl4' style={{ top: 10 }}> py={2}
px={3}
>
<Row collapse>
{atHome ? null : ( {atHome ? null : (
<Box <StatusBarItem mr={2} onClick={() => props.history.push('/')}>
style={{ cursor: 'pointer' }}
display='inline-block'
borderRadius={2}
color='washedGray'
border={1}
py={1}
px={2}
mr={2}
onClick={() => props.history.push('/')}>
<img <img
className='invert-d' className='invert-d'
src='/~landscape/img/icon-home.png' src='/~landscape/img/icon-home.png'
height='12' height='12'
width='12' width='12'
/> />
</Box> </StatusBarItem>
)} )}
<Box <StatusBarItem onClick={() => props.api.local.setOmnibox()}>
border={1}
borderRadius={2}
color='washedGray'
display='inline-block'
style={{ cursor: 'pointer' }}
lineHeight='min'
py={1}
px={2}
onClick={() => props.api.local.setOmnibox()}>
<Text display='inline-block' style={{ transform: 'rotate(180deg)' }}> <Text display='inline-block' style={{ transform: 'rotate(180deg)' }}>
</Text> </Text>
<Text ml={2} color='black'> <Text ml={2} color='black'>
Leap Leap
</Text> </Text>
<Text display={mobile ? 'none' : 'inline-block'} ml={4} color='gray'> <Text display={['none', 'inline']} ml={4} color='gray'>
{metaKey}/ {metaKey}/
</Text> </Text>
</Box> </StatusBarItem>
<ReconnectButton <ReconnectButton
connection={props.connection} connection={props.connection}
subscription={props.subscription} subscription={props.subscription}
/> />
</div> </Row>
<div className='fl absolute relative right-0 pr4' style={{ top: 10 }}> <Row justifyContent="flex-end" collapse>
<Box <StatusBarItem onClick={() => props.history.push('/~groups')} mr={2} badge={Object.keys(invites).length > 0}>
style={{ cursor: 'pointer' }}
display='inline-block'
borderRadius={2}
color='washedGray'
lineHeight='min'
border={1}
px={2}
py={1}
onClick={() => props.history.push('/~groups')}>
<img <img
className='invert-d v-mid mr1' className='invert-d v-mid'
src='/~landscape/img/groups.png' src='/~landscape/img/groups.png'
height='16' height='16'
width='16' width='16'
/> />
{Notification} <Text display={["none", "inline"]} ml={2}>Groups</Text>
<Text ml={1}>Groups</Text> </StatusBarItem>
</Box> <StatusBarItem onClick={() => props.history.push('/~profile')}>
</div> <Sigil ship={props.ship} size={24} color={"#000000"} classes="dib mix-blend-diff" />
</div> <Text ml={2} display={["none", "inline"]} fontFamily="mono">{props.ship}</Text>
</StatusBarItem>
</Row>
</Box>
); );
}; };

View File

@ -0,0 +1,42 @@
import React, { ReactNode } from "react";
import { Row as _Row, Icon } from "@tlon/indigo-react";
import styled from "styled-components";
const Row = styled(_Row)`
cursor: pointer;
`;
type StatusBarItemProps = Parameters<typeof Row>[0] & { badge?: boolean };
export function StatusBarItem({
badge,
children,
...props
}: StatusBarItemProps) {
return (
<Row
position="relative"
collapse
border={1}
borderRadius={2}
color="washedGray"
bg="white"
alignItems="center"
py={1}
px={2}
{...props}
>
{children}
{badge && (
<Icon
size="22px"
icon="Bullet"
fill="blue"
position="absolute"
top={"-10px"}
right={"-12px"}
/>
)}
</Row>
);
}

View File

@ -38,6 +38,8 @@ export default function index(associations, apps) {
commands.push(obj); commands.push(obj);
} }
}); });
commands.push(result('Profile', '/~profile', 'profile', null));
index.set('commands', commands); index.set('commands', commands);
// all metadata from all apps is indexed // all metadata from all apps is indexed