File size: 1,629 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// @flow
import React from 'react';
import styled, { css } from 'styled-components';
import { FlexCol } from 'src/components/globals';
import { MEDIA_BREAK } from 'src/components/layout';

const BaseColumn = styled(FlexCol)`
  margin: 32px 16px;
  align-items: stretch;

  @media (max-width: ${MEDIA_BREAK}px) {
    margin: 0;
    max-width: 100%;
  }

  ${p =>
    p.hideOnMobile &&
    css`
      @media screen and (max-width: ${MEDIA_BREAK}px) {
        display: none;
      }
    `};
`;

const PrimaryColumn = styled(BaseColumn)`
  min-width: 320px;
  flex: 2 1 60%;
  max-width: 640px;

  @media (max-width: ${MEDIA_BREAK}px) {
    width: 100%;
    max-width: 100%;
    margin-top: 2px;
    ${'' /* flex: auto; */} flex: none;
  }
`;

const SecondaryColumn = styled(BaseColumn)`
  min-width: 240px;
  flex: 1 1 30%;
  max-width: 320px;

  @media (max-width: ${MEDIA_BREAK}px) {
    flex: none;
    align-self: stretch;
    max-width: 100%;
  }
`;

const OnlyColumn = styled(PrimaryColumn)`
  max-width: 840px;
  flex: 0 0 75%;

  @media (max-width: ${MEDIA_BREAK}px) {
    flex: 1;
    min-width: 100%;
    width: 100%;
  }
`;

export const Column = (props: Object): React$Element<any> => {
  if (props.type === 'primary') {
    return <PrimaryColumn {...props}>{props.children}</PrimaryColumn>;
  } else if (props.type === 'secondary') {
    return <SecondaryColumn {...props}>{props.children}</SecondaryColumn>;
  } else if (props.type === 'only') {
    return <OnlyColumn {...props}>{props.children}</OnlyColumn>;
  } else {
    return <BaseColumn {...props}>{props.children}</BaseColumn>;
  }
};

export default Column;