@khanacademy/wonder-blocks-dropdown 2.5.2 → 2.6.3
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 +48 -0
- package/dist/es/index.js +185 -183
- package/dist/index.js +5 -3
- package/package.json +12 -13
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +25 -22
- package/src/components/__tests__/action-item.test.js +30 -8
- package/src/components/__tests__/action-menu.test.js +1 -0
- package/src/components/__tests__/dropdown-core-virtualized.test.js +1 -0
- package/src/components/__tests__/dropdown-core.test.js +1 -0
- package/src/components/__tests__/multi-select.test.js +1 -0
- package/src/components/__tests__/search-text-input.test.js +1 -0
- package/src/components/action-item.js +8 -0
- package/src/components/action-menu.stories.js +48 -0
- package/src/components/multi-select.stories.js +3 -3
- package/src/components/option-item.js +1 -1
- package/src/components/select-opener.js +2 -2
- package/LICENSE +0 -21
- package/src/components/__tests__/__snapshots__/action-item.test.js.snap +0 -63
package/dist/index.js
CHANGED
|
@@ -506,6 +506,7 @@ class ActionItem extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
506
506
|
target,
|
|
507
507
|
indent,
|
|
508
508
|
label,
|
|
509
|
+
lang,
|
|
509
510
|
onClick,
|
|
510
511
|
role,
|
|
511
512
|
style,
|
|
@@ -534,6 +535,7 @@ class ActionItem extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
534
535
|
...childrenProps
|
|
535
536
|
};
|
|
536
537
|
const children = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__["LabelMedium"], {
|
|
538
|
+
lang: lang,
|
|
537
539
|
style: [indent && styles.indent, styles.label]
|
|
538
540
|
}, label));
|
|
539
541
|
|
|
@@ -745,7 +747,7 @@ const {
|
|
|
745
747
|
const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
746
748
|
itemContainer: {
|
|
747
749
|
flexDirection: "row",
|
|
748
|
-
|
|
750
|
+
background: white,
|
|
749
751
|
color: offBlack,
|
|
750
752
|
alignItems: "center",
|
|
751
753
|
height: _util_constants_js__WEBPACK_IMPORTED_MODULE_7__[/* DROPDOWN_ITEM_HEIGHT */ "a"],
|
|
@@ -1683,7 +1685,7 @@ const _generateStyles = (light, placeholder) => {
|
|
|
1683
1685
|
if (light) {
|
|
1684
1686
|
newStyles = {
|
|
1685
1687
|
default: {
|
|
1686
|
-
|
|
1688
|
+
background: "transparent",
|
|
1687
1689
|
color: placeholder ? white50 : white,
|
|
1688
1690
|
borderColor: white50,
|
|
1689
1691
|
borderWidth: 1
|
|
@@ -1711,7 +1713,7 @@ const _generateStyles = (light, placeholder) => {
|
|
|
1711
1713
|
} else {
|
|
1712
1714
|
newStyles = {
|
|
1713
1715
|
default: {
|
|
1714
|
-
|
|
1716
|
+
background: white,
|
|
1715
1717
|
borderColor: offBlack16,
|
|
1716
1718
|
borderWidth: 1,
|
|
1717
1719
|
color: placeholder ? offBlack64 : offBlack
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-dropdown",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.3",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"description": "Dropdown variants for Wonder Blocks.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/runtime": "^7.16.3",
|
|
19
|
-
"@khanacademy/wonder-blocks-button": "^2.
|
|
20
|
-
"@khanacademy/wonder-blocks-clickable": "^2.2.
|
|
19
|
+
"@khanacademy/wonder-blocks-button": "^2.11.2",
|
|
20
|
+
"@khanacademy/wonder-blocks-clickable": "^2.2.3",
|
|
21
21
|
"@khanacademy/wonder-blocks-color": "^1.1.20",
|
|
22
|
-
"@khanacademy/wonder-blocks-core": "^4.
|
|
23
|
-
"@khanacademy/wonder-blocks-icon": "^1.2.
|
|
24
|
-
"@khanacademy/wonder-blocks-icon-button": "^3.4.
|
|
25
|
-
"@khanacademy/wonder-blocks-layout": "^1.4.
|
|
26
|
-
"@khanacademy/wonder-blocks-modal": "^2.1
|
|
22
|
+
"@khanacademy/wonder-blocks-core": "^4.2.1",
|
|
23
|
+
"@khanacademy/wonder-blocks-icon": "^1.2.25",
|
|
24
|
+
"@khanacademy/wonder-blocks-icon-button": "^3.4.3",
|
|
25
|
+
"@khanacademy/wonder-blocks-layout": "^1.4.7",
|
|
26
|
+
"@khanacademy/wonder-blocks-modal": "^2.2.1",
|
|
27
27
|
"@khanacademy/wonder-blocks-spacing": "^3.0.5",
|
|
28
|
-
"@khanacademy/wonder-blocks-timing": "^2.0
|
|
29
|
-
"@khanacademy/wonder-blocks-typography": "^1.1.
|
|
28
|
+
"@khanacademy/wonder-blocks-timing": "^2.1.0",
|
|
29
|
+
"@khanacademy/wonder-blocks-typography": "^1.1.29"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@popperjs/core": "^2.10.1",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"react-window": "^1.8.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"wb-dev-build-settings": "^0.
|
|
43
|
-
}
|
|
44
|
-
"gitHead": "9ebea88533e702011165072f090a377e02fa3f0f"
|
|
42
|
+
"wb-dev-build-settings": "^0.3.0"
|
|
43
|
+
}
|
|
45
44
|
}
|
|
@@ -651,7 +651,7 @@ exports[`wonder-blocks-dropdown example 4 1`] = `
|
|
|
651
651
|
"touchAction": "manipulation",
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
|
-
tabIndex={
|
|
654
|
+
tabIndex={0}
|
|
655
655
|
type="button"
|
|
656
656
|
>
|
|
657
657
|
<div
|
|
@@ -1134,8 +1134,8 @@ exports[`wonder-blocks-dropdown example 6 1`] = `
|
|
|
1134
1134
|
}
|
|
1135
1135
|
/>
|
|
1136
1136
|
<button
|
|
1137
|
+
aria-disabled={false}
|
|
1137
1138
|
className=""
|
|
1138
|
-
disabled={false}
|
|
1139
1139
|
onBlur={[Function]}
|
|
1140
1140
|
onClick={[Function]}
|
|
1141
1141
|
onDragStart={[Function]}
|
|
@@ -1334,7 +1334,7 @@ exports[`wonder-blocks-dropdown example 8 1`] = `
|
|
|
1334
1334
|
"border": 0,
|
|
1335
1335
|
},
|
|
1336
1336
|
"alignItems": "center",
|
|
1337
|
-
"
|
|
1337
|
+
"background": "#ffffff",
|
|
1338
1338
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
1339
1339
|
"borderRadius": 4,
|
|
1340
1340
|
"borderStyle": "solid",
|
|
@@ -1470,7 +1470,7 @@ exports[`wonder-blocks-dropdown example 9 1`] = `
|
|
|
1470
1470
|
"border": 0,
|
|
1471
1471
|
},
|
|
1472
1472
|
"alignItems": "center",
|
|
1473
|
-
"
|
|
1473
|
+
"background": "#ffffff",
|
|
1474
1474
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
1475
1475
|
"borderRadius": 4,
|
|
1476
1476
|
"borderStyle": "solid",
|
|
@@ -1606,6 +1606,7 @@ exports[`wonder-blocks-dropdown example 10 1`] = `
|
|
|
1606
1606
|
"border": 0,
|
|
1607
1607
|
},
|
|
1608
1608
|
"alignItems": "center",
|
|
1609
|
+
"background": "#ffffff",
|
|
1609
1610
|
"backgroundColor": "transparent",
|
|
1610
1611
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
1611
1612
|
"borderRadius": 4,
|
|
@@ -1627,7 +1628,7 @@ exports[`wonder-blocks-dropdown example 10 1`] = `
|
|
|
1627
1628
|
"whiteSpace": "nowrap",
|
|
1628
1629
|
}
|
|
1629
1630
|
}
|
|
1630
|
-
tabIndex={
|
|
1631
|
+
tabIndex={0}
|
|
1631
1632
|
type="button"
|
|
1632
1633
|
>
|
|
1633
1634
|
<span
|
|
@@ -1768,7 +1769,7 @@ exports[`wonder-blocks-dropdown example 11 1`] = `
|
|
|
1768
1769
|
"border": 0,
|
|
1769
1770
|
},
|
|
1770
1771
|
"alignItems": "center",
|
|
1771
|
-
"
|
|
1772
|
+
"background": "transparent",
|
|
1772
1773
|
"borderColor": "rgba(255,255,255,0.50)",
|
|
1773
1774
|
"borderRadius": 4,
|
|
1774
1775
|
"borderStyle": "solid",
|
|
@@ -1905,6 +1906,7 @@ exports[`wonder-blocks-dropdown example 12 1`] = `
|
|
|
1905
1906
|
"border": 0,
|
|
1906
1907
|
},
|
|
1907
1908
|
"alignItems": "center",
|
|
1909
|
+
"background": "#ffffff",
|
|
1908
1910
|
"backgroundColor": "transparent",
|
|
1909
1911
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
1910
1912
|
"borderRadius": 4,
|
|
@@ -1926,7 +1928,7 @@ exports[`wonder-blocks-dropdown example 12 1`] = `
|
|
|
1926
1928
|
"whiteSpace": "nowrap",
|
|
1927
1929
|
}
|
|
1928
1930
|
}
|
|
1929
|
-
tabIndex={
|
|
1931
|
+
tabIndex={0}
|
|
1930
1932
|
type="button"
|
|
1931
1933
|
>
|
|
1932
1934
|
<span
|
|
@@ -2062,7 +2064,7 @@ exports[`wonder-blocks-dropdown example 13 1`] = `
|
|
|
2062
2064
|
"border": 0,
|
|
2063
2065
|
},
|
|
2064
2066
|
"alignItems": "center",
|
|
2065
|
-
"
|
|
2067
|
+
"background": "#ffffff",
|
|
2066
2068
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
2067
2069
|
"borderRadius": 4,
|
|
2068
2070
|
"borderStyle": "solid",
|
|
@@ -2198,7 +2200,7 @@ exports[`wonder-blocks-dropdown example 14 1`] = `
|
|
|
2198
2200
|
"border": 0,
|
|
2199
2201
|
},
|
|
2200
2202
|
"alignItems": "center",
|
|
2201
|
-
"
|
|
2203
|
+
"background": "#ffffff",
|
|
2202
2204
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
2203
2205
|
"borderRadius": 4,
|
|
2204
2206
|
"borderStyle": "solid",
|
|
@@ -2292,8 +2294,8 @@ exports[`wonder-blocks-dropdown example 14 1`] = `
|
|
|
2292
2294
|
}
|
|
2293
2295
|
/>
|
|
2294
2296
|
<button
|
|
2297
|
+
aria-disabled={false}
|
|
2295
2298
|
className=""
|
|
2296
|
-
disabled={false}
|
|
2297
2299
|
onBlur={[Function]}
|
|
2298
2300
|
onClick={[Function]}
|
|
2299
2301
|
onDragStart={[Function]}
|
|
@@ -2498,7 +2500,7 @@ exports[`wonder-blocks-dropdown example 16 1`] = `
|
|
|
2498
2500
|
"border": 0,
|
|
2499
2501
|
},
|
|
2500
2502
|
"alignItems": "center",
|
|
2501
|
-
"
|
|
2503
|
+
"background": "#ffffff",
|
|
2502
2504
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
2503
2505
|
"borderRadius": 4,
|
|
2504
2506
|
"borderStyle": "solid",
|
|
@@ -2635,7 +2637,7 @@ exports[`wonder-blocks-dropdown example 17 1`] = `
|
|
|
2635
2637
|
"border": 0,
|
|
2636
2638
|
},
|
|
2637
2639
|
"alignItems": "center",
|
|
2638
|
-
"
|
|
2640
|
+
"background": "#ffffff",
|
|
2639
2641
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
2640
2642
|
"borderRadius": 4,
|
|
2641
2643
|
"borderStyle": "solid",
|
|
@@ -2771,7 +2773,7 @@ exports[`wonder-blocks-dropdown example 18 1`] = `
|
|
|
2771
2773
|
"border": 0,
|
|
2772
2774
|
},
|
|
2773
2775
|
"alignItems": "center",
|
|
2774
|
-
"
|
|
2776
|
+
"background": "#ffffff",
|
|
2775
2777
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
2776
2778
|
"borderRadius": 4,
|
|
2777
2779
|
"borderStyle": "solid",
|
|
@@ -2907,7 +2909,7 @@ exports[`wonder-blocks-dropdown example 19 1`] = `
|
|
|
2907
2909
|
"border": 0,
|
|
2908
2910
|
},
|
|
2909
2911
|
"alignItems": "center",
|
|
2910
|
-
"
|
|
2912
|
+
"background": "#ffffff",
|
|
2911
2913
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
2912
2914
|
"borderRadius": 4,
|
|
2913
2915
|
"borderStyle": "solid",
|
|
@@ -2998,8 +3000,8 @@ exports[`wonder-blocks-dropdown example 20 1`] = `
|
|
|
2998
3000
|
}
|
|
2999
3001
|
>
|
|
3000
3002
|
<button
|
|
3003
|
+
aria-disabled={false}
|
|
3001
3004
|
className=""
|
|
3002
|
-
disabled={false}
|
|
3003
3005
|
onBlur={[Function]}
|
|
3004
3006
|
onClick={[Function]}
|
|
3005
3007
|
onDragStart={[Function]}
|
|
@@ -3138,6 +3140,7 @@ exports[`wonder-blocks-dropdown example 21 1`] = `
|
|
|
3138
3140
|
"border": 0,
|
|
3139
3141
|
},
|
|
3140
3142
|
"alignItems": "center",
|
|
3143
|
+
"background": "#ffffff",
|
|
3141
3144
|
"backgroundColor": "transparent",
|
|
3142
3145
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
3143
3146
|
"borderRadius": 4,
|
|
@@ -3159,7 +3162,7 @@ exports[`wonder-blocks-dropdown example 21 1`] = `
|
|
|
3159
3162
|
"whiteSpace": "nowrap",
|
|
3160
3163
|
}
|
|
3161
3164
|
}
|
|
3162
|
-
tabIndex={
|
|
3165
|
+
tabIndex={0}
|
|
3163
3166
|
type="button"
|
|
3164
3167
|
>
|
|
3165
3168
|
<span
|
|
@@ -3295,7 +3298,7 @@ exports[`wonder-blocks-dropdown example 22 1`] = `
|
|
|
3295
3298
|
"border": 0,
|
|
3296
3299
|
},
|
|
3297
3300
|
"alignItems": "center",
|
|
3298
|
-
"
|
|
3301
|
+
"background": "#ffffff",
|
|
3299
3302
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
3300
3303
|
"borderRadius": 4,
|
|
3301
3304
|
"borderStyle": "solid",
|
|
@@ -3431,7 +3434,7 @@ exports[`wonder-blocks-dropdown example 23 1`] = `
|
|
|
3431
3434
|
"border": 0,
|
|
3432
3435
|
},
|
|
3433
3436
|
"alignItems": "center",
|
|
3434
|
-
"
|
|
3437
|
+
"background": "#ffffff",
|
|
3435
3438
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
3436
3439
|
"borderRadius": 4,
|
|
3437
3440
|
"borderStyle": "solid",
|
|
@@ -3567,7 +3570,7 @@ exports[`wonder-blocks-dropdown example 24 1`] = `
|
|
|
3567
3570
|
"border": 0,
|
|
3568
3571
|
},
|
|
3569
3572
|
"alignItems": "center",
|
|
3570
|
-
"
|
|
3573
|
+
"background": "#ffffff",
|
|
3571
3574
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
3572
3575
|
"borderRadius": 4,
|
|
3573
3576
|
"borderStyle": "solid",
|
|
@@ -3661,8 +3664,8 @@ exports[`wonder-blocks-dropdown example 24 1`] = `
|
|
|
3661
3664
|
}
|
|
3662
3665
|
/>
|
|
3663
3666
|
<button
|
|
3667
|
+
aria-disabled={false}
|
|
3664
3668
|
className=""
|
|
3665
|
-
disabled={false}
|
|
3666
3669
|
onBlur={[Function]}
|
|
3667
3670
|
onClick={[Function]}
|
|
3668
3671
|
onDragStart={[Function]}
|
|
@@ -3801,7 +3804,7 @@ exports[`wonder-blocks-dropdown example 25 1`] = `
|
|
|
3801
3804
|
"border": 0,
|
|
3802
3805
|
},
|
|
3803
3806
|
"alignItems": "center",
|
|
3804
|
-
"
|
|
3807
|
+
"background": "#ffffff",
|
|
3805
3808
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
3806
3809
|
"borderRadius": 4,
|
|
3807
3810
|
"borderStyle": "solid",
|
|
@@ -3984,7 +3987,7 @@ exports[`wonder-blocks-dropdown example 27 1`] = `
|
|
|
3984
3987
|
"border": 0,
|
|
3985
3988
|
},
|
|
3986
3989
|
"alignItems": "center",
|
|
3987
|
-
"
|
|
3990
|
+
"background": "#ffffff",
|
|
3988
3991
|
"borderColor": "rgba(33,36,44,0.16)",
|
|
3989
3992
|
"borderRadius": 4,
|
|
3990
3993
|
"borderStyle": "solid",
|
|
@@ -1,32 +1,54 @@
|
|
|
1
|
+
// @flow
|
|
1
2
|
import * as React from "react";
|
|
2
|
-
import renderer from "react-test-renderer";
|
|
3
3
|
import {MemoryRouter, Link} from "react-router-dom";
|
|
4
4
|
import {mount} from "enzyme";
|
|
5
|
+
import {render, screen} from "@testing-library/react";
|
|
5
6
|
|
|
6
7
|
import ActionItem from "../action-item.js";
|
|
7
8
|
|
|
8
9
|
describe("ActionItem", () => {
|
|
9
10
|
it("should render with disabled styles", () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
// Arrange
|
|
12
|
+
|
|
13
|
+
// Act
|
|
14
|
+
render(<ActionItem href="/foo" label="Example" disabled={true} />);
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
// Assert
|
|
17
|
+
expect(screen.getByRole("menuitem")).toBeDisabled();
|
|
15
18
|
});
|
|
16
19
|
|
|
17
20
|
it("should render an anchor if there's no router", () => {
|
|
18
|
-
|
|
21
|
+
// Arrange
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
// Act
|
|
24
|
+
render(<ActionItem href="/foo" label="Example" />);
|
|
25
|
+
|
|
26
|
+
// Assert
|
|
27
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
28
|
+
expect(document.querySelectorAll("a")).toHaveLength(1);
|
|
21
29
|
});
|
|
22
30
|
|
|
23
31
|
it("should render a Link if there's a router", () => {
|
|
32
|
+
// Arrange
|
|
33
|
+
|
|
34
|
+
// Act
|
|
24
35
|
const wrapper = mount(
|
|
25
36
|
<MemoryRouter>
|
|
26
|
-
<ActionItem href="/foo" />
|
|
37
|
+
<ActionItem href="/foo" label="Example" />
|
|
27
38
|
</MemoryRouter>,
|
|
28
39
|
);
|
|
29
40
|
|
|
41
|
+
// Assert
|
|
30
42
|
expect(wrapper.find(Link)).toHaveLength(1);
|
|
31
43
|
});
|
|
44
|
+
|
|
45
|
+
it("should set the lang attribute if it's passed down", () => {
|
|
46
|
+
// Arrange
|
|
47
|
+
|
|
48
|
+
// Act
|
|
49
|
+
render(<ActionItem label="Español" lang="es" />);
|
|
50
|
+
|
|
51
|
+
// Assert
|
|
52
|
+
expect(screen.getByText("Español")).toHaveAttribute("lang", "es");
|
|
53
|
+
});
|
|
32
54
|
});
|
|
@@ -38,6 +38,12 @@ type ActionProps = {|
|
|
|
38
38
|
*/
|
|
39
39
|
href?: string,
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Optional attribute to indicate to the Screen Reader which language the
|
|
43
|
+
* item text is in.
|
|
44
|
+
*/
|
|
45
|
+
lang?: string,
|
|
46
|
+
|
|
41
47
|
/**
|
|
42
48
|
* A target destination window for a link to open in.
|
|
43
49
|
*/
|
|
@@ -131,6 +137,7 @@ export default class ActionItem extends React.Component<ActionProps> {
|
|
|
131
137
|
target,
|
|
132
138
|
indent,
|
|
133
139
|
label,
|
|
140
|
+
lang,
|
|
134
141
|
onClick,
|
|
135
142
|
role,
|
|
136
143
|
style,
|
|
@@ -176,6 +183,7 @@ export default class ActionItem extends React.Component<ActionProps> {
|
|
|
176
183
|
const children = (
|
|
177
184
|
<React.Fragment>
|
|
178
185
|
<LabelMedium
|
|
186
|
+
lang={lang}
|
|
179
187
|
style={[indent && styles.indent, styles.label]}
|
|
180
188
|
>
|
|
181
189
|
{label}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import type {StoryComponentType} from "@storybook/react";
|
|
5
|
+
import ActionMenu from "./action-menu.js";
|
|
6
|
+
import ActionItem from "./action-item.js";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: "Dropdown / ActionMenu",
|
|
10
|
+
component: ActionMenu,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const ActionMenuWithLang: StoryComponentType = () => (
|
|
14
|
+
<ActionMenu menuText="Locales">
|
|
15
|
+
{locales.map((locale) => (
|
|
16
|
+
<ActionItem
|
|
17
|
+
key={locale.locale}
|
|
18
|
+
label={locale.localName}
|
|
19
|
+
lang={locale.locale}
|
|
20
|
+
testId={"language_picker_" + locale.locale}
|
|
21
|
+
/>
|
|
22
|
+
))}
|
|
23
|
+
</ActionMenu>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
ActionMenuWithLang.storyName = "Using the ActionMenu with the lang attribute";
|
|
27
|
+
|
|
28
|
+
ActionMenuWithLang.parameters = {
|
|
29
|
+
docs: {
|
|
30
|
+
storyDescription:
|
|
31
|
+
"You can use the `lang` attribute to specify the language of the action item(s). This is useful if you want to avoid issues with Screen Readers trying to read the proper language for the rendered text.",
|
|
32
|
+
},
|
|
33
|
+
chromatic: {
|
|
34
|
+
disableSnapshot: true,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const locales = [
|
|
39
|
+
{id: "az", locale: "az", localName: "Azərbaycanca"},
|
|
40
|
+
{id: "id", locale: "id", localName: "Bahasa Indonesia"},
|
|
41
|
+
{id: "cs", locale: "cs", localName: "čeština"},
|
|
42
|
+
{id: "da", locale: "da", localName: "dansk"},
|
|
43
|
+
{id: "de", locale: "de", localName: "Deutsch"},
|
|
44
|
+
{id: "en", locale: "en", localName: "English"},
|
|
45
|
+
{id: "es", locale: "es", localName: "español"},
|
|
46
|
+
{id: "fr", locale: "fr", localName: "français"},
|
|
47
|
+
{id: "it", locale: "it", localName: "italiano"},
|
|
48
|
+
];
|
|
@@ -79,18 +79,18 @@ class MultiSelectWithCustomStyles extends React.Component<Props, State> {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
export const
|
|
82
|
+
export const CustomStyles: StoryComponentType = () => (
|
|
83
83
|
<MultiSelectWithCustomStyles />
|
|
84
84
|
);
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
CustomStyles.parameters = {
|
|
87
87
|
chromatic: {
|
|
88
88
|
// we don't need screenshots because this story only tests behavior.
|
|
89
89
|
disableSnapshot: true,
|
|
90
90
|
},
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
export const
|
|
93
|
+
export const CustomStylesOpened: StoryComponentType = () => (
|
|
94
94
|
<MultiSelectWithCustomStyles opened={true} />
|
|
95
95
|
);
|
|
96
96
|
|
|
@@ -190,7 +190,7 @@ const {blue, white, offBlack, offBlack32} = Color;
|
|
|
190
190
|
const styles = StyleSheet.create({
|
|
191
191
|
itemContainer: {
|
|
192
192
|
flexDirection: "row",
|
|
193
|
-
|
|
193
|
+
background: white,
|
|
194
194
|
color: offBlack,
|
|
195
195
|
alignItems: "center",
|
|
196
196
|
height: DROPDOWN_ITEM_HEIGHT,
|
|
@@ -231,7 +231,7 @@ const _generateStyles = (light, placeholder) => {
|
|
|
231
231
|
if (light) {
|
|
232
232
|
newStyles = {
|
|
233
233
|
default: {
|
|
234
|
-
|
|
234
|
+
background: "transparent",
|
|
235
235
|
color: placeholder ? white50 : white,
|
|
236
236
|
borderColor: white50,
|
|
237
237
|
borderWidth: 1,
|
|
@@ -261,7 +261,7 @@ const _generateStyles = (light, placeholder) => {
|
|
|
261
261
|
} else {
|
|
262
262
|
newStyles = {
|
|
263
263
|
default: {
|
|
264
|
-
|
|
264
|
+
background: white,
|
|
265
265
|
borderColor: offBlack16,
|
|
266
266
|
borderWidth: 1,
|
|
267
267
|
color: placeholder ? offBlack64 : offBlack,
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Khan Academy
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`ActionItem should render with disabled styles 1`] = `
|
|
4
|
-
<button
|
|
5
|
-
className=""
|
|
6
|
-
disabled={true}
|
|
7
|
-
onBlur={[Function]}
|
|
8
|
-
onClick={[Function]}
|
|
9
|
-
onDragStart={[Function]}
|
|
10
|
-
onFocus={[Function]}
|
|
11
|
-
onKeyDown={[Function]}
|
|
12
|
-
onKeyUp={[Function]}
|
|
13
|
-
onMouseDown={[Function]}
|
|
14
|
-
onMouseEnter={[Function]}
|
|
15
|
-
onMouseLeave={[Function]}
|
|
16
|
-
onMouseUp={[Function]}
|
|
17
|
-
onTouchCancel={[Function]}
|
|
18
|
-
onTouchEnd={[Function]}
|
|
19
|
-
onTouchStart={[Function]}
|
|
20
|
-
role="menuitem"
|
|
21
|
-
style={
|
|
22
|
-
Object {
|
|
23
|
-
"::MozFocusInner": Object {
|
|
24
|
-
"border": 0,
|
|
25
|
-
},
|
|
26
|
-
"alignItems": "center",
|
|
27
|
-
"background": "#ffffff",
|
|
28
|
-
"border": "none",
|
|
29
|
-
"color": "rgba(33,36,44,0.32)",
|
|
30
|
-
"cursor": "default",
|
|
31
|
-
"display": "flex",
|
|
32
|
-
"flexDirection": "row",
|
|
33
|
-
"height": 40,
|
|
34
|
-
"margin": 0,
|
|
35
|
-
"minHeight": 40,
|
|
36
|
-
"outline": "none",
|
|
37
|
-
"paddingLeft": 16,
|
|
38
|
-
"paddingRight": 16,
|
|
39
|
-
"textDecoration": "none",
|
|
40
|
-
"touchAction": "manipulation",
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
tabIndex={-1}
|
|
44
|
-
type="button"
|
|
45
|
-
>
|
|
46
|
-
<span
|
|
47
|
-
className=""
|
|
48
|
-
style={
|
|
49
|
-
Object {
|
|
50
|
-
"MozOsxFontSmoothing": "grayscale",
|
|
51
|
-
"WebkitFontSmoothing": "antialiased",
|
|
52
|
-
"display": "block",
|
|
53
|
-
"fontFamily": "Lato, \\"Noto Sans\\", sans-serif",
|
|
54
|
-
"fontSize": 16,
|
|
55
|
-
"fontWeight": 400,
|
|
56
|
-
"lineHeight": "20px",
|
|
57
|
-
"userSelect": "none",
|
|
58
|
-
"whiteSpace": "nowrap",
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/>
|
|
62
|
-
</button>
|
|
63
|
-
`;
|