@khanacademy/math-input 0.3.2 → 0.5.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 +8 -0
- package/README.md +1 -1
- package/{build/math-input.css → dist/es/index.css} +0 -150
- package/dist/es/index.js +2 -0
- package/dist/es/index.js.map +1 -0
- package/dist/index.css +586 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.flow +2 -0
- package/dist/index.js.map +1 -0
- package/dist/strings.js +71 -0
- package/index.html +20 -0
- package/less/echo.less +56 -0
- package/less/main.less +5 -0
- package/less/overrides.less +129 -0
- package/less/popover.less +22 -0
- package/less/tabbar.less +6 -0
- package/package.json +38 -70
- package/src/actions/index.js +57 -0
- package/src/components/__tests__/gesture-state-machine_test.js +437 -0
- package/src/components/__tests__/node-manager_test.js +89 -0
- package/src/components/__tests__/two-page-keypad_test.js +42 -0
- package/src/components/app.js +73 -0
- package/src/components/common-style.js +47 -0
- package/src/components/compute-layout-parameters.js +157 -0
- package/src/components/corner-decal.js +56 -0
- package/src/components/echo-manager.js +160 -0
- package/src/components/empty-keypad-button.js +49 -0
- package/src/components/expression-keypad.js +323 -0
- package/src/components/fraction-keypad.js +176 -0
- package/src/components/gesture-manager.js +226 -0
- package/src/components/gesture-state-machine.js +283 -0
- package/src/components/icon.js +74 -0
- package/src/components/iconography/arrow.js +22 -0
- package/src/components/iconography/backspace.js +29 -0
- package/src/components/iconography/cdot.js +29 -0
- package/src/components/iconography/cos.js +30 -0
- package/src/components/iconography/cube-root.js +36 -0
- package/src/components/iconography/dismiss.js +25 -0
- package/src/components/iconography/divide.js +34 -0
- package/src/components/iconography/down.js +16 -0
- package/src/components/iconography/equal.js +33 -0
- package/src/components/iconography/exp-2.js +29 -0
- package/src/components/iconography/exp-3.js +29 -0
- package/src/components/iconography/exp.js +29 -0
- package/src/components/iconography/frac.js +44 -0
- package/src/components/iconography/geq.js +33 -0
- package/src/components/iconography/gt.js +33 -0
- package/src/components/iconography/index.js +45 -0
- package/src/components/iconography/jump-into-numerator.js +41 -0
- package/src/components/iconography/jump-out-base.js +30 -0
- package/src/components/iconography/jump-out-denominator.js +41 -0
- package/src/components/iconography/jump-out-exponent.js +30 -0
- package/src/components/iconography/jump-out-numerator.js +41 -0
- package/src/components/iconography/jump-out-parentheses.js +33 -0
- package/src/components/iconography/left-paren.js +33 -0
- package/src/components/iconography/left.js +16 -0
- package/src/components/iconography/leq.js +33 -0
- package/src/components/iconography/ln.js +29 -0
- package/src/components/iconography/log-n.js +29 -0
- package/src/components/iconography/log.js +29 -0
- package/src/components/iconography/lt.js +33 -0
- package/src/components/iconography/minus.js +32 -0
- package/src/components/iconography/neq.js +33 -0
- package/src/components/iconography/parens.js +33 -0
- package/src/components/iconography/percent.js +49 -0
- package/src/components/iconography/period.js +26 -0
- package/src/components/iconography/plus.js +32 -0
- package/src/components/iconography/radical.js +36 -0
- package/src/components/iconography/right-paren.js +33 -0
- package/src/components/iconography/right.js +16 -0
- package/src/components/iconography/sin.js +30 -0
- package/src/components/iconography/sqrt.js +32 -0
- package/src/components/iconography/tan.js +30 -0
- package/src/components/iconography/times.js +33 -0
- package/src/components/iconography/up.js +16 -0
- package/src/components/input/__tests__/context-tracking_test.js +177 -0
- package/src/components/input/__tests__/math-wrapper.jsx +33 -0
- package/src/components/input/__tests__/mathquill_test.js +747 -0
- package/src/components/input/cursor-contexts.js +29 -0
- package/src/components/input/cursor-handle.js +137 -0
- package/src/components/input/drag-listener.js +75 -0
- package/src/components/input/math-input.js +924 -0
- package/src/components/input/math-wrapper.js +959 -0
- package/src/components/input/scroll-into-view.js +72 -0
- package/src/components/keypad/button-assets.js +492 -0
- package/src/components/keypad/button.js +106 -0
- package/src/components/keypad/button.stories.js +27 -0
- package/src/components/keypad/index.js +64 -0
- package/src/components/keypad/keypad-page-items.js +106 -0
- package/src/components/keypad/keypad-pages.stories.js +32 -0
- package/src/components/keypad/keypad.stories.js +35 -0
- package/src/components/keypad/numeric-input-page.js +100 -0
- package/src/components/keypad/pre-algebra-page.js +98 -0
- package/src/components/keypad/trigonometry-page.js +90 -0
- package/src/components/keypad-button.js +366 -0
- package/src/components/keypad-container.js +303 -0
- package/src/components/keypad.js +154 -0
- package/src/components/many-keypad-button.js +44 -0
- package/src/components/math-icon.js +65 -0
- package/src/components/multi-symbol-grid.js +182 -0
- package/src/components/multi-symbol-popover.js +59 -0
- package/src/components/navigation-pad.js +139 -0
- package/src/components/node-manager.js +129 -0
- package/src/components/popover-manager.js +76 -0
- package/src/components/popover-state-machine.js +173 -0
- package/src/components/prop-types.js +82 -0
- package/src/components/provided-keypad.js +99 -0
- package/src/components/styles.js +38 -0
- package/src/components/svg-icon.js +25 -0
- package/src/components/tabbar/__tests__/tabbar_test.js +65 -0
- package/src/components/tabbar/icons.js +69 -0
- package/src/components/tabbar/item.js +138 -0
- package/src/components/tabbar/tabbar.js +61 -0
- package/src/components/tabbar/tabbar.stories.js +60 -0
- package/src/components/tabbar/types.js +3 -0
- package/src/components/text-icon.js +52 -0
- package/src/components/touchable-keypad-button.js +146 -0
- package/src/components/two-page-keypad.js +99 -0
- package/src/components/velocity-tracker.js +76 -0
- package/src/components/z-indexes.js +9 -0
- package/src/consts.js +74 -0
- package/src/data/key-configs.js +349 -0
- package/src/data/keys.js +72 -0
- package/src/demo.js +8 -0
- package/src/fake-react-native-web/index.js +12 -0
- package/src/fake-react-native-web/text.js +56 -0
- package/src/fake-react-native-web/view.js +91 -0
- package/src/index.js +13 -0
- package/src/native-app.js +84 -0
- package/src/store/index.js +505 -0
- package/src/utils.js +18 -0
- package/tools/svg-to-react/convert.py +111 -0
- package/tools/svg-to-react/icons/math-keypad-icon-0.svg +32 -0
- package/tools/svg-to-react/icons/math-keypad-icon-1.svg +32 -0
- package/tools/svg-to-react/icons/math-keypad-icon-2.svg +32 -0
- package/tools/svg-to-react/icons/math-keypad-icon-3.svg +32 -0
- package/tools/svg-to-react/icons/math-keypad-icon-4.svg +32 -0
- package/tools/svg-to-react/icons/math-keypad-icon-5.svg +32 -0
- package/tools/svg-to-react/icons/math-keypad-icon-6.svg +32 -0
- package/tools/svg-to-react/icons/math-keypad-icon-7.svg +32 -0
- package/tools/svg-to-react/icons/math-keypad-icon-8.svg +32 -0
- package/tools/svg-to-react/icons/math-keypad-icon-9.svg +32 -0
- package/tools/svg-to-react/icons/math-keypad-icon-addition.svg +34 -0
- package/tools/svg-to-react/icons/math-keypad-icon-cos.svg +38 -0
- package/tools/svg-to-react/icons/math-keypad-icon-delete.svg +36 -0
- package/tools/svg-to-react/icons/math-keypad-icon-dismiss.svg +36 -0
- package/tools/svg-to-react/icons/math-keypad-icon-division.svg +36 -0
- package/tools/svg-to-react/icons/math-keypad-icon-equals-not.svg +50 -0
- package/tools/svg-to-react/icons/math-keypad-icon-equals.svg +48 -0
- package/tools/svg-to-react/icons/math-keypad-icon-exponent-2.svg +38 -0
- package/tools/svg-to-react/icons/math-keypad-icon-exponent-3.svg +38 -0
- package/tools/svg-to-react/icons/math-keypad-icon-exponent.svg +38 -0
- package/tools/svg-to-react/icons/math-keypad-icon-fraction.svg +42 -0
- package/tools/svg-to-react/icons/math-keypad-icon-greater-than.svg +46 -0
- package/tools/svg-to-react/icons/math-keypad-icon-jump-out-base.svg +44 -0
- package/tools/svg-to-react/icons/math-keypad-icon-jump-out-denominator.svg +48 -0
- package/tools/svg-to-react/icons/math-keypad-icon-jump-out-exponent.svg +44 -0
- package/tools/svg-to-react/icons/math-keypad-icon-jump-out-parentheses.svg +44 -0
- package/tools/svg-to-react/icons/math-keypad-icon-less-than.svg +46 -0
- package/tools/svg-to-react/icons/math-keypad-icon-log-10.svg +36 -0
- package/tools/svg-to-react/icons/math-keypad-icon-log-e.svg +36 -0
- package/tools/svg-to-react/icons/math-keypad-icon-log.svg +38 -0
- package/tools/svg-to-react/icons/math-keypad-icon-multiplication-cross.svg +40 -0
- package/tools/svg-to-react/icons/math-keypad-icon-multiplication-dot.svg +38 -0
- package/tools/svg-to-react/icons/math-keypad-icon-percent.svg +42 -0
- package/tools/svg-to-react/icons/math-keypad-icon-radical-2.svg +36 -0
- package/tools/svg-to-react/icons/math-keypad-icon-radical-3.svg +38 -0
- package/tools/svg-to-react/icons/math-keypad-icon-radical.svg +38 -0
- package/tools/svg-to-react/icons/math-keypad-icon-radix-character.svg +32 -0
- package/tools/svg-to-react/icons/math-keypad-icon-sin.svg +38 -0
- package/tools/svg-to-react/icons/math-keypad-icon-subtraction.svg +32 -0
- package/tools/svg-to-react/icons/math-keypad-icon-tan.svg +38 -0
- package/tools/svg-to-react/symbol_map.py +41 -0
- package/LICENSE.txt +0 -21
- package/build/math-input.js +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import Clickable from "@khanacademy/wonder-blocks-clickable";
|
|
3
|
+
import Color from "@khanacademy/wonder-blocks-color";
|
|
4
|
+
import {View} from "@khanacademy/wonder-blocks-core";
|
|
5
|
+
import {StyleSheet} from "aphrodite";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
|
|
8
|
+
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
9
|
+
import type {Node} from "React";
|
|
10
|
+
|
|
11
|
+
const styles = StyleSheet.create({
|
|
12
|
+
base: {
|
|
13
|
+
display: "flex",
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
boxShadow: "0px 1px 0px rgba(33, 36, 44, 0.32)",
|
|
17
|
+
boxSizing: "border-box",
|
|
18
|
+
background: Color.white,
|
|
19
|
+
borderRadius: 4,
|
|
20
|
+
border: `1px solid transparent`,
|
|
21
|
+
flex: 1,
|
|
22
|
+
minHeight: 42,
|
|
23
|
+
minWidth: 42,
|
|
24
|
+
padding: 1,
|
|
25
|
+
},
|
|
26
|
+
hovered: {
|
|
27
|
+
border: `1px solid ${Color.blue}`,
|
|
28
|
+
padding: 1,
|
|
29
|
+
boxShadow: "none",
|
|
30
|
+
},
|
|
31
|
+
focused: {
|
|
32
|
+
border: `2px solid ${Color.blue}`,
|
|
33
|
+
padding: 0,
|
|
34
|
+
boxShadow: "none",
|
|
35
|
+
},
|
|
36
|
+
pressed: {
|
|
37
|
+
border: "2px solid #1B50B3",
|
|
38
|
+
padding: 0,
|
|
39
|
+
background: `linear-gradient(0deg, rgba(24, 101, 242, 0.32), rgba(24, 101, 242, 0.32)), ${Color.white}`,
|
|
40
|
+
boxShadow: "none",
|
|
41
|
+
},
|
|
42
|
+
outerBoxBase: {
|
|
43
|
+
padding: 1,
|
|
44
|
+
height: "100%",
|
|
45
|
+
width: "100%",
|
|
46
|
+
boxSizing: "border-box",
|
|
47
|
+
borderRadius: 7,
|
|
48
|
+
border: "2px solid transparent",
|
|
49
|
+
},
|
|
50
|
+
outerBoxHover: {
|
|
51
|
+
border: `2px solid ${Color.blue}`,
|
|
52
|
+
},
|
|
53
|
+
outerBoxPressed: {
|
|
54
|
+
border: "2px solid #1B50B3",
|
|
55
|
+
},
|
|
56
|
+
clickable: {
|
|
57
|
+
width: "100%",
|
|
58
|
+
height: "100%",
|
|
59
|
+
boxSizing: "border-box",
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
type Props = {|
|
|
64
|
+
onPress: () => void,
|
|
65
|
+
children: Node,
|
|
66
|
+
style?: StyleType,
|
|
67
|
+
tintColor?: string,
|
|
68
|
+
|};
|
|
69
|
+
|
|
70
|
+
type State = {};
|
|
71
|
+
export default class Button extends React.Component<Props, State> {
|
|
72
|
+
render(): React.Node {
|
|
73
|
+
const {onPress, children, style, tintColor} = this.props;
|
|
74
|
+
return (
|
|
75
|
+
<View style={style}>
|
|
76
|
+
<Clickable onClick={onPress} style={styles.clickable}>
|
|
77
|
+
{({hovered, focused, pressed}) => {
|
|
78
|
+
return (
|
|
79
|
+
<View
|
|
80
|
+
style={[
|
|
81
|
+
styles.outerBoxBase,
|
|
82
|
+
hovered && styles.outerBoxHover,
|
|
83
|
+
pressed && styles.outerBoxPressed,
|
|
84
|
+
]}
|
|
85
|
+
>
|
|
86
|
+
<View
|
|
87
|
+
style={[
|
|
88
|
+
styles.base,
|
|
89
|
+
tintColor != null
|
|
90
|
+
? {background: tintColor}
|
|
91
|
+
: undefined,
|
|
92
|
+
hovered && styles.hovered,
|
|
93
|
+
focused && styles.focused,
|
|
94
|
+
pressed && styles.pressed,
|
|
95
|
+
]}
|
|
96
|
+
>
|
|
97
|
+
{children}
|
|
98
|
+
</View>
|
|
99
|
+
</View>
|
|
100
|
+
);
|
|
101
|
+
}}
|
|
102
|
+
</Clickable>
|
|
103
|
+
</View>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {action} from "@storybook/addon-actions";
|
|
2
|
+
import {withKnobs} from "@storybook/addon-knobs";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import KeypadButton from "./button.js";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "Keypad Button",
|
|
9
|
+
decorators: [withKnobs],
|
|
10
|
+
parameters: {
|
|
11
|
+
backgrounds: [
|
|
12
|
+
{name: "dark background", value: "#DBDCDD", default: true},
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const Button = () => (
|
|
18
|
+
<div
|
|
19
|
+
style={{
|
|
20
|
+
width: 58,
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
<KeypadButton onPress={action("pressed")}>
|
|
24
|
+
<p>1</p>
|
|
25
|
+
</KeypadButton>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//@flow
|
|
2
|
+
import {View} from "@khanacademy/wonder-blocks-core";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import Tabbar from "../tabbar/tabbar.js";
|
|
6
|
+
|
|
7
|
+
import NumericInputPage from "./numeric-input-page.js";
|
|
8
|
+
import PreAlgebraPage from "./pre-algebra-page.js";
|
|
9
|
+
import TrigonometryPage from "./trigonometry-page.js";
|
|
10
|
+
|
|
11
|
+
import type {TabbarItemType} from "../tabbar/types.js";
|
|
12
|
+
|
|
13
|
+
type Props = {|
|
|
14
|
+
onClickKey: (keyConfig: string) => void,
|
|
15
|
+
preAlgebra: boolean,
|
|
16
|
+
trigonometry: boolean,
|
|
17
|
+
|};
|
|
18
|
+
type State = {
|
|
19
|
+
selectedPage: TabbarItemType,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function allPages(props: Props): Array<TabbarItemType> {
|
|
23
|
+
const pages: Array<TabbarItemType> = ["Numbers"];
|
|
24
|
+
|
|
25
|
+
if (props.preAlgebra) {
|
|
26
|
+
pages.push("Operators");
|
|
27
|
+
}
|
|
28
|
+
if (props.trigonometry) {
|
|
29
|
+
pages.push("Geometry");
|
|
30
|
+
}
|
|
31
|
+
return pages;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default class PreAlgebraKeypad extends React.Component<Props, State> {
|
|
35
|
+
state: State = {
|
|
36
|
+
selectedPage: "Numbers",
|
|
37
|
+
};
|
|
38
|
+
render(): React.Node {
|
|
39
|
+
const {selectedPage} = this.state;
|
|
40
|
+
const {onClickKey} = this.props;
|
|
41
|
+
|
|
42
|
+
const availablePages = allPages(this.props);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<View>
|
|
46
|
+
<Tabbar
|
|
47
|
+
items={availablePages}
|
|
48
|
+
onSelect={(tabbarItem: TabbarItemType) => {
|
|
49
|
+
this.setState({selectedPage: tabbarItem});
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
{selectedPage === "Numbers" && (
|
|
53
|
+
<NumericInputPage onClickKey={onClickKey} />
|
|
54
|
+
)}
|
|
55
|
+
{selectedPage === "Operators" && (
|
|
56
|
+
<PreAlgebraPage onClickKey={onClickKey} />
|
|
57
|
+
)}
|
|
58
|
+
{selectedPage === "Geometry" && (
|
|
59
|
+
<TrigonometryPage onClickKey={onClickKey} />
|
|
60
|
+
)}
|
|
61
|
+
</View>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import {View} from "@khanacademy/wonder-blocks-core";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import ButtonAsset from "./button-assets.js";
|
|
6
|
+
import Button from "./button.js";
|
|
7
|
+
|
|
8
|
+
import type {KeyConfig} from "../../data/key-configs.js";
|
|
9
|
+
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
10
|
+
import type {Node} from "React";
|
|
11
|
+
|
|
12
|
+
export const KeypadPageContainer = ({
|
|
13
|
+
children,
|
|
14
|
+
}: {
|
|
15
|
+
children: Node,
|
|
16
|
+
}): React.Node => (
|
|
17
|
+
<View
|
|
18
|
+
style={{
|
|
19
|
+
backgroundColor: "#DBDCDD",
|
|
20
|
+
width: "100%",
|
|
21
|
+
height: 192,
|
|
22
|
+
|
|
23
|
+
display: "grid",
|
|
24
|
+
gridTemplateColumns: "repeat(6, 1fr)",
|
|
25
|
+
gridTemplateRows: "repeat(4, 1fr)",
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
{children}
|
|
29
|
+
</View>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export const KeypadButton = ({
|
|
33
|
+
keyConfig,
|
|
34
|
+
onClickKey,
|
|
35
|
+
tintColor,
|
|
36
|
+
style,
|
|
37
|
+
}: {
|
|
38
|
+
keyConfig: KeyConfig,
|
|
39
|
+
tintColor?: string,
|
|
40
|
+
style?: StyleType,
|
|
41
|
+
onClickKey: (keyConfig: string) => void,
|
|
42
|
+
}): React.Node => (
|
|
43
|
+
<Button
|
|
44
|
+
onPress={() => onClickKey(keyConfig.id)}
|
|
45
|
+
tintColor={tintColor}
|
|
46
|
+
style={style}
|
|
47
|
+
>
|
|
48
|
+
<ButtonAsset id={keyConfig.id} />
|
|
49
|
+
</Button>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
export const SecondaryKeypadButton = ({
|
|
53
|
+
keyConfig,
|
|
54
|
+
onClickKey,
|
|
55
|
+
style,
|
|
56
|
+
}: {
|
|
57
|
+
keyConfig: KeyConfig,
|
|
58
|
+
style?: any,
|
|
59
|
+
onClickKey: (keyConfig: string) => void,
|
|
60
|
+
}): React.Node => (
|
|
61
|
+
<KeypadButton
|
|
62
|
+
keyConfig={keyConfig}
|
|
63
|
+
onClickKey={onClickKey}
|
|
64
|
+
style={style}
|
|
65
|
+
tintColor={"#F6F6F7"}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
export const KeypadActionButton = ({
|
|
70
|
+
keyConfig,
|
|
71
|
+
onClickKey,
|
|
72
|
+
style,
|
|
73
|
+
}: {
|
|
74
|
+
keyConfig: KeyConfig,
|
|
75
|
+
style?: any,
|
|
76
|
+
onClickKey: (keyConfig: string) => void,
|
|
77
|
+
}): React.Node => (
|
|
78
|
+
<KeypadButton
|
|
79
|
+
keyConfig={keyConfig}
|
|
80
|
+
onClickKey={onClickKey}
|
|
81
|
+
style={style}
|
|
82
|
+
tintColor={"#DBDCDD"}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
export const PlaceHolderButton = (): React.Node => (
|
|
87
|
+
<View
|
|
88
|
+
style={{
|
|
89
|
+
height: "100%",
|
|
90
|
+
width: "100%",
|
|
91
|
+
boxSizing: "border-box",
|
|
92
|
+
borderRadius: 7,
|
|
93
|
+
border: "4px solid transparent",
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
<View
|
|
97
|
+
style={{
|
|
98
|
+
background: "rgba(33, 36, 44, 0.04)",
|
|
99
|
+
width: "100%",
|
|
100
|
+
height: "100%",
|
|
101
|
+
borderRadius: 4,
|
|
102
|
+
border: `1px solid transparent`,
|
|
103
|
+
}}
|
|
104
|
+
/>
|
|
105
|
+
</View>
|
|
106
|
+
);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//@flow
|
|
2
|
+
|
|
3
|
+
import {action} from "@storybook/addon-actions";
|
|
4
|
+
import {withKnobs} from "@storybook/addon-knobs";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
|
|
7
|
+
import NumericInputPage from "./numeric-input-page.js";
|
|
8
|
+
import PrealgebraInputPage from "./pre-algebra-page.js";
|
|
9
|
+
import TrigonometryInputPage from "./trigonometry-page.js";
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: "Keypad pages",
|
|
13
|
+
decorators: [withKnobs],
|
|
14
|
+
parameters: {
|
|
15
|
+
backgrounds: [
|
|
16
|
+
{name: "light background", value: "white", default: true},
|
|
17
|
+
],
|
|
18
|
+
viewport: {defaultViewport: "iphone6"},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const NumericInput = (): React.Node => (
|
|
23
|
+
<NumericInputPage onClickKey={action("onClickKey")} />
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const PreAlgebraInput = (): React.Node => (
|
|
27
|
+
<PrealgebraInputPage onClickKey={action("onClickKey")} />
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export const TrigonometryInput = (): React.Node => (
|
|
31
|
+
<TrigonometryInputPage onClickKey={action("onClickKey")} />
|
|
32
|
+
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//@flow
|
|
2
|
+
|
|
3
|
+
import {action} from "@storybook/addon-actions";
|
|
4
|
+
import {withKnobs} from "@storybook/addon-knobs";
|
|
5
|
+
import {INITIAL_VIEWPORTS} from "@storybook/addon-viewport";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
|
|
8
|
+
import Keypad from "./index.js";
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
title: "Full Keypad",
|
|
12
|
+
decorators: [withKnobs],
|
|
13
|
+
parameters: {
|
|
14
|
+
backgrounds: [
|
|
15
|
+
{name: "light background", value: "white", default: true},
|
|
16
|
+
],
|
|
17
|
+
viewport: {defaultViewport: "iphone6", viewports: INITIAL_VIEWPORTS},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const PreAlgebra = (): React.Node => (
|
|
22
|
+
<Keypad
|
|
23
|
+
onClickKey={action("onClickKey")}
|
|
24
|
+
preAlgebra={true}
|
|
25
|
+
trigonometry={false}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export const Trigonometry = (): React.Node => (
|
|
30
|
+
<Keypad
|
|
31
|
+
onClickKey={action("onClickKey")}
|
|
32
|
+
preAlgebra={true}
|
|
33
|
+
trigonometry={true}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import Keys from "../../data/key-configs.js";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
KeypadPageContainer,
|
|
8
|
+
KeypadButton,
|
|
9
|
+
SecondaryKeypadButton,
|
|
10
|
+
KeypadActionButton,
|
|
11
|
+
} from "./keypad-page-items.js";
|
|
12
|
+
|
|
13
|
+
type Props = {|
|
|
14
|
+
onClickKey: (keyConfig: string) => void,
|
|
15
|
+
|};
|
|
16
|
+
|
|
17
|
+
export default class NumericInputPage extends React.Component<Props> {
|
|
18
|
+
render(): React.Node {
|
|
19
|
+
const {onClickKey} = this.props;
|
|
20
|
+
return (
|
|
21
|
+
<KeypadPageContainer>
|
|
22
|
+
{/* Row 1 */}
|
|
23
|
+
<KeypadButton keyConfig={Keys.NUM_7} onClickKey={onClickKey} />
|
|
24
|
+
<KeypadButton keyConfig={Keys.NUM_8} onClickKey={onClickKey} />
|
|
25
|
+
<KeypadButton keyConfig={Keys.NUM_9} onClickKey={onClickKey} />
|
|
26
|
+
<SecondaryKeypadButton
|
|
27
|
+
keyConfig={Keys.TIMES}
|
|
28
|
+
onClickKey={onClickKey}
|
|
29
|
+
/>
|
|
30
|
+
<SecondaryKeypadButton
|
|
31
|
+
keyConfig={Keys.LEFT_PAREN}
|
|
32
|
+
onClickKey={onClickKey}
|
|
33
|
+
/>
|
|
34
|
+
<SecondaryKeypadButton
|
|
35
|
+
keyConfig={Keys.RIGHT_PAREN}
|
|
36
|
+
onClickKey={onClickKey}
|
|
37
|
+
/>
|
|
38
|
+
|
|
39
|
+
{/* Row 2 */}
|
|
40
|
+
<KeypadButton keyConfig={Keys.NUM_4} onClickKey={onClickKey} />
|
|
41
|
+
<KeypadButton keyConfig={Keys.NUM_5} onClickKey={onClickKey} />
|
|
42
|
+
<KeypadButton keyConfig={Keys.NUM_6} onClickKey={onClickKey} />
|
|
43
|
+
|
|
44
|
+
<SecondaryKeypadButton
|
|
45
|
+
keyConfig={Keys.MINUS}
|
|
46
|
+
onClickKey={onClickKey}
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
<SecondaryKeypadButton
|
|
50
|
+
keyConfig={Keys.FRAC_INCLUSIVE}
|
|
51
|
+
onClickKey={onClickKey}
|
|
52
|
+
style={{
|
|
53
|
+
gridColumn: "5 / 7",
|
|
54
|
+
}}
|
|
55
|
+
/>
|
|
56
|
+
{/* Row 3 */}
|
|
57
|
+
<KeypadButton keyConfig={Keys.NUM_1} onClickKey={onClickKey} />
|
|
58
|
+
<KeypadButton keyConfig={Keys.NUM_2} onClickKey={onClickKey} />
|
|
59
|
+
<KeypadButton keyConfig={Keys.NUM_3} onClickKey={onClickKey} />
|
|
60
|
+
|
|
61
|
+
<SecondaryKeypadButton
|
|
62
|
+
keyConfig={Keys.PLUS}
|
|
63
|
+
style={{
|
|
64
|
+
gridColumn: "4",
|
|
65
|
+
gridRowStart: "3",
|
|
66
|
+
gridRowEnd: "5",
|
|
67
|
+
}}
|
|
68
|
+
onClickKey={onClickKey}
|
|
69
|
+
/>
|
|
70
|
+
|
|
71
|
+
<KeypadActionButton
|
|
72
|
+
keyConfig={Keys.BACKSPACE}
|
|
73
|
+
style={{
|
|
74
|
+
gridColumn: "6",
|
|
75
|
+
}}
|
|
76
|
+
onClickKey={onClickKey}
|
|
77
|
+
/>
|
|
78
|
+
|
|
79
|
+
{/* Row 4 */}
|
|
80
|
+
<KeypadButton keyConfig={Keys.NUM_0} onClickKey={onClickKey} />
|
|
81
|
+
<KeypadButton
|
|
82
|
+
keyConfig={Keys.DECIMAL}
|
|
83
|
+
onClickKey={onClickKey}
|
|
84
|
+
/>
|
|
85
|
+
<KeypadButton
|
|
86
|
+
keyConfig={Keys.NEGATIVE}
|
|
87
|
+
onClickKey={onClickKey}
|
|
88
|
+
/>
|
|
89
|
+
|
|
90
|
+
<KeypadActionButton
|
|
91
|
+
keyConfig={Keys.DISMISS}
|
|
92
|
+
style={{
|
|
93
|
+
gridColumn: "6",
|
|
94
|
+
}}
|
|
95
|
+
onClickKey={onClickKey}
|
|
96
|
+
/>
|
|
97
|
+
</KeypadPageContainer>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import Keys from "../../data/key-configs.js";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
KeypadPageContainer,
|
|
8
|
+
SecondaryKeypadButton,
|
|
9
|
+
KeypadActionButton,
|
|
10
|
+
PlaceHolderButton,
|
|
11
|
+
} from "./keypad-page-items.js";
|
|
12
|
+
|
|
13
|
+
type Props = {|
|
|
14
|
+
onClickKey: (keyConfig: string) => void,
|
|
15
|
+
|};
|
|
16
|
+
|
|
17
|
+
export default class NumericInputPage extends React.Component<Props> {
|
|
18
|
+
render(): React.Node {
|
|
19
|
+
const {onClickKey} = this.props;
|
|
20
|
+
return (
|
|
21
|
+
<KeypadPageContainer>
|
|
22
|
+
{/* Row 1 */}
|
|
23
|
+
<SecondaryKeypadButton
|
|
24
|
+
keyConfig={Keys.EXP_2}
|
|
25
|
+
onClickKey={onClickKey}
|
|
26
|
+
/>
|
|
27
|
+
<SecondaryKeypadButton
|
|
28
|
+
keyConfig={Keys.EXP}
|
|
29
|
+
onClickKey={onClickKey}
|
|
30
|
+
/>
|
|
31
|
+
<SecondaryKeypadButton
|
|
32
|
+
keyConfig={Keys.SQRT}
|
|
33
|
+
onClickKey={onClickKey}
|
|
34
|
+
/>
|
|
35
|
+
<SecondaryKeypadButton
|
|
36
|
+
keyConfig={Keys.RADICAL}
|
|
37
|
+
onClickKey={onClickKey}
|
|
38
|
+
/>
|
|
39
|
+
|
|
40
|
+
<SecondaryKeypadButton
|
|
41
|
+
keyConfig={Keys.LEFT_PAREN}
|
|
42
|
+
onClickKey={onClickKey}
|
|
43
|
+
/>
|
|
44
|
+
<SecondaryKeypadButton
|
|
45
|
+
keyConfig={Keys.RIGHT_PAREN}
|
|
46
|
+
onClickKey={onClickKey}
|
|
47
|
+
/>
|
|
48
|
+
{/* Row 2 */}
|
|
49
|
+
<PlaceHolderButton />
|
|
50
|
+
<PlaceHolderButton />
|
|
51
|
+
<PlaceHolderButton />
|
|
52
|
+
<SecondaryKeypadButton
|
|
53
|
+
keyConfig={Keys.X}
|
|
54
|
+
onClickKey={onClickKey}
|
|
55
|
+
style={{
|
|
56
|
+
gridColumn: 5,
|
|
57
|
+
}}
|
|
58
|
+
/>
|
|
59
|
+
<SecondaryKeypadButton
|
|
60
|
+
keyConfig={Keys.FRAC_INCLUSIVE}
|
|
61
|
+
onClickKey={onClickKey}
|
|
62
|
+
style={{
|
|
63
|
+
gridColumn: 6,
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
{/* Row 3 */}
|
|
67
|
+
<PlaceHolderButton />
|
|
68
|
+
<PlaceHolderButton />
|
|
69
|
+
<PlaceHolderButton />
|
|
70
|
+
<SecondaryKeypadButton
|
|
71
|
+
keyConfig={Keys.PI}
|
|
72
|
+
onClickKey={onClickKey}
|
|
73
|
+
style={{
|
|
74
|
+
gridColumn: 5,
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
77
|
+
<KeypadActionButton
|
|
78
|
+
keyConfig={Keys.BACKSPACE}
|
|
79
|
+
style={{
|
|
80
|
+
gridColumn: 6,
|
|
81
|
+
}}
|
|
82
|
+
onClickKey={onClickKey}
|
|
83
|
+
/>
|
|
84
|
+
{/* Row 4 */}
|
|
85
|
+
<PlaceHolderButton />
|
|
86
|
+
<PlaceHolderButton />
|
|
87
|
+
<PlaceHolderButton />
|
|
88
|
+
<KeypadActionButton
|
|
89
|
+
keyConfig={Keys.DISMISS}
|
|
90
|
+
style={{
|
|
91
|
+
gridColumn: "6",
|
|
92
|
+
}}
|
|
93
|
+
onClickKey={onClickKey}
|
|
94
|
+
/>
|
|
95
|
+
</KeypadPageContainer>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import Keys from "../../data/key-configs.js";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
KeypadPageContainer,
|
|
8
|
+
SecondaryKeypadButton,
|
|
9
|
+
KeypadActionButton,
|
|
10
|
+
} from "./keypad-page-items.js";
|
|
11
|
+
|
|
12
|
+
type Props = {|
|
|
13
|
+
onClickKey: (keyConfig: string) => void,
|
|
14
|
+
|};
|
|
15
|
+
|
|
16
|
+
export default class TrigonometryInputPage extends React.Component<Props> {
|
|
17
|
+
render(): React.Node {
|
|
18
|
+
const {onClickKey} = this.props;
|
|
19
|
+
return (
|
|
20
|
+
<KeypadPageContainer>
|
|
21
|
+
{/* Row 1 */}
|
|
22
|
+
<SecondaryKeypadButton
|
|
23
|
+
keyConfig={Keys.SIN}
|
|
24
|
+
onClickKey={onClickKey}
|
|
25
|
+
/>
|
|
26
|
+
<SecondaryKeypadButton
|
|
27
|
+
keyConfig={Keys.COS}
|
|
28
|
+
onClickKey={onClickKey}
|
|
29
|
+
/>
|
|
30
|
+
<SecondaryKeypadButton
|
|
31
|
+
keyConfig={Keys.TAN}
|
|
32
|
+
onClickKey={onClickKey}
|
|
33
|
+
/>
|
|
34
|
+
|
|
35
|
+
<SecondaryKeypadButton
|
|
36
|
+
keyConfig={Keys.LEFT_PAREN}
|
|
37
|
+
onClickKey={onClickKey}
|
|
38
|
+
style={{
|
|
39
|
+
gridColumn: 5,
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
<SecondaryKeypadButton
|
|
43
|
+
keyConfig={Keys.RIGHT_PAREN}
|
|
44
|
+
onClickKey={onClickKey}
|
|
45
|
+
style={{
|
|
46
|
+
gridColumn: 6,
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
{/* Row 2 */}
|
|
50
|
+
<SecondaryKeypadButton
|
|
51
|
+
keyConfig={Keys.X}
|
|
52
|
+
onClickKey={onClickKey}
|
|
53
|
+
style={{
|
|
54
|
+
gridColumn: 5,
|
|
55
|
+
}}
|
|
56
|
+
/>
|
|
57
|
+
<SecondaryKeypadButton
|
|
58
|
+
keyConfig={Keys.FRAC_INCLUSIVE}
|
|
59
|
+
onClickKey={onClickKey}
|
|
60
|
+
style={{
|
|
61
|
+
gridColumn: 6,
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
{/* Row 3 */}
|
|
65
|
+
<SecondaryKeypadButton
|
|
66
|
+
keyConfig={Keys.PI}
|
|
67
|
+
onClickKey={onClickKey}
|
|
68
|
+
style={{
|
|
69
|
+
gridColumn: 5,
|
|
70
|
+
}}
|
|
71
|
+
/>
|
|
72
|
+
<KeypadActionButton
|
|
73
|
+
keyConfig={Keys.BACKSPACE}
|
|
74
|
+
style={{
|
|
75
|
+
gridColumn: "6",
|
|
76
|
+
}}
|
|
77
|
+
onClickKey={onClickKey}
|
|
78
|
+
/>
|
|
79
|
+
{/* Row 4 */}
|
|
80
|
+
<KeypadActionButton
|
|
81
|
+
keyConfig={Keys.DISMISS}
|
|
82
|
+
style={{
|
|
83
|
+
gridColumn: "6",
|
|
84
|
+
}}
|
|
85
|
+
onClickKey={onClickKey}
|
|
86
|
+
/>
|
|
87
|
+
</KeypadPageContainer>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|