@khanacademy/wonder-blocks-button 2.11.7 → 3.0.0
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 +6 -0
- package/dist/es/index.js +12 -9
- package/dist/index.js +25 -20
- package/package.json +1 -1
- package/src/__tests__/__snapshots__/custom-snapshot.test.js.snap +4646 -780
- package/src/__tests__/custom-snapshot.test.js +1 -1
- package/src/components/__docs__/accessibility.stories.mdx +1 -1
- package/src/components/__docs__/best-practices.stories.mdx +1 -1
- package/src/components/__docs__/button.argtypes.js +3 -3
- package/src/components/{button.stories.js → __docs__/button.stories.js} +195 -275
- package/src/components/__docs__/navigation-callbacks.stories.mdx +121 -2
- package/src/components/__tests__/button.test.js +138 -191
- package/src/components/button-core.js +14 -8
- package/src/components/button.js +2 -2
- package/src/components/button.md +4 -920
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +0 -5009
- package/src/__tests__/generated-snapshot.test.js +0 -789
|
@@ -87,7 +87,7 @@ export default class ButtonCore extends React.Component<Props> {
|
|
|
87
87
|
? buttonStyles.active
|
|
88
88
|
: (hovered || focused) && buttonStyles.focus),
|
|
89
89
|
size === "small" && sharedStyles.small,
|
|
90
|
-
size === "
|
|
90
|
+
size === "large" && sharedStyles.large,
|
|
91
91
|
];
|
|
92
92
|
|
|
93
93
|
const commonProps = {
|
|
@@ -100,11 +100,15 @@ export default class ButtonCore extends React.Component<Props> {
|
|
|
100
100
|
|
|
101
101
|
const Label = size === "small" ? LabelSmall : LabelLarge;
|
|
102
102
|
|
|
103
|
+
// We have to use `medium` for both md and lg buttons so we can fit the
|
|
104
|
+
// icons in large buttons.
|
|
105
|
+
const iconSize = size === "small" ? "small" : "medium";
|
|
106
|
+
|
|
103
107
|
const label = (
|
|
104
108
|
<Label
|
|
105
109
|
style={[
|
|
106
110
|
sharedStyles.text,
|
|
107
|
-
size === "
|
|
111
|
+
size === "large" && sharedStyles.largeText,
|
|
108
112
|
icon && sharedStyles.textWithIcon,
|
|
109
113
|
spinner && sharedStyles.hiddenText,
|
|
110
114
|
kind === "tertiary" && sharedStyles.textWithFocus,
|
|
@@ -118,7 +122,7 @@ export default class ButtonCore extends React.Component<Props> {
|
|
|
118
122
|
>
|
|
119
123
|
{icon && (
|
|
120
124
|
<Icon
|
|
121
|
-
size={
|
|
125
|
+
size={iconSize}
|
|
122
126
|
color="currentColor"
|
|
123
127
|
icon={icon}
|
|
124
128
|
style={sharedStyles.icon}
|
|
@@ -138,10 +142,11 @@ export default class ButtonCore extends React.Component<Props> {
|
|
|
138
142
|
{
|
|
139
143
|
medium: "small",
|
|
140
144
|
small: "xsmall",
|
|
141
|
-
|
|
145
|
+
large: "medium",
|
|
142
146
|
}[size]
|
|
143
147
|
}
|
|
144
148
|
light={kind === "primary"}
|
|
149
|
+
testId={`${testId || "button"}-spinner`}
|
|
145
150
|
/>
|
|
146
151
|
)}
|
|
147
152
|
</React.Fragment>
|
|
@@ -215,8 +220,9 @@ const sharedStyles = StyleSheet.create({
|
|
|
215
220
|
small: {
|
|
216
221
|
height: 32,
|
|
217
222
|
},
|
|
218
|
-
|
|
219
|
-
|
|
223
|
+
large: {
|
|
224
|
+
borderRadius: Spacing.xxSmall_6,
|
|
225
|
+
height: 56,
|
|
220
226
|
},
|
|
221
227
|
text: {
|
|
222
228
|
alignItems: "center",
|
|
@@ -227,7 +233,7 @@ const sharedStyles = StyleSheet.create({
|
|
|
227
233
|
display: "inline-block", // allows the button text to truncate
|
|
228
234
|
pointerEvents: "none", // fix Safari bug where the browser was eating mouse events
|
|
229
235
|
},
|
|
230
|
-
|
|
236
|
+
largeText: {
|
|
231
237
|
fontSize: 18,
|
|
232
238
|
lineHeight: "20px",
|
|
233
239
|
},
|
|
@@ -260,7 +266,7 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
|
|
|
260
266
|
const {white, white50, white64, offBlack32, offBlack50, darkBlue} = Color;
|
|
261
267
|
const fadedColor = mix(fade(color, 0.32), white);
|
|
262
268
|
const activeColor = mix(offBlack32, color);
|
|
263
|
-
const padding = size === "
|
|
269
|
+
const padding = size === "large" ? Spacing.xLarge_32 : Spacing.medium_16;
|
|
264
270
|
|
|
265
271
|
let newStyles = {};
|
|
266
272
|
if (kind === "primary") {
|
package/src/components/button.js
CHANGED
|
@@ -60,9 +60,9 @@ export type SharedProps = {|
|
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* The size of the button. "medium" = height: 40; "small" = height: 32;
|
|
63
|
-
* "
|
|
63
|
+
* "large" = height: 56;
|
|
64
64
|
*/
|
|
65
|
-
size: "medium" | "small" | "
|
|
65
|
+
size: "medium" | "small" | "large",
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Whether the button is disabled.
|