@cloudflare/component-page 4.2.510 → 5.0.2

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/lib/Page.js CHANGED
@@ -1,18 +1,186 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.default = void 0;
7
9
 
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _reactRouterDom = require("react-router-dom");
13
+
8
14
  var _styleContainer = require("@cloudflare/style-container");
9
15
 
10
- var Page = (0, _styleContainer.createStyledComponent)(function () {
16
+ var _elements = require("@cloudflare/elements");
17
+
18
+ var _componentLabel = require("@cloudflare/component-label");
19
+
20
+ var _intlReact = require("@cloudflare/intl-react");
21
+
22
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
23
+
24
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
26
+ var maxWidthByType = {
27
+ narrow: '64em',
28
+ wide: '79em',
29
+ unbounded: '100%'
30
+ };
31
+ var PageTitle = (0, _styleContainer.createComponent)(function (_ref) {
32
+ var theme = _ref.theme;
33
+ return {
34
+ fontSize: theme.fontSizes[6],
35
+ marginTop: theme.space[0],
36
+ marginBottom: theme.space[0],
37
+ lineHeight: 1.25,
38
+ color: theme.colors.gray[1],
39
+ fontWeight: 600
40
+ };
41
+ }, 'h1');
42
+ PageTitle.displayName = 'Title';
43
+ var PageSubtitle = (0, _styleContainer.createComponent)(function (_ref2) {
44
+ var theme = _ref2.theme;
45
+ return {
46
+ fontSize: theme.fontSizes[5],
47
+ marginBottom: theme.space[0],
48
+ lineHeight: 1.25,
49
+ color: theme.colors.gray[3],
50
+ fontWeight: 400
51
+ };
52
+ }, 'h2');
53
+ PageTitle.displayName = 'PageSubtitle';
54
+ var PageDescription = (0, _styleContainer.createComponent)(function (_ref3) {
55
+ var theme = _ref3.theme;
56
+ return {
57
+ fontSize: theme.fontSizes[4],
58
+ marginBottom: theme.space[0],
59
+ lineHeight: 1.25,
60
+ color: theme.colors.gray[3],
61
+ fontWeight: 400
62
+ };
63
+ }, 'p');
64
+ PageDescription.displayName = 'PageDescription';
65
+ var PageSubtitleDescription = (0, _styleContainer.createComponent)(function (_ref4) {
66
+ var theme = _ref4.theme;
67
+ return {
68
+ fontSize: theme.fontSizes[4],
69
+ marginBottom: theme.space[0],
70
+ lineHeight: 1.25,
71
+ color: theme.colors.gray[3],
72
+ fontWeight: 400
73
+ };
74
+ }, 'h2');
75
+ PageSubtitleDescription.displayName = 'PageSubtitleDescription'; // firstPage is used when dealing with focus. When navigating the dash, focus
76
+ // jumps to the page content, but not when the dash is initially loaded.
77
+
78
+ var firstPage = ''; // firstLoad is used to ensure focus is handled correctly if the user navigates
79
+ // back to the first page that was loaded.
80
+
81
+ var firstLoad = true; // Workaround for a bug where elements don't focus correctly.
82
+
83
+ var maxFocusAttempts = 10;
84
+
85
+ var focus = function focus(el) {
86
+ var attempt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
87
+ el === null || el === void 0 ? void 0 : el.focus();
88
+
89
+ if (typeof document !== 'undefined' && document.activeElement !== el && attempt < maxFocusAttempts) {
90
+ setTimeout(function () {
91
+ return focus(el, attempt + 1);
92
+ }, 10);
93
+ }
94
+ };
95
+
96
+ var Page = function Page(_ref5) {
97
+ var _history$location;
98
+
99
+ var title = _ref5.title,
100
+ subtitle = _ref5.subtitle,
101
+ description = _ref5.description,
102
+ centerHeader = _ref5.centerHeader,
103
+ beta = _ref5.beta,
104
+ testId = _ref5.testId,
105
+ className = _ref5.className,
106
+ sidebar = _ref5.sidebar,
107
+ _ref5$type = _ref5.type,
108
+ type = _ref5$type === void 0 ? 'wide' : _ref5$type,
109
+ _ref5$sidebarPosition = _ref5.sidebarPosition,
110
+ sidebarPosition = _ref5$sidebarPosition === void 0 ? 'inside' : _ref5$sidebarPosition,
111
+ _ref5$autofocus = _ref5.autofocus,
112
+ autofocus = _ref5$autofocus === void 0 ? true : _ref5$autofocus,
113
+ control = _ref5.control,
114
+ children = _ref5.children;
115
+ var history = (0, _reactRouterDom.useHistory)();
116
+ var skipTargetRef = (0, _react.useRef)(null);
117
+ var path = history === null || history === void 0 ? void 0 : (_history$location = history.location) === null || _history$location === void 0 ? void 0 : _history$location.pathname;
118
+ (0, _react.useEffect)(function () {
119
+ // If autofocus is enabled, then focus will move to the title block when
120
+ // the page is navigated to (but not when the dash is first loaded)
121
+ if (autofocus) {
122
+ if (!firstPage) {
123
+ firstPage = path;
124
+ } else if (firstPage !== path || !firstLoad) {
125
+ focus(skipTargetRef.current);
126
+ firstLoad = false;
127
+ }
128
+ }
129
+ }, [path]);
130
+ var headerVisible = !!(title || subtitle || description);
131
+
132
+ var header = /*#__PURE__*/_react.default.createElement(_elements.Header, {
133
+ mb: headerVisible ? 3 : 0,
134
+ textAlign: centerHeader ? 'center' : undefined
135
+ }, title && /*#__PURE__*/_react.default.createElement(PageTitle, null, title, beta && /*#__PURE__*/_react.default.createElement(_componentLabel.Label, {
136
+ hue: "orange",
137
+ ml: 2,
138
+ verticalAlign: "middle"
139
+ }, /*#__PURE__*/_react.default.createElement(_intlReact.Trans, {
140
+ _: "Beta",
141
+ id: "common.beta"
142
+ }))), subtitle && /*#__PURE__*/_react.default.createElement(PageSubtitle, null, subtitle), description && (subtitle ? /*#__PURE__*/_react.default.createElement(PageDescription, null, description) : /*#__PURE__*/_react.default.createElement(PageSubtitleDescription, null, description)));
143
+
144
+ if (control) {
145
+ header = /*#__PURE__*/_react.default.createElement(_elements.Div, {
146
+ display: ['block', 'flex'],
147
+ justifyContent: "space-between"
148
+ }, header, control);
149
+ }
150
+
151
+ var sidebarInside = sidebarPosition === 'inside';
152
+ return /*#__PURE__*/_react.default.createElement(_elements.Main, {
153
+ "data-testid": testId,
154
+ className: className,
155
+ display: sidebar && sidebarInside ? undefined : 'flex'
156
+ }, /*#__PURE__*/_react.default.createElement(_elements.Div, {
157
+ ml: "auto",
158
+ mr: sidebar && !sidebarInside ? 0 : 'auto',
159
+ display: sidebar ? ['block', 'block', 'flex'] : undefined,
160
+ width: type === 'unbounded' ? '100%' : '90%',
161
+ maxWidth: maxWidthByType[type] || maxWidthByType.narrow
162
+ }, /*#__PURE__*/_react.default.createElement(_elements.Div, {
163
+ width: sidebar && sidebarInside ? [1, 1, 2 / 3] : undefined,
164
+ pr: sidebar && sidebarInside ? [0, 0, 3] : undefined,
165
+ mt: 0
166
+ }, /*#__PURE__*/_react.default.createElement("a", {
167
+ id: "skipTarget",
168
+ ref: skipTargetRef,
169
+ tabIndex: -1
170
+ }), header, children), sidebar && sidebarInside && /*#__PURE__*/_react.default.createElement(_elements.Div, {
171
+ width: [1, 1, 1 / 3],
172
+ pl: [0, 0, 3],
173
+ pt: [4, 4, 0]
174
+ }, sidebar)), !sidebarInside && sidebar);
175
+ };
176
+
177
+ Page.displayName = 'Page';
178
+
179
+ var _default = (0, _styleContainer.createStyledComponent)(function () {
11
180
  return {
12
181
  py: 4,
13
182
  minHeight: 411
14
183
  };
15
- }, 'main');
16
- Page.displayName = 'Page';
17
- var _default = Page;
184
+ }, Page);
185
+
18
186
  exports.default = _default;
package/lib/index.js CHANGED
@@ -3,27 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "PageHeader", {
6
+ Object.defineProperty(exports, "Page", {
7
7
  enumerable: true,
8
8
  get: function get() {
9
- return _PageHeader.default;
9
+ return _Page.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "PageContent", {
13
- enumerable: true,
14
- get: function get() {
15
- return _PageContent.default;
16
- }
17
- });
18
- exports.Page = void 0;
19
12
 
20
13
  var _Page = _interopRequireDefault(require("./Page"));
21
14
 
22
- var _PageHeader = _interopRequireDefault(require("./PageHeader"));
23
-
24
- var _PageContent = _interopRequireDefault(require("./PageContent"));
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
-
28
- var Page = _Page.default;
29
- exports.Page = Page;
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudflare/component-page",
3
3
  "description": "Cloudflare Page Component",
4
- "version": "4.2.510",
4
+ "version": "5.0.2",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
7
7
  "author": "James Kyle <jkyle@cloudflare.com>",
@@ -11,10 +11,11 @@
11
11
  "access": "public"
12
12
  },
13
13
  "dependencies": {
14
- "@cloudflare/component-label": "^3.3.26",
15
- "@cloudflare/intl-react": "^1.9.15",
16
- "@cloudflare/style-container": "^7.5.17",
17
- "prop-types": "^15.6.0"
14
+ "@cloudflare/component-label": "^3.3.29",
15
+ "@cloudflare/elements": "^1.11.31",
16
+ "@cloudflare/intl-react": "^1.9.17",
17
+ "@cloudflare/style-container": "^7.5.20",
18
+ "react-router-dom": "^5.1.0"
18
19
  },
19
20
  "peerDependencies": {
20
21
  "react": "^15.0.0-0 || ^16.0.0-0 || ^17.0.0-0"
@@ -30,5 +31,5 @@
30
31
  "test-coverage": "stratus test --coverage",
31
32
  "test-watch": "stratus test --watch"
32
33
  },
33
- "gitHead": "737c0d5801ce0a460ef414075e1de979c645ade4"
34
+ "gitHead": "155894df6e83b90a322155ee33eae61e97d8eb9c"
34
35
  }
package/src/Page.tsx CHANGED
@@ -1,13 +1,220 @@
1
- import { createStyledComponent } from '@cloudflare/style-container';
1
+ import React, { useEffect, useRef } from 'react';
2
+ import { useHistory } from 'react-router-dom';
3
+ import {
4
+ createStyledComponent,
5
+ createComponent
6
+ } from '@cloudflare/style-container';
7
+ import { Main, Header, Div } from '@cloudflare/elements';
8
+ import { Label } from '@cloudflare/component-label';
9
+ import { Trans } from '@cloudflare/intl-react';
2
10
 
3
- const Page = createStyledComponent(
4
- () => ({
5
- py: 4,
6
- minHeight: 411
11
+ type PageWidth = 'narrow' | 'wide' | 'unbounded';
12
+
13
+ type Props = {
14
+ type?: PageWidth;
15
+ className?: string;
16
+ testId?: string;
17
+ title?: React.ReactNode;
18
+ subtitle?: React.ReactNode;
19
+ description?: React.ReactNode;
20
+ control?: React.ReactNode;
21
+ centerHeader?: boolean;
22
+ sidebar?: React.ReactNode;
23
+ sidebarPosition?: 'outside' | 'inside' | 'left';
24
+ beta?: boolean;
25
+ children?: any;
26
+ autofocus?: boolean;
27
+ };
28
+
29
+ const maxWidthByType = {
30
+ narrow: '64em',
31
+ wide: '79em',
32
+ unbounded: '100%'
33
+ };
34
+
35
+ const PageTitle = createComponent(
36
+ ({ theme }) => ({
37
+ fontSize: theme.fontSizes[6],
38
+ marginTop: theme.space[0],
39
+ marginBottom: theme.space[0],
40
+ lineHeight: 1.25,
41
+ color: theme.colors.gray[1],
42
+ fontWeight: 600
43
+ }),
44
+ 'h1'
45
+ );
46
+
47
+ PageTitle.displayName = 'Title';
48
+
49
+ const PageSubtitle = createComponent(
50
+ ({ theme }) => ({
51
+ fontSize: theme.fontSizes[5],
52
+ marginBottom: theme.space[0],
53
+ lineHeight: 1.25,
54
+ color: theme.colors.gray[3],
55
+ fontWeight: 400
56
+ }),
57
+ 'h2'
58
+ );
59
+
60
+ PageTitle.displayName = 'PageSubtitle';
61
+
62
+ const PageDescription = createComponent(
63
+ ({ theme }) => ({
64
+ fontSize: theme.fontSizes[4],
65
+ marginBottom: theme.space[0],
66
+ lineHeight: 1.25,
67
+ color: theme.colors.gray[3],
68
+ fontWeight: 400
69
+ }),
70
+ 'p'
71
+ );
72
+
73
+ PageDescription.displayName = 'PageDescription';
74
+
75
+ const PageSubtitleDescription = createComponent(
76
+ ({ theme }) => ({
77
+ fontSize: theme.fontSizes[4],
78
+ marginBottom: theme.space[0],
79
+ lineHeight: 1.25,
80
+ color: theme.colors.gray[3],
81
+ fontWeight: 400
7
82
  }),
8
- 'main'
83
+ 'h2'
9
84
  );
10
85
 
86
+ PageSubtitleDescription.displayName = 'PageSubtitleDescription';
87
+
88
+ // firstPage is used when dealing with focus. When navigating the dash, focus
89
+ // jumps to the page content, but not when the dash is initially loaded.
90
+ let firstPage = '';
91
+
92
+ // firstLoad is used to ensure focus is handled correctly if the user navigates
93
+ // back to the first page that was loaded.
94
+ let firstLoad = true;
95
+
96
+ // Workaround for a bug where elements don't focus correctly.
97
+ const maxFocusAttempts = 10;
98
+ const focus = (el: HTMLElement | null, attempt: number = 0) => {
99
+ el?.focus();
100
+ if (
101
+ typeof document !== 'undefined' &&
102
+ document.activeElement !== el &&
103
+ attempt < maxFocusAttempts
104
+ ) {
105
+ setTimeout(() => focus(el, attempt + 1), 10);
106
+ }
107
+ };
108
+
109
+ const Page = ({
110
+ title,
111
+ subtitle,
112
+ description,
113
+ centerHeader,
114
+ beta,
115
+ testId,
116
+ className,
117
+ sidebar,
118
+ type = 'wide',
119
+ sidebarPosition = 'inside',
120
+ autofocus = true,
121
+ control,
122
+ children
123
+ }: Props) => {
124
+ const history = useHistory();
125
+ const skipTargetRef = useRef<HTMLAnchorElement>(null);
126
+ const path = history?.location?.pathname;
127
+
128
+ useEffect(() => {
129
+ // If autofocus is enabled, then focus will move to the title block when
130
+ // the page is navigated to (but not when the dash is first loaded)
131
+ if (autofocus) {
132
+ if (!firstPage) {
133
+ firstPage = path;
134
+ } else if (firstPage !== path || !firstLoad) {
135
+ focus(skipTargetRef.current);
136
+ firstLoad = false;
137
+ }
138
+ }
139
+ }, [path]);
140
+
141
+ const headerVisible = !!(title || subtitle || description);
142
+
143
+ let header = (
144
+ <Header
145
+ mb={headerVisible ? 3 : 0}
146
+ textAlign={centerHeader ? 'center' : undefined}
147
+ >
148
+ {title && (
149
+ <PageTitle>
150
+ {title}
151
+ {beta && (
152
+ <Label hue="orange" ml={2} verticalAlign="middle">
153
+ <Trans _="Beta" id="common.beta" />
154
+ </Label>
155
+ )}
156
+ </PageTitle>
157
+ )}
158
+ {subtitle && <PageSubtitle>{subtitle}</PageSubtitle>}
159
+ {description &&
160
+ (subtitle ? (
161
+ <PageDescription>{description}</PageDescription>
162
+ ) : (
163
+ <PageSubtitleDescription>{description}</PageSubtitleDescription>
164
+ ))}
165
+ </Header>
166
+ );
167
+
168
+ if (control) {
169
+ header = (
170
+ <Div display={['block', 'flex']} justifyContent="space-between">
171
+ {header}
172
+ {control}
173
+ </Div>
174
+ );
175
+ }
176
+
177
+ const sidebarInside = sidebarPosition === 'inside';
178
+
179
+ return (
180
+ <Main
181
+ data-testid={testId}
182
+ className={className}
183
+ display={sidebar && sidebarInside ? undefined : 'flex'}
184
+ >
185
+ <Div
186
+ ml="auto"
187
+ mr={sidebar && !sidebarInside ? 0 : 'auto'}
188
+ display={sidebar ? ['block', 'block', 'flex'] : undefined}
189
+ width={type === 'unbounded' ? '100%' : '90%'}
190
+ maxWidth={maxWidthByType[type] || maxWidthByType.narrow}
191
+ >
192
+ <Div
193
+ width={sidebar && sidebarInside ? [1, 1, 2 / 3] : undefined}
194
+ pr={sidebar && sidebarInside ? [0, 0, 3] : undefined}
195
+ mt={0}
196
+ >
197
+ <a id="skipTarget" ref={skipTargetRef} tabIndex={-1} />
198
+ {header}
199
+ {children}
200
+ </Div>
201
+ {sidebar && sidebarInside && (
202
+ <Div width={[1, 1, 1 / 3]} pl={[0, 0, 3]} pt={[4, 4, 0]}>
203
+ {sidebar}
204
+ </Div>
205
+ )}
206
+ </Div>
207
+ {!sidebarInside && sidebar}
208
+ </Main>
209
+ );
210
+ };
211
+
11
212
  Page.displayName = 'Page';
12
213
 
13
- export default Page;
214
+ export default createStyledComponent(
215
+ () => ({
216
+ py: 4,
217
+ minHeight: 411
218
+ }),
219
+ Page
220
+ );
package/src/index.ts CHANGED
@@ -1,7 +1,3 @@
1
- import PageImport from './Page';
2
- import PageHeader from './PageHeader';
3
- import PageContent from './PageContent';
1
+ import Page from './Page';
4
2
 
5
- export const Page = PageImport;
6
-
7
- export { PageHeader, PageContent };
3
+ export { Page };
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- declare type PageWidth = 'narrow' | 'wide' | 'unbounded';
3
- declare const _default: React.ComponentType<{
4
- children?: any;
5
- className?: string | undefined;
6
- testId?: string | undefined;
7
- type?: PageWidth | undefined;
8
- innerRef?: React.Ref<never> | undefined;
9
- }>;
10
- export default _default;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- declare type Props = {
3
- title: React.ReactNode;
4
- subtitle?: React.ReactNode;
5
- beta?: boolean;
6
- };
7
- declare const PageHeader: React.FC<Props>;
8
- export default PageHeader;
package/es/PageContent.js DELETED
@@ -1,29 +0,0 @@
1
- import React from 'react';
2
- import { createComponent } from '@cloudflare/style-container';
3
- const maxWidthByType = {
4
- narrow: '64em',
5
- wide: '79em',
6
- unbounded: '100%'
7
- };
8
-
9
- const styles = ({
10
- type = 'wide'
11
- }) => ({
12
- marginLeft: 'auto',
13
- marginRight: 'auto',
14
- width: type === 'unbounded' ? '100%' : '90%',
15
- maxWidth: maxWidthByType[type] || maxWidthByType.narrow
16
- });
17
-
18
- const PageContent = ({
19
- className,
20
- children,
21
- testId
22
- }) => {
23
- return /*#__PURE__*/React.createElement("div", {
24
- className: className,
25
- "data-testid": testId
26
- }, children);
27
- };
28
-
29
- export default createComponent(styles, PageContent);
package/es/PageHeader.js DELETED
@@ -1,50 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { createComponent } from '@cloudflare/style-container';
4
- import { Label } from '@cloudflare/component-label';
5
- import { Trans } from '@cloudflare/intl-react';
6
- const PageHeading = createComponent(({
7
- theme
8
- }) => ({
9
- fontSize: theme.fontSizes[6],
10
- marginTop: theme.space[0],
11
- marginBottom: theme.space[0],
12
- lineHeight: 1.25,
13
- fontWeight: 600
14
- }), 'h1');
15
- const PageSubheading = createComponent(({
16
- theme
17
- }) => ({
18
- fontSize: theme.fontSizes[4],
19
- marginTop: theme.space[0],
20
- marginBottom: theme.space[0],
21
- lineHeight: 1.25,
22
- color: theme.colors.gray[3],
23
- fontWeight: 400
24
- }), 'h2');
25
- const Beta = createComponent(({
26
- theme
27
- }) => ({
28
- marginLeft: theme.space[2],
29
- verticalAlign: 'middle'
30
- }), Label);
31
-
32
- const PageHeader = ({
33
- title,
34
- subtitle,
35
- beta
36
- }) => {
37
- return /*#__PURE__*/React.createElement("header", null, /*#__PURE__*/React.createElement(PageHeading, null, title, beta && /*#__PURE__*/React.createElement(Beta, {
38
- hue: "orange"
39
- }, /*#__PURE__*/React.createElement(Trans, {
40
- _: "Beta",
41
- id: "common.beta"
42
- }))), subtitle && /*#__PURE__*/React.createElement(PageSubheading, null, subtitle));
43
- };
44
-
45
- PageHeader.propTypes = {
46
- title: PropTypes.node.isRequired,
47
- subtitle: PropTypes.node,
48
- beta: PropTypes.bool
49
- };
50
- export default PageHeader;
@@ -1,43 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _styleContainer = require("@cloudflare/style-container");
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- var maxWidthByType = {
15
- narrow: '64em',
16
- wide: '79em',
17
- unbounded: '100%'
18
- };
19
-
20
- var styles = function styles(_ref) {
21
- var _ref$type = _ref.type,
22
- type = _ref$type === void 0 ? 'wide' : _ref$type;
23
- return {
24
- marginLeft: 'auto',
25
- marginRight: 'auto',
26
- width: type === 'unbounded' ? '100%' : '90%',
27
- maxWidth: maxWidthByType[type] || maxWidthByType.narrow
28
- };
29
- };
30
-
31
- var PageContent = function PageContent(_ref2) {
32
- var className = _ref2.className,
33
- children = _ref2.children,
34
- testId = _ref2.testId;
35
- return /*#__PURE__*/_react.default.createElement("div", {
36
- className: className,
37
- "data-testid": testId
38
- }, children);
39
- };
40
-
41
- var _default = (0, _styleContainer.createComponent)(styles, PageContent);
42
-
43
- exports.default = _default;