From afba1edae4284a3bb9e1948669488fea1f98969f Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 26 Feb 2020 19:36:23 -0800 Subject: [PATCH] feat: Adds visual stacking to nested modals (#1189) Fixes various mobile styling/layout issues --- app/components/Input.js | 1 + app/components/InputSearch.js | 8 +++- app/components/Modal.js | 78 ++++++++++++++++++++++++------- app/components/Sidebar/Sidebar.js | 7 ++- shared/styles/theme.js | 2 + 5 files changed, 76 insertions(+), 20 deletions(-) diff --git a/app/components/Input.js b/app/components/Input.js index 3fc6e5829..b2c7414fb 100644 --- a/app/components/Input.js +++ b/app/components/Input.js @@ -69,6 +69,7 @@ export const Outline = styled(Flex)` border-radius: 4px; font-weight: normal; align-items: center; + overflow: hidden; `; export const LabelText = styled.div` diff --git a/app/components/InputSearch.js b/app/components/InputSearch.js index 5406ac6b2..f318db3de 100644 --- a/app/components/InputSearch.js +++ b/app/components/InputSearch.js @@ -4,7 +4,7 @@ import keydown from 'react-keydown'; import { observer } from 'mobx-react'; import { observable } from 'mobx'; import { withRouter, type RouterHistory } from 'react-router-dom'; -import { withTheme } from 'styled-components'; +import styled, { withTheme } from 'styled-components'; import { SearchIcon } from 'outline-icons'; import { searchUrl } from 'utils/routeHelpers'; import Input from './Input'; @@ -49,7 +49,7 @@ class InputSearch extends React.Component { const { theme, placeholder = 'Search…' } = this.props; return ( - (this.input = ref)} type="search" placeholder={placeholder} @@ -67,4 +67,8 @@ class InputSearch extends React.Component { } } +const InputMaxWidth = styled(Input)` + max-width: 30vw; +`; + export default withTheme(withRouter(InputSearch)); diff --git a/app/components/Modal.js b/app/components/Modal.js index b0aa83bec..5b6d15b81 100644 --- a/app/components/Modal.js +++ b/app/components/Modal.js @@ -5,7 +5,7 @@ import styled, { createGlobalStyle } from 'styled-components'; import breakpoint from 'styled-components-breakpoint'; import ReactModal from 'react-modal'; import { transparentize } from 'polished'; -import { CloseIcon } from 'outline-icons'; +import { CloseIcon, BackIcon } from 'outline-icons'; import NudeButton from 'components/NudeButton'; import { fadeAndScaleIn } from 'shared/styles/animations'; import Flex from 'shared/components/Flex'; @@ -26,6 +26,23 @@ const GlobalStyles = createGlobalStyle` z-index: 100; } + ${breakpoint('tablet')` + .ReactModalPortal + .ReactModalPortal { + .ReactModal__Overlay { + margin-left: 12px; + box-shadow: 0 -2px 10px ${props => props.theme.shadow}; + border-radius: 8px 0 0 8px; + overflow: hidden; + } + } + + .ReactModalPortal + .ReactModalPortal + .ReactModalPortal { + .ReactModal__Overlay { + margin-left: 24px; + } + } + `}; + .ReactModal__Body--open { overflow: hidden; } @@ -51,12 +68,16 @@ const Modal = ({ > ev.stopPropagation()} column> {title &&

{title}

} - - - esc - + {children}
+ + + Back + + + + ); @@ -84,21 +105,27 @@ const StyledModal = styled(ReactModal)` overflow-y: auto; background: ${props => props.theme.background}; transition: ${props => props.theme.backgroundTransition}; - padding: 13vh 2rem 2rem; + padding: 8vh 2rem 2rem; outline: none; + + ${breakpoint('tablet')` + padding-top: 13vh; + `}; `; -const Esc = styled.span` - display: block; - text-align: center; - font-size: 13px; - height: 1em; +const Text = styled.span` + font-size: 16px; + font-weight: 500; + padding-right: 12px; + user-select: none; `; const Close = styled(NudeButton)` - position: fixed; - top: 16px; - right: 16px; + position: absolute; + display: block; + top: 0; + right: 0; + margin: 12px; opacity: 0.75; color: ${props => props.theme.text}; width: auto; @@ -109,8 +136,27 @@ const Close = styled(NudeButton)` } ${breakpoint('tablet')` - top: 3rem; - right: 3rem; + display: none; + `}; +`; + +const Back = styled(NudeButton)` + position: absolute; + display: none; + align-items: center; + top: 2rem; + left: 2rem; + opacity: 0.75; + color: ${props => props.theme.text}; + width: auto; + height: auto; + + &:hover { + opacity: 1; + } + + ${breakpoint('tablet')` + display: flex; `}; `; diff --git a/app/components/Sidebar/Sidebar.js b/app/components/Sidebar/Sidebar.js index 4303142fa..8aced7b10 100644 --- a/app/components/Sidebar/Sidebar.js +++ b/app/components/Sidebar/Sidebar.js @@ -42,7 +42,11 @@ class Sidebar extends React.Component { onClick={this.toggleSidebar} mobileSidebarVisible={ui.mobileSidebarVisible} > - {ui.mobileSidebarVisible ? : } + {ui.mobileSidebarVisible ? ( + + ) : ( + + )} {children} @@ -106,7 +110,6 @@ const Toggle = styled.a` right: ${props => (props.mobileSidebarVisible ? 0 : 'auto')}; z-index: 1; margin: 12px; - height: 32px; ${breakpoint('tablet')` display: none; diff --git a/shared/styles/theme.js b/shared/styles/theme.js index a8239df79..a210392a6 100644 --- a/shared/styles/theme.js +++ b/shared/styles/theme.js @@ -69,6 +69,7 @@ export const light = { sidebarBackground: colors.warmGrey, sidebarItemBackground: colors.black05, sidebarText: 'rgb(78, 92, 110)', + shadow: 'rgba(0, 0, 0, 0.2)', menuBackground: colors.white, menuShadow: @@ -119,6 +120,7 @@ export const dark = { sidebarBackground: colors.veryDarkBlue, sidebarItemBackground: colors.veryDarkBlue, sidebarText: colors.slate, + shadow: 'rgba(0, 0, 0, 0.6)', menuBackground: lighten(0.015, colors.almostBlack), menuShadow: