forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaxWidth.tsx
More file actions
43 lines (37 loc) · 821 Bytes
/
MaxWidth.tsx
File metadata and controls
43 lines (37 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from 'react';
import styled, { css } from 'styled-components';
const Container = styled.div<{ responsive?: boolean }>`
box-sizing: border-box;
display: flex;
padding: 0 2rem;
width: 100%;
justify-content: center;
${props =>
props.responsive &&
css`
@media (max-width: 768px) {
padding: 0;
}
`};
`;
const InnerContainer = styled.div<{ width: number }>`
width: 100%;
max-width: ${props => props.width}px;
`;
export default ({
children,
width = 1280,
className,
responsive = false,
}: {
children: React.CElement<any, any>;
width?: number;
className?: string;
responsive?: boolean;
}) => (
<Container responsive={responsive}>
<InnerContainer className={className} width={width}>
{children}
</InnerContainer>
</Container>
);