@nice-digital/nds-grid 3.0.3 → 4.0.1-alpha.0
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/es/Grid.d.ts +42 -0
- package/es/Grid.js +61 -76
- package/es/Grid.test.d.ts +1 -0
- package/es/Grid.test.js +75 -0
- package/es/GridItem.d.ts +37 -0
- package/es/GridItem.js +48 -74
- package/es/GridItem.test.d.ts +1 -0
- package/es/GridItem.test.js +63 -0
- package/package.json +14 -11
- package/es/Grid.js.map +0 -1
- package/es/GridItem.js.map +0 -1
- package/lib/Grid.js +0 -103
- package/lib/Grid.js.map +0 -1
- package/lib/GridItem.js +0 -99
- package/lib/GridItem.js.map +0 -1
- package/nds-grid.d.ts +0 -93
package/es/Grid.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { GridItem } from "./GridItem";
|
|
3
|
+
import "../scss/grid.scss";
|
|
4
|
+
export { GridItem };
|
|
5
|
+
declare type ValidGridItemProps = React.ReactElement<typeof GridItem> | boolean | null | undefined;
|
|
6
|
+
export declare enum HorizontalAlignmentEnum {
|
|
7
|
+
left = "left",
|
|
8
|
+
center = "center",
|
|
9
|
+
right = "right"
|
|
10
|
+
}
|
|
11
|
+
export declare enum VerticalAlignmentEnum {
|
|
12
|
+
top = "top",
|
|
13
|
+
middle = "middle",
|
|
14
|
+
bottom = "bottom"
|
|
15
|
+
}
|
|
16
|
+
export declare enum GutterEnum {
|
|
17
|
+
standard = "standard",
|
|
18
|
+
none = "none",
|
|
19
|
+
compact = "compact",
|
|
20
|
+
loose = "loose"
|
|
21
|
+
}
|
|
22
|
+
export interface GridProps {
|
|
23
|
+
/** Grid item elements */
|
|
24
|
+
children: ValidGridItemProps[] | ValidGridItemProps;
|
|
25
|
+
/** Renders grid items in the opposite way to the source order */
|
|
26
|
+
reverse?: boolean;
|
|
27
|
+
/** Make children of grid items ahve 100% height to fill the vertical space */
|
|
28
|
+
equalHeight?: boolean;
|
|
29
|
+
/** The horizontal alignment of items within the grid, when there are empty columns. Leave blank to default to left. */
|
|
30
|
+
horizontalAlignment?: HorizontalAlignmentEnum;
|
|
31
|
+
/** The vertical alignment of items within the grid. Leave blank to default to top. */
|
|
32
|
+
verticalAlignment?: VerticalAlignmentEnum;
|
|
33
|
+
/** The gap between grid cells. Leave blank to default to the standard gutter. */
|
|
34
|
+
gutter?: GutterEnum;
|
|
35
|
+
/** Debug puts a coloured outline around the grid and its cells */
|
|
36
|
+
debug?: boolean;
|
|
37
|
+
/** Additional classes to add to the grid, for example mt--e */
|
|
38
|
+
className?: string;
|
|
39
|
+
/** The type of DOM node to render for the grid. Leave blank to default to div. */
|
|
40
|
+
elementType?: React.ElementType;
|
|
41
|
+
}
|
|
42
|
+
export declare const Grid: React.FC<GridProps>;
|
package/es/Grid.js
CHANGED
|
@@ -1,76 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
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
|
-
verticalAlignment: PropTypes.oneOf([Grid.verticalAlignment.top, Grid.verticalAlignment.middle, Grid.verticalAlignment.bottom]),
|
|
63
|
-
gutter: PropTypes.oneOf([Grid.gutter.standard, Grid.gutter.none, Grid.gutter.compact, Grid.gutter.loose]),
|
|
64
|
-
debug: PropTypes.bool,
|
|
65
|
-
className: PropTypes.string,
|
|
66
|
-
elementType: PropTypes.elementType
|
|
67
|
-
};
|
|
68
|
-
Grid.defaultProps = {
|
|
69
|
-
reverse: false,
|
|
70
|
-
equalHeight: false,
|
|
71
|
-
gutter: Grid.gutter.standard,
|
|
72
|
-
horizontalAlignment: Grid.horizontalAlignment.left,
|
|
73
|
-
verticalAlignment: Grid.verticalAlignment.top,
|
|
74
|
-
elementType: "div"
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=Grid.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Grid = exports.GutterEnum = exports.VerticalAlignmentEnum = exports.HorizontalAlignmentEnum = exports.GridItem = void 0;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
20
|
+
const GridItem_1 = require("./GridItem");
|
|
21
|
+
Object.defineProperty(exports, "GridItem", { enumerable: true, get: function () { return GridItem_1.GridItem; } });
|
|
22
|
+
require("../scss/grid.scss");
|
|
23
|
+
var HorizontalAlignmentEnum;
|
|
24
|
+
(function (HorizontalAlignmentEnum) {
|
|
25
|
+
HorizontalAlignmentEnum["left"] = "left";
|
|
26
|
+
HorizontalAlignmentEnum["center"] = "center";
|
|
27
|
+
HorizontalAlignmentEnum["right"] = "right";
|
|
28
|
+
})(HorizontalAlignmentEnum = exports.HorizontalAlignmentEnum || (exports.HorizontalAlignmentEnum = {}));
|
|
29
|
+
var VerticalAlignmentEnum;
|
|
30
|
+
(function (VerticalAlignmentEnum) {
|
|
31
|
+
VerticalAlignmentEnum["top"] = "top";
|
|
32
|
+
VerticalAlignmentEnum["middle"] = "middle";
|
|
33
|
+
VerticalAlignmentEnum["bottom"] = "bottom";
|
|
34
|
+
})(VerticalAlignmentEnum = exports.VerticalAlignmentEnum || (exports.VerticalAlignmentEnum = {}));
|
|
35
|
+
var GutterEnum;
|
|
36
|
+
(function (GutterEnum) {
|
|
37
|
+
GutterEnum["standard"] = "standard";
|
|
38
|
+
GutterEnum["none"] = "none";
|
|
39
|
+
GutterEnum["compact"] = "compact";
|
|
40
|
+
GutterEnum["loose"] = "loose";
|
|
41
|
+
})(GutterEnum = exports.GutterEnum || (exports.GutterEnum = {}));
|
|
42
|
+
const Grid = (props) => {
|
|
43
|
+
const { children, reverse, equalHeight, gutter, horizontalAlignment, verticalAlignment, debug, className, elementType } = props, rest = __rest(props, ["children", "reverse", "equalHeight", "gutter", "horizontalAlignment", "verticalAlignment", "debug", "className", "elementType"]);
|
|
44
|
+
const classNames = (0, classnames_1.default)({
|
|
45
|
+
grid: true,
|
|
46
|
+
"grid--rev": reverse,
|
|
47
|
+
"grid--equal-height": equalHeight,
|
|
48
|
+
"grid--gutterless": gutter === GutterEnum.none,
|
|
49
|
+
"grid--compact": gutter === GutterEnum.compact,
|
|
50
|
+
"grid--loose": gutter === GutterEnum.loose,
|
|
51
|
+
"grid--center": horizontalAlignment === HorizontalAlignmentEnum.center,
|
|
52
|
+
"grid--right": horizontalAlignment === HorizontalAlignmentEnum.right,
|
|
53
|
+
"grid--middle": verticalAlignment === VerticalAlignmentEnum.middle,
|
|
54
|
+
"grid--bottom": verticalAlignment === VerticalAlignmentEnum.bottom,
|
|
55
|
+
"grid--debug": debug,
|
|
56
|
+
[`${className}`]: className
|
|
57
|
+
});
|
|
58
|
+
const GridElementType = elementType || "div";
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)(GridElementType, Object.assign({ className: classNames }, rest, { children: children })));
|
|
60
|
+
};
|
|
61
|
+
exports.Grid = Grid;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/Grid.test.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("@testing-library/react");
|
|
5
|
+
const Grid_1 = require("./Grid");
|
|
6
|
+
describe("Grid", () => {
|
|
7
|
+
it("should match snapshot", () => {
|
|
8
|
+
const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsxs)(Grid_1.Grid, { children: [(0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })), (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" }))] }));
|
|
9
|
+
expect(wrapper).toMatchSnapshot();
|
|
10
|
+
});
|
|
11
|
+
it("should add rev class name to grid with reverse prop", () => {
|
|
12
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.Grid, Object.assign({ reverse: true }, { children: (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })) })));
|
|
13
|
+
expect(container.querySelector(".grid")).toHaveClass("grid grid--rev");
|
|
14
|
+
});
|
|
15
|
+
describe("gutters", () => {
|
|
16
|
+
const gutterTest = (gutter, expectedClassName) => {
|
|
17
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.Grid, Object.assign({ gutter: gutter }, { children: (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })) })));
|
|
18
|
+
expect(container.querySelector(".grid")).toHaveClass(expectedClassName);
|
|
19
|
+
};
|
|
20
|
+
it("shouldn't add any class to grid with gutter prop as standard", () => {
|
|
21
|
+
gutterTest(Grid_1.GutterEnum.standard, "grid");
|
|
22
|
+
});
|
|
23
|
+
it("should add gutterless class to grid with gutter prop as none", () => {
|
|
24
|
+
gutterTest(Grid_1.GutterEnum.none, "grid grid--gutterless");
|
|
25
|
+
});
|
|
26
|
+
it("should add compact class to grid with gutter prop as compact", () => {
|
|
27
|
+
gutterTest(Grid_1.GutterEnum.compact, "grid grid--compact");
|
|
28
|
+
});
|
|
29
|
+
it("should add compact class to grid with gutter prop as compact", () => {
|
|
30
|
+
gutterTest(Grid_1.GutterEnum.loose, "grid grid--loose");
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe("horizontal alignment", () => {
|
|
34
|
+
const horizontalAlignmentTest = (hAlignment, expectedClassName) => {
|
|
35
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.Grid, Object.assign({ horizontalAlignment: hAlignment }, { children: (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })) })));
|
|
36
|
+
expect(container.querySelector(".grid")).toHaveClass(expectedClassName);
|
|
37
|
+
};
|
|
38
|
+
it("shouldn't add any class to grid with horizontalAlignment prop as left", () => {
|
|
39
|
+
horizontalAlignmentTest(Grid_1.HorizontalAlignmentEnum.left, "grid");
|
|
40
|
+
});
|
|
41
|
+
it("should add center modifier class to grid when horizontalAlignment prop set to center", () => {
|
|
42
|
+
horizontalAlignmentTest(Grid_1.HorizontalAlignmentEnum.center, "grid grid--center");
|
|
43
|
+
});
|
|
44
|
+
it("should add right modifier class to grid when horizontalAlignment prop set to right", () => {
|
|
45
|
+
horizontalAlignmentTest(Grid_1.HorizontalAlignmentEnum.right, "grid grid--right");
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe("vertical alignment", () => {
|
|
49
|
+
const verticalAlignmentTest = (vAlignment, expectedClassName) => {
|
|
50
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.Grid, Object.assign({ verticalAlignment: vAlignment }, { children: (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })) })));
|
|
51
|
+
expect(container.querySelector(".grid")).toHaveClass(expectedClassName);
|
|
52
|
+
};
|
|
53
|
+
it("shouldn't add any class to grid with vertical alignment prop as top", () => {
|
|
54
|
+
verticalAlignmentTest(Grid_1.VerticalAlignmentEnum.top, "grid");
|
|
55
|
+
});
|
|
56
|
+
it("should add middle modifier class to grid when verticalAlignment prop set to middle", () => {
|
|
57
|
+
verticalAlignmentTest(Grid_1.VerticalAlignmentEnum.middle, "grid grid--middle");
|
|
58
|
+
});
|
|
59
|
+
it("should add bottom modifier class to grid when verticalAlignment prop set to bottom", () => {
|
|
60
|
+
verticalAlignmentTest(Grid_1.VerticalAlignmentEnum.bottom, "grid grid--bottom");
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
it("should add a debug modifier class when debug prop set to true", () => {
|
|
64
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.Grid, Object.assign({ debug: true }, { children: (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })) })));
|
|
65
|
+
expect(container.querySelector(".grid")).toHaveClass("grid grid--debug");
|
|
66
|
+
});
|
|
67
|
+
it("should add given additional class names to rendered grid class names", () => {
|
|
68
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.Grid, Object.assign({ className: "mt--d" }, { children: (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })) })));
|
|
69
|
+
expect(container.querySelector(".grid")).toHaveClass("grid mt--d");
|
|
70
|
+
});
|
|
71
|
+
it("should use elementType prop as rendered DOM node type", () => {
|
|
72
|
+
const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.Grid, Object.assign({ elementType: "ul" }, { children: (0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })) })));
|
|
73
|
+
expect(wrapper.getByRole("list")).toBeInTheDocument();
|
|
74
|
+
});
|
|
75
|
+
});
|
package/es/GridItem.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare type Columns = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
3
|
+
declare type PullOrPush = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
|
|
4
|
+
declare type BreakPointGridDefinition = Columns | {
|
|
5
|
+
/** The number of columns at this breakpoint */
|
|
6
|
+
cols: Columns;
|
|
7
|
+
/** The number of columns to pull at this breakpoint */
|
|
8
|
+
pull?: PullOrPush;
|
|
9
|
+
/** The number of columns to push at this breakpoint */
|
|
10
|
+
push?: PullOrPush;
|
|
11
|
+
};
|
|
12
|
+
export interface GridItemProps {
|
|
13
|
+
/** Contents of the grid item */
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
/** The number of columns for the first (smallest) screen size */
|
|
16
|
+
cols?: Columns;
|
|
17
|
+
/** The number of columns to pull the grid item for the first (smallest) screen size */
|
|
18
|
+
pull?: PullOrPush;
|
|
19
|
+
/** The number of columns to push the grid item for the first (smallest) screen size */
|
|
20
|
+
push?: PullOrPush;
|
|
21
|
+
/** Grid definition from the xs breakpoint */
|
|
22
|
+
xs?: BreakPointGridDefinition;
|
|
23
|
+
/** Grid definition from the sm breakpoint */
|
|
24
|
+
sm?: BreakPointGridDefinition;
|
|
25
|
+
/** Grid definition from the md breakpoint */
|
|
26
|
+
md?: BreakPointGridDefinition;
|
|
27
|
+
/** Grid definition from the lg breakpoint */
|
|
28
|
+
lg?: BreakPointGridDefinition;
|
|
29
|
+
/** Grid definition from the xl breakpoint */
|
|
30
|
+
xl?: BreakPointGridDefinition;
|
|
31
|
+
/** Additional classes to add to the grid, for example mt--e */
|
|
32
|
+
className?: string;
|
|
33
|
+
/** The type of DOM node to render for the grid item. Leave blank to default to div. */
|
|
34
|
+
elementType?: React.ElementType;
|
|
35
|
+
}
|
|
36
|
+
export declare const GridItem: React.FC<GridItemProps>;
|
|
37
|
+
export {};
|
package/es/GridItem.js
CHANGED
|
@@ -1,74 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
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
|
-
return col;
|
|
50
|
-
}).join(" ");
|
|
51
|
-
return /*#__PURE__*/React.createElement(GridItemElementType, _extends({
|
|
52
|
-
"data-g": gridColsAttr,
|
|
53
|
-
className: className
|
|
54
|
-
}, rest), children);
|
|
55
|
-
};
|
|
56
|
-
var breakpointPropType = PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
57
|
-
cols: PropTypes.number.isRequired,
|
|
58
|
-
push: PropTypes.number,
|
|
59
|
-
pull: PropTypes.number
|
|
60
|
-
})]);
|
|
61
|
-
GridItem.propTypes = {
|
|
62
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
63
|
-
cols: PropTypes.number,
|
|
64
|
-
push: PropTypes.number,
|
|
65
|
-
pull: PropTypes.number,
|
|
66
|
-
xs: breakpointPropType,
|
|
67
|
-
sm: breakpointPropType,
|
|
68
|
-
md: breakpointPropType,
|
|
69
|
-
lg: breakpointPropType,
|
|
70
|
-
xl: breakpointPropType,
|
|
71
|
-
className: PropTypes.string,
|
|
72
|
-
elementType: PropTypes.elementType
|
|
73
|
-
};
|
|
74
|
-
//# sourceMappingURL=GridItem.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.GridItem = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const GridItem = (props) => {
|
|
17
|
+
const { children, cols = 12, push, pull, xs, sm, md, lg, xl, className, elementType: GridItemElementType = "div" } = props, rest = __rest(props, ["children", "cols", "push", "pull", "xs", "sm", "md", "lg", "xl", "className", "elementType"]);
|
|
18
|
+
let gridColsAttr = [cols.toString()];
|
|
19
|
+
if (push)
|
|
20
|
+
gridColsAttr.push("push:" + push);
|
|
21
|
+
if (pull)
|
|
22
|
+
gridColsAttr.push("pull:" + pull);
|
|
23
|
+
const bpGridDefs = { xs, sm, md, lg, xl };
|
|
24
|
+
const mapBpToAttr = (bp) => {
|
|
25
|
+
const key = bp;
|
|
26
|
+
const bpGridDef = bpGridDefs[key];
|
|
27
|
+
if (!bpGridDef)
|
|
28
|
+
return null;
|
|
29
|
+
// E.g. "xs:6"
|
|
30
|
+
if (typeof bpGridDef === "number")
|
|
31
|
+
return bp + ":" + bpGridDef;
|
|
32
|
+
// E.g. "xs:6 xs:push:3"
|
|
33
|
+
const { cols, pull, push } = bpGridDef;
|
|
34
|
+
let gridDefAttr = bp + ":" + cols;
|
|
35
|
+
if (pull)
|
|
36
|
+
gridDefAttr += ` ${bp}:pull:${pull}`;
|
|
37
|
+
if (push)
|
|
38
|
+
gridDefAttr += ` ${bp}:push:${push}`;
|
|
39
|
+
return gridDefAttr;
|
|
40
|
+
};
|
|
41
|
+
const bpGridDefKeys = Object.keys(bpGridDefs).map(mapBpToAttr);
|
|
42
|
+
gridColsAttr = gridColsAttr
|
|
43
|
+
.concat(bpGridDefKeys)
|
|
44
|
+
.filter((col) => col)
|
|
45
|
+
.join(" ");
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)(GridItemElementType, Object.assign({ "data-g": gridColsAttr, className: className }, rest, { children: children })));
|
|
47
|
+
};
|
|
48
|
+
exports.GridItem = GridItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("@testing-library/react");
|
|
5
|
+
const Grid_1 = require("../src/Grid");
|
|
6
|
+
describe("GridItem", () => {
|
|
7
|
+
it("should match snapshot", () => {
|
|
8
|
+
const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6 }, { children: "Test" })));
|
|
9
|
+
expect(wrapper).toMatchSnapshot();
|
|
10
|
+
});
|
|
11
|
+
it("should add push columns to data attribute", () => {
|
|
12
|
+
var _a;
|
|
13
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6, push: 2 }, { children: "Test" })));
|
|
14
|
+
expect((_a = container.querySelector("div")) === null || _a === void 0 ? void 0 : _a.getAttribute("data-g")).toBe("6 push:2");
|
|
15
|
+
});
|
|
16
|
+
it("should add pull columns to data attribute", () => {
|
|
17
|
+
var _a;
|
|
18
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6, pull: 2 }, { children: "Test" })));
|
|
19
|
+
expect((_a = container.querySelector("div")) === null || _a === void 0 ? void 0 : _a.getAttribute("data-g")).toBe("6 pull:2");
|
|
20
|
+
});
|
|
21
|
+
describe("breakpoints", () => {
|
|
22
|
+
const pushDef = { cols: 4, push: 2, toString: () => "push 2" };
|
|
23
|
+
const pullDef = { cols: 3, pull: 1, toString: () => "pull 1" };
|
|
24
|
+
it.each([
|
|
25
|
+
["xs", 8, "xs:8"],
|
|
26
|
+
["xs", pushDef, "xs:4 xs:push:2"],
|
|
27
|
+
["xs", pullDef, "xs:3 xs:pull:1"],
|
|
28
|
+
["sm", 8, "sm:8"],
|
|
29
|
+
["sm", pushDef, "sm:4 sm:push:2"],
|
|
30
|
+
["sm", pullDef, "sm:3 sm:pull:1"],
|
|
31
|
+
["md", 8, "md:8"],
|
|
32
|
+
["md", pushDef, "md:4 md:push:2"],
|
|
33
|
+
["md", pullDef, "md:3 md:pull:1"],
|
|
34
|
+
["lg", 8, "lg:8"],
|
|
35
|
+
["lg", pushDef, "lg:4 lg:push:2"],
|
|
36
|
+
["lg", pullDef, "lg:3 lg:pull:1"],
|
|
37
|
+
["xl", 8, "xl:8"],
|
|
38
|
+
["xl", pushDef, "xl:4 xl:push:2"],
|
|
39
|
+
["xl", pullDef, "xl:3 xl:pull:1"]
|
|
40
|
+
])("for breakpoint '%s' and grid definition '%s' should set data-g to '%s'", (breakpointName, breakpointGridDef, expected) => {
|
|
41
|
+
var _a;
|
|
42
|
+
const cols = 6;
|
|
43
|
+
const breakPointProps = {
|
|
44
|
+
[breakpointName]: breakpointGridDef
|
|
45
|
+
};
|
|
46
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: cols }, breakPointProps, { children: "Test" })));
|
|
47
|
+
expect((_a = container.querySelector("div")) === null || _a === void 0 ? void 0 : _a.getAttribute("data-g")).toBe(cols + " " + expected);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
it("should add given additional class names to rendered grid item class names", () => {
|
|
51
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6, className: "mt--d" }, { children: "Test" })));
|
|
52
|
+
expect(container.querySelector("[data-g]")).toHaveClass("mt--d");
|
|
53
|
+
});
|
|
54
|
+
it("should add other props to rendered grid item", () => {
|
|
55
|
+
var _a;
|
|
56
|
+
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6, "aria-label": "test" }, { children: "Test" })));
|
|
57
|
+
expect((_a = container.querySelector("[data-g]")) === null || _a === void 0 ? void 0 : _a.getAttribute("aria-label")).toBe("test");
|
|
58
|
+
});
|
|
59
|
+
it("should use elementType prop as rendered DOM node type", () => {
|
|
60
|
+
const wrapper = (0, react_1.render)((0, jsx_runtime_1.jsx)(Grid_1.GridItem, Object.assign({ cols: 6, elementType: "li" }, { children: "Test" })));
|
|
61
|
+
expect(wrapper.getByRole("listitem")).toBeInTheDocument();
|
|
62
|
+
});
|
|
63
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nice-digital/nds-grid",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1-alpha.0",
|
|
4
4
|
"description": "Grid component for the NICE Design System",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"grid"
|
|
@@ -8,16 +8,12 @@
|
|
|
8
8
|
"author": "Ian Routledge <ian.routledge@nice.org.uk>",
|
|
9
9
|
"homepage": "https://design-system.nice.org.uk/",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"main": "
|
|
12
|
-
"module": "es/Grid.js",
|
|
11
|
+
"main": "es/Grid.js",
|
|
13
12
|
"style": "scss/grid.scss",
|
|
14
|
-
"types": "nds-grid.d.ts",
|
|
15
13
|
"directories": {
|
|
16
|
-
"lib": "
|
|
17
|
-
"test": "__tests__"
|
|
14
|
+
"lib": "es"
|
|
18
15
|
},
|
|
19
16
|
"files": [
|
|
20
|
-
"lib",
|
|
21
17
|
"es",
|
|
22
18
|
"scss",
|
|
23
19
|
"*.d.ts"
|
|
@@ -37,12 +33,19 @@
|
|
|
37
33
|
"url": "https://github.com/nice-digital/nice-design-system/issues"
|
|
38
34
|
},
|
|
39
35
|
"dependencies": {
|
|
40
|
-
"@nice-digital/nds-core": "^
|
|
41
|
-
"classnames": "^2.2.6"
|
|
42
|
-
"prop-types": "^15.7.2"
|
|
36
|
+
"@nice-digital/nds-core": "^4.0.1-alpha.0",
|
|
37
|
+
"classnames": "^2.2.6"
|
|
43
38
|
},
|
|
44
39
|
"peerDependencies": {
|
|
45
40
|
"react": "^16 || ^17 || ^18"
|
|
46
41
|
},
|
|
47
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "e75957040c9acfbd7eeb164cad724e3b48760679",
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
45
|
+
"@testing-library/react": "^13.4.0",
|
|
46
|
+
"@testing-library/user-event": "^14.4.3",
|
|
47
|
+
"@types/jest": "^29.2.2",
|
|
48
|
+
"@types/node": "^18.11.9",
|
|
49
|
+
"typescript": "^4.8.4"
|
|
50
|
+
}
|
|
48
51
|
}
|
package/es/Grid.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Grid.js","names":["React","PropTypes","classnames","GridItem","Grid","props","children","reverse","equalHeight","gutter","horizontalAlignment","verticalAlignment","debug","className","GridElementType","elementType","rest","classNames","grid","none","compact","loose","center","right","middle","bottom","standard","left","top","propTypes","oneOfType","arrayOf","element","isRequired","bool","oneOf","string","defaultProps"],"sources":["../src/Grid.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport classnames from \"classnames\";\nimport { GridItem } from \"./GridItem\";\nimport \"../scss/grid.scss\";\nexport { GridItem };\n\nexport const Grid = (props) => {\n\tconst {\n\t\tchildren,\n\t\treverse,\n\t\tequalHeight,\n\t\tgutter,\n\t\thorizontalAlignment,\n\t\tverticalAlignment,\n\t\tdebug,\n\t\tclassName,\n\t\telementType: GridElementType,\n\t\t...rest\n\t} = props;\n\n\tconst classNames = classnames({\n\t\tgrid: true,\n\t\t\"grid--rev\": reverse,\n\t\t\"grid--equal-height\": equalHeight,\n\t\t\"grid--gutterless\": gutter === Grid.gutter.none,\n\t\t\"grid--compact\": gutter === Grid.gutter.compact,\n\t\t\"grid--loose\": gutter === Grid.gutter.loose,\n\t\t\"grid--center\": horizontalAlignment === Grid.horizontalAlignment.center,\n\t\t\"grid--right\": horizontalAlignment === Grid.horizontalAlignment.right,\n\t\t\"grid--middle\": verticalAlignment === Grid.verticalAlignment.middle,\n\t\t\"grid--bottom\": verticalAlignment === Grid.verticalAlignment.bottom,\n\t\t\"grid--debug\": debug,\n\t\t[className]: className\n\t});\n\treturn (\n\t\t<GridElementType className={classNames} {...rest}>\n\t\t\t{children}\n\t\t</GridElementType>\n\t);\n};\n\nGrid.gutter = {\n\tnone: \"none\",\n\tstandard: \"standard\",\n\tcompact: \"compact\",\n\tloose: \"loose\"\n};\n\nGrid.horizontalAlignment = {\n\tleft: \"left\",\n\tcenter: \"center\",\n\tright: \"right\"\n};\n\nGrid.verticalAlignment = {\n\ttop: \"top\",\n\tmiddle: \"middle\",\n\tbottom: \"bottom\"\n};\n\nGrid.propTypes = {\n\tchildren: PropTypes.oneOfType([\n\t\tPropTypes.arrayOf(PropTypes.element),\n\t\tPropTypes.element\n\t]).isRequired,\n\treverse: PropTypes.bool,\n\tequalHeight: PropTypes.bool,\n\thorizontalAlignment: PropTypes.oneOf([\n\t\tGrid.horizontalAlignment.left,\n\t\tGrid.horizontalAlignment.center,\n\t\tGrid.horizontalAlignment.right\n\t]),\n\tverticalAlignment: PropTypes.oneOf([\n\t\tGrid.verticalAlignment.top,\n\t\tGrid.verticalAlignment.middle,\n\t\tGrid.verticalAlignment.bottom\n\t]),\n\tgutter: PropTypes.oneOf([\n\t\tGrid.gutter.standard,\n\t\tGrid.gutter.none,\n\t\tGrid.gutter.compact,\n\t\tGrid.gutter.loose\n\t]),\n\tdebug: PropTypes.bool,\n\tclassName: PropTypes.string,\n\telementType: PropTypes.elementType\n};\n\nGrid.defaultProps = {\n\treverse: false,\n\tequalHeight: false,\n\tgutter: Grid.gutter.standard,\n\thorizontalAlignment: Grid.horizontalAlignment.left,\n\tverticalAlignment: Grid.verticalAlignment.top,\n\telementType: \"div\"\n};\n"],"mappings":";;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SAASC,QAAT,QAAyB,YAAzB;AACA,OAAO,mBAAP;AACA,SAASA,QAAT;AAEA,OAAO,IAAMC,IAAI,GAAG,S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CAjBQ;EAuBhBT,KAAK,EAAEX,SAAS,CAACiC,IAvBD;EAwBhBrB,SAAS,EAAEZ,SAAS,CAACmC,MAxBL;EAyBhBrB,WAAW,EAAEd,SAAS,CAACc;AAzBP,CAAjB;AA4BAX,IAAI,CAACiC,YAAL,GAAoB;EACnB9B,OAAO,EAAE,KADU;EAEnBC,WAAW,EAAE,KAFM;EAGnBC,MAAM,EAAEL,IAAI,CAACK,MAAL,CAAYiB,QAHD;EAInBhB,mBAAmB,EAAEN,IAAI,CAACM,mBAAL,CAAyBiB,IAJ3B;EAKnBhB,iBAAiB,EAAEP,IAAI,CAACO,iBAAL,CAAuBiB,GALvB;EAMnBb,WAAW,EAAE;AANM,CAApB"}
|
package/es/GridItem.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GridItem.js","names":["React","PropTypes","GridItem","props","children","cols","push","pull","xs","sm","md","lg","xl","className","elementType","GridItemElementType","rest","gridColsAttr","toString","bpGridDefs","mapBpToAttr","bp","bpGridDef","gridDefAttr","concat","Object","keys","map","filter","col","join","breakpointPropType","oneOfType","number","shape","isRequired","propTypes","arrayOf","node","string"],"sources":["../src/GridItem.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\n\nexport const GridItem = (props) => {\n\tconst {\n\t\tchildren,\n\t\tcols = 12,\n\t\tpush,\n\t\tpull,\n\t\txs,\n\t\tsm,\n\t\tmd,\n\t\tlg,\n\t\txl,\n\t\tclassName,\n\t\telementType: GridItemElementType = \"div\",\n\t\t...rest\n\t} = props;\n\n\tlet gridColsAttr = [cols.toString()];\n\n\tif (push) gridColsAttr.push(\"push:\" + push);\n\tif (pull) gridColsAttr.push(\"pull:\" + pull);\n\n\tconst bpGridDefs = { xs, sm, md, lg, xl };\n\tconst mapBpToAttr = (bp) => {\n\t\tconst bpGridDef = bpGridDefs[bp];\n\n\t\tif (!bpGridDef) return null;\n\n\t\t// E.g. \"xs:6\"\n\t\tif (typeof bpGridDef === \"number\") return bp + \":\" + bpGridDef;\n\n\t\t// E.g. \"xs:6 xs:push:3\"\n\t\tconst { cols, pull, push } = bpGridDef;\n\t\tlet gridDefAttr = bp + \":\" + cols;\n\t\tif (pull) gridDefAttr += ` ${bp}:pull:${pull}`;\n\t\tif (push) gridDefAttr += ` ${bp}:push:${push}`;\n\t\treturn gridDefAttr;\n\t};\n\tgridColsAttr = gridColsAttr\n\t\t.concat(Object.keys(bpGridDefs).map(mapBpToAttr))\n\t\t.filter((col) => col)\n\t\t.join(\" \");\n\n\treturn (\n\t\t<GridItemElementType data-g={gridColsAttr} className={className} {...rest}>\n\t\t\t{children}\n\t\t</GridItemElementType>\n\t);\n};\n\nconst breakpointPropType = PropTypes.oneOfType([\n\tPropTypes.number,\n\tPropTypes.shape({\n\t\tcols: PropTypes.number.isRequired,\n\t\tpush: PropTypes.number,\n\t\tpull: PropTypes.number\n\t})\n]);\n\nGridItem.propTypes = {\n\tchildren: PropTypes.oneOfType([\n\t\tPropTypes.arrayOf(PropTypes.node),\n\t\tPropTypes.node\n\t]).isRequired,\n\tcols: PropTypes.number,\n\tpush: PropTypes.number,\n\tpull: PropTypes.number,\n\txs: breakpointPropType,\n\tsm: breakpointPropType,\n\tmd: breakpointPropType,\n\tlg: breakpointPropType,\n\txl: breakpointPropType,\n\tclassName: PropTypes.string,\n\telementType: PropTypes.elementType\n};\n"],"mappings":";;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAO,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAW;EAClC,IACCC,QADD,GAaID,KAbJ,CACCC,QADD;EAAA,kBAaID,KAbJ,CAECE,IAFD;EAAA,IAECA,IAFD,4BAEQ,EAFR;EAAA,IAGCC,IAHD,GAaIH,KAbJ,CAGCG,IAHD;EAAA,IAICC,IAJD,GAaIJ,KAbJ,CAICI,IAJD;EAAA,IAKCC,EALD,GAaIL,KAbJ,CAKCK,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AEZ,SAAS,CAACsC,MAbD;EAcpBzB,WAAW,EAAEb,SAAS,CAACa;AAdH,CAArB"}
|
package/lib/Grid.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
exports.__esModule = true;
|
|
6
|
-
exports.Grid = void 0;
|
|
7
|
-
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
|
|
10
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
-
|
|
12
|
-
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
|
-
var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
17
|
-
|
|
18
|
-
var _GridItem = require("./GridItem");
|
|
19
|
-
|
|
20
|
-
exports.GridItem = _GridItem.GridItem;
|
|
21
|
-
|
|
22
|
-
require("../scss/grid.scss");
|
|
23
|
-
|
|
24
|
-
var _excluded = ["children", "reverse", "equalHeight", "gutter", "horizontalAlignment", "verticalAlignment", "debug", "className", "elementType"];
|
|
25
|
-
|
|
26
|
-
var _jsxFileName = "C:\\dev\\nice-design-system\\components\\nds-grid\\src\\Grid.js",
|
|
27
|
-
_this = void 0;
|
|
28
|
-
|
|
29
|
-
var Grid = function Grid(props) {
|
|
30
|
-
var _classnames;
|
|
31
|
-
|
|
32
|
-
var children = props.children,
|
|
33
|
-
reverse = props.reverse,
|
|
34
|
-
equalHeight = props.equalHeight,
|
|
35
|
-
gutter = props.gutter,
|
|
36
|
-
horizontalAlignment = props.horizontalAlignment,
|
|
37
|
-
verticalAlignment = props.verticalAlignment,
|
|
38
|
-
debug = props.debug,
|
|
39
|
-
className = props.className,
|
|
40
|
-
GridElementType = props.elementType,
|
|
41
|
-
rest = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded);
|
|
42
|
-
var classNames = (0, _classnames2["default"])((_classnames = {
|
|
43
|
-
grid: true,
|
|
44
|
-
"grid--rev": reverse,
|
|
45
|
-
"grid--equal-height": equalHeight,
|
|
46
|
-
"grid--gutterless": gutter === Grid.gutter.none,
|
|
47
|
-
"grid--compact": gutter === Grid.gutter.compact,
|
|
48
|
-
"grid--loose": gutter === Grid.gutter.loose,
|
|
49
|
-
"grid--center": horizontalAlignment === Grid.horizontalAlignment.center,
|
|
50
|
-
"grid--right": horizontalAlignment === Grid.horizontalAlignment.right,
|
|
51
|
-
"grid--middle": verticalAlignment === Grid.verticalAlignment.middle,
|
|
52
|
-
"grid--bottom": verticalAlignment === Grid.verticalAlignment.bottom,
|
|
53
|
-
"grid--debug": debug
|
|
54
|
-
}, _classnames[className] = className, _classnames));
|
|
55
|
-
return /*#__PURE__*/_react["default"].createElement(GridElementType, (0, _extends2["default"])({
|
|
56
|
-
className: classNames
|
|
57
|
-
}, rest, {
|
|
58
|
-
__self: _this,
|
|
59
|
-
__source: {
|
|
60
|
-
fileName: _jsxFileName,
|
|
61
|
-
lineNumber: 37,
|
|
62
|
-
columnNumber: 3
|
|
63
|
-
}
|
|
64
|
-
}), children);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
exports.Grid = Grid;
|
|
68
|
-
Grid.gutter = {
|
|
69
|
-
none: "none",
|
|
70
|
-
standard: "standard",
|
|
71
|
-
compact: "compact",
|
|
72
|
-
loose: "loose"
|
|
73
|
-
};
|
|
74
|
-
Grid.horizontalAlignment = {
|
|
75
|
-
left: "left",
|
|
76
|
-
center: "center",
|
|
77
|
-
right: "right"
|
|
78
|
-
};
|
|
79
|
-
Grid.verticalAlignment = {
|
|
80
|
-
top: "top",
|
|
81
|
-
middle: "middle",
|
|
82
|
-
bottom: "bottom"
|
|
83
|
-
};
|
|
84
|
-
Grid.propTypes = {
|
|
85
|
-
children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].element), _propTypes["default"].element]).isRequired,
|
|
86
|
-
reverse: _propTypes["default"].bool,
|
|
87
|
-
equalHeight: _propTypes["default"].bool,
|
|
88
|
-
horizontalAlignment: _propTypes["default"].oneOf([Grid.horizontalAlignment.left, Grid.horizontalAlignment.center, Grid.horizontalAlignment.right]),
|
|
89
|
-
verticalAlignment: _propTypes["default"].oneOf([Grid.verticalAlignment.top, Grid.verticalAlignment.middle, Grid.verticalAlignment.bottom]),
|
|
90
|
-
gutter: _propTypes["default"].oneOf([Grid.gutter.standard, Grid.gutter.none, Grid.gutter.compact, Grid.gutter.loose]),
|
|
91
|
-
debug: _propTypes["default"].bool,
|
|
92
|
-
className: _propTypes["default"].string,
|
|
93
|
-
elementType: _propTypes["default"].elementType
|
|
94
|
-
};
|
|
95
|
-
Grid.defaultProps = {
|
|
96
|
-
reverse: false,
|
|
97
|
-
equalHeight: false,
|
|
98
|
-
gutter: Grid.gutter.standard,
|
|
99
|
-
horizontalAlignment: Grid.horizontalAlignment.left,
|
|
100
|
-
verticalAlignment: Grid.verticalAlignment.top,
|
|
101
|
-
elementType: "div"
|
|
102
|
-
};
|
|
103
|
-
//# sourceMappingURL=Grid.js.map
|
package/lib/Grid.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Grid.js","names":["Grid","props","children","reverse","equalHeight","gutter","horizontalAlignment","verticalAlignment","debug","className","GridElementType","elementType","rest","classNames","classnames","grid","none","compact","loose","center","right","middle","bottom","standard","left","top","propTypes","PropTypes","oneOfType","arrayOf","element","isRequired","bool","oneOf","string","defaultProps"],"sources":["../src/Grid.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport classnames from \"classnames\";\nimport { GridItem } from \"./GridItem\";\nimport \"../scss/grid.scss\";\nexport { GridItem };\n\nexport const Grid = (props) => {\n\tconst {\n\t\tchildren,\n\t\treverse,\n\t\tequalHeight,\n\t\tgutter,\n\t\thorizontalAlignment,\n\t\tverticalAlignment,\n\t\tdebug,\n\t\tclassName,\n\t\telementType: GridElementType,\n\t\t...rest\n\t} = props;\n\n\tconst classNames = classnames({\n\t\tgrid: true,\n\t\t\"grid--rev\": reverse,\n\t\t\"grid--equal-height\": equalHeight,\n\t\t\"grid--gutterless\": gutter === Grid.gutter.none,\n\t\t\"grid--compact\": gutter === Grid.gutter.compact,\n\t\t\"grid--loose\": gutter === Grid.gutter.loose,\n\t\t\"grid--center\": horizontalAlignment === Grid.horizontalAlignment.center,\n\t\t\"grid--right\": horizontalAlignment === Grid.horizontalAlignment.right,\n\t\t\"grid--middle\": verticalAlignment === Grid.verticalAlignment.middle,\n\t\t\"grid--bottom\": verticalAlignment === Grid.verticalAlignment.bottom,\n\t\t\"grid--debug\": debug,\n\t\t[className]: className\n\t});\n\treturn (\n\t\t<GridElementType className={classNames} {...rest}>\n\t\t\t{children}\n\t\t</GridElementType>\n\t);\n};\n\nGrid.gutter = {\n\tnone: \"none\",\n\tstandard: \"standard\",\n\tcompact: \"compact\",\n\tloose: \"loose\"\n};\n\nGrid.horizontalAlignment = {\n\tleft: \"left\",\n\tcenter: \"center\",\n\tright: \"right\"\n};\n\nGrid.verticalAlignment = {\n\ttop: \"top\",\n\tmiddle: \"middle\",\n\tbottom: \"bottom\"\n};\n\nGrid.propTypes = {\n\tchildren: PropTypes.oneOfType([\n\t\tPropTypes.arrayOf(PropTypes.element),\n\t\tPropTypes.element\n\t]).isRequired,\n\treverse: PropTypes.bool,\n\tequalHeight: PropTypes.bool,\n\thorizontalAlignment: PropTypes.oneOf([\n\t\tGrid.horizontalAlignment.left,\n\t\tGrid.horizontalAlignment.center,\n\t\tGrid.horizontalAlignment.right\n\t]),\n\tverticalAlignment: PropTypes.oneOf([\n\t\tGrid.verticalAlignment.top,\n\t\tGrid.verticalAlignment.middle,\n\t\tGrid.verticalAlignment.bottom\n\t]),\n\tgutter: PropTypes.oneOf([\n\t\tGrid.gutter.standard,\n\t\tGrid.gutter.none,\n\t\tGrid.gutter.compact,\n\t\tGrid.gutter.loose\n\t]),\n\tdebug: PropTypes.bool,\n\tclassName: PropTypes.string,\n\telementType: PropTypes.elementType\n};\n\nGrid.defaultProps = {\n\treverse: false,\n\tequalHeight: false,\n\tgutter: Grid.gutter.standard,\n\thorizontalAlignment: Grid.horizontalAlignment.left,\n\tverticalAlignment: Grid.verticalAlignment.top,\n\telementType: \"div\"\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AACA;;;;;;;AAGO,IAAMA,IAAI,GAAG,SAAPA,IAAO,CAACC,KAAD,EAAW;EAAA;;EAC9B,IACCC,QADD,GAWID,KAXJ,CACCC,QADD;EAAA,IAECC,OAFD,GAWIF,KAXJ,CAECE,OAFD;EAAA,IAGCC,WAHD,GAWIH,KAXJ,CAGCG,WAHD;EAAA,IAICC,MAJD,GAWIJ,KAXJ,CAICI,MAJD;EAAA,IAKCC,mBALD,GAWIL,KAXJ,CAKCK,mBALD;EAAA,IAMCC,iBAND,GAWIN,KAXJ,CAMCM,iBAND;EAAA,IAOCC,KAPD,GAWIP,KAXJ,CAOCO,KAPD;EAAA,IAQCC,SARD,GAWIR,KAXJ,CAQCQ,SARD;EAAA,IAScC,eATd,GAWIT,KAXJ,CASCU,WATD;EAAA,IAUIC,IAVJ,kDAWIX,KAXJ;EAaA,IAAMY,UAAU,GAAG,IAAAC,uBAAA;IAClBC,IAAI,EAAE,IADY;IAElB,aAAaZ,OAFK;IAGlB,sBAAsBC,WAHJ;IAIlB,oBAAoBC,MAAM,KAAKL,IAAI,CAACK,MAAL,CAAYW,IAJzB;IAKlB,iBAAiBX,MAAM,KAAKL,IAAI,CAACK,MAAL,CAAYY,OALtB;IAMlB,eAAeZ,MAAM,KAAKL,IAAI,CAACK,MAAL,CAAYa,KANpB;IAOlB,gBAAgBZ,mBAAmB,KAAKN,IAAI,CAACM,mBAAL,CAAyBa,MAP/C;IAQlB,eAAeb,mBAAmB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,CAAhB,CAPL;EAYhBb,iBAAiB,EAAEoB,qBAAA,CAAUM,KAAV,CAAgB,CAClCjC,IAAI,CAACO,iBAAL,CAAuBkB,GADW,EAElCzB,IAAI,CAACO,iBAAL,CAAuBc,MAFW,EAGlCrB,IAAI,CAACO,iBAAL,CAAuBe,MAHW,CAAhB,CAZH;EAiBhBjB,MAAM,EAAEsB,qBAAA,CAAUM,KAAV,CAAgB,CACvBjC,IAAI,CAACK,MAAL,CAAYkB,QADW,EAEvBvB,IAAI,CAACK,MAAL,CAAYW,IAFW,EAGvBhB,IAAI,CAACK,MAAL,CAAYY,OAHW,EAIvBjB,IAAI,CAACK,MAAL,CAAYa,KAJW,CAAhB,CAjBQ;EAuBhBV,KAAK,EAAEmB,qBAAA,CAAUK,IAvBD;EAwBhBvB,SAAS,EAAEkB,qBAAA,CAAUO,MAxBL;EAyBhBvB,WAAW,EAAEgB,qBAAA,CAAUhB;AAzBP,CAAjB;AA4BAX,IAAI,CAACmC,YAAL,GAAoB;EACnBhC,OAAO,EAAE,KADU;EAEnBC,WAAW,EAAE,KAFM;EAGnBC,MAAM,EAAEL,IAAI,CAACK,MAAL,CAAYkB,QAHD;EAInBjB,mBAAmB,EAAEN,IAAI,CAACM,mBAAL,CAAyBkB,IAJ3B;EAKnBjB,iBAAiB,EAAEP,IAAI,CAACO,iBAAL,CAAuBkB,GALvB;EAMnBd,WAAW,EAAE;AANM,CAApB"}
|
package/lib/GridItem.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
exports.__esModule = true;
|
|
6
|
-
exports.GridItem = void 0;
|
|
7
|
-
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
|
|
10
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
-
|
|
12
|
-
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
|
-
var _excluded = ["children", "cols", "push", "pull", "xs", "sm", "md", "lg", "xl", "className", "elementType"];
|
|
17
|
-
|
|
18
|
-
var _jsxFileName = "C:\\dev\\nice-design-system\\components\\nds-grid\\src\\GridItem.js",
|
|
19
|
-
_this = void 0;
|
|
20
|
-
|
|
21
|
-
var GridItem = function GridItem(props) {
|
|
22
|
-
var children = props.children,
|
|
23
|
-
_props$cols = props.cols,
|
|
24
|
-
cols = _props$cols === void 0 ? 12 : _props$cols,
|
|
25
|
-
push = props.push,
|
|
26
|
-
pull = props.pull,
|
|
27
|
-
xs = props.xs,
|
|
28
|
-
sm = props.sm,
|
|
29
|
-
md = props.md,
|
|
30
|
-
lg = props.lg,
|
|
31
|
-
xl = props.xl,
|
|
32
|
-
className = props.className,
|
|
33
|
-
_props$elementType = props.elementType,
|
|
34
|
-
GridItemElementType = _props$elementType === void 0 ? "div" : _props$elementType,
|
|
35
|
-
rest = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded);
|
|
36
|
-
var gridColsAttr = [cols.toString()];
|
|
37
|
-
if (push) gridColsAttr.push("push:" + push);
|
|
38
|
-
if (pull) gridColsAttr.push("pull:" + pull);
|
|
39
|
-
var bpGridDefs = {
|
|
40
|
-
xs: xs,
|
|
41
|
-
sm: sm,
|
|
42
|
-
md: md,
|
|
43
|
-
lg: lg,
|
|
44
|
-
xl: xl
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
var mapBpToAttr = function mapBpToAttr(bp) {
|
|
48
|
-
var bpGridDef = bpGridDefs[bp];
|
|
49
|
-
if (!bpGridDef) return null; // E.g. "xs:6"
|
|
50
|
-
|
|
51
|
-
if (typeof bpGridDef === "number") return bp + ":" + bpGridDef; // E.g. "xs:6 xs:push:3"
|
|
52
|
-
|
|
53
|
-
var cols = bpGridDef.cols,
|
|
54
|
-
pull = bpGridDef.pull,
|
|
55
|
-
push = bpGridDef.push;
|
|
56
|
-
var gridDefAttr = bp + ":" + cols;
|
|
57
|
-
if (pull) gridDefAttr += " " + bp + ":pull:" + pull;
|
|
58
|
-
if (push) gridDefAttr += " " + bp + ":push:" + push;
|
|
59
|
-
return gridDefAttr;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
gridColsAttr = gridColsAttr.concat(Object.keys(bpGridDefs).map(mapBpToAttr)).filter(function (col) {
|
|
63
|
-
return col;
|
|
64
|
-
}).join(" ");
|
|
65
|
-
return /*#__PURE__*/_react["default"].createElement(GridItemElementType, (0, _extends2["default"])({
|
|
66
|
-
"data-g": gridColsAttr,
|
|
67
|
-
className: className
|
|
68
|
-
}, rest, {
|
|
69
|
-
__self: _this,
|
|
70
|
-
__source: {
|
|
71
|
-
fileName: _jsxFileName,
|
|
72
|
-
lineNumber: 47,
|
|
73
|
-
columnNumber: 3
|
|
74
|
-
}
|
|
75
|
-
}), children);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
exports.GridItem = GridItem;
|
|
79
|
-
|
|
80
|
-
var breakpointPropType = _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].shape({
|
|
81
|
-
cols: _propTypes["default"].number.isRequired,
|
|
82
|
-
push: _propTypes["default"].number,
|
|
83
|
-
pull: _propTypes["default"].number
|
|
84
|
-
})]);
|
|
85
|
-
|
|
86
|
-
GridItem.propTypes = {
|
|
87
|
-
children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired,
|
|
88
|
-
cols: _propTypes["default"].number,
|
|
89
|
-
push: _propTypes["default"].number,
|
|
90
|
-
pull: _propTypes["default"].number,
|
|
91
|
-
xs: breakpointPropType,
|
|
92
|
-
sm: breakpointPropType,
|
|
93
|
-
md: breakpointPropType,
|
|
94
|
-
lg: breakpointPropType,
|
|
95
|
-
xl: breakpointPropType,
|
|
96
|
-
className: _propTypes["default"].string,
|
|
97
|
-
elementType: _propTypes["default"].elementType
|
|
98
|
-
};
|
|
99
|
-
//# sourceMappingURL=GridItem.js.map
|
package/lib/GridItem.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GridItem.js","names":["GridItem","props","children","cols","push","pull","xs","sm","md","lg","xl","className","elementType","GridItemElementType","rest","gridColsAttr","toString","bpGridDefs","mapBpToAttr","bp","bpGridDef","gridDefAttr","concat","Object","keys","map","filter","col","join","breakpointPropType","PropTypes","oneOfType","number","shape","isRequired","propTypes","arrayOf","node","string"],"sources":["../src/GridItem.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\n\nexport const GridItem = (props) => {\n\tconst {\n\t\tchildren,\n\t\tcols = 12,\n\t\tpush,\n\t\tpull,\n\t\txs,\n\t\tsm,\n\t\tmd,\n\t\tlg,\n\t\txl,\n\t\tclassName,\n\t\telementType: GridItemElementType = \"div\",\n\t\t...rest\n\t} = props;\n\n\tlet gridColsAttr = [cols.toString()];\n\n\tif (push) gridColsAttr.push(\"push:\" + push);\n\tif (pull) gridColsAttr.push(\"pull:\" + pull);\n\n\tconst bpGridDefs = { xs, sm, md, lg, xl };\n\tconst mapBpToAttr = (bp) => {\n\t\tconst bpGridDef = bpGridDefs[bp];\n\n\t\tif (!bpGridDef) return null;\n\n\t\t// E.g. \"xs:6\"\n\t\tif (typeof bpGridDef === \"number\") return bp + \":\" + bpGridDef;\n\n\t\t// E.g. \"xs:6 xs:push:3\"\n\t\tconst { cols, pull, push } = bpGridDef;\n\t\tlet gridDefAttr = bp + \":\" + cols;\n\t\tif (pull) gridDefAttr += ` ${bp}:pull:${pull}`;\n\t\tif (push) gridDefAttr += ` ${bp}:push:${push}`;\n\t\treturn gridDefAttr;\n\t};\n\tgridColsAttr = gridColsAttr\n\t\t.concat(Object.keys(bpGridDefs).map(mapBpToAttr))\n\t\t.filter((col) => col)\n\t\t.join(\" \");\n\n\treturn (\n\t\t<GridItemElementType data-g={gridColsAttr} className={className} {...rest}>\n\t\t\t{children}\n\t\t</GridItemElementType>\n\t);\n};\n\nconst breakpointPropType = PropTypes.oneOfType([\n\tPropTypes.number,\n\tPropTypes.shape({\n\t\tcols: PropTypes.number.isRequired,\n\t\tpush: PropTypes.number,\n\t\tpull: PropTypes.number\n\t})\n]);\n\nGridItem.propTypes = {\n\tchildren: PropTypes.oneOfType([\n\t\tPropTypes.arrayOf(PropTypes.node),\n\t\tPropTypes.node\n\t]).isRequired,\n\tcols: PropTypes.number,\n\tpush: PropTypes.number,\n\tpull: PropTypes.number,\n\txs: breakpointPropType,\n\tsm: breakpointPropType,\n\tmd: breakpointPropType,\n\tlg: breakpointPropType,\n\txl: breakpointPropType,\n\tclassName: PropTypes.string,\n\telementType: PropTypes.elementType\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;;;;;;AAEO,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAW;EAClC,IACCC,QADD,GAaID,KAbJ,CACCC,QADD;EAAA,kBAaID,KAbJ,CAECE,IAFD;EAAA,IAECA,IAFD,4BAEQ,EAFR;EAAA,IAGCC,IAHD,GAaIH,KAbJ,CAGCG,IAHD;EAAA,IAICC,IAJD,GAaIJ,KAbJ,CAICI,IAJD;EAAA,IAKCC,EALD,GAaIL,KAbJ,CAKCK,EALD;EAAA,IAMCC,EAND,GAaIN,KAbJ,CAMCM,EAND;EAAA,IAOCC,EAPD,GAaIP,KAbJ,CAOCO,EAPD;EAAA,IAQCC,EARD,GAaIR,KAbJ,CAQCQ,EARD;EAAA,IASCC,EATD,GAaIT,KAbJ,CASCS,EATD;EAAA,IAUCC,SAVD,GAaIV,KAbJ,CAUCU,SAVD;EAAA,yBAaIV,KAbJ,CAWCW,WAXD;EAAA,IAWcC,mBAXd,mCAWoC,KAXpC;EAAA,IAYIC,IAZJ,kDAaIb,KAbJ;EAeA,IAAIc,YAAY,GAAG,CAACZ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4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
|
|
6
|
-
type BreakPointGridDefinition =
|
|
7
|
-
| Columns
|
|
8
|
-
| {
|
|
9
|
-
/** The number of columns at this breakpoint */
|
|
10
|
-
cols: Columns;
|
|
11
|
-
/** The number of columns to pull at this breakpoint */
|
|
12
|
-
pull?: PullOrPush;
|
|
13
|
-
/** The number of columns to push at this breakpoint */
|
|
14
|
-
push?: PullOrPush;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export interface GridItemProps {
|
|
18
|
-
/** Contents of the grid item */
|
|
19
|
-
children: React.ReactNode;
|
|
20
|
-
/** The number of columns for the first (smallest) screen size */
|
|
21
|
-
cols?: Columns;
|
|
22
|
-
/** The number of columns to pull the grid item for the first (smallest) screen size */
|
|
23
|
-
pull?: PullOrPush;
|
|
24
|
-
/** The number of columns to push the grid item for the first (smallest) screen size */
|
|
25
|
-
push?: PullOrPush;
|
|
26
|
-
/** Grid definition from the xs breakpoint */
|
|
27
|
-
xs?: BreakPointGridDefinition;
|
|
28
|
-
/** Grid definition from the sm breakpoint */
|
|
29
|
-
sm?: BreakPointGridDefinition;
|
|
30
|
-
/** Grid definition from the md breakpoint */
|
|
31
|
-
md?: BreakPointGridDefinition;
|
|
32
|
-
/** Grid definition from the lg breakpoint */
|
|
33
|
-
lg?: BreakPointGridDefinition;
|
|
34
|
-
/** Grid definition from the xl breakpoint */
|
|
35
|
-
xl?: BreakPointGridDefinition;
|
|
36
|
-
/** Additional classes to add to the grid, for example mt--e */
|
|
37
|
-
className?: string;
|
|
38
|
-
/** The type of DOM node to render for the grid item. Leave blank to default to div. */
|
|
39
|
-
elementType?: React.ElementType;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** An item within the grid than spans up to 12 columnns */
|
|
43
|
-
export const GridItem: React.FC<GridItemProps>;
|
|
44
|
-
|
|
45
|
-
type ValidGridItemProps =
|
|
46
|
-
| React.ReactElement<typeof GridItem>
|
|
47
|
-
| boolean
|
|
48
|
-
| null
|
|
49
|
-
| undefined;
|
|
50
|
-
|
|
51
|
-
export interface GridProps {
|
|
52
|
-
/** Grid item elements */
|
|
53
|
-
children: ValidGridItemProps[] | ValidGridItemProps;
|
|
54
|
-
/** Renders grid items in the opposite way to the source order */
|
|
55
|
-
reverse?: boolean;
|
|
56
|
-
/** Make children of grid items ahve 100% height to fill the vertical space */
|
|
57
|
-
equalHeight?: boolean;
|
|
58
|
-
/** The horizontal alignment of items within the grid, when there are empty columns. Leave blank to default to left. */
|
|
59
|
-
horizontalAlignment?: "left" | "center" | "right";
|
|
60
|
-
/** The vertical alignment of items within the grid. Leave blank to default to top. */
|
|
61
|
-
verticalAlignment?: "top" | "middle" | "bottom";
|
|
62
|
-
/** The gap between grid cells. Leave blank to default to the standard gutter. */
|
|
63
|
-
gutter?: "standard" | "none" | "compact" | "loose";
|
|
64
|
-
/** Debug puts a coloured outline around the grid and its cells */
|
|
65
|
-
debug?: boolean;
|
|
66
|
-
/** Additional classes to add to the grid, for example mt--e */
|
|
67
|
-
className?: string;
|
|
68
|
-
/** The type of DOM node to render for the grid. Leave blank to default to div. */
|
|
69
|
-
elementType?: React.ElementType;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
interface GridComponent extends React.FC<GridProps> {
|
|
73
|
-
gutter: {
|
|
74
|
-
none: "none";
|
|
75
|
-
standard: "standard";
|
|
76
|
-
compact: "compact";
|
|
77
|
-
loose: "loose";
|
|
78
|
-
};
|
|
79
|
-
horizontalAlignment: {
|
|
80
|
-
left: "left";
|
|
81
|
-
center: "center";
|
|
82
|
-
right: "right";
|
|
83
|
-
};
|
|
84
|
-
verticalAlignment: {
|
|
85
|
-
top: "top";
|
|
86
|
-
middle: "middle";
|
|
87
|
-
bottom: "bottom";
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** A mobile first, 12 columns grid component */
|
|
92
|
-
export const Grid: GridComponent;
|
|
93
|
-
}
|