feat: add clear for texts state, update tests
This commit is contained in:
@@ -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;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user