Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(captions): add style preset definitions and default settings

Richie McIlroy53741ed0c915
diff --git a/apps/desktop/src/store/captions.ts b/apps/desktop/src/store/captions.ts
index 10b4f7b6a..3874384ac 100644
--- a/apps/desktop/src/store/captions.ts
+++ b/apps/desktop/src/store/captions.ts
@@ -7,8 +7,14 @@ import {
} from "~/utils/tauri";
export type CaptionManualPosition = { x: number; y: number };
+export type CaptionAnimation = "none" | "bounce" | "pop";
+export type CaptionHighlightStyle = "color" | "pill";
export type EditorCaptionSettings = CaptionSettings & {
manualPosition?: CaptionManualPosition | null;
+ preset?: string;
+ animation?: CaptionAnimation;
+ highlightStyle?: CaptionHighlightStyle;
+ uppercase?: boolean;
};
export type CaptionsState = {
@@ -17,25 +23,157 @@ export type CaptionsState = {
currentCaption: string | null;
};
+export type CaptionStylePresetId =
+ | "classic"
+ | "karaoke"
+ | "highlight"
+ | "pop"
+ | "minimal";
+
+export type CaptionPresetStyle = {
+ font: string;
+ fontWeight: number;
+ size: number;
+ color: string;
+ backgroundColor: string;
+ backgroundOpacity: number;
+ outline: boolean;
+ outlineColor: string;
+ highlightColor: string;
+ activeWordHighlight: boolean;
+ highlightStyle: CaptionHighlightStyle;
+ animation: CaptionAnimation;
+ uppercase: boolean;
+ fadeDuration: number;
+};
+
+export type CaptionStylePreset = {
+ id: CaptionStylePresetId;
+ label: string;
+ description: string;
+ style: CaptionPresetStyle;
+};
+
+export const CAPTION_STYLE_PRESETS: CaptionStylePreset[] = [
+ {
+ id: "classic",
+ label: "Classic",
+ description: "Clean text on a solid rounded background.",
+ style: {
+ font: "System Sans-Serif",
+ fontWeight: 700,
+ size: 50,
+ color: "#FFFFFF",
+ backgroundColor: "#000000",
+ backgroundOpacity: 90,
+ outline: false,
+ outlineColor: "#000000",
+ highlightColor: "#FFFFFF",
+ activeWordHighlight: false,
+ highlightStyle: "color",
+ animation: "bounce",
+ uppercase: false,
+ fadeDuration: 0.2,
+ },
+ },
+ {
+ id: "karaoke",
+ label: "Karaoke",
+ description: "Words light up in sync with speech.",
+ style: {
+ font: "System Sans-Serif",
+ fontWeight: 700,
+ size: 52,
+ color: "#FFFFFF",
+ backgroundColor: "#000000",
+ backgroundOpacity: 35,
+ outline: false,
+ outlineColor: "#000000",
+ highlightColor: "#FFD400",
+ activeWordHighlight: true,
+ highlightStyle: "color",
+ animation: "none",
+ uppercase: false,
+ fadeDuration: 0.12,
+ },
+ },
+ {
+ id: "highlight",
+ label: "Highlight",
+ description: "Bold caps with a pill behind the active word.",
+ style: {
+ font: "System Sans-Serif",
+ fontWeight: 700,
+ size: 54,
+ color: "#FFFFFF",
+ backgroundColor: "#000000",
+ backgroundOpacity: 0,
+ outline: true,
+ outlineColor: "#000000",
+ highlightColor: "#7C3AED",
+ activeWordHighlight: true,
+ highlightStyle: "pill",
+ animation: "bounce",
+ uppercase: true,
+ fadeDuration: 0.12,
+ },
+ },
+ {
+ id: "pop",
+ label: "Pop",
+ description: "Playful caps that pop in with a vibrant accent.",
+ style: {
+ font: "System Sans-Serif",
+ fontWeight: 700,
+ size: 56,
+ color: "#FFFFFF",
+ backgroundColor: "#000000",
+ backgroundOpacity: 0,
+ outline: true,
+ outlineColor: "#000000",
+ highlightColor: "#FACC15",
+ activeWordHighlight: true,
+ highlightStyle: "color",
+ animation: "pop",
+ uppercase: true,
+ fadeDuration: 0.18,
+ },
+ },
+ {
+ id: "minimal",
+ label: "Minimal",
+ description: "Subtle outlined text with no background.",
+ style: {
+ font: "System Sans-Serif",
+ fontWeight: 600,
+ size: 46,
+ color: "#FFFFFF",
+ backgroundColor: "#000000",
+ backgroundOpacity: 0,
+ outline: true,
+ outlineColor: "#000000",
+ highlightColor: "#FFFFFF",
+ activeWordHighlight: false,
+ highlightStyle: "color",
+ animation: "none",
+ uppercase: false,
+ fadeDuration: 0.25,
+ },
+ },
+];
+
+const classicPreset = CAPTION_STYLE_PRESETS[0];
+
export const defaultCaptionSettings: EditorCaptionSettings = {
enabled: false,
- font: "System Sans-Serif",
- size: 50,
- color: "#FFFFFF",
- backgroundColor: "#000000",
- backgroundOpacity: 95,
position: "bottom-center",
italic: false,
- fontWeight: 400,
- outline: false,
- outlineColor: "#000000",
exportWithSubtitles: false,
- highlightColor: "#FFFFFF",
- fadeDuration: 0.2,
lingerDuration: 0.4,
wordTransitionDuration: 0.25,
- activeWordHighlight: false,
manualPosition: null,
+ preset: classicPreset.id,
+ ...classicPreset.style,
};
function createCaptionsStore() {