Refactor
This commit is contained in:
@ -10,11 +10,11 @@ import keydown from 'react-keydown';
|
|||||||
import Flex from 'components/Flex';
|
import Flex from 'components/Flex';
|
||||||
import { color, layout } from 'styles/constants';
|
import { color, layout } from 'styles/constants';
|
||||||
import { documentEditUrl, homeUrl, searchUrl } from 'utils/routeHelpers';
|
import { documentEditUrl, homeUrl, searchUrl } from 'utils/routeHelpers';
|
||||||
|
|
||||||
import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu';
|
import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu';
|
||||||
|
|
||||||
|
import Avatar from 'components/Avatar';
|
||||||
import { LoadingIndicatorBar } from 'components/LoadingIndicator';
|
import { LoadingIndicatorBar } from 'components/LoadingIndicator';
|
||||||
import Scrollable from 'components/Scrollable';
|
import Scrollable from 'components/Scrollable';
|
||||||
import Avatar from 'components/Avatar';
|
|
||||||
import Modal from 'components/Modal';
|
import Modal from 'components/Modal';
|
||||||
import AddIcon from 'components/Icon/AddIcon';
|
import AddIcon from 'components/Icon/AddIcon';
|
||||||
import MoreIcon from 'components/Icon/MoreIcon';
|
import MoreIcon from 'components/Icon/MoreIcon';
|
||||||
@ -26,6 +26,7 @@ import Settings from 'scenes/Settings';
|
|||||||
import SidebarCollection from './components/SidebarCollection';
|
import SidebarCollection from './components/SidebarCollection';
|
||||||
import SidebarCollectionList from './components/SidebarCollectionList';
|
import SidebarCollectionList from './components/SidebarCollectionList';
|
||||||
import SidebarLink from './components/SidebarLink';
|
import SidebarLink from './components/SidebarLink';
|
||||||
|
import HeaderBlock from './components/HeaderBlock';
|
||||||
|
|
||||||
import AuthStore from 'stores/AuthStore';
|
import AuthStore from 'stores/AuthStore';
|
||||||
import UiStore from 'stores/UiStore';
|
import UiStore from 'stores/UiStore';
|
||||||
@ -130,11 +131,7 @@ type Props = {
|
|||||||
user &&
|
user &&
|
||||||
team &&
|
team &&
|
||||||
<Sidebar column editMode={ui.editMode}>
|
<Sidebar column editMode={ui.editMode}>
|
||||||
<Header justify="space-between">
|
<HeaderBlock user={user} team={team}>
|
||||||
<Flex align="center">
|
|
||||||
<LogoLink to="/">{team.name}</LogoLink>
|
|
||||||
{user.username}
|
|
||||||
</Flex>
|
|
||||||
<DropdownMenu label={<Avatar src={user.avatarUrl} />}>
|
<DropdownMenu label={<Avatar src={user.avatarUrl} />}>
|
||||||
<DropdownMenuItem onClick={this.handleOpenSettings}>
|
<DropdownMenuItem onClick={this.handleOpenSettings}>
|
||||||
Settings
|
Settings
|
||||||
@ -149,8 +146,7 @@ type Props = {
|
|||||||
Logout
|
Logout
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</Header>
|
</HeaderBlock>
|
||||||
|
|
||||||
<Flex column>
|
<Flex column>
|
||||||
<Scrollable>
|
<Scrollable>
|
||||||
<LinkSection>
|
<LinkSection>
|
||||||
@ -251,19 +247,6 @@ const Container = styled(Flex)`
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const LogoLink = styled(Link)`
|
|
||||||
margin-top: 15px;
|
|
||||||
font-family: 'Atlas Grotesk';
|
|
||||||
font-weight: bold;
|
|
||||||
color: ${color.text};
|
|
||||||
text-decoration: none;
|
|
||||||
font-size: 16px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MenuLink = styled(Link)`
|
|
||||||
color: ${color.text};
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Content = styled(Flex)`
|
const Content = styled(Flex)`
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -274,6 +257,10 @@ const Content = styled(Flex)`
|
|||||||
transition: left 200ms ease-in-out;
|
transition: left 200ms ease-in-out;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const MenuLink = styled(Link)`
|
||||||
|
color: ${color.text};
|
||||||
|
`;
|
||||||
|
|
||||||
const Sidebar = styled(Flex)`
|
const Sidebar = styled(Flex)`
|
||||||
width: ${layout.sidebarWidth};
|
width: ${layout.sidebarWidth};
|
||||||
margin-left: ${props => (props.editMode ? `-${layout.sidebarWidth}` : 0)};
|
margin-left: ${props => (props.editMode ? `-${layout.sidebarWidth}` : 0)};
|
||||||
@ -282,12 +269,6 @@ const Sidebar = styled(Flex)`
|
|||||||
transition: margin-left 200ms ease-in-out;
|
transition: margin-left 200ms ease-in-out;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Header = styled(Flex)`
|
|
||||||
flex-shrink: 0;
|
|
||||||
padding: ${layout.padding};
|
|
||||||
padding-bottom: 10px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const LinkSection = styled(Flex)`
|
const LinkSection = styled(Flex)`
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
|
42
frontend/components/Layout/components/HeaderBlock.js
Normal file
42
frontend/components/Layout/components/HeaderBlock.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// @flow
|
||||||
|
import React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { color, layout } from 'styles/constants';
|
||||||
|
import type { User, Team } from 'types';
|
||||||
|
import Flex from 'components/Flex';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
user: User,
|
||||||
|
team: Team,
|
||||||
|
children?: React$Element<any>,
|
||||||
|
};
|
||||||
|
|
||||||
|
function HeaderBlock({ user, team, children }: Props) {
|
||||||
|
return (
|
||||||
|
<Header justify="space-between">
|
||||||
|
<Flex align="center">
|
||||||
|
<LogoLink to="/">{team.name}</LogoLink>
|
||||||
|
<p>{user.username}</p>
|
||||||
|
</Flex>
|
||||||
|
{children}
|
||||||
|
</Header>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const LogoLink = styled(Link)`
|
||||||
|
margin-top: 15px;
|
||||||
|
font-family: 'Atlas Grotesk';
|
||||||
|
font-weight: bold;
|
||||||
|
color: ${color.text};
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 16px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Header = styled(Flex)`
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: ${layout.padding};
|
||||||
|
padding-bottom: 10px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default HeaderBlock;
|
Reference in New Issue
Block a user