@khanacademy/wonder-blocks-grid 1.0.37 → 1.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/dist/components/cell.d.ts +56 -0
- package/dist/components/cell.js.flow +82 -0
- package/dist/components/gutter.d.ts +29 -0
- package/dist/components/gutter.js.flow +37 -0
- package/dist/components/row.d.ts +48 -0
- package/dist/components/row.js.flow +63 -0
- package/dist/es/index.js +50 -38
- package/dist/index.d.ts +2 -0
- package/dist/index.js +64 -52
- package/dist/index.js.flow +9 -2
- package/dist/util/styles.d.ts +3 -0
- package/dist/util/styles.js.flow +10 -0
- package/dist/util/utils.d.ts +2 -0
- package/dist/util/utils.js.flow +9 -0
- package/package.json +7 -7
- package/src/components/__tests__/{row.test.js → row.test.tsx} +2 -4
- package/src/components/{cell.js → cell.tsx} +30 -31
- package/src/components/{gutter.js → gutter.tsx} +8 -8
- package/src/components/{row.js → row.tsx} +45 -47
- package/src/index.ts +2 -0
- package/src/util/{styles.js → styles.ts} +0 -1
- package/src/util/{utils.js → utils.ts} +0 -1
- package/tsconfig.json +14 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/src/index.js +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-grid
|
|
2
2
|
|
|
3
|
+
## 1.0.39
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d816af08: Update build and test configs use TypeScript
|
|
8
|
+
- 3891f544: Update babel config to include plugins that Storybook needed
|
|
9
|
+
- 0d28bb1c: Configured TypeScript
|
|
10
|
+
- 3d05f764: Fix HOCs and other type errors
|
|
11
|
+
- c2ec4902: Update eslint configuration, fix lint
|
|
12
|
+
- 2983c05b: Include 'types' field in package.json
|
|
13
|
+
- 77ff6a66: Generate Flow types from TypeScript types
|
|
14
|
+
- ec8d4b7f: Fix miscellaneous TypeScript errors
|
|
15
|
+
- Updated dependencies [d816af08]
|
|
16
|
+
- Updated dependencies [3891f544]
|
|
17
|
+
- Updated dependencies [0d28bb1c]
|
|
18
|
+
- Updated dependencies [873f4a14]
|
|
19
|
+
- Updated dependencies [3d05f764]
|
|
20
|
+
- Updated dependencies [c2ec4902]
|
|
21
|
+
- Updated dependencies [2983c05b]
|
|
22
|
+
- Updated dependencies [77ff6a66]
|
|
23
|
+
- Updated dependencies [ec8d4b7f]
|
|
24
|
+
- @khanacademy/wonder-blocks-color@1.2.2
|
|
25
|
+
- @khanacademy/wonder-blocks-core@4.8.0
|
|
26
|
+
- @khanacademy/wonder-blocks-layout@1.4.17
|
|
27
|
+
- @khanacademy/wonder-blocks-spacing@3.0.6
|
|
28
|
+
|
|
29
|
+
## 1.0.38
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- 91cb727c: Remove file extensions from imports
|
|
34
|
+
- Updated dependencies [91cb727c]
|
|
35
|
+
- Updated dependencies [91cb727c]
|
|
36
|
+
- @khanacademy/wonder-blocks-color@1.2.1
|
|
37
|
+
- @khanacademy/wonder-blocks-core@4.7.0
|
|
38
|
+
- @khanacademy/wonder-blocks-layout@1.4.16
|
|
39
|
+
|
|
3
40
|
## 1.0.37
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { MediaSize } from "@khanacademy/wonder-blocks-layout";
|
|
3
|
+
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
4
|
+
type Props = {
|
|
5
|
+
/** The number of columns this cell should span on a Small Grid. */
|
|
6
|
+
smallCols: number;
|
|
7
|
+
/** The number of columns this cell should span on a Medium Grid. */
|
|
8
|
+
mediumCols: number;
|
|
9
|
+
/** The number of columns this cell should span on a Large Grid. */
|
|
10
|
+
largeCols: number;
|
|
11
|
+
/** The number of columns this should should span by default. */
|
|
12
|
+
cols: number | ((mediaSize: MediaSize) => number);
|
|
13
|
+
/**
|
|
14
|
+
* The child components to populate inside the cell. Can also accept a
|
|
15
|
+
* function which receives the `mediaSize`, `totalColumns`, and cell
|
|
16
|
+
* `width` and should return some React Nodes to render.
|
|
17
|
+
*/
|
|
18
|
+
children: React.ReactNode | ((arg1: {
|
|
19
|
+
mediaSize: MediaSize;
|
|
20
|
+
totalColumns: number;
|
|
21
|
+
cols: number;
|
|
22
|
+
}) => React.ReactElement);
|
|
23
|
+
/** The styling to apply to the cell. */
|
|
24
|
+
style?: StyleType;
|
|
25
|
+
};
|
|
26
|
+
type DefaultProps = {
|
|
27
|
+
smallCols: Props["smallCols"];
|
|
28
|
+
mediumCols: Props["mediumCols"];
|
|
29
|
+
largeCols: Props["largeCols"];
|
|
30
|
+
cols: Props["cols"];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* A Cell is a container whose width is set based on the width of the
|
|
34
|
+
* specified columns at the current grid size. You will specify the number
|
|
35
|
+
* of columns that you want this component to span at each grid size.
|
|
36
|
+
* This component should only be used as a child of a [Row](#row).
|
|
37
|
+
*
|
|
38
|
+
* This component renders a [View](#view) that
|
|
39
|
+
* uses Flex Box and has a [flex-basis](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis)
|
|
40
|
+
* of the specified "width" and [flex-shrink](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-shrink)
|
|
41
|
+
* of 0.
|
|
42
|
+
*
|
|
43
|
+
* By default (with no properties specified) it will display at all
|
|
44
|
+
* grid sizes. If you specify the `smallCols`, `mediumCols`, `largeCols`, or
|
|
45
|
+
* `cols` props then the component will only be shown at those grid sizes and
|
|
46
|
+
* using the specified column width.
|
|
47
|
+
*/
|
|
48
|
+
export default class Cell extends React.Component<Props> {
|
|
49
|
+
static isClassOf(instance: React.ReactElement<any>): boolean;
|
|
50
|
+
static getCols(props: Props, mediaSize: MediaSize): number | null | undefined;
|
|
51
|
+
static shouldDisplay(props: Props, mediaSize: MediaSize): boolean;
|
|
52
|
+
static defaultProps: DefaultProps;
|
|
53
|
+
static __IS_CELL__: boolean;
|
|
54
|
+
render(): React.ReactElement | null;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for cell
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import type { MediaSize } from "@khanacademy/wonder-blocks-layout";
|
|
10
|
+
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
11
|
+
declare type Props = {
|
|
12
|
+
/**
|
|
13
|
+
* The number of columns this cell should span on a Small Grid.
|
|
14
|
+
*/
|
|
15
|
+
smallCols: number,
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The number of columns this cell should span on a Medium Grid.
|
|
19
|
+
*/
|
|
20
|
+
mediumCols: number,
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The number of columns this cell should span on a Large Grid.
|
|
24
|
+
*/
|
|
25
|
+
largeCols: number,
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The number of columns this should should span by default.
|
|
29
|
+
*/
|
|
30
|
+
cols: number | ((mediaSize: MediaSize) => number),
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The child components to populate inside the cell. Can also accept a
|
|
34
|
+
* function which receives the `mediaSize`, `totalColumns`, and cell
|
|
35
|
+
* `width` and should return some React Nodes to render.
|
|
36
|
+
*/
|
|
37
|
+
children:
|
|
38
|
+
| React.Node
|
|
39
|
+
| ((arg1: {
|
|
40
|
+
mediaSize: MediaSize,
|
|
41
|
+
totalColumns: number,
|
|
42
|
+
cols: number,
|
|
43
|
+
...
|
|
44
|
+
}) => React.Element<>),
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The styling to apply to the cell.
|
|
48
|
+
*/
|
|
49
|
+
style?: StyleType,
|
|
50
|
+
...
|
|
51
|
+
};
|
|
52
|
+
declare type DefaultProps = {
|
|
53
|
+
smallCols: $PropertyType<Props, "smallCols">,
|
|
54
|
+
mediumCols: $PropertyType<Props, "mediumCols">,
|
|
55
|
+
largeCols: $PropertyType<Props, "largeCols">,
|
|
56
|
+
cols: $PropertyType<Props, "cols">,
|
|
57
|
+
...
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* A Cell is a container whose width is set based on the width of the
|
|
61
|
+
* specified columns at the current grid size. You will specify the number
|
|
62
|
+
* of columns that you want this component to span at each grid size.
|
|
63
|
+
* This component should only be used as a child of a [Row](#row).
|
|
64
|
+
*
|
|
65
|
+
* This component renders a [View](#view) that
|
|
66
|
+
* uses Flex Box and has a [flex-basis](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis)
|
|
67
|
+
* of the specified "width" and [flex-shrink](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-shrink)
|
|
68
|
+
* of 0.
|
|
69
|
+
*
|
|
70
|
+
* By default (with no properties specified) it will display at all
|
|
71
|
+
* grid sizes. If you specify the `smallCols`, `mediumCols`, `largeCols`, or
|
|
72
|
+
* `cols` props then the component will only be shown at those grid sizes and
|
|
73
|
+
* using the specified column width.
|
|
74
|
+
*/
|
|
75
|
+
declare export default class Cell mixins React.Component<Props> {
|
|
76
|
+
static isClassOf(instance: React.Element<any>): boolean;
|
|
77
|
+
static getCols(props: Props, mediaSize: MediaSize): number | null | void;
|
|
78
|
+
static shouldDisplay(props: Props, mediaSize: MediaSize): boolean;
|
|
79
|
+
static defaultProps: DefaultProps;
|
|
80
|
+
static __IS_CELL__: boolean;
|
|
81
|
+
render(): React.Element<> | null;
|
|
82
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { MediaQuery } from "@khanacademy/wonder-blocks-layout";
|
|
3
|
+
type Props = {
|
|
4
|
+
/**
|
|
5
|
+
* Which media should this cell be renderer on. Defaults to all.
|
|
6
|
+
*/
|
|
7
|
+
mediaQuery: MediaQuery;
|
|
8
|
+
};
|
|
9
|
+
type DefaultProps = {
|
|
10
|
+
mediaQuery: Props["mediaQuery"];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Gutter is a component whose width is set based on the size of grid currently
|
|
14
|
+
* being displayed. Used for spacing out cells from each other. The gutter
|
|
15
|
+
* itself doesn't hold any content, it just spaces it out.
|
|
16
|
+
*
|
|
17
|
+
* Gutters are inserted automatically inside of a [Row](#row) in-between Cells.
|
|
18
|
+
* You may only need to use Gutters if you're manually building your own
|
|
19
|
+
* sub-grid, or some-such (this should be relatively rare).
|
|
20
|
+
*
|
|
21
|
+
* By default (with no properties specified) it will display at all
|
|
22
|
+
* grid sizes. If you specify the `small`, `medium`, or `large`
|
|
23
|
+
* props then the component will only be shown at those grid sizes.
|
|
24
|
+
*/
|
|
25
|
+
export default class Gutter extends React.Component<Props> {
|
|
26
|
+
static defaultProps: DefaultProps;
|
|
27
|
+
render(): React.ReactElement | null;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for gutter
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import type { MediaQuery } from "@khanacademy/wonder-blocks-layout";
|
|
10
|
+
declare type Props = {
|
|
11
|
+
/**
|
|
12
|
+
* Which media should this cell be renderer on. Defaults to all.
|
|
13
|
+
*/
|
|
14
|
+
mediaQuery: MediaQuery,
|
|
15
|
+
...
|
|
16
|
+
};
|
|
17
|
+
declare type DefaultProps = {
|
|
18
|
+
mediaQuery: $PropertyType<Props, "mediaQuery">,
|
|
19
|
+
...
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Gutter is a component whose width is set based on the size of grid currently
|
|
23
|
+
* being displayed. Used for spacing out cells from each other. The gutter
|
|
24
|
+
* itself doesn't hold any content, it just spaces it out.
|
|
25
|
+
*
|
|
26
|
+
* Gutters are inserted automatically inside of a [Row](#row) in-between Cells.
|
|
27
|
+
* You may only need to use Gutters if you're manually building your own
|
|
28
|
+
* sub-grid, or some-such (this should be relatively rare).
|
|
29
|
+
*
|
|
30
|
+
* By default (with no properties specified) it will display at all
|
|
31
|
+
* grid sizes. If you specify the `small`, `medium`, or `large`
|
|
32
|
+
* props then the component will only be shown at those grid sizes.
|
|
33
|
+
*/
|
|
34
|
+
declare export default class Gutter mixins React.Component<Props> {
|
|
35
|
+
static defaultProps: DefaultProps;
|
|
36
|
+
render(): React.Element<> | null;
|
|
37
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
|
+
import type { MediaQuery, MediaSize } from "@khanacademy/wonder-blocks-layout";
|
|
4
|
+
type Props = {
|
|
5
|
+
/**
|
|
6
|
+
* Which media should this cell be renderer on. Defaults to all.
|
|
7
|
+
*/
|
|
8
|
+
mediaQuery: MediaQuery;
|
|
9
|
+
/**
|
|
10
|
+
* The child components to populate inside the row. Typically this will be
|
|
11
|
+
* a [Cell](#cell), but it can also include any elements
|
|
12
|
+
* that could fit in a [flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox).
|
|
13
|
+
* Can also accept a function which receives the `mediaSize` and
|
|
14
|
+
* `totalColumns` and should return some React Nodes to render.
|
|
15
|
+
*/
|
|
16
|
+
children: React.ReactNode | ((arg1: {
|
|
17
|
+
mediaSize: MediaSize;
|
|
18
|
+
totalColumns: number;
|
|
19
|
+
}) => React.ReactElement);
|
|
20
|
+
/** The styling to apply to the row. */
|
|
21
|
+
style?: StyleType;
|
|
22
|
+
};
|
|
23
|
+
type DefaultProps = {
|
|
24
|
+
mediaQuery: Props["mediaQuery"];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A Row holds all of the Cells that make up the contents of the grid. A row
|
|
28
|
+
* also provides the margins on the sides and inserts the gutter spacing
|
|
29
|
+
* in-between the cells. Typically this component will hold a [Cell](#cell),
|
|
30
|
+
* but it can also include any elements that could fit in a
|
|
31
|
+
* [flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox).
|
|
32
|
+
*
|
|
33
|
+
* This component will automatically attempt to insert [Gutters](#gutter)
|
|
34
|
+
* in-between all child elements. Additionally, it'll perform some basic checks
|
|
35
|
+
* to ensure that no impossible layouts are accidentally generated.
|
|
36
|
+
*
|
|
37
|
+
* Typically this component will be used as a child of a [Grid](#grid-1),
|
|
38
|
+
* but it's not a requirement, you can use it as a descendant, as well.
|
|
39
|
+
*
|
|
40
|
+
* By default (with no properties specified) it will display at all
|
|
41
|
+
* grid sizes. If you specify the `small`, `medium`, or `large`
|
|
42
|
+
* props then the component will only be shown at those grid sizes.
|
|
43
|
+
*/
|
|
44
|
+
export default class Row extends React.Component<Props> {
|
|
45
|
+
static defaultProps: DefaultProps;
|
|
46
|
+
render(): React.ReactElement | null;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for row
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
10
|
+
import type { MediaQuery, MediaSize } from "@khanacademy/wonder-blocks-layout";
|
|
11
|
+
declare type Props = {
|
|
12
|
+
/**
|
|
13
|
+
* Which media should this cell be renderer on. Defaults to all.
|
|
14
|
+
*/
|
|
15
|
+
mediaQuery: MediaQuery,
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The child components to populate inside the row. Typically this will be
|
|
19
|
+
* a [Cell](#cell), but it can also include any elements
|
|
20
|
+
* that could fit in a [flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox).
|
|
21
|
+
* Can also accept a function which receives the `mediaSize` and
|
|
22
|
+
* `totalColumns` and should return some React Nodes to render.
|
|
23
|
+
*/
|
|
24
|
+
children:
|
|
25
|
+
| React.Node
|
|
26
|
+
| ((arg1: {
|
|
27
|
+
mediaSize: MediaSize,
|
|
28
|
+
totalColumns: number,
|
|
29
|
+
...
|
|
30
|
+
}) => React.Element<>),
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The styling to apply to the row.
|
|
34
|
+
*/
|
|
35
|
+
style?: StyleType,
|
|
36
|
+
...
|
|
37
|
+
};
|
|
38
|
+
declare type DefaultProps = {
|
|
39
|
+
mediaQuery: $PropertyType<Props, "mediaQuery">,
|
|
40
|
+
...
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A Row holds all of the Cells that make up the contents of the grid. A row
|
|
44
|
+
* also provides the margins on the sides and inserts the gutter spacing
|
|
45
|
+
* in-between the cells. Typically this component will hold a [Cell](#cell),
|
|
46
|
+
* but it can also include any elements that could fit in a
|
|
47
|
+
* [flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox).
|
|
48
|
+
*
|
|
49
|
+
* This component will automatically attempt to insert [Gutters](#gutter)
|
|
50
|
+
* in-between all child elements. Additionally, it'll perform some basic checks
|
|
51
|
+
* to ensure that no impossible layouts are accidentally generated.
|
|
52
|
+
*
|
|
53
|
+
* Typically this component will be used as a child of a [Grid](#grid-1),
|
|
54
|
+
* but it's not a requirement, you can use it as a descendant, as well.
|
|
55
|
+
*
|
|
56
|
+
* By default (with no properties specified) it will display at all
|
|
57
|
+
* grid sizes. If you specify the `small`, `medium`, or `large`
|
|
58
|
+
* props then the component will only be shown at those grid sizes.
|
|
59
|
+
*/
|
|
60
|
+
declare export default class Row mixins React.Component<Props> {
|
|
61
|
+
static defaultProps: DefaultProps;
|
|
62
|
+
render(): React.Element<> | null;
|
|
63
|
+
}
|
package/dist/es/index.js
CHANGED
|
@@ -3,6 +3,20 @@ import { MediaLayout, queryMatchesSize, Strut } from '@khanacademy/wonder-blocks
|
|
|
3
3
|
import { View } from '@khanacademy/wonder-blocks-core';
|
|
4
4
|
import { StyleSheet } from 'aphrodite';
|
|
5
5
|
|
|
6
|
+
function _setPrototypeOf(o, p) {
|
|
7
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
8
|
+
o.__proto__ = p;
|
|
9
|
+
return o;
|
|
10
|
+
};
|
|
11
|
+
return _setPrototypeOf(o, p);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function _inheritsLoose(subClass, superClass) {
|
|
15
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
16
|
+
subClass.prototype.constructor = subClass;
|
|
17
|
+
_setPrototypeOf(subClass, superClass);
|
|
18
|
+
}
|
|
19
|
+
|
|
6
20
|
const WIDE_SCREEN = "@media (min-width: 1168px)";
|
|
7
21
|
const styles = StyleSheet.create({
|
|
8
22
|
row: {
|
|
@@ -32,12 +46,15 @@ const flexBasis = size => {
|
|
|
32
46
|
};
|
|
33
47
|
};
|
|
34
48
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
49
|
+
let Cell = function (_React$Component) {
|
|
50
|
+
_inheritsLoose(Cell, _React$Component);
|
|
51
|
+
function Cell() {
|
|
52
|
+
return _React$Component.apply(this, arguments) || this;
|
|
38
53
|
}
|
|
39
|
-
|
|
40
|
-
|
|
54
|
+
Cell.isClassOf = function isClassOf(instance) {
|
|
55
|
+
return instance && instance.type && instance.type.__IS_CELL__;
|
|
56
|
+
};
|
|
57
|
+
Cell.getCols = function getCols(props, mediaSize) {
|
|
41
58
|
if (!props.smallCols && !props.mediumCols && !props.largeCols && !props.cols) {
|
|
42
59
|
return undefined;
|
|
43
60
|
} else if (props.smallCols && mediaSize === "small") {
|
|
@@ -51,16 +68,14 @@ class Cell extends React.Component {
|
|
|
51
68
|
} else if (props.cols) {
|
|
52
69
|
return props.cols;
|
|
53
70
|
}
|
|
54
|
-
|
|
55
71
|
return null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
static shouldDisplay(props, mediaSize) {
|
|
72
|
+
};
|
|
73
|
+
Cell.shouldDisplay = function shouldDisplay(props, mediaSize) {
|
|
59
74
|
const cols = Cell.getCols(props, mediaSize);
|
|
60
75
|
return cols !== null && cols !== 0;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
render() {
|
|
76
|
+
};
|
|
77
|
+
var _proto = Cell.prototype;
|
|
78
|
+
_proto.render = function render() {
|
|
64
79
|
const {
|
|
65
80
|
children,
|
|
66
81
|
style
|
|
@@ -70,26 +85,21 @@ class Cell extends React.Component {
|
|
|
70
85
|
mediaSpec
|
|
71
86
|
}) => {
|
|
72
87
|
const spec = mediaSpec[mediaSize];
|
|
73
|
-
|
|
74
88
|
if (!spec) {
|
|
75
89
|
throw new Error(`mediaSpec.${mediaSize} is undefined`);
|
|
76
90
|
}
|
|
77
|
-
|
|
78
91
|
const {
|
|
79
92
|
totalColumns,
|
|
80
93
|
gutterWidth,
|
|
81
94
|
marginWidth
|
|
82
95
|
} = spec;
|
|
83
96
|
const cols = Cell.getCols(this.props, mediaSize);
|
|
84
|
-
|
|
85
97
|
if (cols === undefined || cols === null || cols === 0) {
|
|
86
98
|
return null;
|
|
87
99
|
}
|
|
88
|
-
|
|
89
100
|
if (cols > totalColumns) {
|
|
90
101
|
throw new Error(`Specified columns ${cols} is greater than the maximum ` + `${totalColumns} at the ${mediaSize} grid size.`);
|
|
91
102
|
}
|
|
92
|
-
|
|
93
103
|
const contentWidth = `(100% - ${gutterWidth * (totalColumns - 1)}px - ${marginWidth * 2}px)`;
|
|
94
104
|
const calcWidth = `calc(${contentWidth} * ${cols / totalColumns} + ${gutterWidth * (cols - 1)}px)`;
|
|
95
105
|
const contents = typeof children === "function" ? children({
|
|
@@ -101,9 +111,9 @@ class Cell extends React.Component {
|
|
|
101
111
|
style: [styles.cellFixed, flexBasis(calcWidth), style]
|
|
102
112
|
}, contents);
|
|
103
113
|
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
}
|
|
114
|
+
};
|
|
115
|
+
return Cell;
|
|
116
|
+
}(React.Component);
|
|
107
117
|
Cell.defaultProps = {
|
|
108
118
|
smallCols: 0,
|
|
109
119
|
mediumCols: 0,
|
|
@@ -112,39 +122,45 @@ Cell.defaultProps = {
|
|
|
112
122
|
};
|
|
113
123
|
Cell.__IS_CELL__ = true;
|
|
114
124
|
|
|
115
|
-
|
|
116
|
-
|
|
125
|
+
let Gutter = function (_React$Component) {
|
|
126
|
+
_inheritsLoose(Gutter, _React$Component);
|
|
127
|
+
function Gutter() {
|
|
128
|
+
return _React$Component.apply(this, arguments) || this;
|
|
129
|
+
}
|
|
130
|
+
var _proto = Gutter.prototype;
|
|
131
|
+
_proto.render = function render() {
|
|
117
132
|
return React.createElement(MediaLayout, null, ({
|
|
118
133
|
mediaSize,
|
|
119
134
|
mediaSpec
|
|
120
135
|
}) => {
|
|
121
136
|
const spec = mediaSpec[mediaSize];
|
|
122
|
-
|
|
123
137
|
if (!spec) {
|
|
124
138
|
throw new Error(`mediaSpec.${mediaSize} is undefined`);
|
|
125
139
|
}
|
|
126
|
-
|
|
127
140
|
const {
|
|
128
141
|
gutterWidth
|
|
129
142
|
} = spec;
|
|
130
|
-
|
|
131
143
|
if (!queryMatchesSize(this.props.mediaQuery, mediaSize)) {
|
|
132
144
|
return null;
|
|
133
145
|
}
|
|
134
|
-
|
|
135
146
|
return React.createElement(Strut, {
|
|
136
147
|
size: gutterWidth
|
|
137
148
|
});
|
|
138
149
|
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
}
|
|
150
|
+
};
|
|
151
|
+
return Gutter;
|
|
152
|
+
}(React.Component);
|
|
142
153
|
Gutter.defaultProps = {
|
|
143
154
|
mediaQuery: "all"
|
|
144
155
|
};
|
|
145
156
|
|
|
146
|
-
|
|
147
|
-
|
|
157
|
+
let Row = function (_React$Component) {
|
|
158
|
+
_inheritsLoose(Row, _React$Component);
|
|
159
|
+
function Row() {
|
|
160
|
+
return _React$Component.apply(this, arguments) || this;
|
|
161
|
+
}
|
|
162
|
+
var _proto = Row.prototype;
|
|
163
|
+
_proto.render = function render() {
|
|
148
164
|
const {
|
|
149
165
|
style,
|
|
150
166
|
children
|
|
@@ -154,22 +170,18 @@ class Row extends React.Component {
|
|
|
154
170
|
mediaSpec
|
|
155
171
|
}) => {
|
|
156
172
|
const spec = mediaSpec[mediaSize];
|
|
157
|
-
|
|
158
173
|
if (!spec) {
|
|
159
174
|
throw new Error(`mediaSpec.${mediaSize} is undefined`);
|
|
160
175
|
}
|
|
161
|
-
|
|
162
176
|
const {
|
|
163
177
|
marginWidth,
|
|
164
178
|
maxWidth,
|
|
165
179
|
totalColumns
|
|
166
180
|
} = spec;
|
|
167
181
|
const shouldDisplay = queryMatchesSize(this.props.mediaQuery, mediaSize);
|
|
168
|
-
|
|
169
182
|
if (!shouldDisplay) {
|
|
170
183
|
return null;
|
|
171
184
|
}
|
|
172
|
-
|
|
173
185
|
const contents = typeof children === "function" ? children({
|
|
174
186
|
mediaSize,
|
|
175
187
|
totalColumns
|
|
@@ -187,9 +199,9 @@ class Row extends React.Component {
|
|
|
187
199
|
size: marginWidth
|
|
188
200
|
}));
|
|
189
201
|
});
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
}
|
|
202
|
+
};
|
|
203
|
+
return Row;
|
|
204
|
+
}(React.Component);
|
|
193
205
|
Row.defaultProps = {
|
|
194
206
|
mediaQuery: "all"
|
|
195
207
|
};
|
package/dist/index.d.ts
ADDED