diff --git a/app/components/Sidebar/Main.js b/app/components/Sidebar/Main.js index 0457fa225..10e7f5765 100644 --- a/app/components/Sidebar/Main.js +++ b/app/components/Sidebar/Main.js @@ -7,8 +7,9 @@ import { HomeIcon, EditIcon, SearchIcon, StarredIcon } from 'outline-icons'; import Flex from 'shared/components/Flex'; import AccountMenu from 'menus/AccountMenu'; -import Sidebar, { Section } from './Sidebar'; +import Sidebar from './Sidebar'; import Scrollable from 'components/Scrollable'; +import Section from './components/Section'; import Collections from './components/Collections'; import SidebarLink from './components/SidebarLink'; import HeaderBlock from './components/HeaderBlock'; @@ -56,24 +57,31 @@ class MainSidebar extends React.Component {
- } exact={false}> - Home - - }> - Search - - } exact={false}> - Starred - + } + exact={false} + label="Home" + /> + } label="Search" /> + } + exact={false} + label="Starred" + /> } active={ documents.active ? !documents.active.publishedAt : undefined } - > - Drafts - + label={ + + Drafts + + } + />
{
Account
- }> - Profile - - }> - Notifications - - }> - API Tokens - + } + label="Profile" + /> + } + label="Notifications" + /> + } + label="API Tokens" + />
Team
{user.isAdmin && ( - }> - Details - + } + label="Details" + /> )} {user.isAdmin && ( - }> - Security - + } + label="Security" + /> )} } exact={false} - > - People - - }> - Share Links - + label="People" + /> + } + label="Share Links" + /> {user.isAdmin && ( - }> - Export Data - + } + label="Export Data" + /> )}
{user.isAdmin && ( @@ -94,15 +108,13 @@ class SettingsSidebar extends React.Component { } - > - Slack - + label="Slack" + /> } - > - Zapier - + label="Zapier" + />
)}
diff --git a/app/components/Sidebar/Sidebar.js b/app/components/Sidebar/Sidebar.js index f69ac1620..5668ccbbf 100644 --- a/app/components/Sidebar/Sidebar.js +++ b/app/components/Sidebar/Sidebar.js @@ -88,13 +88,6 @@ const Container = styled(Flex)` `}; `; -export const Section = styled(Flex)` - flex-direction: column; - margin: 24px 0; - padding: 0 24px; - position: relative; -`; - const Toggle = styled.a` position: fixed; top: 0; diff --git a/app/components/Sidebar/components/Bubble.js b/app/components/Sidebar/components/Bubble.js index 03377d93d..7710dfcf1 100644 --- a/app/components/Sidebar/components/Bubble.js +++ b/app/components/Sidebar/components/Bubble.js @@ -18,9 +18,11 @@ const Wrapper = styled.div` color: ${props => props.theme.white}; background: ${props => props.theme.slateDark}; display: inline-block; - min-width: 15px; - padding: 0 5px; + font-feature-settings: "tnum"; + font-weight: 500; font-size: 10px; + min-width: 15px; + padding: 0 4px; position: relative; top: -2px; left: 2px; diff --git a/app/components/Sidebar/components/CollectionLink.js b/app/components/Sidebar/components/CollectionLink.js index dbdb73352..252490cc9 100644 --- a/app/components/Sidebar/components/CollectionLink.js +++ b/app/components/Sidebar/components/CollectionLink.js @@ -3,7 +3,6 @@ import * as React from 'react'; import { observer } from 'mobx-react'; import { observable } from 'mobx'; import { CollectionIcon, PrivateCollectionIcon } from 'outline-icons'; -import styled from 'styled-components'; import Collection from 'models/Collection'; import Document from 'models/Document'; import CollectionMenu from 'menus/CollectionMenu'; @@ -56,23 +55,10 @@ class CollectionLink extends React.Component { ) } iconColor={collection.color} - expand={expanded} - hideExpandToggle + expanded={expanded} + hideDisclosure menuOpen={this.menuOpen} - expandedContent={ - - {collection.documents.map(document => ( - - ))} - - } + label={collection.name} menu={ { /> } > - - {collection.name} - + + {collection.documents.map(document => ( + + ))} + ); } } -const CollectionName = styled(Flex)` - padding: 0 0 4px; -`; - -const CollectionChildren = styled(Flex)` - margin-top: -4px; - margin-left: 36px; - padding-bottom: 4px; -`; - export default CollectionLink; diff --git a/app/components/Sidebar/components/Collections.js b/app/components/Sidebar/components/Collections.js index 9e7c2076d..330db016e 100644 --- a/app/components/Sidebar/components/Collections.js +++ b/app/components/Sidebar/components/Collections.js @@ -50,9 +50,8 @@ class Collections extends React.Component { } - > - New collection… - + label="New collection…" + />
); diff --git a/app/components/Sidebar/components/DocumentLink.js b/app/components/Sidebar/components/DocumentLink.js index ce9d324f5..77c20be28 100644 --- a/app/components/Sidebar/components/DocumentLink.js +++ b/app/components/Sidebar/components/DocumentLink.js @@ -46,6 +46,7 @@ class DocumentLink extends React.Component { .includes(document.id) || isActiveDocument) ); + const hasChildren = !!document.children.length; return ( { pathname: document.url, state: { title: document.title }, }} - expand={showChildren} - expandedContent={ - document.children.length ? ( - - {document.children.map(childDocument => ( - - ))} - - ) : ( - undefined - ) - } + expanded={showChildren} + label={document.title} + depth={depth} > - {document.title} + {hasChildren && ( + + {document.children.map(childDocument => ( + + ))} + + )} @@ -92,9 +90,6 @@ class DocumentLink extends React.Component { } } -const DocumentChildren = styled(Flex)` - margin-top: -4px; - margin-left: 12px; -`; +const DocumentChildren = styled(Flex)``; export default DocumentLink; diff --git a/app/components/Sidebar/components/Header.js b/app/components/Sidebar/components/Header.js index 0e3e94815..48c7405df 100644 --- a/app/components/Sidebar/components/Header.js +++ b/app/components/Sidebar/components/Header.js @@ -8,7 +8,7 @@ const Header = styled(Flex)` text-transform: uppercase; color: ${props => props.theme.slateDark}; letter-spacing: 0.04em; - margin-bottom: 4px; + margin: 4px 16px; `; export default Header; diff --git a/app/components/Sidebar/components/Section.js b/app/components/Sidebar/components/Section.js new file mode 100644 index 000000000..df8d97ce1 --- /dev/null +++ b/app/components/Sidebar/components/Section.js @@ -0,0 +1,11 @@ +// @flow +import styled from 'styled-components'; +import Flex from 'shared/components/Flex'; + +const Section = styled(Flex)` + position: relative; + flex-direction: column; + margin: 24px 8px; +`; + +export default Section; diff --git a/app/components/Sidebar/components/SidebarLink.js b/app/components/Sidebar/components/SidebarLink.js index b459d6add..82577590a 100644 --- a/app/components/Sidebar/components/SidebarLink.js +++ b/app/components/Sidebar/components/SidebarLink.js @@ -7,78 +7,52 @@ import { CollapsedIcon } from 'outline-icons'; import styled, { withTheme } from 'styled-components'; import Flex from 'shared/components/Flex'; -const StyledGoTo = styled(CollapsedIcon)` - margin-bottom: -4px; - margin-left: 1px; - margin-right: -3px; - ${({ expanded }) => !expanded && 'transform: rotate(-90deg);'}; -`; - -const IconWrapper = styled.span` - margin-left: -4px; - margin-right: 4px; - height: 24px; -`; - -const StyledNavLink = styled(NavLink)` - display: flex; - width: 100%; - position: relative; - overflow: hidden; - text-overflow: ellipsis; - padding: 4px 0; - margin-left: ${props => (props.icon ? '-20px;' : '0')}; - color: ${props => props.theme.slateDark}; - font-size: 15px; - cursor: pointer; - - &:hover { - color: ${props => props.theme.text}; - } -`; - type Props = { to?: string | Object, onClick?: (SyntheticEvent<*>) => *, children?: React.Node, icon?: React.Node, - expand?: boolean, - expandedContent?: React.Node, + expanded?: boolean, + label?: React.Node, menu?: React.Node, menuOpen?: boolean, - hideExpandToggle?: boolean, + hideDisclosure?: boolean, iconColor?: string, active?: boolean, theme: Object, exact?: boolean, + depth?: number, }; @observer class SidebarLink extends React.Component { - @observable expanded: boolean = false; - activeStyle: Object; + @observable expanded: boolean; - constructor(props) { - super(props); + style = { + paddingLeft: `${(this.props.depth || 0) * 16 + 16}px`, + }; - this.activeStyle = { - color: props.theme.black, - fontWeight: 500, - }; - } + activeStyle = { + color: this.props.theme.text, + background: 'rgba(0, 0, 0, 0.05)', + fontWeight: 600, + ...this.style, + }; componentDidMount() { - if (this.props.expand) this.handleExpand(); + if (this.props.expanded) this.handleExpand(); } componentWillReceiveProps(nextProps: Props) { - if (nextProps.expand) this.handleExpand(); + if (nextProps.expanded !== undefined) { + this.expanded = nextProps.expanded; + } } @action - handleClick = (event: SyntheticEvent<*>) => { - event.preventDefault(); - event.stopPropagation(); + handleClick = (ev: SyntheticEvent<*>) => { + ev.preventDefault(); + ev.stopPropagation(); this.expanded = !this.expanded; }; @@ -93,47 +67,69 @@ class SidebarLink extends React.Component { children, onClick, to, - expandedContent, - expand, + label, active, menu, menuOpen, - hideExpandToggle, + hideDisclosure, exact, } = this.props; - const showExpandIcon = - expandedContent && !hideExpandToggle ? true : undefined; + const showDisclosure = !!children && !hideDisclosure; return ( {icon && {icon}} - {showExpandIcon && ( - - )} - {children} + - {/* Collection */ expand && hideExpandToggle && expandedContent} - {/* Document */ this.expanded && !hideExpandToggle && expandedContent} + {this.expanded && children} {menu && {menu}} ); } } +// accounts for whitespace around icon +const IconWrapper = styled.span` + margin-left: -4px; + margin-right: 4px; + height: 24px; +`; + +const StyledNavLink = styled(NavLink)` + display: flex; + position: relative; + overflow: hidden; + text-overflow: ellipsis; + padding: 4px 16px; + border-radius: 4px; + color: ${props => props.theme.slateDark}; + font-size: 15px; + cursor: pointer; + + &:hover { + color: ${props => props.theme.text}; + } +`; + const Action = styled.span` position: absolute; - right: 0; - top: 2px; + top: 4px; + right: 4px; color: ${props => props.theme.slate}; + svg { opacity: 0.75; } @@ -159,9 +155,17 @@ const Wrapper = styled(Flex)` } `; -const Content = styled.div` +const Label = styled.div` + position: relative; width: 100%; - max-height: 4em; + max-height: 4.4em; +`; + +const Disclosure = styled(CollapsedIcon)` + position: absolute; + left: -24px; + + ${({ expanded }) => !expanded && 'transform: rotate(-90deg);'}; `; export default withRouter(withTheme(SidebarLink)); diff --git a/app/scenes/Document/components/Breadcrumb.js b/app/scenes/Document/components/Breadcrumb.js index ca680a9cc..61496c260 100644 --- a/app/scenes/Document/components/Breadcrumb.js +++ b/app/scenes/Document/components/Breadcrumb.js @@ -35,7 +35,10 @@ const Breadcrumb = observer(({ document, collections }: Props) => { {path.map(n => ( - {n.title} + {' '} + + {n.title} + ))}