feat: add clear for texts state, update tests

This commit is contained in:
2026-02-09 09:34:01 +05:00
parent a146fee41c
commit ede31942d0
2 changed files with 56 additions and 82 deletions
+5 -1
View File
@@ -5,7 +5,7 @@ export interface TextItem {
const defaultTexts: Array<TextItem> = ["About me", "Links", "Projects"].map((text, idx) => ({ text, id: idx }));
function createState() {
export function createState() {
let texts: Array<TextItem> = $state(defaultTexts);
let nextId = $state(defaultTexts.length);
@@ -21,6 +21,10 @@ function createState() {
removeText(id: number) {
texts = texts.filter((textItem) => textItem.id !== id);
},
clear() {
texts = [];
nextId = 0;
},
};
}