From b44487494472ac79a852e45ba170ee80187a40af Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 9 Jun 2020 20:38:34 -0700 Subject: [PATCH] fix: Shared documents with system in dark mode display partially on light background closes #1300 --- app/components/Layout.js | 10 ++++----- app/scenes/Document/components/Document.js | 25 ++++++++++++++++++---- shared/components/Branding.js | 14 ++++++------ 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/app/components/Layout.js b/app/components/Layout.js index acbdd4063..d48ce0f4e 100644 --- a/app/components/Layout.js +++ b/app/components/Layout.js @@ -57,6 +57,11 @@ class Layout extends React.Component { } } + updateBackground() { + // ensure the wider page color always matches the theme + window.document.body.style.background = this.props.theme.background; + } + @keydown('shift+/') handleOpenKeyboardShortcuts() { if (this.props.ui.editMode) return; @@ -67,11 +72,6 @@ class Layout extends React.Component { this.keyboardShortcutsOpen = false; }; - updateBackground() { - // ensure the wider page color always matches the theme - window.document.body.style.background = this.props.theme.background; - } - @keydown(['t', '/', 'meta+k']) goToSearch(ev) { if (this.props.ui.editMode) return; diff --git a/app/scenes/Document/components/Document.js b/app/scenes/Document/components/Document.js index c91aca205..da1a6855e 100644 --- a/app/scenes/Document/components/Document.js +++ b/app/scenes/Document/components/Document.js @@ -1,7 +1,7 @@ // @flow import * as React from 'react'; import { debounce } from 'lodash'; -import styled from 'styled-components'; +import styled, { withTheme } from 'styled-components'; import breakpoint from 'styled-components-breakpoint'; import { observable } from 'mobx'; import { observer, inject } from 'mobx-react'; @@ -59,6 +59,7 @@ type Props = { revision: Revision, readOnly: boolean, onSearchLink: (term: string) => mixed, + theme: Object, auth: AuthStore, ui: UiStore, }; @@ -87,6 +88,7 @@ class DocumentScene extends React.Component { componentDidMount() { this.updateIsDirty(); + this.updateBackground(); } componentDidUpdate(prevProps) { @@ -110,6 +112,14 @@ class DocumentScene extends React.Component { ); } } + + this.updateBackground(); + } + + updateBackground() { + // ensure the wider page color always matches the theme. This is to + // account for share links which don't sit in the wider Layout component + window.document.body.style.background = this.props.theme.background; } @keydown('m') @@ -327,7 +337,7 @@ class DocumentScene extends React.Component { return ( - { )} - + {isShare ? : } ); } } +const Background = styled(Container)` + background: ${props => props.theme.background}; + transition: ${props => props.theme.backgroundTransition}; +`; + const ReferencesWrapper = styled('div')` margin-top: ${props => (props.isOnlyTitle ? -45 : 16)}px; `; @@ -476,5 +491,7 @@ const MaxWidth = styled(Flex)` `; export default withRouter( - inject('ui', 'auth', 'documents', 'policies', 'revisions')(DocumentScene) + inject('ui', 'auth', 'documents', 'policies', 'revisions')( + withTheme(DocumentScene) + ) ); diff --git a/shared/components/Branding.js b/shared/components/Branding.js index 8460ce527..59b331eba 100644 --- a/shared/components/Branding.js +++ b/shared/components/Branding.js @@ -10,7 +10,7 @@ type Props = { function Branding({ href = process.env.URL }: Props) { return ( -  Outline +  Outline ); } @@ -24,15 +24,17 @@ const Link = styled.a` font-size: 14px; text-decoration: none; border-top-right-radius: 2px; - color: ${props => props.theme.black}; + color: ${props => props.theme.text}; display: flex; align-items: center; - padding: 12px; - opacity: 0.8; + padding: 16px; + + svg { + fill: ${props => props.theme.text}; + } &:hover { - opacity: 1; - background: ${props => props.theme.smoke}; + background: ${props => props.theme.sidebarBackground}; } `;