Added: Dashboard help tip

This commit is contained in:
Tom Moor
2018-12-25 17:12:37 -08:00
parent e08cb10b7f
commit 96b1d6257e
3 changed files with 124 additions and 1 deletions

59
app/components/Tip.js Normal file
View File

@@ -0,0 +1,59 @@
// @flow
import * as React from 'react';
import styled from 'styled-components';
import { CloseIcon } from 'outline-icons';
import Button from './Button';
import Tooltip from './Tooltip';
import Flex from 'shared/components/Flex';
type Props = {
id: string,
children: React.Node,
};
type State = {
isHidden: boolean,
};
class Tip extends React.Component<Props, State> {
state = {
isHidden: window.localStorage.getItem(this.storageId) === 'hidden',
};
get storageId() {
return `tip-${this.props.id}`;
}
hide = () => {
window.localStorage.setItem(this.storageId, 'hidden');
this.setState({ isHidden: true });
};
render() {
const { children } = this.props;
if (this.state.isHidden) return null;
return (
<Wrapper align="center">
<span>{children}</span>
<Tooltip tooltip="Hide this message" placement="bottom">
<Button
onClick={this.hide}
icon={<CloseIcon type="close" size={32} color="#FFF" />}
/>
</Tooltip>
</Wrapper>
);
}
}
const Wrapper = styled(Flex)`
background: ${props => props.theme.primary};
color: ${props => props.theme.text};
padding: 8px 16px;
border-radius: 4px;
font-weight: 400;
`;
export default Tip;

View File

@@ -0,0 +1,62 @@
// @flow
import * as React from 'react';
import styled from 'styled-components';
import Tip from './Tip';
import CopyToClipboard from './CopyToClipboard';
import Team from '../models/Team';
type Props = {
team: Team,
};
type State = {
linkCopied: boolean,
};
class TipInvite extends React.Component<Props, State> {
state = {
linkCopied: false,
};
handleCopy = () => {
this.setState({ linkCopied: true });
};
render() {
const { team } = this.props;
return (
<Tip id="subdomain-invite">
<Heading>Looking to invite your team?</Heading>
<Paragraph>
Your teammates can sign in with{' '}
{team.slackConnected ? 'Slack' : 'Google'} to join this knowledgebase
at your teams own subdomain ({team.url.replace(/^https?:\/\//, '')})
{' '}
<CopyToClipboard text={team.url} onCopy={this.handleCopy}>
<a>
{this.state.linkCopied
? 'link copied to clipboard!'
: 'copy a link to share.'}
</a>
</CopyToClipboard>
</Paragraph>
</Tip>
);
}
}
const Heading = styled.h3`
margin: 0.25em 0 0.5em 0;
`;
const Paragraph = styled.p`
margin: 0.25em 0;
a {
color: ${props => props.theme.text};
text-decoration: underline;
}
`;
export default TipInvite;

View File

@@ -12,6 +12,7 @@ import CenteredContent from 'components/CenteredContent';
import PageTitle from 'components/PageTitle';
import Tabs from 'components/Tabs';
import Tab from 'components/Tab';
import TipInvite from 'components/TipInvite';
import PaginatedDocumentList from '../components/PaginatedDocumentList';
type Props = {
@@ -23,11 +24,12 @@ type Props = {
class Dashboard extends React.Component<Props> {
render() {
const { documents, auth } = this.props;
if (!auth.user) return null;
if (!auth.user || !auth.team) return null;
const user = auth.user.id;
return (
<CenteredContent>
{auth.team.subdomain && <TipInvite team={auth.team} />}
<PageTitle title="Home" />
<h1>Home</h1>
<Tabs>