@khanacademy/wonder-blocks-icon-button 3.4.8 → 3.4.9
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
CHANGED
package/dist/index.js
CHANGED
|
@@ -169,6 +169,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
169
169
|
*
|
|
170
170
|
* ```js
|
|
171
171
|
* import {icons} from "@khanacademy/wonder-blocks-icon";
|
|
172
|
+
* import IconButton from "@khanacademy/wonder-blocks-icon-button";
|
|
172
173
|
*
|
|
173
174
|
* <IconButton
|
|
174
175
|
* icon={icons.anIcon}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-icon-button",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.9",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"author": "",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@babel/runtime": "^7.
|
|
19
|
-
"@khanacademy/wonder-blocks-clickable": "^2.
|
|
18
|
+
"@babel/runtime": "^7.18.6",
|
|
19
|
+
"@khanacademy/wonder-blocks-clickable": "^2.3.0",
|
|
20
20
|
"@khanacademy/wonder-blocks-color": "^1.1.20",
|
|
21
21
|
"@khanacademy/wonder-blocks-core": "^4.3.2",
|
|
22
22
|
"@khanacademy/wonder-blocks-icon": "^1.2.29"
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
// @flow
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import {StyleSheet} from "aphrodite";
|
|
5
|
+
import {action} from "@storybook/addon-actions";
|
|
6
|
+
import type {StoryComponentType} from "@storybook/react";
|
|
7
|
+
|
|
8
|
+
import Color from "@khanacademy/wonder-blocks-color";
|
|
9
|
+
import {View} from "@khanacademy/wonder-blocks-core";
|
|
10
|
+
import {icons} from "@khanacademy/wonder-blocks-icon";
|
|
11
|
+
import IconButton from "@khanacademy/wonder-blocks-icon-button";
|
|
12
|
+
import {Strut} from "@khanacademy/wonder-blocks-layout";
|
|
13
|
+
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
14
|
+
|
|
15
|
+
import ComponentInfo from "../../../../../.storybook/components/component-info.js";
|
|
16
|
+
import {name, version} from "../../../package.json";
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
title: "IconButton / IconButton",
|
|
20
|
+
component: IconButton,
|
|
21
|
+
parameters: {
|
|
22
|
+
componentSubtitle: ((
|
|
23
|
+
<ComponentInfo name={name} version={version} />
|
|
24
|
+
): any),
|
|
25
|
+
},
|
|
26
|
+
argTypes: {
|
|
27
|
+
icon: {
|
|
28
|
+
options: icons,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const Default: StoryComponentType = (args) => {
|
|
34
|
+
return <IconButton {...args} />;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
Default.args = {
|
|
38
|
+
icon: icons.search,
|
|
39
|
+
color: "default",
|
|
40
|
+
kind: "primary",
|
|
41
|
+
onClick: (e) => {
|
|
42
|
+
console.log("Click!");
|
|
43
|
+
action("clicked")(e);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Basic: StoryComponentType = () => {
|
|
48
|
+
return (
|
|
49
|
+
<IconButton icon={icons.search} onClick={() => console.log("Click!")} />
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Basic.parameters = {
|
|
54
|
+
docs: {
|
|
55
|
+
storyDescription: `Minimal icon button. The only props specified in
|
|
56
|
+
this example are \`icon\` and \`onClick\`.`,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const Variants: StoryComponentType = () => {
|
|
61
|
+
return (
|
|
62
|
+
<View style={{flexDirection: "row"}}>
|
|
63
|
+
<IconButton
|
|
64
|
+
icon={icons.search}
|
|
65
|
+
aria-label="search"
|
|
66
|
+
onClick={(e) => console.log("Click!")}
|
|
67
|
+
/>
|
|
68
|
+
<Strut size={Spacing.medium_16} />
|
|
69
|
+
<IconButton
|
|
70
|
+
icon={icons.search}
|
|
71
|
+
aria-label="search"
|
|
72
|
+
kind="secondary"
|
|
73
|
+
onClick={(e) => console.log("Click!")}
|
|
74
|
+
/>
|
|
75
|
+
<Strut size={Spacing.medium_16} />
|
|
76
|
+
<IconButton
|
|
77
|
+
icon={icons.search}
|
|
78
|
+
aria-label="search"
|
|
79
|
+
kind="tertiary"
|
|
80
|
+
onClick={(e) => console.log("Click!")}
|
|
81
|
+
/>
|
|
82
|
+
<Strut size={Spacing.medium_16} />
|
|
83
|
+
<IconButton
|
|
84
|
+
disabled={true}
|
|
85
|
+
icon={icons.search}
|
|
86
|
+
aria-label="search"
|
|
87
|
+
onClick={(e) => console.log("Click!")}
|
|
88
|
+
/>
|
|
89
|
+
</View>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
Variants.parameters = {
|
|
94
|
+
docs: {
|
|
95
|
+
storyDescription: `In this example, we have primary, secondary,
|
|
96
|
+
tertiary, and disabled \`IconButton\`s from left to right.`,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const Light: StoryComponentType = () => {
|
|
101
|
+
return (
|
|
102
|
+
<View style={styles.dark}>
|
|
103
|
+
<IconButton
|
|
104
|
+
icon={icons.search}
|
|
105
|
+
aria-label="search"
|
|
106
|
+
light={true}
|
|
107
|
+
onClick={(e) => console.log("Click!")}
|
|
108
|
+
/>
|
|
109
|
+
</View>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
Light.parameters = {
|
|
114
|
+
docs: {
|
|
115
|
+
storyDescription: `An IconButton on a dark background.
|
|
116
|
+
Only the primary kind is allowed to have the \`light\`
|
|
117
|
+
prop set to true.`,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const DisabledLight: StoryComponentType = () => {
|
|
122
|
+
return (
|
|
123
|
+
<View style={styles.dark}>
|
|
124
|
+
<IconButton
|
|
125
|
+
disabled={true}
|
|
126
|
+
icon={icons.search}
|
|
127
|
+
aria-label="search"
|
|
128
|
+
light={true}
|
|
129
|
+
onClick={(e) => console.log("Click!")}
|
|
130
|
+
/>
|
|
131
|
+
</View>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
DisabledLight.parameters = {
|
|
136
|
+
docs: {
|
|
137
|
+
storyDescription:
|
|
138
|
+
"This is a disabled icon button with the `light` prop set to true.",
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const UsingHref: StoryComponentType = () => {
|
|
143
|
+
return (
|
|
144
|
+
<IconButton
|
|
145
|
+
icon={icons.info}
|
|
146
|
+
aria-label="More information"
|
|
147
|
+
href="/"
|
|
148
|
+
target="_blank"
|
|
149
|
+
onClick={(e) => console.log("Click!")}
|
|
150
|
+
/>
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
UsingHref.parameters = {
|
|
155
|
+
docs: {
|
|
156
|
+
storyDescription: `This example has an \`href\` prop in addition to the
|
|
157
|
+
\`onClick\` prop. \`href\` takes a URL or path, and clicking the
|
|
158
|
+
icon button will result in a navigation to the specified page.
|
|
159
|
+
Note that \`onClick\` is not required if \`href\` is defined.
|
|
160
|
+
The \`target="_blank"\` prop will cause the href page to open in
|
|
161
|
+
a new tab.`,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export const WithAriaLabel: StoryComponentType = () => {
|
|
166
|
+
return (
|
|
167
|
+
<View style={styles.arrowsWrapper}>
|
|
168
|
+
<IconButton
|
|
169
|
+
icon={icons.caretLeft}
|
|
170
|
+
onClick={(e) => console.log("Click!")}
|
|
171
|
+
aria-label="Previous page"
|
|
172
|
+
/>
|
|
173
|
+
<IconButton
|
|
174
|
+
icon={icons.caretRight}
|
|
175
|
+
onClick={(e) => console.log("Click!")}
|
|
176
|
+
aria-label="Next page"
|
|
177
|
+
/>
|
|
178
|
+
</View>
|
|
179
|
+
);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
WithAriaLabel.parameters = {
|
|
183
|
+
docs: {
|
|
184
|
+
storyDescription: `By default, the icon buttons do not have
|
|
185
|
+
accessible names. The \`aria-label\` prop must be used to explain
|
|
186
|
+
the function of the button. Remember to keep the description
|
|
187
|
+
concise but understandable.`,
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const styles = StyleSheet.create({
|
|
192
|
+
dark: {
|
|
193
|
+
backgroundColor: Color.darkBlue,
|
|
194
|
+
padding: Spacing.medium_16,
|
|
195
|
+
},
|
|
196
|
+
arrowsWrapper: {
|
|
197
|
+
flexDirection: "row",
|
|
198
|
+
justifyContent: "space-between",
|
|
199
|
+
width: Spacing.xxxLarge_64,
|
|
200
|
+
},
|
|
201
|
+
});
|
|
@@ -79,10 +79,9 @@ export type SharedProps = {|
|
|
|
79
79
|
*/
|
|
80
80
|
href?: string,
|
|
81
81
|
|
|
82
|
+
// TODO(WB-1262): only allow this prop when `href` is also set.
|
|
82
83
|
/**
|
|
83
84
|
* A target destination window for a link to open in.
|
|
84
|
-
*
|
|
85
|
-
* TODO(WB-1262): only allow this prop when `href` is also set.t
|
|
86
85
|
*/
|
|
87
86
|
target?: "_blank",
|
|
88
87
|
|
|
@@ -163,6 +162,7 @@ type DefaultProps = {|
|
|
|
163
162
|
*
|
|
164
163
|
* ```js
|
|
165
164
|
* import {icons} from "@khanacademy/wonder-blocks-icon";
|
|
165
|
+
* import IconButton from "@khanacademy/wonder-blocks-icon-button";
|
|
166
166
|
*
|
|
167
167
|
* <IconButton
|
|
168
168
|
* icon={icons.anIcon}
|