Skip to content

Commit

Permalink
Move line stroke style into CSS attribute and introduce variable to c…
Browse files Browse the repository at this point in the history
…ontrol/override it
  • Loading branch information
jeremywiebe committed Apr 23, 2024
1 parent 9112529 commit 480a157
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions core.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

--mafs-origin-color: var(--mafs-fg);
--mafs-line-color: #555;
--mafs-line-stroke-dash-style: 4, 3;
--grid-line-subdivision-color: #222;

--mafs-red: #f11d0e;
Expand Down
3 changes: 2 additions & 1 deletion src/display/Ellipse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ export function Ellipse({
rx={radius[0]}
ry={radius[1]}
strokeWidth={weight}
strokeDasharray={strokeStyle === "dashed" ? "4,3" : undefined}
transform={cssTransform}
{...svgEllipseProps}
style={{
stroke: color,
strokeDasharray:
strokeStyle === "dashed" ? "var(--mafs-line-stroke-dash-style)" : undefined,
fill: color,
fillOpacity,
strokeOpacity,
Expand Down
6 changes: 4 additions & 2 deletions src/display/Line/Segment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ export function Segment({
y1={round(scaledPoint1[1], 2)}
x2={round(scaledPoint2[0], 2)}
y2={round(scaledPoint2[1], 2)}
style={{ stroke: color }}
style={{
stroke: color,
strokeDasharray: style === "dashed" ? "var(--mafs-line-stroke-dash-style)" : undefined,
}}
strokeWidth={weight}
opacity={opacity}
strokeDasharray={style === "dashed" ? "1,10" : undefined}
/>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/display/Line/ThroughPoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ export function ThroughPoints({
y2={round(offscreen2[1], 2)}
style={{
stroke: color,
strokeDasharray: style === "dashed" ? "var(--mafs-line-stroke-dash-style)" : undefined,
transform: "var(--mafs-view-transform)",
vectorEffect: "non-scaling-stroke",
}}
strokeWidth={weight}
opacity={opacity}
strokeDasharray={style === "dashed" ? "4,3" : undefined}
/>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/display/Plot/Parametric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export function Parametric({
fill="none"
strokeLinecap="round"
strokeLinejoin="round"
strokeDasharray={style === "dashed" ? "1,10" : undefined}
{...svgPathProps}
style={{
stroke: color || "var(--mafs-fg)",
strokeOpacity: opacity,
strokeDasharray: style === "dashed" ? "var(--mafs-line-stroke-dash-style)" : undefined,
vectorEffect: "non-scaling-stroke",
transform: "var(--mafs-view-transform)",
...(svgPathProps.style || {}),
Expand Down
2 changes: 1 addition & 1 deletion src/display/PolyBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function PolyBase({
points={scaledPoints}
strokeWidth={weight}
fillOpacity={fillOpacity}
strokeDasharray={strokeStyle === "dashed" ? "4,3" : undefined}
strokeDasharray={strokeStyle === "dashed" ? "var(--mafs-line-stroke-dash-style)" : undefined}
strokeLinejoin="round"
{...svgPolyProps}
style={{
Expand Down
2 changes: 1 addition & 1 deletion src/display/Vector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export function Vector({
y2={pixelTip[1]}
strokeWidth={weight}
markerEnd={`url(#${id})`}
strokeDasharray={style === "dashed" ? "4,3" : undefined}
{...svgLineProps}
style={{
stroke: color || "var(--mafs-fg)",
strokeDasharray: style === "dashed" ? "var(--mafs-line-stroke-dash-style)" : undefined,
fill: color,
strokeOpacity: opacity,
...(svgLineProps?.style || {}),
Expand Down

0 comments on commit 480a157

Please sign in to comment.