Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding zIndex object to theme styling #736

Merged
merged 4 commits into from
Nov 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/Links/LinkTargetBlank/LinkTargetBlank.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react'
import { Link } from 'rebass'
import ImageTargetBlank from 'src/assets/icons/link-target-blank.svg'
import { zIndex } from 'src/themes/styled.theme'

export const LinkTargetBlank = props => (
<Link
Expand All @@ -14,7 +15,7 @@ export const LinkTargetBlank = props => (
backgroundImage: `url("${ImageTargetBlank}")`,
width: '20px',
height: '20px',
zIndex: 0,
zIndex: `${zIndex.level}`,
backgroundSize: 'contain',
backgroundRepeat: 'no-repeat',
position: 'absolute',
Expand Down
5 changes: 3 additions & 2 deletions src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react'
import { Portal } from 'react-portal'
import { Box } from 'rebass'
import styled from 'styled-components'
import { zIndex } from 'src/themes/styled.theme'

interface IProps {
// provide onDidDismiss function to enable backdrop click dismiss
Expand All @@ -18,7 +19,7 @@ const ModalBackdrop = styled(Box)`
left: 0;
width: 100%;
height: 100%;
z-index: 9;
z-index: ${zIndex.modalBackdrop};
background: rgba(0, 0, 0, 0.4);
`
const ModalContent = styled(Box)`
Expand All @@ -31,7 +32,7 @@ const ModalContent = styled(Box)`
max-width: 100%;
max-height: 100%;
position: fixed;
z-index: 10;
z-index: ${zIndex.modalContent};
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
Expand Down
3 changes: 2 additions & 1 deletion src/components/MoreContainer/MoreContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import WhiteBubble1 from 'src/assets/images/white-bubble_1.svg'
import WhiteBubble2 from 'src/assets/images/white-bubble_2.svg'
import WhiteBubble3 from 'src/assets/images/white-bubble_3.svg'
import { BoxProps } from 'rebass'
import { zIndex } from 'src/themes/styled.theme'

const MoreModalContainer = styled(Box)`
position: relative;
Expand All @@ -16,7 +17,7 @@ const MoreModalContainer = styled(Box)`
background-image: url(${WhiteBubble0});
width: 100%;
height: 100%;
z-index: -1;
z-index: ${zIndex.behind};
background-size: contain;
background-repeat: no-repeat;
position: absolute;
Expand Down
20 changes: 12 additions & 8 deletions src/components/ProfileModal/ProfileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { inject, observer } from 'mobx-react'
import { COMMUNITY_PAGES_PROFILE } from 'src/pages/PageList'
import { NavLink } from 'react-router-dom'
import Flex from 'src/components/Flex'
import theme from 'src/themes/styled.theme'
import theme, { zIndex } from 'src/themes/styled.theme'

interface IProps {
username: string
Expand All @@ -24,11 +24,11 @@ const ModalContainer = styled(Box)`
position: absolute;
right: 10px;
top: 60px;
z-index: 900;
z-index: ${zIndex.modalProfile};
height: 100%;
`
const ModalContent = styled(Box)`
z-index: 900;
const ModalContainerInner = styled(Box)`
z-index: ${zIndex.modalProfile};
position: relative;
background: white;
border: 2px solid black;
Expand All @@ -38,7 +38,7 @@ const ModalContent = styled(Box)`
const ModalLink = styled(NavLink).attrs(({ name }) => ({
activeClassName: 'current',
}))`
z-index: 900;
z-index: ${zIndex.modalProfile};
display: flex;
flex-direction: column;
color: #000;
Expand Down Expand Up @@ -80,7 +80,7 @@ export class ProfileModal extends React.Component<IProps> {
const { username } = this.props
return (
<ModalContainer data-cy="user-menu-list">
<ModalContent>
<ModalContainerInner>
<Flex>
<ModalLink to={'/u/' + username} data-cy="menu-item">
<Flex>Profile</Flex>
Expand All @@ -94,11 +94,15 @@ export class ProfileModal extends React.Component<IProps> {
))}
</Flex>
<Flex>
<ModalLink onClick={() => this.logout()} to={'/how-to'} data-cy="menu-item">
<ModalLink
onClick={() => this.logout()}
to={'/how-to'}
data-cy="menu-item"
>
<Flex color="rgba(27,27,27,0.5)">Log out</Flex>
</ModalLink>
</Flex>
</ModalContent>
</ModalContainerInner>
</ModalContainer>
)
}
Expand Down
7 changes: 5 additions & 2 deletions src/pages/Howto/Content/Howto/Howto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import WhiteBubble2 from 'src/assets/images/white-bubble_2.svg'
import WhiteBubble3 from 'src/assets/images/white-bubble_3.svg'
import { IUser } from 'src/models/user.models'
import { Link } from 'src/components/Links'
import { zIndex } from 'src/themes/styled.theme'

// The parent container injects router props along with a custom slug parameter (RouteComponentProps<IRouterCustomParams>).
// We also have injected the doc store to access its methods to get doc by slug.
Expand All @@ -41,7 +42,7 @@ const MoreBox = styled(Box)`
background-image: url(${WhiteBubble0});
width: 100%;
height: 100%;
z-index: -1;
z-index: ${zIndex.behind};
background-size: contain;
background-repeat: no-repeat;
position: absolute;
Expand Down Expand Up @@ -120,7 +121,9 @@ export class Howto extends React.Component<
</Text>
<Flex justifyContent={'center'} mt={2}>
<Link to={'/how-to/'}>
<Button variant={'secondary'} data-cy="go-back">Back</Button>
<Button variant={'secondary'} data-cy="go-back">
Back
</Button>
</Link>
</Flex>
</MoreBox>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Maps/Content/Controls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { HashLink } from 'react-router-hash-link'
import { AuthWrapper } from 'src/components/Auth/AuthWrapper'
import { Map } from 'react-leaflet'
import { ILocation } from 'src/models/common.models'
import { zIndex } from 'src/themes/styled.theme'
import { inject } from 'mobx-react'
import { MapsStore } from 'src/stores/Maps/maps.store'

Expand All @@ -35,7 +36,7 @@ const MapFlexBar = styled(Flex)`
position: absolute;
top: 25px;
width: 100%;
z-index: 3;
z-index: ${zIndex.mapFlexBar};
left: 50%;
transform: translateX(-50%);
`
Expand Down
5 changes: 3 additions & 2 deletions src/pages/User/content/UserPage/UserPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import styled from 'styled-components'
import Icon from 'src/components/Icons'
import Flex from 'src/components/Flex'
import ElWithBeforeIcon from 'src/components/ElWithBeforeIcon'
import { zIndex } from 'src/themes/styled.theme'

import theme from 'src/themes/styled.theme'
import { capitalizeFirstLetter } from 'src/utils/helpers'
Expand Down Expand Up @@ -78,7 +79,7 @@ interface IProps {}
const UserCategory = styled.div`
position: relative;
display: inline-block;
z-index: 1;
z-index: ${zIndex.default};

&:after {
content: '';
Expand All @@ -87,7 +88,7 @@ const UserCategory = styled.div`
position: absolute;
top: 0;

z-index: -1;
z-index: ${zIndex.behind};
background-repeat: no-repeat;
background-size: contain;
left: 0;
Expand Down
14 changes: 13 additions & 1 deletion src/pages/common/Header/Menu/Logo/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import LogoImage from 'src/assets/images/logo.svg'
import MobileLogoImage from 'src/assets/images/logo-mobile.svg'
import LogoBackground from 'src/assets/images/logo-background.svg'
import Text from 'src/components/Text'
import { zIndex } from 'src/themes/styled.theme'

interface IProps {
isMobile?: boolean
Expand All @@ -16,7 +17,18 @@ const LogoContainer = styled(Flex)`
width: 200px;
align-items: center;
position: relative;

&:before {
content: '';
position: absolute;
background-image: url(${LogoBackground});
width: 250px;
height: 70px;
z-index: ${zIndex.logoContainer};
background-size: contain;
background-repeat: no-repeat;
top: 0;
left: 0px;
}
@media only screen and (max-width: ${theme.breakpoints[1]}) {
&:before {
left: -50px;
Expand Down
5 changes: 3 additions & 2 deletions src/pages/common/Header/Menu/MenuDesktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import theme from 'src/themes/styled.theme'
import { Flex } from 'rebass/styled-components'
import styled from 'styled-components'
import MenuCurrent from 'src/assets/images/menu-current.svg'
import { zIndex } from 'src/themes/styled.theme'

const MenuLink = styled(NavLink).attrs(({ name }) => ({
activeClassName: 'current',
Expand All @@ -13,7 +14,7 @@ const MenuLink = styled(NavLink).attrs(({ name }) => ({
color: ${'black'};
position: relative;
> div {
z-index: 1;
z-index: ${zIndex.default};
position: relative;
&:hover {
opacity: 0.7;
Expand All @@ -28,7 +29,7 @@ const MenuLink = styled(NavLink).attrs(({ name }) => ({
position: absolute;
bottom: -6px;
background-image: url(${MenuCurrent});
z-index: 0;
z-index: ${zIndex.level};
background-repeat: no-repeat;
background-size: contain;
left: 50%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ export class ProfileButtonItem extends React.Component<IProps> {
? ['flex', 'flex', 'none']
: ['none', 'none', 'flex']
}
{...(this.props.isMobile
? { large: true }
: { medium: true })}
{...(this.props.isMobile ? { large: true } : { medium: true })}
data-cy={this.props.text.toLowerCase()}
style={this.props.style}
>
Expand Down
4 changes: 2 additions & 2 deletions src/themes/app.globalStyle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createGlobalStyle } from 'styled-components'
import theme from 'src/themes/styled.theme'
import theme, { zIndex } from 'src/themes/styled.theme'
// Import css files for Slick-slider
// import "../../node_modules/slick-carousel/slick/slick.css";
// import "../../node_modules/slick-carousel/slick/slick-theme.css";
Expand Down Expand Up @@ -34,7 +34,7 @@ export const GlobalStyle = createGlobalStyle`
.slick-next {
position: absolute;
top: 50%;
z-index: 100;
z-index: ${zIndex.slickArrows};
transform: translateY(-50%);
cursor: pointer;
}
Expand Down
13 changes: 13 additions & 0 deletions src/themes/styled.theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ export const colors = {
silver: '#c0c0c0',
}

export const zIndex = {
behind: -1,
level: 0,
default: 1,
modalBackdrop: 9,
modalContent: 10,
slickArrows: 100,
modalProfile: 900,
logoContainer: 999,
mapFlexBar: 99999,
}

export type ButtonVariants =
| 'primary'
| 'secondary'
Expand Down Expand Up @@ -176,4 +188,5 @@ export default {
maxContainerWidth,
regular,
bold,
zIndex,
}