Skip to content

🎥 Make videos programmatically with React

hide guides that are to be deleted

ChetanKarwa2846f52bcda5
diff --git a/packages/cli/src/editor/components/EditorGuides/Guide.tsx b/packages/cli/src/editor/components/EditorGuides/Guide.tsx
index 66c0247c22..a9e66f6130 100644
--- a/packages/cli/src/editor/components/EditorGuides/Guide.tsx
+++ b/packages/cli/src/editor/components/EditorGuides/Guide.tsx
@@ -7,6 +7,7 @@ const Guide: React.FC<{
guideDetails: {
position: number;
orientation: 'horizontal' | 'vertical';
+ show: boolean;
};
index: number;
canvasDimensions: {
@@ -46,8 +47,9 @@ const Guide: React.FC<{
minHeight: `${isVerticalGuide ? `calc(100% + ${RULER_WIDTH}px` : '1px'}`,
top: `${isVerticalGuide ? `-${RULER_WIDTH}px` : '0px'}`,
left: `${isVerticalGuide ? '0px' : `-${RULER_WIDTH}px`}`,
+ display: guideDetails.show ? 'block' : 'none',
};
- }, [isVerticalGuide]);
+ }, [isVerticalGuide, guideDetails.show]);
const onMouseDown = useCallback(
(e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
diff --git a/packages/cli/src/editor/components/EditorRuler/Ruler.tsx b/packages/cli/src/editor/components/EditorRuler/Ruler.tsx
index 0bc713b68c..d0a0486905 100644
--- a/packages/cli/src/editor/components/EditorRuler/Ruler.tsx
+++ b/packages/cli/src/editor/components/EditorRuler/Ruler.tsx
@@ -89,6 +89,7 @@ const Ruler: React.FC<RulerProps> = ({
{
orientation,
position: -originOffset,
+ show: false,
},
];
});
diff --git a/packages/cli/src/editor/components/EditorRuler/index.tsx b/packages/cli/src/editor/components/EditorRuler/index.tsx
index ae0e8aa9db..c7a72ee4e8 100644
--- a/packages/cli/src/editor/components/EditorRuler/index.tsx
+++ b/packages/cli/src/editor/components/EditorRuler/index.tsx
@@ -119,6 +119,15 @@ export const EditorRulers: React.FC<{
if (document.body.style.cursor !== 'no-drop') {
document.body.style.cursor = 'no-drop';
}
+
+ setGuidesList((prevState) => {
+ const newGuidesList = [...prevState];
+ newGuidesList[selectedGuideIndex] = {
+ ...newGuidesList[selectedGuideIndex],
+ show: false,
+ };
+ return newGuidesList;
+ });
} else {
if (shouldDeleteGuideRef.current) {
shouldDeleteGuideRef.current = false;
@@ -142,6 +151,7 @@ export const EditorRulers: React.FC<{
newGuidesList[selectedGuideIndex] = {
...newGuidesList[selectedGuideIndex],
position: Math.floor(position / 1.0),
+ show: true,
};
return newGuidesList;
});
diff --git a/packages/cli/src/editor/components/ShowGuidesProvider.tsx b/packages/cli/src/editor/components/ShowGuidesProvider.tsx
index d5c71ad156..09c80ae375 100644
--- a/packages/cli/src/editor/components/ShowGuidesProvider.tsx
+++ b/packages/cli/src/editor/components/ShowGuidesProvider.tsx
@@ -12,6 +12,7 @@ export const ShowGuidesProvider: React.FC<{
{
orientation: 'horizontal' | 'vertical';
position: number;
+ show: boolean;
}[]
>([]);
const [selectedGuideIndex, setSelectedGuideIndex] = useState(-1);
diff --git a/packages/cli/src/editor/state/editor-guides.ts b/packages/cli/src/editor/state/editor-guides.ts
index 87de326f8a..1493600c86 100644
--- a/packages/cli/src/editor/state/editor-guides.ts
+++ b/packages/cli/src/editor/state/editor-guides.ts
@@ -6,16 +6,19 @@ type State = {
guidesList: {
orientation: 'horizontal' | 'vertical';
position: number;
+ show: boolean;
}[];
setGuidesList: (
cb: (
prevState: {
orientation: 'horizontal' | 'vertical';
position: number;
+ show: boolean;
}[],
) => {
orientation: 'horizontal' | 'vertical';
position: number;
+ show: boolean;
}[],
) => void;
selectedGuideIndex: number;