Merge pull request #217 from jorilallo/jori/cosmetics

Cosmetics tweaks
This commit is contained in:
Jori Lallo
2017-09-11 22:14:47 -07:00
committed by GitHub
7 changed files with 51 additions and 28 deletions

View File

@ -25,15 +25,20 @@ const Collaborators = function({ document }: { document: Document }) {
return (
<Avatars>
<Tooltip tooltip={tooltip} placement="bottom">
<StyledTooltip tooltip={tooltip} placement="bottom">
{collaborators.map(user => (
<Avatar key={user.id} src={user.avatarUrl} />
))}
</Tooltip>
</StyledTooltip>
</Avatars>
);
};
const StyledTooltip = styled(Tooltip)`
display: flex;
flex-direction: row-reverse;
`;
const Avatars = styled(Flex)`
flex-direction: row-reverse;
height: 26px;
@ -45,7 +50,7 @@ const Avatar = styled.img`
flex-shrink: 0;
border-radius: 50%;
border: 2px solid ${color.white};
margin-right: -13px;
margin-right: -10px;
&:first-child {
margin-right: 0;

View File

@ -15,13 +15,18 @@ type Props = {
innerRef?: Function,
};
const StyledStar = styled(Icon).attrs({
const StyledStar = styled(({ solid, ...props }) => <Icon {...props} />).attrs({
type: 'Star',
color: color.text,
})`
width: 16px;
height: 16px;
top: 1px;
margin-left: 4px;
opacity: ${props => (props.solid ? '1 !important' : 0)};
transition: opacity 100ms ease-in-out;
${props => props.solid && 'polygon { fill: #000};'}
`;
const DocumentLink = styled(Link)`

View File

@ -92,12 +92,15 @@ const MenuItem = styled.div`
cursor: pointer;
border-left: 2px solid transparent;
color: ${color.text};
span {
margin-top: 2px;
}
a {
text-decoration: none;
color: ${color.text};
width: 100%;
}

View File

@ -3,7 +3,6 @@ import styled from 'styled-components';
import { color } from 'styles/constants';
const HelpText = styled.p`
user-select: none;
color: ${color.slateDark};
`;

View File

@ -1,11 +1,16 @@
// @flow
import React from 'react';
import _ from 'lodash';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import styled from 'styled-components';
import Mask from './components/Mask';
import Flex from 'components/Flex';
export default (props: Object) => {
type Props = {
count?: number,
};
const ListPlaceHolder = ({ count }: Props) => {
return (
<ReactCSSTransitionGroup
transitionName="fadeIn"
@ -16,14 +21,12 @@ export default (props: Object) => {
transitionEnter
transitionLeave
>
<Item column auto>
<Mask header />
<Mask />
</Item>
<Item column auto>
<Mask header />
<Mask />
</Item>
{_.times(count || 2, index => (
<Item key={index} column auto>
<Mask header />
<Mask />
</Item>
))}
</ReactCSSTransitionGroup>
);
};
@ -31,3 +34,5 @@ export default (props: Object) => {
const Item = styled(Flex)`
padding: 18px 0;
`;
export default ListPlaceHolder;

View File

@ -1,9 +1,11 @@
// @flow
import React from 'react';
import { observable } from 'mobx';
import { observer, inject } from 'mobx-react';
import styled from 'styled-components';
import DocumentsStore from 'stores/DocumentsStore';
import Flex from 'components/Flex';
import DocumentList from 'components/DocumentList';
import PageTitle from 'components/PageTitle';
import CenteredContent from 'components/CenteredContent';
@ -26,29 +28,33 @@ type Props = {
@observer class Dashboard extends React.Component {
props: Props;
@observable isLoaded = false;
componentDidMount() {
this.props.documents.fetchRecentlyModified({ limit: 5 });
this.props.documents.fetchRecentlyViewed({ limit: 5 });
this.loadContent();
}
get showPlaceholder() {
const { isLoaded, isFetching } = this.props.documents;
return !isLoaded && isFetching;
}
loadContent = async () => {
await Promise.all([
this.props.documents.fetchRecentlyModified({ limit: 5 }),
this.props.documents.fetchRecentlyViewed({ limit: 5 }),
]);
this.isLoaded = true;
};
render() {
return (
<CenteredContent>
<PageTitle title="Home" />
<h1>Home</h1>
<Subheading>Recently viewed</Subheading>
{this.showPlaceholder && <ListPlaceholder />}
<DocumentList documents={this.props.documents.recentlyViewed} />
<Subheading>Recently edited</Subheading>
<DocumentList documents={this.props.documents.recentlyEdited} />
{this.showPlaceholder && <ListPlaceholder />}
{this.isLoaded
? <Flex column>
<Subheading>Recently viewed</Subheading>
<DocumentList documents={this.props.documents.recentlyViewed} />
<Subheading>Recently edited</Subheading>
<DocumentList documents={this.props.documents.recentlyEdited} />
</Flex>
: <ListPlaceholder count={5} />}
</CenteredContent>
);
}

View File

@ -88,7 +88,7 @@ class DocumentsStore extends BaseStore {
};
@action fetchRecentlyModified = async (options: ?Object): Promise<*> => {
return this.fetchAll('list', options);
return await this.fetchAll('list', options);
};
@action fetchRecentlyViewed = async (options: ?Object): Promise<*> => {