Skip to content

Commit 3fc039b

Browse files
committed
use media queries instead of ResponsiveContext
1 parent 25d8727 commit 3fc039b

File tree

2 files changed

+77
-69
lines changed

2 files changed

+77
-69
lines changed

src/App.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,32 @@ pre {
2525
overflow: scroll;
2626
font-size: 11.9px;
2727
}
28+
29+
.layout {
30+
display: grid;
31+
box-sizing: border-box;
32+
width: 100%;
33+
height: 100%;
34+
grid-template-areas:
35+
"header header"
36+
"main sidebar";
37+
grid-template-columns: auto auto;
38+
-webkit-box-pack: center;
39+
-webkit-justify-content: center;
40+
-ms-flex-pack: center;
41+
justify-content: center;
42+
grid-template-rows: auto 1fr;
43+
}
44+
45+
@media(max-width: 800px) {
46+
.layout {
47+
grid-template-areas:
48+
"header"
49+
"main"
50+
"sidebar";
51+
grid-template-columns: 1fr;
52+
}
53+
.sidebar {
54+
display: none;
55+
}
56+
}

src/App.js

Lines changed: 48 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -227,75 +227,54 @@ export default class App extends React.Component<
227227
}}>
228228
<NotificationContainer>
229229
<Grommet theme={theme}>
230-
<ResponsiveContext.Consumer>
231-
{size => {
232-
const small = size === 'small';
233-
return (
234-
<Grid
235-
fill
236-
rows={['auto', 'flex']}
237-
columns={small ? ['flex'] : ['flex', 'auto']}
238-
areas={
239-
small
240-
? [
241-
{name: 'header', start: [0, 0], end: [1, 0]},
242-
{name: 'main', start: [0, 1], end: [1, 1]},
243-
]
244-
: [
245-
{name: 'header', start: [0, 0], end: [1, 0]},
246-
{name: 'main', start: [0, 1], end: [1, 1]},
247-
{name: 'sidebar', start: [1, 1], end: [1, 1]},
248-
]
249-
}>
250-
<Box
251-
gridArea="header"
252-
direction="row"
253-
align="center"
254-
justify="between"
255-
pad={{horizontal: 'medium', vertical: 'medium'}}
256-
wrap={true}>
257-
<Box align="center" direction="row">
258-
<OneGraphLogo width="96px" height="96px" />{' '}
259-
<Heading level={2}>
260-
<Link style={{color: 'inherit'}} to="/">
261-
OneGraph Product Updates
262-
</Link>
263-
</Heading>
264-
</Box>
265-
<Anchor href="https://onegraph.com">
266-
<Text size="small">Learn more about OneGraph</Text>
267-
</Anchor>
268-
</Box>
269-
{small ||
270-
!process.env.RAZZLE_ENABLE_MAILCHIMP_SIGNUP ? null : (
271-
<Box gridArea="sidebar" pad="medium" width="medium">
272-
<NewsletterSignup />
273-
</Box>
274-
)}
275-
<Box gridArea="main">
276-
<ScrollMemory />
277-
<Switch>
278-
{routes.map((routeConfig, i) => (
279-
<Route
280-
key={i}
281-
path={routeConfig.path}
282-
exact={routeConfig.exact}
283-
strict={routeConfig.strict}
284-
render={props => (
285-
<RenderRoute
286-
environment={this.props.environment}
287-
match={props.match}
288-
routeConfig={routeConfig}
289-
/>
290-
)}
291-
/>
292-
))}
293-
</Switch>
294-
</Box>
295-
</Grid>
296-
);
297-
}}
298-
</ResponsiveContext.Consumer>
230+
<div className="layout">
231+
<Box
232+
gridArea="header"
233+
direction="row"
234+
align="center"
235+
justify="between"
236+
pad={{horizontal: 'medium', vertical: 'medium'}}
237+
wrap={true}>
238+
<Box align="center" direction="row">
239+
<OneGraphLogo width="96px" height="96px" />{' '}
240+
<Heading level={2}>
241+
<Link style={{color: 'inherit'}} to="/">
242+
OneGraph Product Updates
243+
</Link>
244+
</Heading>
245+
</Box>
246+
<Anchor href="https://onegraph.com">
247+
<Text size="small">Learn more about OneGraph</Text>
248+
</Anchor>
249+
</Box>
250+
{!process.env.RAZZLE_ENABLE_MAILCHIMP_SIGNUP ? null : (
251+
<div className="sidebar">
252+
<Box gridArea="sidebar" pad="medium" width="medium">
253+
<NewsletterSignup />
254+
</Box>
255+
</div>
256+
)}
257+
<Box gridArea="main">
258+
<ScrollMemory />
259+
<Switch>
260+
{routes.map((routeConfig, i) => (
261+
<Route
262+
key={i}
263+
path={routeConfig.path}
264+
exact={routeConfig.exact}
265+
strict={routeConfig.strict}
266+
render={props => (
267+
<RenderRoute
268+
environment={this.props.environment}
269+
match={props.match}
270+
routeConfig={routeConfig}
271+
/>
272+
)}
273+
/>
274+
))}
275+
</Switch>
276+
</Box>
277+
</div>
299278
</Grommet>
300279
</NotificationContainer>
301280
</UserContext.Provider>

0 commit comments

Comments
 (0)