Add real buttons to document header
Fixed: Incorrect page title when starting a new doc Fixed: Linting error
This commit is contained in:
@ -14,7 +14,7 @@ const RealButton = styled.button`
|
|||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
height: 36px;
|
height: ${props => (props.small ? 24 : 36)}px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
@ -69,9 +69,9 @@ const Label = styled.span`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const Inner = styled.span`
|
const Inner = styled.span`
|
||||||
padding: 0 12px;
|
padding: 0 ${props => (props.small ? 8 : 12)}px;
|
||||||
display: flex;
|
display: flex;
|
||||||
line-height: 28px;
|
line-height: ${props => (props.small ? 24 : 28)}px;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
@ -86,6 +86,7 @@ export type Props = {
|
|||||||
icon?: React.Node,
|
icon?: React.Node,
|
||||||
className?: string,
|
className?: string,
|
||||||
children?: React.Node,
|
children?: React.Node,
|
||||||
|
small?: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Button({
|
export default function Button({
|
||||||
@ -93,14 +94,15 @@ export default function Button({
|
|||||||
icon,
|
icon,
|
||||||
children,
|
children,
|
||||||
value,
|
value,
|
||||||
|
small,
|
||||||
...rest
|
...rest
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const hasText = children !== undefined || value !== undefined;
|
const hasText = children !== undefined || value !== undefined;
|
||||||
const hasIcon = icon !== undefined;
|
const hasIcon = icon !== undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RealButton {...rest}>
|
<RealButton small={small} {...rest}>
|
||||||
<Inner hasIcon={hasIcon}>
|
<Inner hasIcon={hasIcon} small={small}>
|
||||||
{hasIcon && icon}
|
{hasIcon && icon}
|
||||||
{hasText && <Label hasIcon={hasIcon}>{children || value}</Label>}
|
{hasText && <Label hasIcon={hasIcon}>{children || value}</Label>}
|
||||||
</Inner>
|
</Inner>
|
||||||
|
@ -46,7 +46,8 @@ const Modal = ({
|
|||||||
<Content column>
|
<Content column>
|
||||||
{title && <h1>{title}</h1>}
|
{title && <h1>{title}</h1>}
|
||||||
<Close onClick={onRequestClose}>
|
<Close onClick={onRequestClose}>
|
||||||
<CloseIcon size={32} />
|
<CloseIcon size={40} />
|
||||||
|
<Esc>esc</Esc>
|
||||||
</Close>
|
</Close>
|
||||||
{children}
|
{children}
|
||||||
</Content>
|
</Content>
|
||||||
@ -80,6 +81,13 @@ const StyledModal = styled(ReactModal)`
|
|||||||
outline: none;
|
outline: none;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const Esc = styled.span`
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
margin-top: -10px;
|
||||||
|
font-size: 13px;
|
||||||
|
`;
|
||||||
|
|
||||||
const Close = styled.a`
|
const Close = styled.a`
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 16px;
|
top: 16px;
|
||||||
|
@ -4,7 +4,6 @@ import { observable } from 'mobx';
|
|||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { CloseIcon } from 'outline-icons';
|
import { CloseIcon } from 'outline-icons';
|
||||||
import Button from './Button';
|
|
||||||
import Tooltip from './Tooltip';
|
import Tooltip from './Tooltip';
|
||||||
import Flex from 'shared/components/Flex';
|
import Flex from 'shared/components/Flex';
|
||||||
|
|
||||||
|
@ -300,7 +300,9 @@ class DocumentScene extends React.Component<Props> {
|
|||||||
if (!document || !Editor) {
|
if (!document || !Editor) {
|
||||||
return (
|
return (
|
||||||
<Container column auto>
|
<Container column auto>
|
||||||
<PageTitle title={location.state ? location.state.title : ''} />
|
<PageTitle
|
||||||
|
title={location.state ? location.state.title : 'Untitled'}
|
||||||
|
/>
|
||||||
<CenteredContent>
|
<CenteredContent>
|
||||||
<LoadingState />
|
<LoadingState />
|
||||||
</CenteredContent>
|
</CenteredContent>
|
||||||
@ -330,7 +332,7 @@ class DocumentScene extends React.Component<Props> {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<PageTitle
|
<PageTitle
|
||||||
title={document.title.replace(document.emoji, '')}
|
title={document.title.replace(document.emoji, '') || 'Untitled'}
|
||||||
favicon={document.emoji ? emojiToUrl(document.emoji) : undefined}
|
favicon={document.emoji ? emojiToUrl(document.emoji) : undefined}
|
||||||
/>
|
/>
|
||||||
{(this.isUploading || this.isSaving) && <LoadingIndicator />}
|
{(this.isUploading || this.isSaving) && <LoadingIndicator />}
|
||||||
|
@ -15,6 +15,7 @@ import Breadcrumb from './Breadcrumb';
|
|||||||
import DocumentMenu from 'menus/DocumentMenu';
|
import DocumentMenu from 'menus/DocumentMenu';
|
||||||
import NewChildDocumentMenu from 'menus/NewChildDocumentMenu';
|
import NewChildDocumentMenu from 'menus/NewChildDocumentMenu';
|
||||||
import DocumentShare from 'scenes/DocumentShare';
|
import DocumentShare from 'scenes/DocumentShare';
|
||||||
|
import Button from 'components/Button';
|
||||||
import Modal from 'components/Modal';
|
import Modal from 'components/Modal';
|
||||||
import Collaborators from 'components/Collaborators';
|
import Collaborators from 'components/Collaborators';
|
||||||
import { Action, Separator } from 'components/Actions';
|
import { Action, Separator } from 'components/Actions';
|
||||||
@ -126,45 +127,53 @@ class Header extends React.Component<Props> {
|
|||||||
<Status>Saving…</Status>
|
<Status>Saving…</Status>
|
||||||
</Action>
|
</Action>
|
||||||
)}
|
)}
|
||||||
{isDraft && (
|
|
||||||
<Action>
|
|
||||||
<Link
|
|
||||||
onClick={this.handlePublish}
|
|
||||||
title="Publish document (Cmd+Enter)"
|
|
||||||
disabled={savingIsDisabled}
|
|
||||||
highlight
|
|
||||||
>
|
|
||||||
{isPublishing ? 'Publishing…' : 'Publish'}
|
|
||||||
</Link>
|
|
||||||
</Action>
|
|
||||||
)}
|
|
||||||
{!isDraft &&
|
{!isDraft &&
|
||||||
!isEditing &&
|
!isEditing &&
|
||||||
canShareDocuments && (
|
canShareDocuments && (
|
||||||
<Action>
|
<Action>
|
||||||
<Link onClick={this.handleShareLink} title="Share document">
|
<Button
|
||||||
|
onClick={this.handleShareLink}
|
||||||
|
title="Share document"
|
||||||
|
neutral
|
||||||
|
small
|
||||||
|
>
|
||||||
Share
|
Share
|
||||||
</Link>
|
</Button>
|
||||||
</Action>
|
</Action>
|
||||||
)}
|
)}
|
||||||
{isEditing && (
|
{isEditing && (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Action>
|
<Action>
|
||||||
<Link
|
<Button
|
||||||
onClick={this.handleSave}
|
onClick={this.handleSave}
|
||||||
title="Save changes (Cmd+Enter)"
|
title="Save changes (Cmd+Enter)"
|
||||||
disabled={savingIsDisabled}
|
disabled={savingIsDisabled}
|
||||||
isSaving={isSaving}
|
isSaving={isSaving}
|
||||||
highlight={!isDraft}
|
neutral={isDraft}
|
||||||
|
small
|
||||||
>
|
>
|
||||||
{isDraft ? 'Save Draft' : 'Done'}
|
{isDraft ? 'Save Draft' : 'Done Editing'}
|
||||||
</Link>
|
</Button>
|
||||||
</Action>
|
</Action>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)}
|
)}
|
||||||
|
{isDraft && (
|
||||||
|
<Action>
|
||||||
|
<Button
|
||||||
|
onClick={this.handlePublish}
|
||||||
|
title="Publish document (Cmd+Enter)"
|
||||||
|
disabled={savingIsDisabled}
|
||||||
|
small
|
||||||
|
>
|
||||||
|
{isPublishing ? 'Publishing…' : 'Publish'}
|
||||||
|
</Button>
|
||||||
|
</Action>
|
||||||
|
)}
|
||||||
{!isEditing && (
|
{!isEditing && (
|
||||||
<Action>
|
<Action>
|
||||||
<Link onClick={this.handleEdit}>Edit</Link>
|
<Button onClick={this.handleEdit} neutral small>
|
||||||
|
Edit
|
||||||
|
</Button>
|
||||||
</Action>
|
</Action>
|
||||||
)}
|
)}
|
||||||
{!isEditing && (
|
{!isEditing && (
|
||||||
@ -250,15 +259,4 @@ const Title = styled.div`
|
|||||||
`};
|
`};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Link = styled.a`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
font-weight: ${props => (props.highlight ? 500 : 'inherit')};
|
|
||||||
color: ${props =>
|
|
||||||
props.highlight ? `${props.theme.primary} !important` : 'inherit'};
|
|
||||||
opacity: ${props => (props.disabled ? 0.5 : 1)};
|
|
||||||
pointer-events: ${props => (props.disabled ? 'none' : 'auto')};
|
|
||||||
cursor: ${props => (props.disabled ? 'default' : 'pointer')};
|
|
||||||
`;
|
|
||||||
|
|
||||||
export default inject('auth')(Header);
|
export default inject('auth')(Header);
|
||||||
|
Reference in New Issue
Block a user