Skip to content
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

[Interactive Graph Editor] Add white as a fill option for locked ellipses and polygons #1478

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions .changeset/gentle-roses-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/perseus": patch
"@khanacademy/perseus-editor": patch
---

[Interactive Graph Editor] Add "white" as a fill option for locked ellipses and polygons
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
styles.innerCircle,
{
backgroundColor: lockedFigureColors[color],
opacity: lockedFigureFillStyles[fillStyle],
opacity:
fillStyle === "white"
? 0

Check warning on line 38 in packages/perseus-editor/src/components/graph-locked-figures/ellipse-swatch.tsx

View check run for this annotation

Codecov / codecov/patch

packages/perseus-editor/src/components/graph-locked-figures/ellipse-swatch.tsx#L38

Added line #L38 was not covered by tests
: lockedFigureFillStyles[fillStyle],
},
]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
styles.innerSquare,
{
backgroundColor: lockedFigureColors[color],
opacity: lockedFigureFillStyles[fillStyle],
opacity:
fillStyle === "white"
? 0

Check warning on line 38 in packages/perseus-editor/src/components/graph-locked-figures/polygon-swatch.tsx

View check run for this annotation

Codecov / codecov/patch

packages/perseus-editor/src/components/graph-locked-figures/polygon-swatch.tsx#L38

Added line #L38 was not covered by tests
: lockedFigureFillStyles[fillStyle],
},
]}
/>
Expand Down
5 changes: 3 additions & 2 deletions packages/perseus/src/perseus-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -722,11 +722,12 @@ export type LockedVectorType = {
color: LockedFigureColor;
};

export type LockedFigureFillType = "none" | "solid" | "translucent";
export type LockedFigureFillType = "none" | "white" | "translucent" | "solid";
export const lockedFigureFillStyles: Record<LockedFigureFillType, number> = {
none: 0,
solid: 1,
white: 1,
translucent: 0.4,
solid: 1,
} as const;

export type LockedEllipseType = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
fillOpacity={lockedFigureFillStyles[fillStyle]}
strokeStyle={strokeStyle}
color={lockedFigureColors[color]}
// We need to override the svg props if we want to have a
// different fill color than the stroke color (specifically,
// in the case where the fillStyle is "white").
svgEllipseProps={{
style: {
fill:
fillStyle === "white"
? "white"
: lockedFigureColors[color],

Check warning on line 29 in packages/perseus/src/widgets/interactive-graphs/locked-figures/locked-ellipse.tsx

View check run for this annotation

Codecov / codecov/patch

packages/perseus/src/widgets/interactive-graphs/locked-figures/locked-ellipse.tsx#L28-L29

Added lines #L28 - L29 were not covered by tests
},
}}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ const LockedPolygon = (props: LockedPolygonType) => {
fillOpacity={lockedFigureFillStyles[fillStyle]}
strokeStyle={strokeStyle}
color={lockedFigureColors[color]}
// We need to override the svg props if we want to have a
// different fill color than the stroke color (specifically,
// in the case where the fillStyle is "white").
svgPolygonProps={{
style: {
fill:
fillStyle === "white"
? "white"
: lockedFigureColors[color],
},
}}
/>
{showVertices &&
points.map((point, index) => (
Expand Down
Loading