feat: start implement mvp

This commit is contained in:
2026-02-03 21:30:14 +05:00
parent 3f35247928
commit ac864e3791
10 changed files with 1132 additions and 2 deletions
+51
View File
@@ -0,0 +1,51 @@
import { writable, type Writable } from "svelte/store";
import { type Panel } from "../lib/types/panel";
import { v4 as uuidv4 } from "uuid";
export const panelStore: Writable<Panel | null> = writable(null);
export const createEmptyPanel = (height: number = 100): Panel => {
return {
id: uuidv4(),
backgroundImage: "",
texts: [],
height,
createdAt: new Date(),
updatedAt: new Date(),
};
};
export const updatePanel = (panel: Panel, updates: Partial<Panel>): Panel => {
return {
...panel,
...updates,
updatedAt: new Date(),
};
};
export const addTextToPanel = (panel: Panel, text: string): Panel => {
const newText = {
id: uuidv4(),
text,
fontSize: 18,
fontFamily: "Arial",
color: "#ffffff",
x: 160, // center horizontally
y: 50, // center vertically
};
return updatePanel(panel, {
texts: [...panel.texts, newText],
});
};
export const updateTextInPanel = (panel: Panel, textId: string, updates: Partial<Panel["texts"][0]>): Panel => {
const updatedTexts = panel.texts.map((text) => (text.id === textId ? { ...text, ...updates } : text));
return updatePanel(panel, { texts: updatedTexts });
};
export const removeTextFromPanel = (panel: Panel, textId: string): Panel => {
const updatedTexts = panel.texts.filter((text) => text.id !== textId);
return updatePanel(panel, { texts: updatedTexts });
};