diff --git a/app/components/Layout.js b/app/components/Layout.js index bc09750c..80cbb5d9 100644 --- a/app/components/Layout.js +++ b/app/components/Layout.js @@ -21,6 +21,8 @@ import Sidebar from 'components/Sidebar'; import SettingsSidebar from 'components/Sidebar/Settings'; import Modals from 'components/Modals'; import DocumentHistory from 'components/DocumentHistory'; +import Modal from 'components/Modal'; +import KeyboardShortcuts from 'scenes/KeyboardShortcuts'; import ErrorSuspended from 'scenes/ErrorSuspended'; import AuthStore from 'stores/AuthStore'; import UiStore from 'stores/UiStore'; @@ -41,6 +43,7 @@ type Props = { class Layout extends React.Component { scrollable: ?HTMLDivElement; @observable redirectTo: ?string; + @observable keyboardShortcutsOpen: boolean = false; componentWillMount() { this.updateBackground(); @@ -54,6 +57,15 @@ class Layout extends React.Component { } } + @keydown('shift+/') + handleOpenKeyboardShortcuts() { + this.keyboardShortcutsOpen = true; + } + + handleCloseKeyboardShortcuts = () => { + this.keyboardShortcutsOpen = false; + }; + updateBackground() { // ensure the wider page color always matches the theme window.document.body.style.background = this.props.theme.background; @@ -71,11 +83,6 @@ class Layout extends React.Component { this.redirectTo = homeUrl(); } - @keydown('shift+/') - openKeyboardShortcuts() { - this.props.ui.setActiveModal('keyboard-shortcuts'); - } - render() { const { auth, ui } = this.props; const { user, team } = auth; @@ -118,6 +125,13 @@ class Layout extends React.Component { + + + ); diff --git a/app/components/Modals.js b/app/components/Modals.js index 203a5d58..64c360e1 100644 --- a/app/components/Modals.js +++ b/app/components/Modals.js @@ -9,7 +9,6 @@ import CollectionDelete from 'scenes/CollectionDelete'; import CollectionExport from 'scenes/CollectionExport'; import DocumentDelete from 'scenes/DocumentDelete'; import DocumentShare from 'scenes/DocumentShare'; -import KeyboardShortcuts from 'scenes/KeyboardShortcuts'; type Props = { ui: UiStore, @@ -55,9 +54,6 @@ class Modals extends React.Component { - - - ); } diff --git a/app/components/Tooltip.js b/app/components/Tooltip.js index c87c48fb..f347f120 100644 --- a/app/components/Tooltip.js +++ b/app/components/Tooltip.js @@ -9,6 +9,7 @@ type Props = { children: React.Node, delay?: number, className?: string, + block?: boolean, }; class Tooltip extends React.Component { @@ -17,7 +18,15 @@ class Tooltip extends React.Component { } render() { - const { tooltip, delay = 50, children, className, ...rest } = this.props; + const { + tooltip, + delay = 50, + children, + block, + className, + ...rest + } = this.props; + const Component = block ? 'div' : 'span'; return ( { inertia {...rest} > - {children} + {children} ); } diff --git a/app/menus/AccountMenu.js b/app/menus/AccountMenu.js index 975240fa..1409049a 100644 --- a/app/menus/AccountMenu.js +++ b/app/menus/AccountMenu.js @@ -1,6 +1,7 @@ // @flow import * as React from 'react'; import { Link } from 'react-router-dom'; +import { observable } from 'mobx'; import { inject, observer } from 'mobx-react'; import { MoonIcon } from 'outline-icons'; import styled, { withTheme } from 'styled-components'; @@ -8,6 +9,8 @@ import UiStore from 'stores/UiStore'; import AuthStore from 'stores/AuthStore'; import Flex from 'shared/components/Flex'; import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu'; +import Modal from 'components/Modal'; +import KeyboardShortcuts from 'scenes/KeyboardShortcuts'; import { developers, changelog, @@ -26,57 +29,74 @@ type Props = { @observer class AccountMenu extends React.Component { - handleOpenKeyboardShortcuts = () => { - this.props.ui.setActiveModal('keyboard-shortcuts'); - }; + @observable keyboardShortcutsOpen: boolean = false; handleLogout = () => { this.props.auth.logout(); }; + handleOpenKeyboardShortcuts = () => { + this.keyboardShortcutsOpen = true; + }; + + handleCloseKeyboardShortcuts = () => { + this.keyboardShortcutsOpen = false; + }; + render() { const { ui, theme } = this.props; const isLightTheme = ui.theme === 'light'; return ( - - - Settings - - - Keyboard shortcuts - - - API documentation - -
- - Changelog - - - Community - - - Send us feedback - - - Report a bug - -
- - - Night Mode{' '} - - - -
- Log out -
+ + + + + + + Settings + + + Keyboard shortcuts + + + API documentation + +
+ + Changelog + + + Community + + + Send us feedback + + + Report a bug + +
+ + + Night Mode{' '} + + + +
+ + Log out + +
+
); } } diff --git a/app/scenes/Document/Document.js b/app/scenes/Document/Document.js index aac98576..5e1ab14f 100644 --- a/app/scenes/Document/Document.js +++ b/app/scenes/Document/Document.js @@ -22,6 +22,7 @@ import { emojiToUrl } from 'utils/emoji'; import Header from './components/Header'; import DocumentMove from './components/DocumentMove'; import Branding from './components/Branding'; +import KeyboardShortcuts from './components/KeyboardShortcuts'; import Backlinks from './components/Backlinks'; import ErrorBoundary from 'components/ErrorBoundary'; import LoadingPlaceholder from 'components/LoadingPlaceholder'; @@ -426,7 +427,7 @@ class DocumentScene extends React.Component { - {isShare && } + {isShare ? : } ); } diff --git a/app/scenes/Document/components/KeyboardShortcuts.js b/app/scenes/Document/components/KeyboardShortcuts.js new file mode 100644 index 00000000..34823fd5 --- /dev/null +++ b/app/scenes/Document/components/KeyboardShortcuts.js @@ -0,0 +1,72 @@ +// @flow +import * as React from 'react'; +import styled from 'styled-components'; +import breakpoint from 'styled-components-breakpoint'; +import { observable } from 'mobx'; +import { observer } from 'mobx-react'; +import { KeyboardIcon } from 'outline-icons'; +import Modal from 'components/Modal'; +import Tooltip from 'components/Tooltip'; +import KeyboardShortcuts from 'scenes/KeyboardShortcuts'; + +type Props = {}; + +@observer +class KeyboardShortcutsButton extends React.Component { + @observable keyboardShortcutsOpen: boolean = false; + + handleOpenKeyboardShortcuts = () => { + this.keyboardShortcutsOpen = true; + }; + + handleCloseKeyboardShortcuts = () => { + this.keyboardShortcutsOpen = false; + }; + + render() { + return ( + + + + + + + ); + } +} + +const Button = styled.button` + display: none; + position: fixed; + bottom: 0; + right: 0; + margin: 24px; + width: 24px; + height: 24px; + opacity: 0.8; + background: none; + line-height: 0; + border: 0; + + &:hover { + opacity: 1; + } + + ${breakpoint('tablet')` + display: block; + `}; + + @media print { + display: none; + } +`; + +export default KeyboardShortcutsButton; diff --git a/app/scenes/KeyboardShortcuts.js b/app/scenes/KeyboardShortcuts.js index adb2d14f..92ce3d34 100644 --- a/app/scenes/KeyboardShortcuts.js +++ b/app/scenes/KeyboardShortcuts.js @@ -10,10 +10,8 @@ function KeyboardShortcuts() { return ( - Outline is designed to be super fast and easy to use. All of your usual - keyboard shortcuts work here, and there - {"'"} - s Markdown too. + Outline is designed to be fast and easy to use. All of your usual + keyboard shortcuts work here, and there’s Markdown too.

Navigation