@khanacademy/wonder-blocks-link 3.8.8 → 3.8.10
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 +15 -0
- package/dist/index.js +78 -52
- package/package.json +4 -4
- package/src/__tests__/__snapshots__/custom-snapshot.test.js.snap +33 -33
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +13 -13
- package/src/components/__docs__/link.argtypes.js +143 -0
- package/src/components/__docs__/link.stories.js +197 -0
- package/src/components/link.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-link
|
|
2
2
|
|
|
3
|
+
## 3.8.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [6ee20af9]
|
|
8
|
+
- @khanacademy/wonder-blocks-core@4.4.0
|
|
9
|
+
- @khanacademy/wonder-blocks-clickable@2.3.1
|
|
10
|
+
|
|
11
|
+
## 3.8.9
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [34c7aacb]
|
|
16
|
+
- @khanacademy/wonder-blocks-color@1.2.0
|
|
17
|
+
|
|
3
18
|
## 3.8.8
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -82,7 +82,7 @@ module.exports =
|
|
|
82
82
|
/******/
|
|
83
83
|
/******/
|
|
84
84
|
/******/ // Load entry module and return exports
|
|
85
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 10);
|
|
86
86
|
/******/ })
|
|
87
87
|
/************************************************************************/
|
|
88
88
|
/******/ ([
|
|
@@ -101,35 +101,59 @@ module.exports = require("@khanacademy/wonder-blocks-color");
|
|
|
101
101
|
/* 2 */
|
|
102
102
|
/***/ (function(module, exports) {
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
function _extends() {
|
|
105
|
+
module.exports = _extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
106
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
107
|
+
var source = arguments[i];
|
|
108
|
+
|
|
109
|
+
for (var key in source) {
|
|
110
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
111
|
+
target[key] = source[key];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return target;
|
|
117
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
118
|
+
return _extends.apply(this, arguments);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
module.exports = _extends, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
105
122
|
|
|
106
123
|
/***/ }),
|
|
107
124
|
/* 3 */
|
|
108
125
|
/***/ (function(module, exports) {
|
|
109
126
|
|
|
110
|
-
module.exports = require("
|
|
127
|
+
module.exports = require("react-router");
|
|
111
128
|
|
|
112
129
|
/***/ }),
|
|
113
130
|
/* 4 */
|
|
131
|
+
/***/ (function(module, exports) {
|
|
132
|
+
|
|
133
|
+
module.exports = require("@khanacademy/wonder-blocks-clickable");
|
|
134
|
+
|
|
135
|
+
/***/ }),
|
|
136
|
+
/* 5 */
|
|
114
137
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
115
138
|
|
|
116
139
|
"use strict";
|
|
117
140
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return LinkCore; });
|
|
118
|
-
/* harmony import */ var
|
|
119
|
-
/* harmony import */ var
|
|
120
|
-
/* harmony import */ var
|
|
121
|
-
/* harmony import */ var
|
|
122
|
-
/* harmony import */ var
|
|
123
|
-
/* harmony import */ var
|
|
124
|
-
/* harmony import */ var
|
|
125
|
-
/* harmony import */ var
|
|
126
|
-
/* harmony import */ var
|
|
127
|
-
/* harmony import */ var
|
|
128
|
-
/* harmony import */ var
|
|
129
|
-
/* harmony import */ var
|
|
130
|
-
/* harmony import */ var
|
|
131
|
-
/* harmony import */ var
|
|
132
|
-
|
|
141
|
+
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
|
|
142
|
+
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
|
|
143
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
|
|
144
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
145
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
|
|
146
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_2__);
|
|
147
|
+
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9);
|
|
148
|
+
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_3__);
|
|
149
|
+
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3);
|
|
150
|
+
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react_router__WEBPACK_IMPORTED_MODULE_4__);
|
|
151
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7);
|
|
152
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5__);
|
|
153
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1);
|
|
154
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6__);
|
|
155
|
+
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(4);
|
|
156
|
+
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_7__);
|
|
133
157
|
|
|
134
158
|
|
|
135
159
|
|
|
@@ -138,9 +162,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
138
162
|
|
|
139
163
|
|
|
140
164
|
|
|
141
|
-
const StyledAnchor = Object(
|
|
142
|
-
const StyledLink = Object(
|
|
143
|
-
class LinkCore extends
|
|
165
|
+
const StyledAnchor = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5__["addStyle"])("a");
|
|
166
|
+
const StyledLink = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5__["addStyle"])(react_router_dom__WEBPACK_IMPORTED_MODULE_3__["Link"]);
|
|
167
|
+
class LinkCore extends react__WEBPACK_IMPORTED_MODULE_1__["Component"] {
|
|
144
168
|
renderInner(router) {
|
|
145
169
|
const {
|
|
146
170
|
children,
|
|
@@ -166,20 +190,20 @@ class LinkCore extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
166
190
|
style: [defaultStyles, style],
|
|
167
191
|
...restProps
|
|
168
192
|
};
|
|
169
|
-
return router && !skipClientNav && Object(
|
|
193
|
+
return router && !skipClientNav && Object(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_7__["isClientSideUrl"])(href) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["createElement"](StyledLink, _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({}, commonProps, {
|
|
170
194
|
to: href
|
|
171
|
-
}), children) : /*#__PURE__*/
|
|
195
|
+
}), children) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["createElement"](StyledAnchor, _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({}, commonProps, {
|
|
172
196
|
href: href
|
|
173
197
|
}), children);
|
|
174
198
|
}
|
|
175
199
|
|
|
176
200
|
render() {
|
|
177
|
-
return /*#__PURE__*/
|
|
201
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["createElement"](react_router__WEBPACK_IMPORTED_MODULE_4__["__RouterContext"].Consumer, null, router => this.renderInner(router));
|
|
178
202
|
}
|
|
179
203
|
|
|
180
204
|
}
|
|
181
205
|
const styles = {};
|
|
182
|
-
const sharedStyles =
|
|
206
|
+
const sharedStyles = aphrodite__WEBPACK_IMPORTED_MODULE_2__["StyleSheet"].create({
|
|
183
207
|
shared: {
|
|
184
208
|
cursor: "pointer",
|
|
185
209
|
textDecoration: "none",
|
|
@@ -208,11 +232,11 @@ const _generateStyles = (kind, light, visitable) => {
|
|
|
208
232
|
white,
|
|
209
233
|
offBlack,
|
|
210
234
|
offBlack32
|
|
211
|
-
} =
|
|
212
|
-
const linkPurple = Object(
|
|
235
|
+
} = _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6___default.a;
|
|
236
|
+
const linkPurple = Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6__["mix"])(Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6__["fade"])(offBlack, 0.08), purple);
|
|
213
237
|
const defaultTextColor = kind === "primary" ? light ? white : blue : offBlack;
|
|
214
238
|
const focusColor = light ? white : blue;
|
|
215
|
-
const activeColor = light ? Object(
|
|
239
|
+
const activeColor = light ? Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6__["mix"])(Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6__["fade"])(blue, 0.32), white) : Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6__["mix"])(offBlack32, blue);
|
|
216
240
|
const defaultVisited = visitable ? {
|
|
217
241
|
":visited": {
|
|
218
242
|
color: linkPurple
|
|
@@ -220,7 +244,7 @@ const _generateStyles = (kind, light, visitable) => {
|
|
|
220
244
|
} : Object.freeze({});
|
|
221
245
|
const activeVisited = visitable ? {
|
|
222
246
|
":visited": {
|
|
223
|
-
color: Object(
|
|
247
|
+
color: Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6__["mix"])(offBlack32, linkPurple)
|
|
224
248
|
}
|
|
225
249
|
} : Object.freeze({});
|
|
226
250
|
const newStyles = {
|
|
@@ -239,36 +263,37 @@ const _generateStyles = (kind, light, visitable) => {
|
|
|
239
263
|
...activeVisited
|
|
240
264
|
}
|
|
241
265
|
};
|
|
242
|
-
styles[buttonType] =
|
|
266
|
+
styles[buttonType] = aphrodite__WEBPACK_IMPORTED_MODULE_2__["StyleSheet"].create(newStyles);
|
|
243
267
|
return styles[buttonType];
|
|
244
268
|
};
|
|
245
269
|
|
|
246
270
|
/***/ }),
|
|
247
|
-
/*
|
|
271
|
+
/* 6 */
|
|
248
272
|
/***/ (function(module, exports) {
|
|
249
273
|
|
|
250
274
|
module.exports = require("aphrodite");
|
|
251
275
|
|
|
252
276
|
/***/ }),
|
|
253
|
-
/*
|
|
277
|
+
/* 7 */
|
|
254
278
|
/***/ (function(module, exports) {
|
|
255
279
|
|
|
256
280
|
module.exports = require("@khanacademy/wonder-blocks-core");
|
|
257
281
|
|
|
258
282
|
/***/ }),
|
|
259
|
-
/*
|
|
283
|
+
/* 8 */
|
|
260
284
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
261
285
|
|
|
262
286
|
"use strict";
|
|
263
287
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Link; });
|
|
264
|
-
/* harmony import */ var
|
|
265
|
-
/* harmony import */ var
|
|
266
|
-
/* harmony import */ var
|
|
267
|
-
/* harmony import */ var
|
|
268
|
-
/* harmony import */ var
|
|
269
|
-
/* harmony import */ var
|
|
270
|
-
/* harmony import */ var
|
|
271
|
-
|
|
288
|
+
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
|
|
289
|
+
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
|
|
290
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
|
|
291
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
292
|
+
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
|
|
293
|
+
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_router__WEBPACK_IMPORTED_MODULE_2__);
|
|
294
|
+
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4);
|
|
295
|
+
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_3__);
|
|
296
|
+
/* harmony import */ var _link_core_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5);
|
|
272
297
|
|
|
273
298
|
|
|
274
299
|
|
|
@@ -283,7 +308,8 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
283
308
|
* `LinkCore` is a stateless component which displays the different states
|
|
284
309
|
* the `Link` can take.
|
|
285
310
|
*
|
|
286
|
-
*
|
|
311
|
+
* ### Usage
|
|
312
|
+
*
|
|
287
313
|
* ```jsx
|
|
288
314
|
* <Link
|
|
289
315
|
* href="https://khanacademy.org/"
|
|
@@ -292,7 +318,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
292
318
|
* </Link>
|
|
293
319
|
* ```
|
|
294
320
|
*/
|
|
295
|
-
class Link extends
|
|
321
|
+
class Link extends react__WEBPACK_IMPORTED_MODULE_1__["Component"] {
|
|
296
322
|
renderClickableBehavior(router) {
|
|
297
323
|
const {
|
|
298
324
|
onClick,
|
|
@@ -307,10 +333,10 @@ class Link extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
307
333
|
target = undefined,
|
|
308
334
|
...sharedProps
|
|
309
335
|
} = this.props;
|
|
310
|
-
const ClickableBehavior = Object(
|
|
336
|
+
const ClickableBehavior = Object(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_3__["getClickableBehavior"])(href, skipClientNav, router);
|
|
311
337
|
|
|
312
338
|
if (beforeNav) {
|
|
313
|
-
return /*#__PURE__*/
|
|
339
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["createElement"](ClickableBehavior, {
|
|
314
340
|
disabled: false,
|
|
315
341
|
href: href,
|
|
316
342
|
role: "link",
|
|
@@ -323,7 +349,7 @@ class Link extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
323
349
|
tabIndex: clickableTabIndex,
|
|
324
350
|
...childrenProps
|
|
325
351
|
}) => {
|
|
326
|
-
return /*#__PURE__*/
|
|
352
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_link_core_js__WEBPACK_IMPORTED_MODULE_4__[/* default */ "a"], _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({}, sharedProps, state, childrenProps, {
|
|
327
353
|
skipClientNav: skipClientNav,
|
|
328
354
|
href: href,
|
|
329
355
|
target: target // If tabIndex is provide to the component we allow
|
|
@@ -334,7 +360,7 @@ class Link extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
334
360
|
}), children);
|
|
335
361
|
});
|
|
336
362
|
} else {
|
|
337
|
-
return /*#__PURE__*/
|
|
363
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["createElement"](ClickableBehavior, {
|
|
338
364
|
disabled: false,
|
|
339
365
|
href: href,
|
|
340
366
|
role: "link",
|
|
@@ -347,7 +373,7 @@ class Link extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
347
373
|
tabIndex: clickableTabIndex,
|
|
348
374
|
...childrenProps
|
|
349
375
|
}) => {
|
|
350
|
-
return /*#__PURE__*/
|
|
376
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_link_core_js__WEBPACK_IMPORTED_MODULE_4__[/* default */ "a"], _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({}, sharedProps, state, childrenProps, {
|
|
351
377
|
skipClientNav: skipClientNav,
|
|
352
378
|
href: href,
|
|
353
379
|
target: target // If tabIndex is provide to the component we allow
|
|
@@ -361,7 +387,7 @@ class Link extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
361
387
|
}
|
|
362
388
|
|
|
363
389
|
render() {
|
|
364
|
-
return /*#__PURE__*/
|
|
390
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__["createElement"](react_router__WEBPACK_IMPORTED_MODULE_2__["__RouterContext"].Consumer, null, router => this.renderClickableBehavior(router));
|
|
365
391
|
}
|
|
366
392
|
|
|
367
393
|
}
|
|
@@ -372,18 +398,18 @@ Link.defaultProps = {
|
|
|
372
398
|
};
|
|
373
399
|
|
|
374
400
|
/***/ }),
|
|
375
|
-
/*
|
|
401
|
+
/* 9 */
|
|
376
402
|
/***/ (function(module, exports) {
|
|
377
403
|
|
|
378
404
|
module.exports = require("react-router-dom");
|
|
379
405
|
|
|
380
406
|
/***/ }),
|
|
381
|
-
/*
|
|
407
|
+
/* 10 */
|
|
382
408
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
383
409
|
|
|
384
410
|
"use strict";
|
|
385
411
|
__webpack_require__.r(__webpack_exports__);
|
|
386
|
-
/* harmony import */ var _components_link_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
412
|
+
/* harmony import */ var _components_link_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
|
|
387
413
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _components_link_js__WEBPACK_IMPORTED_MODULE_0__["a"]; });
|
|
388
414
|
|
|
389
415
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-link",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.10",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/runtime": "^7.18.6",
|
|
19
|
-
"@khanacademy/wonder-blocks-clickable": "^2.3.
|
|
20
|
-
"@khanacademy/wonder-blocks-color": "^1.
|
|
21
|
-
"@khanacademy/wonder-blocks-core": "^4.
|
|
19
|
+
"@khanacademy/wonder-blocks-clickable": "^2.3.1",
|
|
20
|
+
"@khanacademy/wonder-blocks-color": "^1.2.0",
|
|
21
|
+
"@khanacademy/wonder-blocks-core": "^4.4.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"aphrodite": "^1.2.5",
|
|
@@ -18,7 +18,7 @@ exports[`Link <Link tabIndex={-1}> 1`] = `
|
|
|
18
18
|
onTouchEnd={[Function]}
|
|
19
19
|
onTouchStart={[Function]}
|
|
20
20
|
style={
|
|
21
|
-
|
|
21
|
+
{
|
|
22
22
|
"color": "#1865f2",
|
|
23
23
|
"cursor": "pointer",
|
|
24
24
|
"outline": "none",
|
|
@@ -49,7 +49,7 @@ exports[`Link <Link tabIndex={0}> 1`] = `
|
|
|
49
49
|
onTouchEnd={[Function]}
|
|
50
50
|
onTouchStart={[Function]}
|
|
51
51
|
style={
|
|
52
|
-
|
|
52
|
+
{
|
|
53
53
|
"color": "#1865f2",
|
|
54
54
|
"cursor": "pointer",
|
|
55
55
|
"outline": "none",
|
|
@@ -80,7 +80,7 @@ exports[`Link <Link tabIndex={1}> 1`] = `
|
|
|
80
80
|
onTouchEnd={[Function]}
|
|
81
81
|
onTouchStart={[Function]}
|
|
82
82
|
style={
|
|
83
|
-
|
|
83
|
+
{
|
|
84
84
|
"color": "#1865f2",
|
|
85
85
|
"cursor": "pointer",
|
|
86
86
|
"outline": "none",
|
|
@@ -111,7 +111,7 @@ exports[`LinkCore kind:primary href:# light:false visitable:false focused 1`] =
|
|
|
111
111
|
onTouchEnd={[Function]}
|
|
112
112
|
onTouchStart={[Function]}
|
|
113
113
|
style={
|
|
114
|
-
|
|
114
|
+
{
|
|
115
115
|
"color": "#1865f2",
|
|
116
116
|
"cursor": "pointer",
|
|
117
117
|
"outline": "none",
|
|
@@ -142,7 +142,7 @@ exports[`LinkCore kind:primary href:# light:false visitable:false hovered 1`] =
|
|
|
142
142
|
onTouchEnd={[Function]}
|
|
143
143
|
onTouchStart={[Function]}
|
|
144
144
|
style={
|
|
145
|
-
|
|
145
|
+
{
|
|
146
146
|
"color": "#1865f2",
|
|
147
147
|
"cursor": "pointer",
|
|
148
148
|
"outline": "none",
|
|
@@ -173,7 +173,7 @@ exports[`LinkCore kind:primary href:# light:false visitable:false pressed 1`] =
|
|
|
173
173
|
onTouchEnd={[Function]}
|
|
174
174
|
onTouchStart={[Function]}
|
|
175
175
|
style={
|
|
176
|
-
|
|
176
|
+
{
|
|
177
177
|
"color": "#1b50b3",
|
|
178
178
|
"cursor": "pointer",
|
|
179
179
|
"outline": "none",
|
|
@@ -204,8 +204,8 @@ exports[`LinkCore kind:primary href:# light:false visitable:true focused 1`] = `
|
|
|
204
204
|
onTouchEnd={[Function]}
|
|
205
205
|
onTouchStart={[Function]}
|
|
206
206
|
style={
|
|
207
|
-
|
|
208
|
-
":visited":
|
|
207
|
+
{
|
|
208
|
+
":visited": {
|
|
209
209
|
"color": "#8755ee",
|
|
210
210
|
},
|
|
211
211
|
"color": "#1865f2",
|
|
@@ -238,8 +238,8 @@ exports[`LinkCore kind:primary href:# light:false visitable:true hovered 1`] = `
|
|
|
238
238
|
onTouchEnd={[Function]}
|
|
239
239
|
onTouchStart={[Function]}
|
|
240
240
|
style={
|
|
241
|
-
|
|
242
|
-
":visited":
|
|
241
|
+
{
|
|
242
|
+
":visited": {
|
|
243
243
|
"color": "#8755ee",
|
|
244
244
|
},
|
|
245
245
|
"color": "#1865f2",
|
|
@@ -272,8 +272,8 @@ exports[`LinkCore kind:primary href:# light:false visitable:true pressed 1`] = `
|
|
|
272
272
|
onTouchEnd={[Function]}
|
|
273
273
|
onTouchStart={[Function]}
|
|
274
274
|
style={
|
|
275
|
-
|
|
276
|
-
":visited":
|
|
275
|
+
{
|
|
276
|
+
":visited": {
|
|
277
277
|
"color": "#6645b0",
|
|
278
278
|
},
|
|
279
279
|
"color": "#1b50b3",
|
|
@@ -306,7 +306,7 @@ exports[`LinkCore kind:primary href:# light:true visitable:false focused 1`] = `
|
|
|
306
306
|
onTouchEnd={[Function]}
|
|
307
307
|
onTouchStart={[Function]}
|
|
308
308
|
style={
|
|
309
|
-
|
|
309
|
+
{
|
|
310
310
|
"color": "#ffffff",
|
|
311
311
|
"cursor": "pointer",
|
|
312
312
|
"outline": "none",
|
|
@@ -337,7 +337,7 @@ exports[`LinkCore kind:primary href:# light:true visitable:false hovered 1`] = `
|
|
|
337
337
|
onTouchEnd={[Function]}
|
|
338
338
|
onTouchStart={[Function]}
|
|
339
339
|
style={
|
|
340
|
-
|
|
340
|
+
{
|
|
341
341
|
"color": "#ffffff",
|
|
342
342
|
"cursor": "pointer",
|
|
343
343
|
"outline": "none",
|
|
@@ -368,7 +368,7 @@ exports[`LinkCore kind:primary href:# light:true visitable:false pressed 1`] = `
|
|
|
368
368
|
onTouchEnd={[Function]}
|
|
369
369
|
onTouchStart={[Function]}
|
|
370
370
|
style={
|
|
371
|
-
|
|
371
|
+
{
|
|
372
372
|
"color": "#b5cefb",
|
|
373
373
|
"cursor": "pointer",
|
|
374
374
|
"outline": "none",
|
|
@@ -399,7 +399,7 @@ exports[`LinkCore kind:primary href:#non-existent-link light:false visitable:fal
|
|
|
399
399
|
onTouchEnd={[Function]}
|
|
400
400
|
onTouchStart={[Function]}
|
|
401
401
|
style={
|
|
402
|
-
|
|
402
|
+
{
|
|
403
403
|
"color": "#1865f2",
|
|
404
404
|
"cursor": "pointer",
|
|
405
405
|
"outline": "none",
|
|
@@ -430,7 +430,7 @@ exports[`LinkCore kind:primary href:#non-existent-link light:false visitable:fal
|
|
|
430
430
|
onTouchEnd={[Function]}
|
|
431
431
|
onTouchStart={[Function]}
|
|
432
432
|
style={
|
|
433
|
-
|
|
433
|
+
{
|
|
434
434
|
"color": "#1865f2",
|
|
435
435
|
"cursor": "pointer",
|
|
436
436
|
"outline": "none",
|
|
@@ -461,7 +461,7 @@ exports[`LinkCore kind:primary href:#non-existent-link light:false visitable:fal
|
|
|
461
461
|
onTouchEnd={[Function]}
|
|
462
462
|
onTouchStart={[Function]}
|
|
463
463
|
style={
|
|
464
|
-
|
|
464
|
+
{
|
|
465
465
|
"color": "#1b50b3",
|
|
466
466
|
"cursor": "pointer",
|
|
467
467
|
"outline": "none",
|
|
@@ -492,8 +492,8 @@ exports[`LinkCore kind:primary href:#non-existent-link light:false visitable:tru
|
|
|
492
492
|
onTouchEnd={[Function]}
|
|
493
493
|
onTouchStart={[Function]}
|
|
494
494
|
style={
|
|
495
|
-
|
|
496
|
-
":visited":
|
|
495
|
+
{
|
|
496
|
+
":visited": {
|
|
497
497
|
"color": "#8755ee",
|
|
498
498
|
},
|
|
499
499
|
"color": "#1865f2",
|
|
@@ -526,8 +526,8 @@ exports[`LinkCore kind:primary href:#non-existent-link light:false visitable:tru
|
|
|
526
526
|
onTouchEnd={[Function]}
|
|
527
527
|
onTouchStart={[Function]}
|
|
528
528
|
style={
|
|
529
|
-
|
|
530
|
-
":visited":
|
|
529
|
+
{
|
|
530
|
+
":visited": {
|
|
531
531
|
"color": "#8755ee",
|
|
532
532
|
},
|
|
533
533
|
"color": "#1865f2",
|
|
@@ -560,8 +560,8 @@ exports[`LinkCore kind:primary href:#non-existent-link light:false visitable:tru
|
|
|
560
560
|
onTouchEnd={[Function]}
|
|
561
561
|
onTouchStart={[Function]}
|
|
562
562
|
style={
|
|
563
|
-
|
|
564
|
-
":visited":
|
|
563
|
+
{
|
|
564
|
+
":visited": {
|
|
565
565
|
"color": "#6645b0",
|
|
566
566
|
},
|
|
567
567
|
"color": "#1b50b3",
|
|
@@ -594,7 +594,7 @@ exports[`LinkCore kind:primary href:#non-existent-link light:true visitable:fals
|
|
|
594
594
|
onTouchEnd={[Function]}
|
|
595
595
|
onTouchStart={[Function]}
|
|
596
596
|
style={
|
|
597
|
-
|
|
597
|
+
{
|
|
598
598
|
"color": "#ffffff",
|
|
599
599
|
"cursor": "pointer",
|
|
600
600
|
"outline": "none",
|
|
@@ -625,7 +625,7 @@ exports[`LinkCore kind:primary href:#non-existent-link light:true visitable:fals
|
|
|
625
625
|
onTouchEnd={[Function]}
|
|
626
626
|
onTouchStart={[Function]}
|
|
627
627
|
style={
|
|
628
|
-
|
|
628
|
+
{
|
|
629
629
|
"color": "#ffffff",
|
|
630
630
|
"cursor": "pointer",
|
|
631
631
|
"outline": "none",
|
|
@@ -656,7 +656,7 @@ exports[`LinkCore kind:primary href:#non-existent-link light:true visitable:fals
|
|
|
656
656
|
onTouchEnd={[Function]}
|
|
657
657
|
onTouchStart={[Function]}
|
|
658
658
|
style={
|
|
659
|
-
|
|
659
|
+
{
|
|
660
660
|
"color": "#b5cefb",
|
|
661
661
|
"cursor": "pointer",
|
|
662
662
|
"outline": "none",
|
|
@@ -687,7 +687,7 @@ exports[`LinkCore kind:secondary href:# light:false visitable:false focused 1`]
|
|
|
687
687
|
onTouchEnd={[Function]}
|
|
688
688
|
onTouchStart={[Function]}
|
|
689
689
|
style={
|
|
690
|
-
|
|
690
|
+
{
|
|
691
691
|
"color": "#1865f2",
|
|
692
692
|
"cursor": "pointer",
|
|
693
693
|
"outline": "none",
|
|
@@ -718,7 +718,7 @@ exports[`LinkCore kind:secondary href:# light:false visitable:false hovered 1`]
|
|
|
718
718
|
onTouchEnd={[Function]}
|
|
719
719
|
onTouchStart={[Function]}
|
|
720
720
|
style={
|
|
721
|
-
|
|
721
|
+
{
|
|
722
722
|
"color": "#1865f2",
|
|
723
723
|
"cursor": "pointer",
|
|
724
724
|
"outline": "none",
|
|
@@ -749,7 +749,7 @@ exports[`LinkCore kind:secondary href:# light:false visitable:false pressed 1`]
|
|
|
749
749
|
onTouchEnd={[Function]}
|
|
750
750
|
onTouchStart={[Function]}
|
|
751
751
|
style={
|
|
752
|
-
|
|
752
|
+
{
|
|
753
753
|
"color": "#1b50b3",
|
|
754
754
|
"cursor": "pointer",
|
|
755
755
|
"outline": "none",
|
|
@@ -780,7 +780,7 @@ exports[`LinkCore kind:secondary href:#non-existent-link light:false visitable:f
|
|
|
780
780
|
onTouchEnd={[Function]}
|
|
781
781
|
onTouchStart={[Function]}
|
|
782
782
|
style={
|
|
783
|
-
|
|
783
|
+
{
|
|
784
784
|
"color": "#1865f2",
|
|
785
785
|
"cursor": "pointer",
|
|
786
786
|
"outline": "none",
|
|
@@ -811,7 +811,7 @@ exports[`LinkCore kind:secondary href:#non-existent-link light:false visitable:f
|
|
|
811
811
|
onTouchEnd={[Function]}
|
|
812
812
|
onTouchStart={[Function]}
|
|
813
813
|
style={
|
|
814
|
-
|
|
814
|
+
{
|
|
815
815
|
"color": "#1865f2",
|
|
816
816
|
"cursor": "pointer",
|
|
817
817
|
"outline": "none",
|
|
@@ -842,7 +842,7 @@ exports[`LinkCore kind:secondary href:#non-existent-link light:false visitable:f
|
|
|
842
842
|
onTouchEnd={[Function]}
|
|
843
843
|
onTouchStart={[Function]}
|
|
844
844
|
style={
|
|
845
|
-
|
|
845
|
+
{
|
|
846
846
|
"color": "#1b50b3",
|
|
847
847
|
"cursor": "pointer",
|
|
848
848
|
"outline": "none",
|
|
@@ -4,7 +4,7 @@ exports[`wonder-blocks-link example 1 1`] = `
|
|
|
4
4
|
<div
|
|
5
5
|
className=""
|
|
6
6
|
style={
|
|
7
|
-
|
|
7
|
+
{
|
|
8
8
|
"alignItems": "stretch",
|
|
9
9
|
"borderStyle": "solid",
|
|
10
10
|
"borderWidth": 0,
|
|
@@ -39,7 +39,7 @@ exports[`wonder-blocks-link example 1 1`] = `
|
|
|
39
39
|
onTouchEnd={[Function]}
|
|
40
40
|
onTouchStart={[Function]}
|
|
41
41
|
style={
|
|
42
|
-
|
|
42
|
+
{
|
|
43
43
|
"color": "#1865f2",
|
|
44
44
|
"cursor": "pointer",
|
|
45
45
|
"outline": "none",
|
|
@@ -54,7 +54,7 @@ exports[`wonder-blocks-link example 1 1`] = `
|
|
|
54
54
|
|
|
55
55
|
<span
|
|
56
56
|
style={
|
|
57
|
-
|
|
57
|
+
{
|
|
58
58
|
"color": "rgba(33,36,44,0.64)",
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -77,7 +77,7 @@ exports[`wonder-blocks-link example 1 1`] = `
|
|
|
77
77
|
onTouchEnd={[Function]}
|
|
78
78
|
onTouchStart={[Function]}
|
|
79
79
|
style={
|
|
80
|
-
|
|
80
|
+
{
|
|
81
81
|
"color": "#21242c",
|
|
82
82
|
"cursor": "pointer",
|
|
83
83
|
"outline": "none",
|
|
@@ -110,8 +110,8 @@ exports[`wonder-blocks-link example 1 1`] = `
|
|
|
110
110
|
onTouchEnd={[Function]}
|
|
111
111
|
onTouchStart={[Function]}
|
|
112
112
|
style={
|
|
113
|
-
|
|
114
|
-
":visited":
|
|
113
|
+
{
|
|
114
|
+
":visited": {
|
|
115
115
|
"color": "#8755ee",
|
|
116
116
|
},
|
|
117
117
|
"color": "#1865f2",
|
|
@@ -129,8 +129,8 @@ exports[`wonder-blocks-link example 1 1`] = `
|
|
|
129
129
|
</p>
|
|
130
130
|
<p
|
|
131
131
|
style={
|
|
132
|
-
|
|
133
|
-
"backgroundColor": "#
|
|
132
|
+
{
|
|
133
|
+
"backgroundColor": "#0b2149",
|
|
134
134
|
"color": "rgba(255,255,255,0.64)",
|
|
135
135
|
"padding": 10,
|
|
136
136
|
}
|
|
@@ -155,7 +155,7 @@ exports[`wonder-blocks-link example 1 1`] = `
|
|
|
155
155
|
onTouchEnd={[Function]}
|
|
156
156
|
onTouchStart={[Function]}
|
|
157
157
|
style={
|
|
158
|
-
|
|
158
|
+
{
|
|
159
159
|
"color": "#ffffff",
|
|
160
160
|
"cursor": "pointer",
|
|
161
161
|
"outline": "none",
|
|
@@ -176,7 +176,7 @@ exports[`wonder-blocks-link example 2 1`] = `
|
|
|
176
176
|
<div
|
|
177
177
|
className=""
|
|
178
178
|
style={
|
|
179
|
-
|
|
179
|
+
{
|
|
180
180
|
"alignItems": "stretch",
|
|
181
181
|
"borderStyle": "solid",
|
|
182
182
|
"borderWidth": 0,
|
|
@@ -210,7 +210,7 @@ exports[`wonder-blocks-link example 2 1`] = `
|
|
|
210
210
|
onTouchEnd={[Function]}
|
|
211
211
|
onTouchStart={[Function]}
|
|
212
212
|
style={
|
|
213
|
-
|
|
213
|
+
{
|
|
214
214
|
"color": "#1865f2",
|
|
215
215
|
"cursor": "pointer",
|
|
216
216
|
"outline": "none",
|
|
@@ -222,11 +222,11 @@ exports[`wonder-blocks-link example 2 1`] = `
|
|
|
222
222
|
<h4
|
|
223
223
|
className=""
|
|
224
224
|
style={
|
|
225
|
-
|
|
225
|
+
{
|
|
226
226
|
"MozOsxFontSmoothing": "grayscale",
|
|
227
227
|
"WebkitFontSmoothing": "antialiased",
|
|
228
228
|
"display": "block",
|
|
229
|
-
"fontFamily": "Lato,
|
|
229
|
+
"fontFamily": "Lato, "Noto Sans", sans-serif",
|
|
230
230
|
"fontSize": 20,
|
|
231
231
|
"fontWeight": 700,
|
|
232
232
|
"lineHeight": "24px",
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
children: {
|
|
5
|
+
control: {type: "text"},
|
|
6
|
+
description:
|
|
7
|
+
"Text to appear on the link. It can be a plain text or Typography element.",
|
|
8
|
+
table: {type: {summary: "string | React.Element<Typography>"}},
|
|
9
|
+
type: {required: true},
|
|
10
|
+
},
|
|
11
|
+
href: {
|
|
12
|
+
control: {type: "text"},
|
|
13
|
+
description: "URL to navigate to.",
|
|
14
|
+
table: {type: {summary: "string"}},
|
|
15
|
+
type: {required: true},
|
|
16
|
+
},
|
|
17
|
+
id: {
|
|
18
|
+
control: {type: "text"},
|
|
19
|
+
description: "An optional id attribute.",
|
|
20
|
+
table: {type: {summary: "string"}},
|
|
21
|
+
type: {required: false},
|
|
22
|
+
},
|
|
23
|
+
kind: {
|
|
24
|
+
control: {type: "select"},
|
|
25
|
+
description:
|
|
26
|
+
"Kind of Link. Note: Secondary light Links are not supported.",
|
|
27
|
+
options: ["primary", "secondary"],
|
|
28
|
+
table: {
|
|
29
|
+
type: {summary: `"primary" | "secondary"`},
|
|
30
|
+
},
|
|
31
|
+
type: {required: false},
|
|
32
|
+
},
|
|
33
|
+
light: {
|
|
34
|
+
control: {type: "boolean"},
|
|
35
|
+
description: "Whether the button is on a dark/colored background.",
|
|
36
|
+
table: {
|
|
37
|
+
type: {summary: "boolean"},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
visitable: {
|
|
41
|
+
control: {type: "boolean"},
|
|
42
|
+
description:
|
|
43
|
+
"Whether the link should change color once it's visited. Secondary or primary (light) links are not allowed to be visitable.",
|
|
44
|
+
table: {
|
|
45
|
+
type: {summary: "boolean"},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
rel: {
|
|
49
|
+
control: {type: "text"},
|
|
50
|
+
description: `Specifies the type of relationship between the current
|
|
51
|
+
document and the linked document. Should only be used when
|
|
52
|
+
\`href\` is specified. This defaults to "noopener noreferrer"
|
|
53
|
+
when \`target="_blank"\`, but can be overridden by setting this
|
|
54
|
+
prop to something else.`,
|
|
55
|
+
table: {
|
|
56
|
+
type: {summary: "string"},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
tabIndex: {
|
|
60
|
+
control: {type: "number"},
|
|
61
|
+
description: "Set the tabindex attribute on the rendered element.",
|
|
62
|
+
table: {
|
|
63
|
+
defaultValue: {summary: 0},
|
|
64
|
+
type: {summary: "number"},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
testId: {
|
|
68
|
+
control: {type: "text"},
|
|
69
|
+
description: "Test ID used for e2e testing.",
|
|
70
|
+
table: {
|
|
71
|
+
type: {summary: "string"},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
style: {
|
|
76
|
+
control: {type: "object"},
|
|
77
|
+
description: "custom styles.",
|
|
78
|
+
table: {type: {summary: "StyleType"}},
|
|
79
|
+
},
|
|
80
|
+
className: {
|
|
81
|
+
control: {type: "text"},
|
|
82
|
+
description: "Adds CSS classes to the Link.",
|
|
83
|
+
table: {type: {summary: "string"}},
|
|
84
|
+
},
|
|
85
|
+
beforeNav: {
|
|
86
|
+
description: `Run async code before navigating to the URL passed to
|
|
87
|
+
\`href\`. If the promise returned rejects then navigation will not
|
|
88
|
+
occur. If both safeWithNav and beforeNav are provided, beforeNav
|
|
89
|
+
will be run first and safeWithNav will only be run if beforeNav
|
|
90
|
+
does not reject.`,
|
|
91
|
+
table: {
|
|
92
|
+
category: "Navigation",
|
|
93
|
+
type: {summary: "() => Promise<mixed>"},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
safeWithNav: {
|
|
97
|
+
description: `Run async code in the background while client-side
|
|
98
|
+
navigating. If the browser does a full page load navigation, the
|
|
99
|
+
callback promise must be settled before the navigation will occur.
|
|
100
|
+
Errors are ignored so that navigation is guaranteed to succeed.`,
|
|
101
|
+
table: {
|
|
102
|
+
category: "Navigation",
|
|
103
|
+
type: {summary: "() => Promise<mixed>"},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
skipClientNav: {
|
|
107
|
+
control: {type: "boolean"},
|
|
108
|
+
description: `Whether to avoid using client-side navigation.
|
|
109
|
+
If the URL passed to href is local to the client-side, e.g.
|
|
110
|
+
/math/algebra/eval-exprs, then it tries to use react-router-dom's
|
|
111
|
+
Link component which handles the client-side navigation. You can set
|
|
112
|
+
\`skipClientNav\` to true avoid using client-side nav entirely.`,
|
|
113
|
+
table: {
|
|
114
|
+
category: "Navigation",
|
|
115
|
+
type: {summary: "boolean"},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
onClick: {
|
|
119
|
+
description: `Function to call when button is clicked.
|
|
120
|
+
This should NOT be used to redirect to a different URL or to
|
|
121
|
+
prevent navigation via e.preventDefault(). The event passed to this
|
|
122
|
+
handler will have its preventDefault() and stopPropagation() methods
|
|
123
|
+
stubbed out.`,
|
|
124
|
+
table: {
|
|
125
|
+
category: "Events",
|
|
126
|
+
type: {summary: "(e: SyntheticEvent<>) => mixed"},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
onKeyDown: {
|
|
130
|
+
description: `Respond to raw "keydown" event.`,
|
|
131
|
+
table: {
|
|
132
|
+
category: "Events",
|
|
133
|
+
type: {summary: "(e: SyntheticKeyboardEvent<>) => mixed"},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
onKeyUp: {
|
|
137
|
+
description: `Respond to raw "keyup" event.`,
|
|
138
|
+
table: {
|
|
139
|
+
category: "Events",
|
|
140
|
+
type: {summary: "(e: SyntheticKeyboardEvent<>) => mixed"},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import {StyleSheet} from "aphrodite";
|
|
4
|
+
import {MemoryRouter, Route, Switch} from "react-router-dom";
|
|
5
|
+
|
|
6
|
+
import Color from "@khanacademy/wonder-blocks-color";
|
|
7
|
+
import {View} from "@khanacademy/wonder-blocks-core";
|
|
8
|
+
import Link from "@khanacademy/wonder-blocks-link";
|
|
9
|
+
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
10
|
+
import {
|
|
11
|
+
Body,
|
|
12
|
+
HeadingSmall,
|
|
13
|
+
LabelLarge,
|
|
14
|
+
} from "@khanacademy/wonder-blocks-typography";
|
|
15
|
+
import type {StoryComponentType} from "@storybook/react";
|
|
16
|
+
|
|
17
|
+
import LinkArgTypes from "./link.argtypes.js";
|
|
18
|
+
import ComponentInfo from "../../../../../.storybook/components/component-info.js";
|
|
19
|
+
import {name, version} from "../../../package.json";
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
title: "Link",
|
|
23
|
+
component: Link,
|
|
24
|
+
parameters: {
|
|
25
|
+
componentSubtitle: ((
|
|
26
|
+
<ComponentInfo name={name} version={version} />
|
|
27
|
+
): any),
|
|
28
|
+
},
|
|
29
|
+
argTypes: LinkArgTypes,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const Default: StoryComponentType = (args) => (
|
|
33
|
+
<Link target="_blank" {...args} />
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
Default.args = {
|
|
37
|
+
href: "/",
|
|
38
|
+
children: "Hello, world!",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Basic: StoryComponentType = () => (
|
|
42
|
+
<Link href="#">Hello, world!</Link>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
Basic.parameters = {
|
|
46
|
+
docs: {
|
|
47
|
+
storyDescription: `Minimal link usage.
|
|
48
|
+
This links to the top of the page.`,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const Variants: StoryComponentType = () => (
|
|
53
|
+
<Body>
|
|
54
|
+
I am a <Link href="#nonexistent-link">Primary Link</Link>.{" "}
|
|
55
|
+
<span style={{color: Color.offBlack64}}>
|
|
56
|
+
My friend the{" "}
|
|
57
|
+
<Link href="#secondary-nonexistent-link" kind="secondary">
|
|
58
|
+
Secondary Link
|
|
59
|
+
</Link>{" "}
|
|
60
|
+
is used here with a lighter text.
|
|
61
|
+
</span>{" "}
|
|
62
|
+
We also have a{" "}
|
|
63
|
+
<Link href="#" visitable={true}>
|
|
64
|
+
Visitable Primary Link
|
|
65
|
+
</Link>{" "}
|
|
66
|
+
friend.
|
|
67
|
+
</Body>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
Variants.parameters = {
|
|
71
|
+
docs: {
|
|
72
|
+
storyDescription: `Primary links are blue, secondary links are black,
|
|
73
|
+
and visitable links turn purple after they've been clicked on.`,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const LightVariants: StoryComponentType = () => (
|
|
78
|
+
<Body style={styles.darkBackground}>
|
|
79
|
+
I am a{" "}
|
|
80
|
+
<Link href="#dark-link" light={true}>
|
|
81
|
+
Primary Link
|
|
82
|
+
</Link>{" "}
|
|
83
|
+
used on a dark background. My friend the Secondary Link is not supported
|
|
84
|
+
on this dark background.
|
|
85
|
+
</Body>
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
LightVariants.parameters = {
|
|
89
|
+
docs: {
|
|
90
|
+
storyDescription: `Links are white on a dark background when the
|
|
91
|
+
\`light\` prop is true. Secondary \`light\` links are not supported.
|
|
92
|
+
Links also cannot be \`visitable\` if they're \`light\`. If
|
|
93
|
+
a link has \`light\` set to \`true\` and you try to set \`kind\`
|
|
94
|
+
to \`"secondary"\` or \`visitable\` to \`true\`, it will throw
|
|
95
|
+
an error.`,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const WithTypography: StoryComponentType = () => (
|
|
100
|
+
<Link href="#nonexistent-link" id="typography-link">
|
|
101
|
+
<HeadingSmall>Heading inside a Link element</HeadingSmall>
|
|
102
|
+
</Link>
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
WithTypography.parameters = {
|
|
106
|
+
docs: {
|
|
107
|
+
storyDescription: `Wonder Blocks Typography elements can also be used
|
|
108
|
+
inside Links instead of plain text. Here, we have a \`Link\`
|
|
109
|
+
containing a \`HeadingSmall\`.`,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const WithStyle: StoryComponentType = () => (
|
|
114
|
+
<Link href="#" style={styles.pinkLink}>
|
|
115
|
+
This link has a style.
|
|
116
|
+
</Link>
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
WithStyle.parameters = {
|
|
120
|
+
docs: {
|
|
121
|
+
storyDescription: `Link can take a \`style\` prop. Here, the
|
|
122
|
+
Link has been given a style in which the \`color\` field has
|
|
123
|
+
been set to \`Colors.pink\`.`,
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const Navigation: StoryComponentType = () => (
|
|
128
|
+
<MemoryRouter>
|
|
129
|
+
<View>
|
|
130
|
+
<View style={styles.row}>
|
|
131
|
+
<Link
|
|
132
|
+
href="/foo"
|
|
133
|
+
style={styles.heading}
|
|
134
|
+
onClick={() => {
|
|
135
|
+
// eslint-disable-next-line no-console
|
|
136
|
+
console.log("I'm still on the same page!");
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
<LabelLarge>Uses Client-side Nav</LabelLarge>
|
|
140
|
+
</Link>
|
|
141
|
+
<Link
|
|
142
|
+
href="/iframe.html?id=link--default&viewMode=story"
|
|
143
|
+
style={styles.heading}
|
|
144
|
+
skipClientNav
|
|
145
|
+
>
|
|
146
|
+
<LabelLarge>Avoids Client-side Nav</LabelLarge>
|
|
147
|
+
</Link>
|
|
148
|
+
</View>
|
|
149
|
+
<View style={styles.navigation}>
|
|
150
|
+
<Switch>
|
|
151
|
+
<Route path="/foo">
|
|
152
|
+
<View id="foo">
|
|
153
|
+
The first link does client-side navigation here.
|
|
154
|
+
</View>
|
|
155
|
+
</Route>
|
|
156
|
+
<Route path="*">See navigation changes here</Route>
|
|
157
|
+
</Switch>
|
|
158
|
+
</View>
|
|
159
|
+
</View>
|
|
160
|
+
</MemoryRouter>
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
Navigation.parameters = {
|
|
164
|
+
docs: {
|
|
165
|
+
storyDescription: `If you want to navigate to an external URL
|
|
166
|
+
and/or reload the window, make sure to use \`href\` and
|
|
167
|
+
\`skipClientNav={true}\`, as shown in this example.
|
|
168
|
+
**For navigation callbacks:** The \`onClick\`, \`beforeNav\`, and
|
|
169
|
+
\`safeWithNav\` props can be used to run callbacks when navigating
|
|
170
|
+
to the new URL. Which prop to use depends on the use case. See the
|
|
171
|
+
[Button documentation](/story/button-navigation-callbacks--before-nav-callbacks&viewMode=docs)
|
|
172
|
+
for details.`,
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const styles = StyleSheet.create({
|
|
177
|
+
darkBackground: {
|
|
178
|
+
backgroundColor: Color.darkBlue,
|
|
179
|
+
color: Color.white64,
|
|
180
|
+
padding: 10,
|
|
181
|
+
},
|
|
182
|
+
heading: {
|
|
183
|
+
marginRight: Spacing.large_24,
|
|
184
|
+
},
|
|
185
|
+
navigation: {
|
|
186
|
+
border: `1px dashed ${Color.lightBlue}`,
|
|
187
|
+
marginTop: Spacing.large_24,
|
|
188
|
+
padding: Spacing.large_24,
|
|
189
|
+
},
|
|
190
|
+
pinkLink: {
|
|
191
|
+
color: Color.pink,
|
|
192
|
+
},
|
|
193
|
+
row: {
|
|
194
|
+
flexDirection: "row",
|
|
195
|
+
alignItems: "center",
|
|
196
|
+
},
|
|
197
|
+
});
|
package/src/components/link.js
CHANGED