Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pink-ghosts-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Updates perseus to use WB `semanticColor` tokens instead of the now deprecated `color` tokens.
8 changes: 4 additions & 4 deletions packages/perseus/src/components/math-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import Clickable from "@khanacademy/wonder-blocks-clickable";
import {View} from "@khanacademy/wonder-blocks-core";
import {Popover, PopoverContentCore} from "@khanacademy/wonder-blocks-popover";
import {color, semanticColor, sizing} from "@khanacademy/wonder-blocks-tokens";
import {semanticColor, sizing} from "@khanacademy/wonder-blocks-tokens";
import {HeadingMedium} from "@khanacademy/wonder-blocks-typography";
import {StyleSheet} from "aphrodite";
import classNames from "classnames";
Expand Down Expand Up @@ -550,17 +550,17 @@ const styles = StyleSheet.create({
},
iconInactive: {
border: "2px solid transparent",
backgroundColor: color.offBlack8,
backgroundColor: semanticColor.core.background.neutral.subtle,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
iconActive: {
border: `2px solid ${semanticColor.core.border.knockout.default}`,
backgroundColor: color.offBlack64,
backgroundColor: semanticColor.core.background.neutral.default,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
outerWrapper: {
display: "inline-block",
borderStyle: "solid",
borderWidth: 1,
borderColor: color.offBlack50,
borderColor: semanticColor.core.border.neutral.default,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

borderRadius: 3,
background: semanticColor.core.background.base.default,
":hover": inputFocused,
Expand Down
3 changes: 3 additions & 0 deletions packages/perseus/src/util/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*/
import {color} from "@khanacademy/wonder-blocks-tokens";

// TODO(WB-2160): Update these to use the new semanticColor tokens, and use the
// new tokenValue() function to get the raw value of the token. This is
// necessary because graphie only supports raw CSS colors.
Comment on lines +11 to +13
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Left this comment as I'm planning to come back to this later. As you are aware, Graphie doesn't support CSS variable references, so I'm planning to do something like this:

BLUE: tokenValue(semanticColor.core.foreground.instructive.default), // outputs the HEX value of that token

const KhanColors = {
BLUE: color.blue,
ORANGE: "#FFA500",
Expand Down
9 changes: 2 additions & 7 deletions packages/perseus/src/widgets/free-response/free-response.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import {Text, View} from "@khanacademy/wonder-blocks-core";
import {TextArea} from "@khanacademy/wonder-blocks-form";
import {PhosphorIcon} from "@khanacademy/wonder-blocks-icon";
import {LabeledField} from "@khanacademy/wonder-blocks-labeled-field";
import {
color,
font,
spacing,
semanticColor,
} from "@khanacademy/wonder-blocks-tokens";
import {font, spacing, semanticColor} from "@khanacademy/wonder-blocks-tokens";
import warningCircleIcon from "@phosphor-icons/core/regular/warning-circle.svg";
import {StyleSheet} from "aphrodite";
import * as React from "react";
Expand Down Expand Up @@ -158,7 +153,7 @@ const styles = StyleSheet.create({
fontSize: font.size.small,
},
overCharacterLimit: {
color: color.red,
color: semanticColor.core.foreground.critical.default,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
textarea: {
padding: spacing.medium_16,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ exports[`graded-group-set should render all graded groups 1`] = `
</span>
</button>
<button
class="showHintLink_oak3yy"
class="showHintLink_1n4y2tp"
tabindex="0"
>
Explain
Expand Down Expand Up @@ -174,7 +174,7 @@ exports[`graded-group-set should render all graded groups 1`] = `
</span>
</button>
<button
class="showHintLink_oak3yy"
class="showHintLink_1n4y2tp"
tabindex="0"
>
Explain
Expand Down Expand Up @@ -251,7 +251,7 @@ exports[`graded-group-set should render all graded groups 1`] = `
</span>
</button>
<button
class="showHintLink_oak3yy"
class="showHintLink_1n4y2tp"
tabindex="0"
>
Explain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exports[`graded group set widget should snapshot 1`] = `
class="top_cjo0m2"
>
<div
class="title_vo78fw"
class="title_t78eih"
>
Problem 1a
</div>
Expand All @@ -50,10 +50,10 @@ exports[`graded group set widget should snapshot 1`] = `
type="button"
>
<div
class="default_xu2jcg-o_O-indicatorDot_yy8ygm"
class="default_xu2jcg-o_O-indicatorDot_1ppx7bq"
>
<div
class="default_xu2jcg-o_O-indicatorDotActive_1pky1a"
class="default_xu2jcg-o_O-indicatorDotActive_xgych8"
>
<span
class="srOnly_19bpjuy"
Expand All @@ -74,7 +74,7 @@ exports[`graded group set widget should snapshot 1`] = `
type="button"
>
<div
class="default_xu2jcg-o_O-indicatorDot_yy8ygm"
class="default_xu2jcg-o_O-indicatorDot_1ppx7bq"
/>
</button>
</li>
Expand All @@ -88,7 +88,7 @@ exports[`graded group set widget should snapshot 1`] = `
type="button"
>
<div
class="default_xu2jcg-o_O-indicatorDot_yy8ygm"
class="default_xu2jcg-o_O-indicatorDot_1ppx7bq"
/>
</button>
</li>
Expand Down Expand Up @@ -160,7 +160,7 @@ exports[`graded group set widget should snapshot 1`] = `
</span>
</button>
<button
class="showHintLink_oak3yy"
class="showHintLink_1n4y2tp"
tabindex="0"
>
Explain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {linterContextDefault} from "@khanacademy/perseus-linter";
import Clickable from "@khanacademy/wonder-blocks-clickable";
import {View} from "@khanacademy/wonder-blocks-core";
import {color} from "@khanacademy/wonder-blocks-tokens";
import {semanticColor} from "@khanacademy/wonder-blocks-tokens";
import {StyleSheet, css} from "aphrodite";
import classNames from "classnames";
import * as React from "react";
Expand Down Expand Up @@ -263,7 +263,7 @@ const styles = StyleSheet.create({

title: {
fontSize: 12,
color: color.offBlack64,
color: semanticColor.core.foreground.neutral.subtle,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

textTransform: "uppercase",
marginBottom: 11,
letterSpacing: 0.8,
Expand Down Expand Up @@ -302,7 +302,7 @@ const styles = StyleSheet.create({
height: 10,
borderRadius: "100%",
borderWidth: 2,
borderColor: color.blue,
borderColor: semanticColor.core.border.instructive.default,
borderStyle: "solid",
},

Expand All @@ -312,7 +312,7 @@ const styles = StyleSheet.create({
},

indicatorDotActive: {
backgroundColor: color.blue,
backgroundColor: semanticColor.core.background.instructive.default,
width: "100%",
height: "100%",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ exports[`graded-group should snapshot: initial render (mobile: false) 1`] = `
</span>
</button>
<button
class="showHintLink_oak3yy"
class="showHintLink_1n4y2tp"
tabindex="0"
>
Explain
Expand Down Expand Up @@ -738,13 +738,13 @@ exports[`graded-group should snapshot: initial render (mobile: true) 1`] = `
</div>
</div>
<button
class="showHintLink_oak3yy"
class="showHintLink_1n4y2tp"
tabindex="0"
>
Explain
</button>
<div
style="display: flex; align-items: center; height: 68px; margin: 16px -16px -16px -16px; padding-left: 16px; padding-right: 10px; border-top: 1px solid rgba(33,36,44,0.50); background-color: white; justify-content: space-between;"
style="display: flex; align-items: center; height: 68px; margin: 16px -16px -16px -16px; padding-left: 16px; padding-right: 10px; justify-content: space-between;"
>
<span />
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Renders answer bar for mobile graded groups. [STATELESS]
*/
import Button from "@khanacademy/wonder-blocks-button";
import {color} from "@khanacademy/wonder-blocks-tokens";
import {semanticColor} from "@khanacademy/wonder-blocks-tokens";
import * as React from "react";

import {PerseusI18nContext} from "../../components/i18n-context";
Expand Down Expand Up @@ -50,7 +50,9 @@ class GradedGroupAnswerBar extends React.Component<Props> {
const answerBarStyle = {
...styles.answerBar,
backgroundColor:
answerBarState === "CORRECT" ? color.offWhite : "white",
answerBarState === "CORRECT"
? semanticColor.core.background.base.subtle
: semanticColor.core.background.base.default,
// Center the "Correct!" message only when there's no next question
justifyContent:
answerBarState === "CORRECT" && !onNextQuestion
Expand Down Expand Up @@ -91,7 +93,13 @@ class GradedGroupAnswerBar extends React.Component<Props> {
return (
<div style={answerBarStyle}>
<span style={styles.text}>
<span style={{fontSize: 28, color: color.green}}>
<span
style={{
fontSize: 28,
color: semanticColor.core.foreground.success
.default,
}}
>
<InlineIcon {...iconStar} style={{marginBottom: 5}} />
</span>
<span
Expand Down Expand Up @@ -123,7 +131,7 @@ const styles = {
marginTop: phoneMargin,
paddingLeft: phoneMargin,
paddingRight: 10,
borderTop: `1px solid ${color.offBlack50}`,
borderTop: `1px solid ${semanticColor.core.border.neutral.default}`,
},

tryAgainIcon: {
Expand Down
6 changes: 3 additions & 3 deletions packages/perseus/src/widgets/graded-group/graded-group.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @khanacademy/ts-no-error-suppressions */
import {linterContextDefault} from "@khanacademy/perseus-linter";
import Button from "@khanacademy/wonder-blocks-button";
import {color} from "@khanacademy/wonder-blocks-tokens";
import {semanticColor} from "@khanacademy/wonder-blocks-tokens";
import {StyleSheet, css} from "aphrodite";
import classNames from "classnames";
import * as React from "react";
Expand Down Expand Up @@ -482,7 +482,7 @@ const styles = StyleSheet.create({
padding: 0,
border: "none",
marginTop: 20,
color: color.blue,
color: semanticColor.core.foreground.instructive.default,
cursor: "pointer",
display: "block",
clear: "both",
Expand All @@ -491,7 +491,7 @@ const styles = StyleSheet.create({
explanationTitle: {
backgroundColor: "unset",
marginTop: 20,
color: color.blue,
color: semanticColor.core.foreground.instructive.default,
marginBottom: 10,
cursor: "pointer",
fontSize: 14,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {angles, geometry} from "@khanacademy/kmath";
import {color} from "@khanacademy/wonder-blocks-tokens";
import {semanticColor} from "@khanacademy/wonder-blocks-tokens";
import {vec} from "mafs";
import * as React from "react";

Expand Down Expand Up @@ -261,7 +261,11 @@ export const Angle = ({
<Arc arc={arc} className={arcClassName} />
)}
{showAngles && (
<TextLabel x={textX} y={textY} color={color.blue}>
<TextLabel
x={textX}
y={textY}
color={semanticColor.core.foreground.instructive.default}
>
{angleLabel}°
</TextLabel>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {color} from "@khanacademy/wonder-blocks-tokens";
import {semanticColor} from "@khanacademy/wonder-blocks-tokens";
import * as React from "react";

import useGraphConfig from "../../reducer/use-graph-config";
Expand Down Expand Up @@ -34,14 +34,14 @@ export default function Hairlines(props: Props) {
y1={y}
x2={verticalEndX}
y2={y}
stroke={color.blue}
stroke={semanticColor.core.border.instructive.default}
/>
<line
x1={x}
y1={horizontalStartY}
x2={x}
y2={horizontalEndY}
stroke={color.blue}
stroke={semanticColor.core.border.instructive.default}
/>
</g>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
splitPerseusItem,
getDefaultFigureForType,
} from "@khanacademy/perseus-core";
import {color as wbColor} from "@khanacademy/wonder-blocks-tokens";
import {semanticColor} from "@khanacademy/wonder-blocks-tokens";
import {waitFor} from "@testing-library/react";
import {userEvent as userEventLib} from "@testing-library/user-event";
import {Plot} from "mafs";
Expand Down Expand Up @@ -413,7 +413,7 @@ describe("Interactive Graph", function () {
stroke: lockedFigureColors.grayH,
});
expect(points[1]).toHaveStyle({
fill: wbColor.white,
fill: semanticColor.core.background.base.default,
stroke: lockedFigureColors.grayH,
});
});
Expand Down Expand Up @@ -535,7 +535,7 @@ describe("Interactive Graph", function () {
stroke: lockedFigureColors.grayH,
});
expect(points[1]).toHaveStyle({
fill: wbColor.white,
fill: semanticColor.core.background.base.default,
stroke: lockedFigureColors.grayH,
});
});
Expand Down Expand Up @@ -785,19 +785,19 @@ describe("Interactive Graph", function () {
stroke: lockedFigureColors.green,
});
expect(linePoints[1]).toHaveStyle({
fill: wbColor.white,
fill: semanticColor.core.background.base.default,
stroke: lockedFigureColors.green,
});
expect(linePoints[2]).toHaveStyle({
fill: wbColor.white,
fill: semanticColor.core.background.base.default,
stroke: lockedFigureColors.grayH,
});
expect(linePoints[3]).toHaveStyle({
fill: lockedFigureColors.grayH,
stroke: lockedFigureColors.grayH,
});
expect(rayPoints[0]).toHaveStyle({
fill: wbColor.white,
fill: semanticColor.core.background.base.default,
stroke: lockedFigureColors.pink,
});
});
Expand Down Expand Up @@ -1015,7 +1015,7 @@ describe("Interactive Graph", function () {
// Assert
expect(whiteCircle).toHaveStyle({
"fill-opacity": 1,
fill: wbColor.white,
fill: semanticColor.core.background.base.default,
stroke: lockedFigureColors["green"],
});
expect(translucentCircle).toHaveStyle({
Expand Down Expand Up @@ -1186,7 +1186,7 @@ describe("Interactive Graph", function () {
// Assert
expect(whitePolygon).toHaveStyle({
"fill-opacity": 1,
fill: wbColor.white,
fill: semanticColor.core.background.base.default,
stroke: lockedFigureColors["green"],
});
expect(translucentPolygon).toHaveStyle({
Expand Down
Loading
Loading