forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddSlideButton.tsx
More file actions
36 lines (34 loc) · 1.03 KB
/
Copy pathAddSlideButton.tsx
File metadata and controls
36 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { SlideModel } from "@/app/types";
import { ActionButton } from "./ActionButton";
import { PlusCircleIcon } from "@heroicons/react/24/outline";
interface AddSlideButtonProps {
currentSlideIndex: number;
setCurrentSlideIndex: (fn: (i: number) => number) => void;
setSlides: (fn: (slides: SlideModel[]) => SlideModel[]) => void;
}
export function AddSlideButton({
currentSlideIndex,
setCurrentSlideIndex,
setSlides,
}: AddSlideButtonProps) {
return (
<ActionButton
onClick={() => {
const newSlide: SlideModel = {
content: "",
backgroundImageUrl:
"https://loremflickr.com/cache/resized/65535_53415810728_d1db6e2660_h_800_600_nofilter.jpg",
spokenNarration: "",
};
setSlides((slides) => [
...slides.slice(0, currentSlideIndex + 1),
newSlide,
...slides.slice(currentSlideIndex + 1),
]);
setCurrentSlideIndex((i) => i + 1);
}}
>
<PlusCircleIcon className="h-5 w-5" />
</ActionButton>
);
}