-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary: Added the fraction keypad view to the new v2 keypad as part of our overhaul of MathInput. This fraction view is used by the following Perseus Widgets: - InputNumber - Matrix - NumberLine - NumericInput - Table I've also updated existing stories to be able to demonstrate this new view. As it turns out, we're not doing anything custom with our numberpad page for the Fraction Keypad, so we can reuse the preexisting page. Note: I've settled on the prop name of "fractionsOnly" but I am open to any suggestions on a more descriptive name. I felt "fractionsOnly" was the closest I could get to a balance of being descriptive against the tab props, yet brief. ## Screenshots: (Forcing the "IN_NUMERATOR" calculator context in the _Full Mobile MathInput_ Story to show the context button) ![Screenshot 2023-08-15 at 3 43 51 PM](https://github.com/Khan/perseus/assets/12463099/16dc4ca1-a1ba-4cbc-85e6-86ed3678b644) (No cursor context using _Full Keypad_ Story) ![Screenshot 2023-08-15 at 3 40 34 PM](https://github.com/Khan/perseus/assets/12463099/ffa3ce6c-057a-4146-8d5c-2984098535d5) (Based on our [Figma Designs](https://www.figma.com/file/2lUPOSbOP8tbW7RLqbBFLh/Expression-Widget?type=design&node-id=4674-87332&mode=design&t=gZTp9zvbYilUKfYa-0)) Issue: LC-1098 ## Test plan: - manual testing - new stories Author: SonicScrewdriver Reviewers: handeyeco, SonicScrewdriver Required Reviewers: Approved By: handeyeco, handeyeco Checks: ✅ finish_coverage, ✅ Publish npm snapshot (ubuntu-latest, 16.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 16.x), ✅ Extract i18n strings (ubuntu-latest, 16.x), ✅ Cypress Coverage (ubuntu-latest, 16.x), ✅ Check for .changeset file (ubuntu-latest, 16.x), ✅ Check builds for changes in size (ubuntu-latest, 16.x), ✅ Jest Coverage (ubuntu-latest, 16.x), ✅ gerald Pull Request URL: #667
- Loading branch information
1 parent
1905432
commit b93f9f7
Showing
10 changed files
with
280 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/math-input": minor | ||
--- | ||
|
||
Added new Mobile Fraction Keypad View to the V2 Keypad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
packages/math-input/src/components/keypad/keypad-pages/fractions-page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import * as React from "react"; | ||
|
||
import Keys from "../../../data/key-configs"; | ||
import {KeypadButton} from "../keypad-button"; | ||
import {getCursorContextConfig} from "../utils"; | ||
|
||
import type {ClickKeyCallback} from "../../../types"; | ||
import type {CursorContext} from "../../input/cursor-contexts"; | ||
|
||
type Props = { | ||
onClickKey: ClickKeyCallback; | ||
cursorContext?: typeof CursorContext[keyof typeof CursorContext]; | ||
}; | ||
|
||
export default function FractionsPage(props: Props) { | ||
const {onClickKey, cursorContext} = props; | ||
const cursorKeyConfig = getCursorContextConfig(cursorContext); | ||
// These keys are arranged sequentially so that tabbing follows numerical order. This | ||
// allows us to visually mimic a keypad without affecting a11y. The visual order of the | ||
// keys in the keypad is determined by their coordinates, not their order in the DOM. | ||
return ( | ||
<> | ||
{/* Row 4 */} | ||
<KeypadButton | ||
keyConfig={Keys.NUM_1} | ||
onClickKey={onClickKey} | ||
coord={[0, 2]} | ||
/> | ||
<KeypadButton | ||
keyConfig={Keys.NUM_2} | ||
onClickKey={onClickKey} | ||
coord={[1, 2]} | ||
/> | ||
<KeypadButton | ||
keyConfig={Keys.NUM_3} | ||
onClickKey={onClickKey} | ||
coord={[2, 2]} | ||
/> | ||
|
||
{/* Row 3 */} | ||
<KeypadButton | ||
keyConfig={Keys.NUM_4} | ||
onClickKey={onClickKey} | ||
coord={[0, 1]} | ||
/> | ||
<KeypadButton | ||
keyConfig={Keys.NUM_5} | ||
onClickKey={onClickKey} | ||
coord={[1, 1]} | ||
/> | ||
<KeypadButton | ||
keyConfig={Keys.NUM_6} | ||
onClickKey={onClickKey} | ||
coord={[2, 1]} | ||
/> | ||
|
||
{/* Row 2 */} | ||
<KeypadButton | ||
keyConfig={Keys.NUM_7} | ||
onClickKey={onClickKey} | ||
coord={[0, 0]} | ||
/> | ||
<KeypadButton | ||
keyConfig={Keys.NUM_8} | ||
onClickKey={onClickKey} | ||
coord={[1, 0]} | ||
/> | ||
<KeypadButton | ||
keyConfig={Keys.NUM_9} | ||
onClickKey={onClickKey} | ||
coord={[2, 0]} | ||
/> | ||
|
||
{/* Row 1 */} | ||
<KeypadButton | ||
keyConfig={Keys.NUM_0} | ||
onClickKey={onClickKey} | ||
coord={[0, 3]} | ||
/> | ||
<KeypadButton | ||
keyConfig={Keys.DECIMAL} | ||
onClickKey={onClickKey} | ||
coord={[1, 3]} | ||
/> | ||
<KeypadButton | ||
keyConfig={Keys.NEGATIVE} | ||
onClickKey={onClickKey} | ||
coord={[2, 3]} | ||
/> | ||
{/* Side Column */} | ||
<KeypadButton | ||
keyConfig={Keys.PERCENT} | ||
onClickKey={onClickKey} | ||
coord={[3, 0]} | ||
secondary | ||
/> | ||
<KeypadButton | ||
keyConfig={Keys.PI} | ||
onClickKey={onClickKey} | ||
coord={[3, 1]} | ||
secondary | ||
/> | ||
<KeypadButton | ||
keyConfig={Keys.FRAC_INCLUSIVE} | ||
onClickKey={onClickKey} | ||
coord={[3, 2]} | ||
secondary | ||
/> | ||
{cursorKeyConfig && ( | ||
<KeypadButton | ||
keyConfig={cursorKeyConfig} | ||
onClickKey={onClickKey} | ||
coord={[3, 3]} | ||
secondary | ||
/> | ||
)} | ||
<KeypadButton | ||
keyConfig={Keys.BACKSPACE} | ||
onClickKey={onClickKey} | ||
coord={[4, 3]} | ||
action | ||
/> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.