11import * as React from 'react' ;
22import styled from 'styled-components' ;
3+ import { createMuiTheme , MuiThemeProvider } from '@material-ui/core' ;
34
45const PixelContainer = styled . div `
56 height: 100vh;
@@ -12,12 +13,19 @@ const PixelContainer = styled.div`
1213 font-family: Roboto, HelveticaNeue, Arial, sans-serif;
1314 user-select: none;
1415 position: relative;
16+ overflow: hidden;
17+ display: flex;
18+ flex-direction: column;
1519
1620 * {
1721 box-sizing: border-box;
1822 user-select: none;
1923 }
2024
25+ button::-moz-focus-inner {
26+ border: 0;
27+ }
28+
2129 ul {
2230 padding: 0;
2331 margin: 0;
@@ -37,14 +45,21 @@ const Toolbar = styled.div`
3745 background-color: rgba(0, 0, 0, 0.15);
3846 display: flex;
3947 align-items: center;
40- z-index: 9999999;
4148` ;
4249
43- const Square = styled . div `
50+ const ToolbarContainer = styled . div `
51+ z-index: 999999999;
52+ ` ;
53+
54+ interface SquareProps {
55+ invertColor : boolean ;
56+ }
57+
58+ const Square = styled . div < SquareProps > `
4459 height: 12px;
4560 width: 12px;
4661 margin-left: auto;
47- background-color: # 000;
62+ background-color: ${ props => ( props . invertColor ? '#fff' : '# 000' ) } ;
4863 margin-right: 9px;
4964 opacity: 0.35;
5065` ;
@@ -61,25 +76,58 @@ const Triangle = styled(Square)`
6176 background-color: transparent;
6277 border-left: 7px solid transparent;
6378 border-right: 7px solid transparent;
64- border-top: 12px solid #000;
79+ border-top: 12px solid ${ props => ( props . invertColor ? '#fff' : '#000' ) } ;
80+ ` ;
81+
82+ const RelativeContainer = styled . div `
83+ position: relative;
84+ /* Hack to align contents to container taking off header height */
85+ height: calc(100% - 82px);
86+
87+ @media (min-width: 584px) {
88+ /* Hack to align contents to container taking off header height */
89+ height: calc(100% - 90px);
90+ }
6591` ;
6692
6793interface SmallViewportProps {
6894 children : React . ReactNode ;
95+ invertColor ?: boolean ;
96+ appBar ?: React . ReactNode ;
6997}
7098
7199export default class SmallViewport extends React . Component < SmallViewportProps > {
100+ theme = createMuiTheme ( {
101+ palette : {
102+ primary : {
103+ light : '#484848' ,
104+ main : '#212121' ,
105+ dark : '#000000' ,
106+ contrastText : '#fff' ,
107+ } ,
108+ } ,
109+ } ) ;
110+
72111 render ( ) {
112+ const { invertColor, children, appBar } = this . props ;
73113 return (
74- < PixelContainer id = "small-viewport" >
75- < Toolbar >
76- < Square />
77- < Circle />
78- < Triangle />
79- </ Toolbar >
80-
81- < OverflowContainer > { this . props . children } </ OverflowContainer >
82- </ PixelContainer >
114+ < MuiThemeProvider theme = { this . theme } >
115+ < PixelContainer >
116+ < ToolbarContainer >
117+ < Toolbar >
118+ < Square invertColor = { ! ! invertColor } />
119+ < Circle invertColor = { ! ! invertColor } />
120+ < Triangle invertColor = { ! ! invertColor } />
121+ </ Toolbar >
122+
123+ { appBar }
124+ </ ToolbarContainer >
125+
126+ < RelativeContainer >
127+ < OverflowContainer > { children } </ OverflowContainer >
128+ </ RelativeContainer >
129+ </ PixelContainer >
130+ </ MuiThemeProvider >
83131 ) ;
84132 }
85133}
0 commit comments