Skip to content

🎥 Make videos programmatically with React

interesting

Jonny Burgereda7707c69cd
diff --git a/packages/docs/components/demos/Pie.tsx b/packages/docs/components/demos/Pie.tsx
index 182139510e..213f96f4f3 100644
--- a/packages/docs/components/demos/Pie.tsx
+++ b/packages/docs/components/demos/Pie.tsx
@@ -6,7 +6,9 @@ export const PieDemo: React.FC<{
radius: number;
darkMode: boolean;
fillAmount: number;
-}> = ({ radius, darkMode, fillAmount }) => {
+ closePath: boolean;
+ stroke: boolean;
+}> = ({ radius, darkMode, fillAmount, closePath, stroke }) => {
return (
<AbsoluteFill
style={{
@@ -16,8 +18,13 @@ export const PieDemo: React.FC<{
>
<Pie
fillAmount={fillAmount}
- fill={darkMode ? "white" : "var(--ifm-link-color)"}
+ fill={
+ stroke ? "transparent" : darkMode ? "white" : "var(--ifm-link-color)"
+ }
radius={radius}
+ closePath={closePath}
+ stroke={darkMode ? "white" : "var(--ifm-link-color)"}
+ strokeWidth={stroke ? 5 : 0}
/>
</AbsoluteFill>
);
diff --git a/packages/docs/components/demos/types.ts b/packages/docs/components/demos/types.ts
index a528387a6d..e8698351c6 100644
--- a/packages/docs/components/demos/types.ts
+++ b/packages/docs/components/demos/types.ts
@@ -193,6 +193,18 @@ export const pieDemo: DemoType = {
name: "fillAmount",
optional: "no",
},
+ {
+ default: true,
+ type: "boolean",
+ name: "closePath",
+ optional: "no",
+ },
+ {
+ default: false,
+ type: "boolean",
+ name: "stroke",
+ optional: "no",
+ },
],
};
diff --git a/packages/shapes/src/components/pie.tsx b/packages/shapes/src/components/pie.tsx
index ba41d30b6e..66ead81167 100644
--- a/packages/shapes/src/components/pie.tsx
+++ b/packages/shapes/src/components/pie.tsx
@@ -6,6 +6,11 @@ import {RenderSvg} from './render-svg';
export type PieProps = MakePieProps & AllShapesProps;
-export const Pie: React.FC<PieProps> = ({radius, fillAmount, ...props}) => {
- return <RenderSvg {...makePie({radius, fillAmount})} {...props} />;
+export const Pie: React.FC<PieProps> = ({
+ radius,
+ fillAmount,
+ closePath,
+ ...props
+}) => {
+ return <RenderSvg {...makePie({radius, fillAmount, closePath})} {...props} />;
};
diff --git a/packages/shapes/src/utils/make-pie.ts b/packages/shapes/src/utils/make-pie.ts
index 49b6b28687..2b8388c275 100644
--- a/packages/shapes/src/utils/make-pie.ts
+++ b/packages/shapes/src/utils/make-pie.ts
@@ -4,9 +4,10 @@ import {serializeInstructions} from './instructions';
export type MakePieProps = {
radius: number;
fillAmount: number;
+ closePath: boolean;
};
-export const makePie = ({fillAmount, radius}: MakePieProps) => {
+export const makePie = ({fillAmount, radius, closePath}: MakePieProps) => {
const actualFillAmount = Math.min(Math.max(fillAmount, 0), 1);
const endAngleX =
@@ -42,16 +43,18 @@ export const makePie = ({fillAmount, radius}: MakePieProps) => {
y: endAngleY,
}
: null,
- actualFillAmount > 0 && actualFillAmount < 1
+ actualFillAmount > 0 && actualFillAmount < 1 && closePath
? {
type: 'L',
x: radius,
y: radius,
}
: null,
- {
- type: 'z',
- },
+ closePath
+ ? {
+ type: 'z',
+ }
+ : null,
].filter(Boolean) as Instruction[];
const path = serializeInstructions(instructions);