-
Notifications
You must be signed in to change notification settings - Fork 359
[Keypad] Update Keypad to use WonderBlocks Tabs component #2952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ivyolamit
wants to merge
11
commits into
main
Choose a base branch
from
LEMS-3361/use-wb-tab-in-expression
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3f49852
[LEMS-3361/use-wb-tab-in-expression] docs(changeset): Update Keypad t…
ivyolamit 344be98
[LEMS-3361/use-wb-tab-in-expression] Refactor Keypad to use WB Tabs i…
ivyolamit ff78281
[LEMS-3361/use-wb-tab-in-expression] temp changes
ivyolamit ca5090c
[LEMS-3361/use-wb-tab-in-expression] use wonderblock tokens
ivyolamit cc963ce
[LEMS-3361/use-wb-tab-in-expression] update test
ivyolamit bcd9679
[LEMS-3361/use-wb-tab-in-expression] use IconButton for close button …
ivyolamit e4df1f4
[LEMS-3361/use-wb-tab-in-expression] undo moving of file
ivyolamit 4eef022
[LEMS-3361/use-wb-tab-in-expression] have a consistent way of importing
ivyolamit 9542b49
[LEMS-3361/use-wb-tab-in-expression] move logic for WB Tabs styles
ivyolamit bfa3a3b
[LEMS-3361/use-wb-tab-in-expression] undo changes in test since chang…
ivyolamit 8ee2f62
[LEMS-3361/use-wb-tab-in-expression] update snapshot
ivyolamit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 | ||
| --- | ||
|
|
||
| Update Keypad to use WonderBlocks Tabs component |
3,152 changes: 1,577 additions & 1,575 deletions
3,152
packages/math-input/src/components/keypad/__tests__/__snapshots__/keypad.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
54 changes: 54 additions & 0 deletions
54
packages/math-input/src/components/keypad/keypad-fractions-only.tsx
This file contains hidden or 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,54 @@ | ||
| import {View} from "@khanacademy/wonder-blocks-core"; | ||
| import {semanticColor} from "@khanacademy/wonder-blocks-tokens"; | ||
| import * as React from "react"; | ||
|
|
||
| import FractionsPage from "./keypad-pages/fractions-page"; | ||
| import styles from "./keypad.module.css"; | ||
| import {RenderKeyPadPanel} from "./render-keypad-panel"; | ||
|
|
||
| import type {KeypadProps} from "./keypad"; | ||
| import type {KeypadPageType} from "../../types"; | ||
|
|
||
| export type KeypadFractionsOnlyProps = Pick< | ||
| KeypadProps, | ||
| | "fractionsOnly" | ||
| | "onClickKey" | ||
| | "cursorContext" | ||
| | "convertDotToTimes" | ||
| | "divisionKey" | ||
| | "expandedView" | ||
| >; | ||
|
|
||
| // Inline styles needed because CSS modules don't have enough specificity | ||
| // to override Wonder Blocks View default styles | ||
| const keypadInnerContainerStyle = { | ||
| display: "flex", | ||
| flexDirection: "row", | ||
| flexWrap: "nowrap", | ||
| backgroundColor: semanticColor.core.background.disabled.strong, | ||
| // Even in RTL languages, math is LTR. | ||
| // So we force this component to always render LTR | ||
| direction: "ltr", | ||
| } as const; | ||
|
|
||
| export function KeypadFractionsOnly(props: KeypadFractionsOnlyProps) { | ||
| const {onClickKey, cursorContext, expandedView} = props; | ||
| const selectedPage: KeypadPageType = "Fractions"; | ||
|
|
||
| return ( | ||
| <View className={expandedView ? styles.keypadOuterContainer : ""}> | ||
| <View | ||
| className={`${styles.wrapper} ${expandedView ? styles.expandedWrapper : ""}`} | ||
| > | ||
| <View style={keypadInnerContainerStyle}> | ||
| <RenderKeyPadPanel {...props} selectedPage={selectedPage}> | ||
| <FractionsPage | ||
| onClickKey={onClickKey} | ||
| cursorContext={cursorContext} | ||
| /> | ||
| </RenderKeyPadPanel> | ||
| </View> | ||
| </View> | ||
| </View> | ||
| ); | ||
| } | ||
This file contains hidden or 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
35 changes: 35 additions & 0 deletions
35
packages/math-input/src/components/keypad/keypad.module.css
This file contains hidden or 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,35 @@ | ||
| .keypad-outer-container { | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
|
|
||
| .wrapper { | ||
| background-color: var(--wb-semanticColor-core-background-base-default); | ||
| } | ||
|
|
||
| .expanded-wrapper { | ||
| border-width: 1px 1px 0 1px; | ||
| border-color: var(--wb-semanticColor-core-border-neutral-default); | ||
| /* see expandedViewThreshold */ | ||
| max-width: 500px; | ||
| border-radius: 3px 3px 0 0; | ||
| } | ||
|
|
||
| .keypad-inner-container { | ||
| display: flex; | ||
| flex-direction: row; | ||
| flex-wrap: nowrap; | ||
| background-color: var(--wb-semanticColor-core-background-disabled-strong); | ||
| /* Even in RTL languages, math is LTR, So we force this component to always render LTR. */ | ||
| direction: ltr; | ||
| } | ||
|
|
||
| .keypad-grid { | ||
| display: grid !important; | ||
| grid-template-rows: repeat(4, 1fr); | ||
| flex: 1; | ||
| } | ||
|
|
||
| .fractions-grid { | ||
| grid-template-columns: repeat(5, 1fr); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me why we need both KeypadFractionsOnly and FractionsPage. Couldn't KeypadFractionsOnly just be part of Keypad?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During the refactor i've separated the logic
Both of this uses the FractionsPage, the first one is rendered directly from the KeyPad while the second one is is rendered via the util getAvailableTabs which will form the props that will be provided to the WB Tabs component.
Initially with #1 I added it in the Keypad component, but since it has a number of lines of code i decided to make it a different component so it will be easier to read in Keypad component like this (making the code dry):