@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
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
|
-
export type Props = {
|
|
4
|
-
onPress: () => void;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
ariaLabel: string;
|
|
7
|
-
style?: StyleType;
|
|
8
|
-
tintColor?: string;
|
|
9
|
-
};
|
|
10
|
-
export default class Button extends React.Component<Props> {
|
|
11
|
-
render(): React.ReactNode;
|
|
12
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import * as React from "react";
|
|
8
|
-
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
9
|
-
export type Props = {|
|
|
10
|
-
onPress: () => void,
|
|
11
|
-
children: React.Node,
|
|
12
|
-
ariaLabel: string,
|
|
13
|
-
style?: StyleType,
|
|
14
|
-
tintColor?: string,
|
|
15
|
-
|};
|
|
16
|
-
declare export default class Button extends React.Component<Props> {
|
|
17
|
-
render(): React.Node;
|
|
18
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import Key from "../../../data/keys";
|
|
3
|
-
type Props = {
|
|
4
|
-
extraKeys: ReadonlyArray<Key>;
|
|
5
|
-
onClickKey: (keyConfig: string) => void;
|
|
6
|
-
};
|
|
7
|
-
export default class ExtrasPage extends React.Component<Props> {
|
|
8
|
-
render(): React.ReactNode;
|
|
9
|
-
}
|
|
10
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import * as React from "react";
|
|
8
|
-
import Key from "../../../data/keys";
|
|
9
|
-
declare type Props = {|
|
|
10
|
-
extraKeys: $ReadOnlyArray<Key>,
|
|
11
|
-
onClickKey: (keyConfig: string) => void,
|
|
12
|
-
|};
|
|
13
|
-
declare export default class ExtrasPage extends React.Component<Props> {
|
|
14
|
-
render(): React.Node;
|
|
15
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import * as React from "react";
|
|
8
|
-
import { ClickKeyCallback } from "../../../types";
|
|
9
|
-
declare type Props = {|
|
|
10
|
-
onClickKey: ClickKeyCallback,
|
|
11
|
-
|};
|
|
12
|
-
declare export default class GeometryPage extends React.Component<Props> {
|
|
13
|
-
render(): React.Node;
|
|
14
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { KeyConfig, ClickKeyCallback } from "../../types";
|
|
3
|
-
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
4
|
-
type KeypadPageContainerProps = {
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
};
|
|
7
|
-
export declare const KeypadPageContainer: ({ children, }: KeypadPageContainerProps) => React.ReactElement;
|
|
8
|
-
type SharedButtonProps = {
|
|
9
|
-
keyConfig: KeyConfig;
|
|
10
|
-
style?: StyleType;
|
|
11
|
-
onClickKey: ClickKeyCallback;
|
|
12
|
-
};
|
|
13
|
-
export type KeypadButtonProps = SharedButtonProps & {
|
|
14
|
-
tintColor?: string;
|
|
15
|
-
};
|
|
16
|
-
export declare const KeypadButton: ({ keyConfig, onClickKey, tintColor, style, }: KeypadButtonProps) => React.ReactElement;
|
|
17
|
-
export declare const SecondaryKeypadButton: ({ keyConfig, onClickKey, style, }: SharedButtonProps) => React.ReactElement;
|
|
18
|
-
export declare const KeypadActionButton: ({ keyConfig, onClickKey, style, }: SharedButtonProps) => React.ReactElement;
|
|
19
|
-
/**
|
|
20
|
-
* A placeholder button for the keypad. Optional count prop to render multiple
|
|
21
|
-
* buttons. Defaults to 1.
|
|
22
|
-
*/
|
|
23
|
-
export declare const PlaceHolderButtons: ({ count, }: {
|
|
24
|
-
count?: number | undefined;
|
|
25
|
-
}) => React.ReactElement;
|
|
26
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import * as React from "react";
|
|
8
|
-
import { KeyConfig, ClickKeyCallback } from "../../types";
|
|
9
|
-
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
10
|
-
declare type KeypadPageContainerProps = {|
|
|
11
|
-
children: React.Node,
|
|
12
|
-
|};
|
|
13
|
-
declare export var KeypadPageContainer: (
|
|
14
|
-
x: KeypadPageContainerProps
|
|
15
|
-
) => React.Element<any>;
|
|
16
|
-
declare type SharedButtonProps = {|
|
|
17
|
-
keyConfig: KeyConfig,
|
|
18
|
-
style?: StyleType,
|
|
19
|
-
onClickKey: ClickKeyCallback,
|
|
20
|
-
|};
|
|
21
|
-
export type KeypadButtonProps = {|
|
|
22
|
-
...SharedButtonProps,
|
|
23
|
-
...{|
|
|
24
|
-
tintColor?: string,
|
|
25
|
-
|},
|
|
26
|
-
|};
|
|
27
|
-
declare export var KeypadButton: (x: KeypadButtonProps) => React.Element<any>;
|
|
28
|
-
declare export var SecondaryKeypadButton: (
|
|
29
|
-
x: SharedButtonProps
|
|
30
|
-
) => React.Element<any>;
|
|
31
|
-
declare export var KeypadActionButton: (
|
|
32
|
-
x: SharedButtonProps
|
|
33
|
-
) => React.Element<any>;
|
|
34
|
-
/**
|
|
35
|
-
* A placeholder button for the keypad. Optional count prop to render multiple
|
|
36
|
-
* buttons. Defaults to 1.
|
|
37
|
-
*/
|
|
38
|
-
declare export var PlaceHolderButtons: (x: {|
|
|
39
|
-
count?: number | void,
|
|
40
|
-
|}) => React.Element<any>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { ClickKeyCallback } from "../../../types";
|
|
3
|
-
import { NumbersPageOptions } from "./types";
|
|
4
|
-
type Props = {
|
|
5
|
-
onClickKey: ClickKeyCallback;
|
|
6
|
-
} & NumbersPageOptions;
|
|
7
|
-
export default class NumbersPage extends React.Component<Props> {
|
|
8
|
-
render(): React.ReactNode;
|
|
9
|
-
}
|
|
10
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import * as React from "react";
|
|
8
|
-
import { ClickKeyCallback } from "../../../types";
|
|
9
|
-
import { NumbersPageOptions } from "./types";
|
|
10
|
-
declare type Props = {|
|
|
11
|
-
...{|
|
|
12
|
-
onClickKey: ClickKeyCallback,
|
|
13
|
-
|},
|
|
14
|
-
...NumbersPageOptions,
|
|
15
|
-
|};
|
|
16
|
-
declare export default class NumbersPage extends React.Component<Props> {
|
|
17
|
-
render(): React.Node;
|
|
18
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ClickKeyCallback } from "../../../types";
|
|
3
|
-
type Props = {
|
|
4
|
-
onClickKey: ClickKeyCallback;
|
|
5
|
-
placeholder?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare const AdvancedRelations: ({ onClickKey, placeholder, }: Props) => React.ReactElement;
|
|
8
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ClickKeyCallback } from "../../../types";
|
|
3
|
-
type Props = {
|
|
4
|
-
onClickKey: ClickKeyCallback;
|
|
5
|
-
placeholder?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare const BasicRelations: ({ onClickKey, placeholder, }: Props) => React.ReactElement;
|
|
8
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { ClickKeyCallback } from "../../../types";
|
|
3
|
-
import { OperatorsButtonSets } from "./types";
|
|
4
|
-
type Props = {
|
|
5
|
-
onClickKey: ClickKeyCallback;
|
|
6
|
-
} & OperatorsButtonSets;
|
|
7
|
-
export default class OperatorsPage extends React.Component<Props> {
|
|
8
|
-
render(): React.ReactNode;
|
|
9
|
-
}
|
|
10
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import * as React from "react";
|
|
8
|
-
import { ClickKeyCallback } from "../../../types";
|
|
9
|
-
import { OperatorsButtonSets } from "./types";
|
|
10
|
-
declare type Props = {|
|
|
11
|
-
...{|
|
|
12
|
-
onClickKey: ClickKeyCallback,
|
|
13
|
-
|},
|
|
14
|
-
...OperatorsButtonSets,
|
|
15
|
-
|};
|
|
16
|
-
declare export default class OperatorsPage extends React.Component<Props> {
|
|
17
|
-
render(): React.Node;
|
|
18
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ClickKeyCallback } from "../../../types";
|
|
3
|
-
type Props = {
|
|
4
|
-
onClickKey: ClickKeyCallback;
|
|
5
|
-
placeholder?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare const Logarithms: ({ onClickKey, placeholder, }: Props) => React.ReactElement;
|
|
8
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ClickKeyCallback } from "../../../types";
|
|
3
|
-
type Props = {
|
|
4
|
-
onClickKey: ClickKeyCallback;
|
|
5
|
-
placeholder?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare const PreAlgebra: ({ onClickKey, placeholder, }: Props) => React.ReactElement;
|
|
8
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
export type OperatorsButtonSets = {|
|
|
8
|
-
preAlgebra?: boolean,
|
|
9
|
-
logarithms?: boolean,
|
|
10
|
-
basicRelations?: boolean,
|
|
11
|
-
advancedRelations?: boolean,
|
|
12
|
-
|};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {render, screen} from "@testing-library/react";
|
|
2
|
-
import userEvent from "@testing-library/user-event";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import "@testing-library/jest-dom";
|
|
5
|
-
|
|
6
|
-
import Button from "../button";
|
|
7
|
-
|
|
8
|
-
describe("<Button />", () => {
|
|
9
|
-
it("uses the aria label", () => {
|
|
10
|
-
// Arrange
|
|
11
|
-
render(
|
|
12
|
-
<Button onPress={() => {}} ariaLabel="Oranges">
|
|
13
|
-
<p />
|
|
14
|
-
</Button>,
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
// Assert
|
|
18
|
-
expect(
|
|
19
|
-
screen.getByRole("button", {name: "Oranges"}),
|
|
20
|
-
).toBeInTheDocument();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("handles callback on press", () => {
|
|
24
|
-
// Arrange
|
|
25
|
-
const mockPressCallback = jest.fn();
|
|
26
|
-
render(
|
|
27
|
-
<Button onPress={mockPressCallback} ariaLabel="Oranges">
|
|
28
|
-
<p />
|
|
29
|
-
</Button>,
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
// Act
|
|
33
|
-
userEvent.click(screen.getByRole("button", {name: "Oranges"}));
|
|
34
|
-
|
|
35
|
-
// Assert
|
|
36
|
-
expect(mockPressCallback).toHaveBeenCalled();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("renders child", () => {
|
|
40
|
-
// Arrange
|
|
41
|
-
render(
|
|
42
|
-
<Button onPress={() => {}} ariaLabel="Test">
|
|
43
|
-
<img aria-label="child1" />
|
|
44
|
-
</Button>,
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
// Assert
|
|
48
|
-
expect(screen.getByRole("button", {name: "Test"})).toBeInTheDocument();
|
|
49
|
-
expect(screen.getByRole("img", {name: "child1"})).toBeInTheDocument();
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,108 +0,0 @@
|
|
|
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 type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
8
|
-
|
|
9
|
-
const styles = StyleSheet.create({
|
|
10
|
-
base: {
|
|
11
|
-
display: "flex",
|
|
12
|
-
justifyContent: "center",
|
|
13
|
-
alignItems: "center",
|
|
14
|
-
boxShadow: "0px 1px 0px rgba(33, 36, 44, 0.32)",
|
|
15
|
-
boxSizing: "border-box",
|
|
16
|
-
background: Color.white,
|
|
17
|
-
borderRadius: 4,
|
|
18
|
-
border: `1px solid transparent`,
|
|
19
|
-
flex: 1,
|
|
20
|
-
minHeight: 42,
|
|
21
|
-
minWidth: 42,
|
|
22
|
-
padding: 1,
|
|
23
|
-
},
|
|
24
|
-
hovered: {
|
|
25
|
-
border: `1px solid ${Color.blue}`,
|
|
26
|
-
padding: 1,
|
|
27
|
-
boxShadow: "none",
|
|
28
|
-
},
|
|
29
|
-
focused: {
|
|
30
|
-
border: `2px solid ${Color.blue}`,
|
|
31
|
-
padding: 0,
|
|
32
|
-
boxShadow: "none",
|
|
33
|
-
},
|
|
34
|
-
pressed: {
|
|
35
|
-
border: "2px solid #1B50B3",
|
|
36
|
-
padding: 0,
|
|
37
|
-
background: `linear-gradient(0deg, rgba(24, 101, 242, 0.32), rgba(24, 101, 242, 0.32)), ${Color.white}`,
|
|
38
|
-
boxShadow: "none",
|
|
39
|
-
},
|
|
40
|
-
outerBoxBase: {
|
|
41
|
-
padding: 1,
|
|
42
|
-
height: "100%",
|
|
43
|
-
width: "100%",
|
|
44
|
-
boxSizing: "border-box",
|
|
45
|
-
borderRadius: 7,
|
|
46
|
-
border: "2px solid transparent",
|
|
47
|
-
},
|
|
48
|
-
outerBoxHover: {
|
|
49
|
-
border: `2px solid ${Color.blue}`,
|
|
50
|
-
},
|
|
51
|
-
outerBoxPressed: {
|
|
52
|
-
border: "2px solid #1B50B3",
|
|
53
|
-
},
|
|
54
|
-
clickable: {
|
|
55
|
-
width: "100%",
|
|
56
|
-
height: "100%",
|
|
57
|
-
boxSizing: "border-box",
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
export type Props = {
|
|
62
|
-
onPress: () => void;
|
|
63
|
-
children: React.ReactNode;
|
|
64
|
-
ariaLabel: string;
|
|
65
|
-
style?: StyleType;
|
|
66
|
-
tintColor?: string;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export default class Button extends React.Component<Props> {
|
|
70
|
-
render(): React.ReactNode {
|
|
71
|
-
const {onPress, ariaLabel, children, style, tintColor} = this.props;
|
|
72
|
-
return (
|
|
73
|
-
<View style={style}>
|
|
74
|
-
<Clickable
|
|
75
|
-
onClick={onPress}
|
|
76
|
-
style={styles.clickable}
|
|
77
|
-
aria-label={ariaLabel}
|
|
78
|
-
>
|
|
79
|
-
{({hovered, focused, pressed}) => {
|
|
80
|
-
return (
|
|
81
|
-
<View
|
|
82
|
-
style={[
|
|
83
|
-
styles.outerBoxBase,
|
|
84
|
-
hovered && styles.outerBoxHover,
|
|
85
|
-
pressed && styles.outerBoxPressed,
|
|
86
|
-
]}
|
|
87
|
-
>
|
|
88
|
-
<View
|
|
89
|
-
style={[
|
|
90
|
-
styles.base,
|
|
91
|
-
tintColor != null
|
|
92
|
-
? {background: tintColor}
|
|
93
|
-
: undefined,
|
|
94
|
-
hovered && styles.hovered,
|
|
95
|
-
focused && styles.focused,
|
|
96
|
-
pressed && styles.pressed,
|
|
97
|
-
]}
|
|
98
|
-
>
|
|
99
|
-
{children}
|
|
100
|
-
</View>
|
|
101
|
-
</View>
|
|
102
|
-
);
|
|
103
|
-
}}
|
|
104
|
-
</Clickable>
|
|
105
|
-
</View>
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import Keys from "../../../data/key-configs";
|
|
4
|
-
import Key from "../../../data/keys";
|
|
5
|
-
import {KeypadPageContainer, KeypadButton} from "../keypad-page-items";
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
extraKeys: ReadonlyArray<Key>;
|
|
9
|
-
onClickKey: (keyConfig: string) => void;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default class ExtrasPage extends React.Component<Props> {
|
|
13
|
-
render(): React.ReactNode {
|
|
14
|
-
const {extraKeys, onClickKey} = this.props;
|
|
15
|
-
return (
|
|
16
|
-
<KeypadPageContainer>
|
|
17
|
-
{extraKeys.map((key) => (
|
|
18
|
-
<KeypadButton
|
|
19
|
-
key={key}
|
|
20
|
-
keyConfig={Keys[key]}
|
|
21
|
-
onClickKey={onClickKey}
|
|
22
|
-
/>
|
|
23
|
-
))}
|
|
24
|
-
</KeypadPageContainer>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import Keys from "../../../data/key-configs";
|
|
4
|
-
import {ClickKeyCallback} from "../../../types";
|
|
5
|
-
import {
|
|
6
|
-
KeypadPageContainer,
|
|
7
|
-
SecondaryKeypadButton,
|
|
8
|
-
KeypadActionButton,
|
|
9
|
-
} from "../keypad-page-items";
|
|
10
|
-
|
|
11
|
-
type Props = {
|
|
12
|
-
onClickKey: ClickKeyCallback;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default class GeometryPage extends React.Component<Props> {
|
|
16
|
-
render(): React.ReactNode {
|
|
17
|
-
const {onClickKey} = this.props;
|
|
18
|
-
return (
|
|
19
|
-
<KeypadPageContainer>
|
|
20
|
-
{/* Row 1 */}
|
|
21
|
-
<SecondaryKeypadButton
|
|
22
|
-
keyConfig={Keys.SIN}
|
|
23
|
-
onClickKey={onClickKey}
|
|
24
|
-
/>
|
|
25
|
-
<SecondaryKeypadButton
|
|
26
|
-
keyConfig={Keys.COS}
|
|
27
|
-
onClickKey={onClickKey}
|
|
28
|
-
/>
|
|
29
|
-
<SecondaryKeypadButton
|
|
30
|
-
keyConfig={Keys.TAN}
|
|
31
|
-
onClickKey={onClickKey}
|
|
32
|
-
/>
|
|
33
|
-
|
|
34
|
-
<SecondaryKeypadButton
|
|
35
|
-
keyConfig={Keys.LEFT_PAREN}
|
|
36
|
-
onClickKey={onClickKey}
|
|
37
|
-
style={{
|
|
38
|
-
gridColumn: 5,
|
|
39
|
-
}}
|
|
40
|
-
/>
|
|
41
|
-
<SecondaryKeypadButton
|
|
42
|
-
keyConfig={Keys.RIGHT_PAREN}
|
|
43
|
-
onClickKey={onClickKey}
|
|
44
|
-
style={{
|
|
45
|
-
gridColumn: 6,
|
|
46
|
-
}}
|
|
47
|
-
/>
|
|
48
|
-
{/* Row 2 */}
|
|
49
|
-
<SecondaryKeypadButton
|
|
50
|
-
keyConfig={Keys.x}
|
|
51
|
-
onClickKey={onClickKey}
|
|
52
|
-
style={{
|
|
53
|
-
gridColumn: 5,
|
|
54
|
-
}}
|
|
55
|
-
/>
|
|
56
|
-
<SecondaryKeypadButton
|
|
57
|
-
keyConfig={Keys.FRAC_INCLUSIVE}
|
|
58
|
-
onClickKey={onClickKey}
|
|
59
|
-
style={{
|
|
60
|
-
gridColumn: 6,
|
|
61
|
-
}}
|
|
62
|
-
/>
|
|
63
|
-
{/* Row 3 */}
|
|
64
|
-
<SecondaryKeypadButton
|
|
65
|
-
keyConfig={Keys.PI}
|
|
66
|
-
onClickKey={onClickKey}
|
|
67
|
-
style={{
|
|
68
|
-
gridColumn: 5,
|
|
69
|
-
}}
|
|
70
|
-
/>
|
|
71
|
-
<KeypadActionButton
|
|
72
|
-
keyConfig={Keys.BACKSPACE}
|
|
73
|
-
style={{
|
|
74
|
-
gridColumn: "6",
|
|
75
|
-
}}
|
|
76
|
-
onClickKey={onClickKey}
|
|
77
|
-
/>
|
|
78
|
-
{/* Row 4 */}
|
|
79
|
-
<KeypadActionButton
|
|
80
|
-
keyConfig={Keys.DISMISS}
|
|
81
|
-
style={{
|
|
82
|
-
gridColumn: "6",
|
|
83
|
-
}}
|
|
84
|
-
onClickKey={onClickKey}
|
|
85
|
-
/>
|
|
86
|
-
</KeypadPageContainer>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import {View} from "@khanacademy/wonder-blocks-core";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
import {KeyConfig, ClickKeyCallback} from "../../types";
|
|
5
|
-
|
|
6
|
-
import Button from "./button";
|
|
7
|
-
import ButtonAsset from "./button-assets";
|
|
8
|
-
|
|
9
|
-
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
10
|
-
|
|
11
|
-
type KeypadPageContainerProps = {
|
|
12
|
-
children: React.ReactNode;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const KeypadPageContainer = ({
|
|
16
|
-
children,
|
|
17
|
-
}: KeypadPageContainerProps): React.ReactElement => (
|
|
18
|
-
<View
|
|
19
|
-
style={{
|
|
20
|
-
backgroundColor: "#DBDCDD",
|
|
21
|
-
width: "100%",
|
|
22
|
-
height: 192,
|
|
23
|
-
|
|
24
|
-
display: "grid",
|
|
25
|
-
gridTemplateColumns: "repeat(6, 1fr)",
|
|
26
|
-
gridTemplateRows: "repeat(4, 1fr)",
|
|
27
|
-
}}
|
|
28
|
-
>
|
|
29
|
-
{children}
|
|
30
|
-
</View>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
type SharedButtonProps = {
|
|
34
|
-
keyConfig: KeyConfig;
|
|
35
|
-
style?: StyleType;
|
|
36
|
-
onClickKey: ClickKeyCallback;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type KeypadButtonProps = SharedButtonProps & {
|
|
40
|
-
tintColor?: string;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const KeypadButton = ({
|
|
44
|
-
keyConfig,
|
|
45
|
-
onClickKey,
|
|
46
|
-
tintColor,
|
|
47
|
-
style,
|
|
48
|
-
}: KeypadButtonProps): React.ReactElement => (
|
|
49
|
-
<Button
|
|
50
|
-
onPress={() => onClickKey(keyConfig.id)}
|
|
51
|
-
tintColor={tintColor}
|
|
52
|
-
style={style}
|
|
53
|
-
ariaLabel={keyConfig.ariaLabel}
|
|
54
|
-
>
|
|
55
|
-
<ButtonAsset id={keyConfig.id} />
|
|
56
|
-
</Button>
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
export const SecondaryKeypadButton = ({
|
|
60
|
-
keyConfig,
|
|
61
|
-
onClickKey,
|
|
62
|
-
style,
|
|
63
|
-
}: SharedButtonProps): React.ReactElement => (
|
|
64
|
-
<KeypadButton
|
|
65
|
-
keyConfig={keyConfig}
|
|
66
|
-
onClickKey={onClickKey}
|
|
67
|
-
style={style}
|
|
68
|
-
tintColor={"#F6F6F7"}
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
export const KeypadActionButton = ({
|
|
73
|
-
keyConfig,
|
|
74
|
-
onClickKey,
|
|
75
|
-
style,
|
|
76
|
-
}: SharedButtonProps): React.ReactElement => (
|
|
77
|
-
<KeypadButton
|
|
78
|
-
keyConfig={keyConfig}
|
|
79
|
-
onClickKey={onClickKey}
|
|
80
|
-
style={style}
|
|
81
|
-
tintColor={"#DBDCDD"}
|
|
82
|
-
/>
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* A placeholder button for the keypad. Optional count prop to render multiple
|
|
87
|
-
* buttons. Defaults to 1.
|
|
88
|
-
*/
|
|
89
|
-
export const PlaceHolderButtons = ({
|
|
90
|
-
count = 1,
|
|
91
|
-
}: {
|
|
92
|
-
count?: number;
|
|
93
|
-
}): React.ReactElement => (
|
|
94
|
-
<React.Fragment>
|
|
95
|
-
{Array.from({length: count}).map((_, index) => (
|
|
96
|
-
<View
|
|
97
|
-
key={index}
|
|
98
|
-
style={{
|
|
99
|
-
height: "100%",
|
|
100
|
-
width: "100%",
|
|
101
|
-
boxSizing: "border-box",
|
|
102
|
-
borderRadius: 7,
|
|
103
|
-
border: "4px solid transparent",
|
|
104
|
-
}}
|
|
105
|
-
>
|
|
106
|
-
<View
|
|
107
|
-
style={{
|
|
108
|
-
background: "rgba(33, 36, 44, 0.04)",
|
|
109
|
-
width: "100%",
|
|
110
|
-
height: "100%",
|
|
111
|
-
borderRadius: 4,
|
|
112
|
-
border: `1px solid transparent`,
|
|
113
|
-
}}
|
|
114
|
-
/>
|
|
115
|
-
</View>
|
|
116
|
-
))}
|
|
117
|
-
</React.Fragment>
|
|
118
|
-
);
|