@khanacademy/math-input 4.2.0 → 4.3.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/components/input/mathquill-types.d.ts +2 -0
- package/dist/components/input/mathquill-types.js.flow +2 -0
- package/dist/components/keypad/index.d.ts +8 -16
- package/dist/components/keypad/index.js.flow +10 -22
- package/dist/components/keypad/keypad-button.d.ts +12 -0
- package/dist/components/keypad/keypad-button.js.flow +18 -0
- package/dist/components/keypad/keypad-pages/extras-page.d.ts +9 -0
- package/dist/components/keypad/{operators-page/basic-relations-buttons.js.flow → keypad-pages/extras-page.js.flow} +3 -3
- package/dist/components/keypad/keypad-pages/geometry-page.d.ts +7 -0
- package/dist/components/keypad/{operators-page/logarithms-buttons.js.flow → keypad-pages/geometry-page.js.flow} +1 -3
- package/dist/components/keypad/keypad-pages/numbers-page.d.ts +7 -0
- package/dist/components/keypad/{operators-page/pre-algebra-buttons.js.flow → keypad-pages/numbers-page.js.flow} +1 -3
- package/dist/components/keypad/keypad-pages/operators-page.d.ts +11 -0
- package/dist/components/keypad/{operators-page/advanced-relations-buttons.js.flow → keypad-pages/operators-page.js.flow} +5 -3
- package/dist/components/keypad/shared-keys.d.ts +9 -0
- package/dist/components/keypad/{numbers-page/types.js.flow → shared-keys.js.flow} +4 -1
- package/dist/es/index.js +321 -465
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +319 -488
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
- package/src/components/input/__tests__/test-math-wrapper.ts +2 -5
- package/src/components/input/mathquill-types.ts +6 -0
- package/src/components/keypad/__tests__/keypad-button.test.tsx +4 -2
- package/src/components/keypad/index.tsx +73 -49
- package/src/components/keypad/{button.stories.tsx → keypad-button.stories.tsx} +2 -1
- package/src/components/keypad/keypad-button.tsx +128 -0
- package/src/components/keypad/keypad-mathquill.stories.tsx +9 -3
- package/src/components/keypad/keypad-pages/extras-page.tsx +34 -0
- package/src/components/keypad/keypad-pages/geometry-page.tsx +33 -0
- package/src/components/keypad/keypad-pages/numbers-page.tsx +84 -0
- package/src/components/keypad/keypad-pages/operators-page.tsx +116 -0
- package/src/components/keypad/shared-keys.tsx +78 -0
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/components/keypad/button.d.ts +0 -12
- package/dist/components/keypad/button.js.flow +0 -18
- package/dist/components/keypad/extras-page/index.d.ts +0 -10
- package/dist/components/keypad/extras-page/index.js.flow +0 -15
- package/dist/components/keypad/geometry-page/index.d.ts +0 -9
- package/dist/components/keypad/geometry-page/index.js.flow +0 -14
- package/dist/components/keypad/keypad-page-items.d.ts +0 -26
- package/dist/components/keypad/keypad-page-items.js.flow +0 -40
- package/dist/components/keypad/numbers-page/index.d.ts +0 -10
- package/dist/components/keypad/numbers-page/index.js.flow +0 -18
- package/dist/components/keypad/numbers-page/types.d.ts +0 -4
- package/dist/components/keypad/operators-page/advanced-relations-buttons.d.ts +0 -8
- package/dist/components/keypad/operators-page/basic-relations-buttons.d.ts +0 -8
- package/dist/components/keypad/operators-page/index.d.ts +0 -10
- package/dist/components/keypad/operators-page/index.js.flow +0 -18
- package/dist/components/keypad/operators-page/logarithms-buttons.d.ts +0 -8
- package/dist/components/keypad/operators-page/pre-algebra-buttons.d.ts +0 -8
- package/dist/components/keypad/operators-page/types.d.ts +0 -6
- package/dist/components/keypad/operators-page/types.js.flow +0 -12
- package/src/components/keypad/__tests__/Button.test.tsx +0 -51
- package/src/components/keypad/button.tsx +0 -108
- package/src/components/keypad/extras-page/index.tsx +0 -27
- package/src/components/keypad/geometry-page/index.tsx +0 -89
- package/src/components/keypad/keypad-page-items.tsx +0 -118
- package/src/components/keypad/numbers-page/index.tsx +0 -136
- package/src/components/keypad/numbers-page/types.ts +0 -4
- package/src/components/keypad/operators-page/advanced-relations-buttons.tsx +0 -33
- package/src/components/keypad/operators-page/basic-relations-buttons.tsx +0 -33
- package/src/components/keypad/operators-page/index.tsx +0 -94
- package/src/components/keypad/operators-page/logarithms-buttons.tsx +0 -33
- package/src/components/keypad/operators-page/pre-algebra-buttons.tsx +0 -37
- package/src/components/keypad/operators-page/types.ts +0 -6
- /package/src/components/keypad/{keypad-pages.stories.tsx → keypad-pages/keypad-pages.stories.tsx} +0 -0
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Khan Academy's new expression editor for the mobile web.",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "4.
|
|
6
|
+
"version": "4.3.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"source": "src/index.ts",
|
|
20
20
|
"scripts": {},
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"mathquill": "git+https://git@github.com/Khan/mathquill.git#a9ae54e057c5c1acc8244a5627acbff29901d992",
|
|
22
23
|
"performance-now": "^0.2.0"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
@@ -31,7 +32,6 @@
|
|
|
31
32
|
"aphrodite": "^1.1.0",
|
|
32
33
|
"jquery": "^2.1.1",
|
|
33
34
|
"katex": "^0.11.1",
|
|
34
|
-
"mathquill": "git+https://git@github.com/Khan/mathquill.git#a9ae54e057c5c1acc8244a5627acbff29901d992",
|
|
35
35
|
"perseus-build-settings": "^0.1.0",
|
|
36
36
|
"prop-types": "15.6.1",
|
|
37
37
|
"react": "^16.8.0",
|
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
"aphrodite": "^1.1.0",
|
|
52
52
|
"jquery": "^2.1.1",
|
|
53
53
|
"katex": "^0.11.1",
|
|
54
|
-
"mathquill": "git+https://git@github.com/Khan/mathquill.git#a9ae54e057c5c1acc8244a5627acbff29901d992",
|
|
55
54
|
"prop-types": "15.6.1",
|
|
56
55
|
"react": "^16.8.0",
|
|
57
56
|
"react-dom": "^16.8.0",
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import MathQuill from "mathquill";
|
|
2
|
-
|
|
3
1
|
import MathWrapper from "../math-wrapper";
|
|
4
|
-
|
|
5
|
-
const MQ = MathQuill.getInterface(2);
|
|
2
|
+
import {mathQuillInstance} from "../mathquill-instance";
|
|
6
3
|
|
|
7
4
|
export default class TestMathWrapper extends MathWrapper {
|
|
8
5
|
getContent() {
|
|
@@ -18,7 +15,7 @@ export default class TestMathWrapper extends MathWrapper {
|
|
|
18
15
|
}
|
|
19
16
|
|
|
20
17
|
moveToStart() {
|
|
21
|
-
this.mathField.moveToDirEnd(
|
|
18
|
+
this.mathField.moveToDirEnd(mathQuillInstance.L);
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
isSelected() {
|
|
@@ -62,6 +62,12 @@ export interface MathFieldInterface {
|
|
|
62
62
|
// Clears the selection
|
|
63
63
|
// https://docs.mathquill.com/en/latest/Api_Methods/#clearselection
|
|
64
64
|
clearSelection: () => void;
|
|
65
|
+
// Custom helper in our MathQuill fork
|
|
66
|
+
// check to see if cursor is on right end
|
|
67
|
+
cursorAtRightEnd: () => boolean;
|
|
68
|
+
// Custom helper in our MathQuill fork
|
|
69
|
+
// check to see if cursor is on left end
|
|
70
|
+
cursorAtLeftEnd: () => boolean;
|
|
65
71
|
// This isn't part of the MathQuill public API
|
|
66
72
|
// I don't know what it is and it feels wrong using it
|
|
67
73
|
__controller: any;
|
|
@@ -4,15 +4,16 @@ import * as React from "react";
|
|
|
4
4
|
import "@testing-library/jest-dom";
|
|
5
5
|
|
|
6
6
|
import Keys from "../../../data/key-configs";
|
|
7
|
-
import {KeypadButton} from "../keypad-
|
|
7
|
+
import {KeypadButton} from "../keypad-button";
|
|
8
8
|
|
|
9
9
|
describe("<KeypadButton />", () => {
|
|
10
10
|
it("uses the aria label from the key config", () => {
|
|
11
11
|
// Arrange
|
|
12
12
|
render(
|
|
13
13
|
<KeypadButton
|
|
14
|
-
onClickKey={(
|
|
14
|
+
onClickKey={() => {}}
|
|
15
15
|
keyConfig={Keys.LEFT_PAREN}
|
|
16
|
+
coord={[0, 0]}
|
|
16
17
|
/>,
|
|
17
18
|
);
|
|
18
19
|
|
|
@@ -29,6 +30,7 @@ describe("<KeypadButton />", () => {
|
|
|
29
30
|
<KeypadButton
|
|
30
31
|
onClickKey={mockClickKeyCallback}
|
|
31
32
|
keyConfig={Keys.LEFT_PAREN}
|
|
33
|
+
coord={[0, 0]}
|
|
32
34
|
/>,
|
|
33
35
|
);
|
|
34
36
|
|
|
@@ -8,35 +8,27 @@ import {ClickKeyCallback} from "../../types";
|
|
|
8
8
|
import Tabbar from "../tabbar/tabbar";
|
|
9
9
|
import {TabbarItemType} from "../tabbar/types";
|
|
10
10
|
|
|
11
|
-
import ExtrasPage from "./extras-page";
|
|
12
|
-
import GeometryPage from "./geometry-page";
|
|
13
|
-
import NumbersPage from "./numbers-page";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {OperatorsButtonSets} from "./operators-page/types";
|
|
11
|
+
import ExtrasPage from "./keypad-pages/extras-page";
|
|
12
|
+
import GeometryPage from "./keypad-pages/geometry-page";
|
|
13
|
+
import NumbersPage from "./keypad-pages/numbers-page";
|
|
14
|
+
import OperatorsPage from "./keypad-pages/operators-page";
|
|
15
|
+
import SharedKeys from "./shared-keys";
|
|
17
16
|
|
|
18
17
|
export type Props = {
|
|
19
18
|
onClickKey: ClickKeyCallback;
|
|
20
19
|
trigonometry?: boolean;
|
|
21
20
|
extraKeys: ReadonlyArray<Key>;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
type DefaultProps = {
|
|
30
|
-
extraKeys: Props["extraKeys"];
|
|
21
|
+
multiplicationDot?: boolean;
|
|
22
|
+
divisionKey?: boolean;
|
|
23
|
+
preAlgebra?: boolean;
|
|
24
|
+
logarithms?: boolean;
|
|
25
|
+
basicRelations?: boolean;
|
|
26
|
+
advancedRelations?: boolean;
|
|
31
27
|
};
|
|
32
28
|
|
|
33
29
|
function allPages(props: Props): ReadonlyArray<TabbarItemType> {
|
|
34
30
|
const pages: Array<TabbarItemType> = ["Numbers"];
|
|
35
31
|
|
|
36
|
-
if (props.extraKeys?.length) {
|
|
37
|
-
pages.push("Extras");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
32
|
if (
|
|
41
33
|
// OperatorsButtonSets
|
|
42
34
|
props.preAlgebra ||
|
|
@@ -51,48 +43,80 @@ function allPages(props: Props): ReadonlyArray<TabbarItemType> {
|
|
|
51
43
|
pages.push("Geometry");
|
|
52
44
|
}
|
|
53
45
|
|
|
46
|
+
if (props.extraKeys?.length) {
|
|
47
|
+
pages.push("Extras");
|
|
48
|
+
}
|
|
49
|
+
|
|
54
50
|
return pages;
|
|
55
51
|
}
|
|
56
52
|
|
|
57
|
-
export default
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
{
|
|
53
|
+
export default function Keypad(props: Props) {
|
|
54
|
+
const [selectedPage, setSelectedPage] =
|
|
55
|
+
React.useState<TabbarItemType>("Numbers");
|
|
56
|
+
|
|
57
|
+
const availablePages = allPages(props);
|
|
58
|
+
|
|
59
|
+
const {
|
|
60
|
+
onClickKey,
|
|
61
|
+
extraKeys = [],
|
|
62
|
+
multiplicationDot,
|
|
63
|
+
divisionKey,
|
|
64
|
+
preAlgebra,
|
|
65
|
+
logarithms,
|
|
66
|
+
basicRelations,
|
|
67
|
+
advancedRelations,
|
|
68
|
+
} = props;
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<View>
|
|
72
|
+
<Tabbar
|
|
73
|
+
items={availablePages}
|
|
74
|
+
selectedItem={selectedPage}
|
|
75
|
+
onSelectItem={(tabbarItem: TabbarItemType) => {
|
|
76
|
+
setSelectedPage(tabbarItem);
|
|
77
|
+
}}
|
|
78
|
+
style={styles.tabbar}
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
<View style={styles.grid}>
|
|
82
|
+
{selectedPage === "Numbers" && (
|
|
83
|
+
<NumbersPage onClickKey={onClickKey} />
|
|
84
|
+
)}
|
|
85
|
+
{selectedPage === "Extras" && (
|
|
86
|
+
<ExtrasPage onClickKey={onClickKey} extraKeys={extraKeys} />
|
|
87
|
+
)}
|
|
83
88
|
{selectedPage === "Operators" && (
|
|
84
|
-
<OperatorsPage
|
|
89
|
+
<OperatorsPage
|
|
90
|
+
onClickKey={onClickKey}
|
|
91
|
+
preAlgebra={preAlgebra}
|
|
92
|
+
logarithms={logarithms}
|
|
93
|
+
basicRelations={basicRelations}
|
|
94
|
+
advancedRelations={advancedRelations}
|
|
95
|
+
/>
|
|
85
96
|
)}
|
|
86
97
|
{selectedPage === "Geometry" && (
|
|
87
|
-
<GeometryPage {
|
|
98
|
+
<GeometryPage onClickKey={onClickKey} />
|
|
88
99
|
)}
|
|
100
|
+
<SharedKeys
|
|
101
|
+
onClickKey={onClickKey}
|
|
102
|
+
multiplicationDot={multiplicationDot}
|
|
103
|
+
divisionKey={divisionKey}
|
|
104
|
+
/>
|
|
89
105
|
</View>
|
|
90
|
-
|
|
91
|
-
|
|
106
|
+
</View>
|
|
107
|
+
);
|
|
92
108
|
}
|
|
93
109
|
|
|
94
110
|
const styles = StyleSheet.create({
|
|
95
111
|
tabbar: {
|
|
96
112
|
background: Color.white,
|
|
97
113
|
},
|
|
114
|
+
grid: {
|
|
115
|
+
display: "grid",
|
|
116
|
+
gridTemplateColumns: "repeat(6, 1fr)",
|
|
117
|
+
gridTemplateRows: "repeat(4, 1fr)",
|
|
118
|
+
backgroundColor: "#DBDCDD",
|
|
119
|
+
maxHeight: 200,
|
|
120
|
+
maxWidth: 300,
|
|
121
|
+
},
|
|
98
122
|
});
|
|
@@ -4,7 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
|
|
5
5
|
import KeyConfigs from "../../data/key-configs";
|
|
6
6
|
|
|
7
|
-
import {KeypadButton, KeypadButtonProps} from "./keypad-
|
|
7
|
+
import {KeypadButton, KeypadButtonProps} from "./keypad-button";
|
|
8
8
|
|
|
9
9
|
export default {
|
|
10
10
|
title: "Keypad Button",
|
|
@@ -70,6 +70,7 @@ export const AllButtons: ComponentStory<typeof KeypadButton> = ({
|
|
|
70
70
|
<KeypadButton
|
|
71
71
|
keyConfig={KeyConfigs[key]}
|
|
72
72
|
onClickKey={action("pressed")}
|
|
73
|
+
coord={[0, 0]}
|
|
73
74
|
/>
|
|
74
75
|
</div>
|
|
75
76
|
))}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import Clickable from "@khanacademy/wonder-blocks-clickable";
|
|
2
|
+
import Color from "@khanacademy/wonder-blocks-color";
|
|
3
|
+
import {View} from "@khanacademy/wonder-blocks-core";
|
|
4
|
+
import {StyleSheet} from "aphrodite";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
|
|
7
|
+
import {KeyConfig, ClickKeyCallback} from "../../types";
|
|
8
|
+
|
|
9
|
+
import ButtonAsset from "./button-assets";
|
|
10
|
+
|
|
11
|
+
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
12
|
+
|
|
13
|
+
export type KeypadButtonProps = {
|
|
14
|
+
// 0 indexed [x, y] position in keypad CSS grid
|
|
15
|
+
coord: readonly [number, number];
|
|
16
|
+
keyConfig: KeyConfig;
|
|
17
|
+
onClickKey: ClickKeyCallback;
|
|
18
|
+
// Apply action button styles
|
|
19
|
+
action?: boolean;
|
|
20
|
+
// Apply secondary button styles
|
|
21
|
+
secondary?: boolean;
|
|
22
|
+
style?: StyleType;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const KeypadButton = ({
|
|
26
|
+
coord,
|
|
27
|
+
keyConfig,
|
|
28
|
+
onClickKey,
|
|
29
|
+
style,
|
|
30
|
+
secondary,
|
|
31
|
+
action,
|
|
32
|
+
}: KeypadButtonProps): React.ReactElement => {
|
|
33
|
+
const tintColor = secondary ? "#F6F6F7" : action ? "#DBDCDD" : undefined;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<View
|
|
37
|
+
style={{
|
|
38
|
+
gridColumn: coord[0] + 1,
|
|
39
|
+
gridRow: coord[1] + 1,
|
|
40
|
+
...style,
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<Clickable
|
|
44
|
+
onClick={() => onClickKey(keyConfig.id)}
|
|
45
|
+
style={styles.clickable}
|
|
46
|
+
aria-label={keyConfig.ariaLabel}
|
|
47
|
+
>
|
|
48
|
+
{({hovered, focused, pressed}) => {
|
|
49
|
+
return (
|
|
50
|
+
<View
|
|
51
|
+
style={[
|
|
52
|
+
styles.outerBoxBase,
|
|
53
|
+
hovered && styles.outerBoxHover,
|
|
54
|
+
pressed && styles.outerBoxPressed,
|
|
55
|
+
]}
|
|
56
|
+
>
|
|
57
|
+
<View
|
|
58
|
+
style={[
|
|
59
|
+
styles.base,
|
|
60
|
+
tintColor != null
|
|
61
|
+
? {background: tintColor}
|
|
62
|
+
: undefined,
|
|
63
|
+
hovered && styles.hovered,
|
|
64
|
+
focused && styles.focused,
|
|
65
|
+
pressed && styles.pressed,
|
|
66
|
+
]}
|
|
67
|
+
>
|
|
68
|
+
<ButtonAsset id={keyConfig.id} />
|
|
69
|
+
</View>
|
|
70
|
+
</View>
|
|
71
|
+
);
|
|
72
|
+
}}
|
|
73
|
+
</Clickable>
|
|
74
|
+
</View>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const styles = StyleSheet.create({
|
|
79
|
+
base: {
|
|
80
|
+
display: "flex",
|
|
81
|
+
justifyContent: "center",
|
|
82
|
+
alignItems: "center",
|
|
83
|
+
boxShadow: "0px 1px 0px rgba(33, 36, 44, 0.32)",
|
|
84
|
+
boxSizing: "border-box",
|
|
85
|
+
background: Color.white,
|
|
86
|
+
borderRadius: 4,
|
|
87
|
+
border: `1px solid transparent`,
|
|
88
|
+
flex: 1,
|
|
89
|
+
minHeight: 42,
|
|
90
|
+
minWidth: 42,
|
|
91
|
+
padding: 1,
|
|
92
|
+
},
|
|
93
|
+
hovered: {
|
|
94
|
+
border: `1px solid ${Color.blue}`,
|
|
95
|
+
padding: 1,
|
|
96
|
+
boxShadow: "none",
|
|
97
|
+
},
|
|
98
|
+
focused: {
|
|
99
|
+
border: `2px solid ${Color.blue}`,
|
|
100
|
+
padding: 0,
|
|
101
|
+
boxShadow: "none",
|
|
102
|
+
},
|
|
103
|
+
pressed: {
|
|
104
|
+
border: "2px solid #1B50B3",
|
|
105
|
+
padding: 0,
|
|
106
|
+
background: `linear-gradient(0deg, rgba(24, 101, 242, 0.32), rgba(24, 101, 242, 0.32)), ${Color.white}`,
|
|
107
|
+
boxShadow: "none",
|
|
108
|
+
},
|
|
109
|
+
outerBoxBase: {
|
|
110
|
+
padding: 1,
|
|
111
|
+
height: "100%",
|
|
112
|
+
width: "100%",
|
|
113
|
+
boxSizing: "border-box",
|
|
114
|
+
borderRadius: 7,
|
|
115
|
+
border: "2px solid transparent",
|
|
116
|
+
},
|
|
117
|
+
outerBoxHover: {
|
|
118
|
+
border: `2px solid ${Color.blue}`,
|
|
119
|
+
},
|
|
120
|
+
outerBoxPressed: {
|
|
121
|
+
border: "2px solid #1B50B3",
|
|
122
|
+
},
|
|
123
|
+
clickable: {
|
|
124
|
+
width: "100%",
|
|
125
|
+
height: "100%",
|
|
126
|
+
boxSizing: "border-box",
|
|
127
|
+
},
|
|
128
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Color from "@khanacademy/wonder-blocks-color";
|
|
2
|
-
import {Popover} from "@khanacademy/wonder-blocks-popover";
|
|
2
|
+
import {Popover, PopoverContentCore} from "@khanacademy/wonder-blocks-popover";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
|
|
5
5
|
import Key from "../../data/keys";
|
|
@@ -44,7 +44,12 @@ export function V2KeypadWithMathquill() {
|
|
|
44
44
|
<div style={{maxWidth: "400px", margin: "2em"}}>
|
|
45
45
|
<Popover
|
|
46
46
|
content={
|
|
47
|
-
<
|
|
47
|
+
<PopoverContentCore
|
|
48
|
+
style={{
|
|
49
|
+
padding: 10,
|
|
50
|
+
maxWidth: "initial",
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
48
53
|
<Keypad
|
|
49
54
|
extraKeys={["a", "b", "c"]}
|
|
50
55
|
onClickKey={handleClickKey}
|
|
@@ -56,9 +61,10 @@ export function V2KeypadWithMathquill() {
|
|
|
56
61
|
preAlgebra
|
|
57
62
|
trigonometry
|
|
58
63
|
/>
|
|
59
|
-
</
|
|
64
|
+
</PopoverContentCore>
|
|
60
65
|
}
|
|
61
66
|
dismissEnabled
|
|
67
|
+
opened
|
|
62
68
|
>
|
|
63
69
|
<div
|
|
64
70
|
style={{
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import Keys from "../../../data/key-configs";
|
|
4
|
+
import Key from "../../../data/keys";
|
|
5
|
+
import {ClickKeyCallback} from "../../../types";
|
|
6
|
+
import {KeypadButton} from "../keypad-button";
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
extraKeys: ReadonlyArray<Key>;
|
|
10
|
+
onClickKey: ClickKeyCallback;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const columns = 4;
|
|
14
|
+
|
|
15
|
+
export default function ExtrasPage(props: Props) {
|
|
16
|
+
const {extraKeys, onClickKey} = props;
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
{extraKeys.map((key, i) => {
|
|
20
|
+
// Map 1D array to Cartesian coordinates
|
|
21
|
+
const coordX = i % columns;
|
|
22
|
+
const coordY = i / columns;
|
|
23
|
+
return (
|
|
24
|
+
<KeypadButton
|
|
25
|
+
key={key}
|
|
26
|
+
keyConfig={Keys[key]}
|
|
27
|
+
onClickKey={onClickKey}
|
|
28
|
+
coord={[coordX, coordY]}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
})}
|
|
32
|
+
</>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import Keys from "../../../data/key-configs";
|
|
4
|
+
import {ClickKeyCallback} from "../../../types";
|
|
5
|
+
import {KeypadButton} from "../keypad-button";
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
onClickKey: ClickKeyCallback;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default function GeometryPage(props: Props) {
|
|
12
|
+
const {onClickKey} = props;
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
{/* Row 1 */}
|
|
16
|
+
<KeypadButton
|
|
17
|
+
keyConfig={Keys.SIN}
|
|
18
|
+
onClickKey={onClickKey}
|
|
19
|
+
coord={[0, 0]}
|
|
20
|
+
/>
|
|
21
|
+
<KeypadButton
|
|
22
|
+
keyConfig={Keys.COS}
|
|
23
|
+
onClickKey={onClickKey}
|
|
24
|
+
coord={[1, 0]}
|
|
25
|
+
/>
|
|
26
|
+
<KeypadButton
|
|
27
|
+
keyConfig={Keys.TAN}
|
|
28
|
+
onClickKey={onClickKey}
|
|
29
|
+
coord={[2, 0]}
|
|
30
|
+
/>
|
|
31
|
+
</>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import Keys from "../../../data/key-configs";
|
|
4
|
+
import {ClickKeyCallback} from "../../../types";
|
|
5
|
+
import {KeypadButton} from "../keypad-button";
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
onClickKey: ClickKeyCallback;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default function NumbersPage(props: Props) {
|
|
12
|
+
const {onClickKey} = props;
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
{/* Row 1 */}
|
|
16
|
+
<KeypadButton
|
|
17
|
+
keyConfig={Keys.NUM_7}
|
|
18
|
+
onClickKey={onClickKey}
|
|
19
|
+
coord={[0, 0]}
|
|
20
|
+
/>
|
|
21
|
+
<KeypadButton
|
|
22
|
+
keyConfig={Keys.NUM_8}
|
|
23
|
+
onClickKey={onClickKey}
|
|
24
|
+
coord={[1, 0]}
|
|
25
|
+
/>
|
|
26
|
+
<KeypadButton
|
|
27
|
+
keyConfig={Keys.NUM_9}
|
|
28
|
+
onClickKey={onClickKey}
|
|
29
|
+
coord={[2, 0]}
|
|
30
|
+
/>
|
|
31
|
+
|
|
32
|
+
{/* Row 2 */}
|
|
33
|
+
<KeypadButton
|
|
34
|
+
keyConfig={Keys.NUM_4}
|
|
35
|
+
onClickKey={onClickKey}
|
|
36
|
+
coord={[0, 1]}
|
|
37
|
+
/>
|
|
38
|
+
<KeypadButton
|
|
39
|
+
keyConfig={Keys.NUM_5}
|
|
40
|
+
onClickKey={onClickKey}
|
|
41
|
+
coord={[1, 1]}
|
|
42
|
+
/>
|
|
43
|
+
<KeypadButton
|
|
44
|
+
keyConfig={Keys.NUM_6}
|
|
45
|
+
onClickKey={onClickKey}
|
|
46
|
+
coord={[2, 1]}
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
{/* Row 3 */}
|
|
50
|
+
<KeypadButton
|
|
51
|
+
keyConfig={Keys.NUM_1}
|
|
52
|
+
onClickKey={onClickKey}
|
|
53
|
+
coord={[0, 2]}
|
|
54
|
+
/>
|
|
55
|
+
<KeypadButton
|
|
56
|
+
keyConfig={Keys.NUM_2}
|
|
57
|
+
onClickKey={onClickKey}
|
|
58
|
+
coord={[1, 2]}
|
|
59
|
+
/>
|
|
60
|
+
<KeypadButton
|
|
61
|
+
keyConfig={Keys.NUM_3}
|
|
62
|
+
onClickKey={onClickKey}
|
|
63
|
+
coord={[2, 2]}
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
{/* Row 4 */}
|
|
67
|
+
<KeypadButton
|
|
68
|
+
keyConfig={Keys.NUM_0}
|
|
69
|
+
onClickKey={onClickKey}
|
|
70
|
+
coord={[0, 3]}
|
|
71
|
+
/>
|
|
72
|
+
<KeypadButton
|
|
73
|
+
keyConfig={Keys.DECIMAL}
|
|
74
|
+
onClickKey={onClickKey}
|
|
75
|
+
coord={[1, 3]}
|
|
76
|
+
/>
|
|
77
|
+
<KeypadButton
|
|
78
|
+
keyConfig={Keys.NEGATIVE}
|
|
79
|
+
onClickKey={onClickKey}
|
|
80
|
+
coord={[2, 3]}
|
|
81
|
+
/>
|
|
82
|
+
</>
|
|
83
|
+
);
|
|
84
|
+
}
|