@cloudflare/component-page 9.0.0 → 9.1.1
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 +14 -0
- package/dist/Page.d.ts +2 -0
- package/es/Page.js +19 -4
- package/lib/Page.js +20 -4
- package/package.json +3 -3
- package/src/Page.tsx +38 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 9.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [0d66b430a2]
|
|
8
|
+
- @cloudflare/elements@3.0.4
|
|
9
|
+
- @cloudflare/component-link@8.0.8
|
|
10
|
+
|
|
11
|
+
## 9.1.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 47cd1e5858: add support for rendering documentation button instead of a link in page header
|
|
16
|
+
|
|
3
17
|
## 9.0.0
|
|
4
18
|
|
|
5
19
|
### Major Changes
|
package/dist/Page.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ declare const _default: React.ComponentType<{
|
|
|
13
13
|
titleRef?: React.RefObject<HTMLHeadingElement> | undefined;
|
|
14
14
|
parentPageLabelRef?: React.RefObject<HTMLHeadingElement> | undefined;
|
|
15
15
|
navigation?: React.ReactNode;
|
|
16
|
+
onDocumentationButtonClick?: (() => void) | undefined;
|
|
17
|
+
documentationAsButton?: boolean | undefined;
|
|
16
18
|
type?: PageWidth | undefined;
|
|
17
19
|
className?: string | undefined;
|
|
18
20
|
testId?: string | undefined;
|
package/es/Page.js
CHANGED
|
@@ -8,6 +8,7 @@ import { Heading, Section } from './Heading';
|
|
|
8
8
|
import { DocumentationLink, Link } from '@cloudflare/component-link';
|
|
9
9
|
import { useIsMobile } from '@cloudflare/util-responsive';
|
|
10
10
|
import { Icon } from '@cloudflare/component-icon';
|
|
11
|
+
import { Button } from '@cloudflare/component-button';
|
|
11
12
|
var maxWidthByType = {
|
|
12
13
|
narrow: '64em',
|
|
13
14
|
wide: '79em',
|
|
@@ -28,7 +29,9 @@ var PageHeader = _ref => {
|
|
|
28
29
|
beta,
|
|
29
30
|
titleRef,
|
|
30
31
|
parentPageLabelRef,
|
|
31
|
-
navigation
|
|
32
|
+
navigation,
|
|
33
|
+
onDocumentationButtonClick,
|
|
34
|
+
documentationAsButton
|
|
32
35
|
} = _ref;
|
|
33
36
|
var headerVisible = !!(title || description);
|
|
34
37
|
var titlesCount = Math.min([title, description].filter(Boolean).length, 2);
|
|
@@ -69,7 +72,15 @@ var PageHeader = _ref => {
|
|
|
69
72
|
mb: documentationHref ? 2 : 3,
|
|
70
73
|
lineHeight: 1.25,
|
|
71
74
|
fontWeight: 400
|
|
72
|
-
}, description),
|
|
75
|
+
}, description), documentationAsButton ? /*#__PURE__*/React.createElement(Button, {
|
|
76
|
+
type: "primary",
|
|
77
|
+
borderRadius: '20vh',
|
|
78
|
+
inverted: true,
|
|
79
|
+
iconType: "documentation",
|
|
80
|
+
onClick: onDocumentationButtonClick,
|
|
81
|
+
px: 3,
|
|
82
|
+
py: 1
|
|
83
|
+
}, documentationLabel) : documentationHref && /*#__PURE__*/React.createElement(DocumentationLink, {
|
|
73
84
|
fontSize: 2,
|
|
74
85
|
iconSize: 14,
|
|
75
86
|
mb: [3, 0],
|
|
@@ -124,7 +135,9 @@ var Page = _ref2 => {
|
|
|
124
135
|
titleRef,
|
|
125
136
|
parentPageLabelRef,
|
|
126
137
|
children,
|
|
127
|
-
navigation
|
|
138
|
+
navigation,
|
|
139
|
+
onDocumentationButtonClick,
|
|
140
|
+
documentationAsButton
|
|
128
141
|
} = _ref2;
|
|
129
142
|
var history = useHistory();
|
|
130
143
|
var skipTargetRef = useRef(null);
|
|
@@ -174,7 +187,9 @@ var Page = _ref2 => {
|
|
|
174
187
|
beta: beta,
|
|
175
188
|
titleRef: titleRef,
|
|
176
189
|
parentPageLabelRef: parentPageLabelRef,
|
|
177
|
-
navigation: navigation
|
|
190
|
+
navigation: navigation,
|
|
191
|
+
onDocumentationButtonClick: onDocumentationButtonClick,
|
|
192
|
+
documentationAsButton: documentationAsButton
|
|
178
193
|
})), sidebar && sidebarInside && /*#__PURE__*/React.createElement(Div, {
|
|
179
194
|
width: [1, 1, 1 / 3],
|
|
180
195
|
pl: [0, 0, 3],
|
package/lib/Page.js
CHANGED
|
@@ -27,6 +27,8 @@ var _utilResponsive = require("@cloudflare/util-responsive");
|
|
|
27
27
|
|
|
28
28
|
var _componentIcon = require("@cloudflare/component-icon");
|
|
29
29
|
|
|
30
|
+
var _componentButton = require("@cloudflare/component-button");
|
|
31
|
+
|
|
30
32
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
33
|
|
|
32
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
@@ -50,7 +52,9 @@ var PageHeader = function PageHeader(_ref) {
|
|
|
50
52
|
beta = _ref.beta,
|
|
51
53
|
titleRef = _ref.titleRef,
|
|
52
54
|
parentPageLabelRef = _ref.parentPageLabelRef,
|
|
53
|
-
navigation = _ref.navigation
|
|
55
|
+
navigation = _ref.navigation,
|
|
56
|
+
onDocumentationButtonClick = _ref.onDocumentationButtonClick,
|
|
57
|
+
documentationAsButton = _ref.documentationAsButton;
|
|
54
58
|
var headerVisible = !!(title || description);
|
|
55
59
|
var titlesCount = Math.min([title, description].filter(Boolean).length, 2);
|
|
56
60
|
var isMobile = (0, _utilResponsive.useIsMobile)();
|
|
@@ -90,7 +94,15 @@ var PageHeader = function PageHeader(_ref) {
|
|
|
90
94
|
mb: documentationHref ? 2 : 3,
|
|
91
95
|
lineHeight: 1.25,
|
|
92
96
|
fontWeight: 400
|
|
93
|
-
}, description),
|
|
97
|
+
}, description), documentationAsButton ? /*#__PURE__*/_react.default.createElement(_componentButton.Button, {
|
|
98
|
+
type: "primary",
|
|
99
|
+
borderRadius: '20vh',
|
|
100
|
+
inverted: true,
|
|
101
|
+
iconType: "documentation",
|
|
102
|
+
onClick: onDocumentationButtonClick,
|
|
103
|
+
px: 3,
|
|
104
|
+
py: 1
|
|
105
|
+
}, documentationLabel) : documentationHref && /*#__PURE__*/_react.default.createElement(_componentLink.DocumentationLink, {
|
|
94
106
|
fontSize: 2,
|
|
95
107
|
iconSize: 14,
|
|
96
108
|
mb: [3, 0],
|
|
@@ -149,7 +161,9 @@ var Page = function Page(_ref2) {
|
|
|
149
161
|
titleRef = _ref2.titleRef,
|
|
150
162
|
parentPageLabelRef = _ref2.parentPageLabelRef,
|
|
151
163
|
children = _ref2.children,
|
|
152
|
-
navigation = _ref2.navigation
|
|
164
|
+
navigation = _ref2.navigation,
|
|
165
|
+
onDocumentationButtonClick = _ref2.onDocumentationButtonClick,
|
|
166
|
+
documentationAsButton = _ref2.documentationAsButton;
|
|
153
167
|
var history = (0, _reactRouterDom.useHistory)();
|
|
154
168
|
var skipTargetRef = (0, _react.useRef)(null);
|
|
155
169
|
var path = history === null || history === void 0 ? void 0 : (_history$location = history.location) === null || _history$location === void 0 ? void 0 : _history$location.pathname;
|
|
@@ -198,7 +212,9 @@ var Page = function Page(_ref2) {
|
|
|
198
212
|
beta: beta,
|
|
199
213
|
titleRef: titleRef,
|
|
200
214
|
parentPageLabelRef: parentPageLabelRef,
|
|
201
|
-
navigation: navigation
|
|
215
|
+
navigation: navigation,
|
|
216
|
+
onDocumentationButtonClick: onDocumentationButtonClick,
|
|
217
|
+
documentationAsButton: documentationAsButton
|
|
202
218
|
})), sidebar && sidebarInside && /*#__PURE__*/_react.default.createElement(_elements.Div, {
|
|
203
219
|
width: [1, 1, 1 / 3],
|
|
204
220
|
pl: [0, 0, 3],
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/component-page",
|
|
3
3
|
"description": "Cloudflare Page Component",
|
|
4
|
-
"version": "9.
|
|
4
|
+
"version": "9.1.1",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
7
|
"author": "James Kyle <jkyle@cloudflare.com>",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@cloudflare/component-label": "^5.0.4",
|
|
17
|
-
"@cloudflare/component-link": "^8.0.
|
|
18
|
-
"@cloudflare/elements": "^3.0.
|
|
17
|
+
"@cloudflare/component-link": "^8.0.8",
|
|
18
|
+
"@cloudflare/elements": "^3.0.4",
|
|
19
19
|
"@cloudflare/intl-react": "^1.9.80"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
package/src/Page.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import { Heading, Section } from './Heading';
|
|
|
8
8
|
import { DocumentationLink, Link } from '@cloudflare/component-link';
|
|
9
9
|
import { useIsMobile } from '@cloudflare/util-responsive';
|
|
10
10
|
import { Icon } from '@cloudflare/component-icon';
|
|
11
|
+
import { Button } from '@cloudflare/component-button';
|
|
11
12
|
|
|
12
13
|
type PageWidth = 'narrow' | 'wide' | 'unbounded';
|
|
13
14
|
|
|
@@ -24,6 +25,8 @@ type PageHeaderProps = {
|
|
|
24
25
|
titleRef?: React.RefObject<HTMLHeadingElement>;
|
|
25
26
|
parentPageLabelRef?: React.RefObject<HTMLHeadingElement>;
|
|
26
27
|
navigation?: React.ReactNode;
|
|
28
|
+
onDocumentationButtonClick?: () => void;
|
|
29
|
+
documentationAsButton?: boolean;
|
|
27
30
|
};
|
|
28
31
|
|
|
29
32
|
type Props = PageHeaderProps & {
|
|
@@ -55,7 +58,9 @@ const PageHeader = ({
|
|
|
55
58
|
beta,
|
|
56
59
|
titleRef,
|
|
57
60
|
parentPageLabelRef,
|
|
58
|
-
navigation
|
|
61
|
+
navigation,
|
|
62
|
+
onDocumentationButtonClick,
|
|
63
|
+
documentationAsButton
|
|
59
64
|
}: PageHeaderProps) => {
|
|
60
65
|
const headerVisible = !!(title || description);
|
|
61
66
|
const titlesCount = Math.min([title, description].filter(Boolean).length, 2);
|
|
@@ -107,20 +112,34 @@ const PageHeader = ({
|
|
|
107
112
|
{description}
|
|
108
113
|
</P>
|
|
109
114
|
)}
|
|
110
|
-
{
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
{documentationAsButton ? (
|
|
116
|
+
<Button
|
|
117
|
+
type="primary"
|
|
118
|
+
borderRadius={'20vh'}
|
|
119
|
+
inverted
|
|
120
|
+
iconType="documentation"
|
|
121
|
+
onClick={onDocumentationButtonClick}
|
|
122
|
+
px={3}
|
|
123
|
+
py={1}
|
|
117
124
|
>
|
|
118
|
-
{documentationLabel
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
125
|
+
{documentationLabel}
|
|
126
|
+
</Button>
|
|
127
|
+
) : (
|
|
128
|
+
documentationHref && (
|
|
129
|
+
<DocumentationLink
|
|
130
|
+
fontSize={2}
|
|
131
|
+
iconSize={14}
|
|
132
|
+
mb={[3, 0]}
|
|
133
|
+
href={documentationHref}
|
|
134
|
+
display="inline-block"
|
|
135
|
+
>
|
|
136
|
+
{documentationLabel ? (
|
|
137
|
+
documentationLabel
|
|
138
|
+
) : (
|
|
139
|
+
<Trans id="common.documentation" _={'Documentation'} />
|
|
140
|
+
)}
|
|
141
|
+
</DocumentationLink>
|
|
142
|
+
)
|
|
124
143
|
)}
|
|
125
144
|
</Header>
|
|
126
145
|
{control}
|
|
@@ -173,7 +192,9 @@ const Page = ({
|
|
|
173
192
|
titleRef,
|
|
174
193
|
parentPageLabelRef,
|
|
175
194
|
children,
|
|
176
|
-
navigation
|
|
195
|
+
navigation,
|
|
196
|
+
onDocumentationButtonClick,
|
|
197
|
+
documentationAsButton
|
|
177
198
|
}: Props) => {
|
|
178
199
|
const history = useHistory();
|
|
179
200
|
const skipTargetRef = useRef<HTMLAnchorElement>(null);
|
|
@@ -231,6 +252,8 @@ const Page = ({
|
|
|
231
252
|
titleRef={titleRef}
|
|
232
253
|
parentPageLabelRef={parentPageLabelRef}
|
|
233
254
|
navigation={navigation}
|
|
255
|
+
onDocumentationButtonClick={onDocumentationButtonClick}
|
|
256
|
+
documentationAsButton={documentationAsButton}
|
|
234
257
|
/>
|
|
235
258
|
</Div>
|
|
236
259
|
{sidebar && sidebarInside && (
|