@khanacademy/wonder-blocks-button 2.9.13
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/LICENSE +21 -0
- package/dist/es/index.js +402 -0
- package/dist/index.js +668 -0
- package/dist/index.js.flow +2 -0
- package/docs.md +0 -0
- package/package.json +37 -0
- package/src/__tests__/__snapshots__/custom-snapshot.test.js.snap +8710 -0
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +4774 -0
- package/src/__tests__/custom-snapshot.test.js +117 -0
- package/src/__tests__/generated-snapshot.test.js +727 -0
- package/src/components/__tests__/button.flowtest.js +53 -0
- package/src/components/__tests__/button.test.js +826 -0
- package/src/components/button-core.js +375 -0
- package/src/components/button.js +347 -0
- package/src/components/button.md +810 -0
- package/src/components/button.stories.js +276 -0
- package/src/index.js +6 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
/* eslint-disable flowtype/no-unused-expressions */
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import Button from "../button.js";
|
|
6
|
+
|
|
7
|
+
// $FlowExpectedError[incompatible-type]: href must be used with beforeNav
|
|
8
|
+
<Button beforeNav={() => Promise.resolve()}>Hello, world!</Button>;
|
|
9
|
+
|
|
10
|
+
// $FlowExpectedError[incompatible-type]: href must be used with safeWithNav
|
|
11
|
+
<Button safeWithNav={() => Promise.resolve()}>Hello, world!</Button>;
|
|
12
|
+
|
|
13
|
+
// It's okay to use onClick with href
|
|
14
|
+
<Button href="/foo" onClick={() => {}}>
|
|
15
|
+
Hello, world!
|
|
16
|
+
</Button>;
|
|
17
|
+
|
|
18
|
+
<Button href="/foo" beforeNav={() => Promise.resolve()}>
|
|
19
|
+
Hello, world!
|
|
20
|
+
</Button>;
|
|
21
|
+
|
|
22
|
+
<Button href="/foo" safeWithNav={() => Promise.resolve()}>
|
|
23
|
+
Hello, world!
|
|
24
|
+
</Button>;
|
|
25
|
+
|
|
26
|
+
// All three of these props can be used together
|
|
27
|
+
<Button
|
|
28
|
+
href="/foo"
|
|
29
|
+
beforeNav={() => Promise.resolve()}
|
|
30
|
+
safeWithNav={() => Promise.resolve()}
|
|
31
|
+
onClick={() => {}}
|
|
32
|
+
>
|
|
33
|
+
Hello, world!
|
|
34
|
+
</Button>;
|
|
35
|
+
|
|
36
|
+
// It's also fine to use href by itself
|
|
37
|
+
<Button href="/foo">Hello, world!</Button>;
|
|
38
|
+
|
|
39
|
+
const getUrl = () => "/foo";
|
|
40
|
+
|
|
41
|
+
// This test purposefully uses a function to get a string to pass with href.
|
|
42
|
+
// This can trigger errors if there are ambiguous cases in the disjoint union
|
|
43
|
+
// type being used to describe the props. It's unclear why this error isn't
|
|
44
|
+
// trigger by passing a string directly as the href.
|
|
45
|
+
<Button href={getUrl()}>Hello, world!</Button>;
|
|
46
|
+
|
|
47
|
+
// $FlowExpectedError[incompatible-type]: type="submit" can't be used with href since we render an anchor.
|
|
48
|
+
<Button href="/foo" type="submit">
|
|
49
|
+
Hello, world!
|
|
50
|
+
</Button>;
|
|
51
|
+
|
|
52
|
+
// type="submit" on its own is fine.
|
|
53
|
+
<Button type="submit">Hello, world!</Button>;
|