diff --git a/src/components/ColorSelect.ts b/src/components/ColorSelect.ts index 7978e3a..1ab4abf 100644 --- a/src/components/ColorSelect.ts +++ b/src/components/ColorSelect.ts @@ -1,9 +1,13 @@ import elt from "../utils/createElement"; +import { UIComponent, EditorState } from "../types"; class ColorSelect implements UIComponent { public input: HTMLInputElement; public dom: HTMLElement; - constructor(state: EditorState, { dispatch }) { + constructor( + state: EditorState, + { dispatch }: { dispatch: (...args: any[]) => void } + ) { this.input = elt("input", { type: "color", value: state.color, diff --git a/src/components/LoadButton.ts b/src/components/LoadButton.ts index b2ba00f..299c9ca 100644 --- a/src/components/LoadButton.ts +++ b/src/components/LoadButton.ts @@ -1,8 +1,10 @@ import elt from "../utils/createElement"; +import { EditorConfig, UIComponent } from "../types"; +import { startLoad } from "../utils/fileLoader"; class LoadButton implements UIComponent { public dom: HTMLElement; - constructor(_, { dispatch }) { + constructor(_: any, { dispatch }: EditorConfig) { this.dom = elt( "button", { diff --git a/src/components/SaveButton.ts b/src/components/SaveButton.ts index 2d54dd9..bf60e31 100644 --- a/src/components/SaveButton.ts +++ b/src/components/SaveButton.ts @@ -1,10 +1,13 @@ import elt from "../utils/createElement"; +import { EditorState, UIComponent } from "../types"; +import Picture from "../models/Picture"; +import { drawPicture } from "../utils/drawHelpers"; class SaveButton implements UIComponent { public picture: Picture; public dom: HTMLElement; - constructor(state) { + constructor(state: EditorState) { this.picture = state.picture; this.dom = elt( "button", @@ -25,7 +28,7 @@ class SaveButton implements UIComponent { link.click(); link.remove(); } - syncState(state) { + syncState(state: EditorState) { this.picture = state.picture; } } diff --git a/src/components/ToolSelect.ts b/src/components/ToolSelect.ts index 5036bbe..5775645 100644 --- a/src/components/ToolSelect.ts +++ b/src/components/ToolSelect.ts @@ -1,10 +1,11 @@ import elt from "../utils/createElement"; +import { EditorConfig, EditorState, UIComponent } from "../types"; class ToolSelect implements UIComponent { public select: HTMLSelectElement; public dom: HTMLElement; - constructor(state: EditorState, { tools, dispatch }) { + constructor(state: EditorState, { tools, dispatch }: EditorConfig) { this.select = elt( "select", { diff --git a/src/components/UndoButton.ts b/src/components/UndoButton.ts index c07b9a5..f739034 100644 --- a/src/components/UndoButton.ts +++ b/src/components/UndoButton.ts @@ -1,8 +1,9 @@ import elt from "../utils/createElement"; +import { EditorConfig, EditorState, UIComponent } from "../types"; class UndoButton implements UIComponent { public dom: HTMLButtonElement; - constructor(state, { dispatch }) { + constructor(state: EditorState, { dispatch }: EditorConfig) { this.dom = elt( "button", { diff --git a/src/types.ts b/src/types.ts index b514cb2..df8f395 100644 --- a/src/types.ts +++ b/src/types.ts @@ -23,7 +23,7 @@ export interface EditorState { export interface EditorConfig { tools: any; controls: (typeof UIComponent)[]; - dispatch: any; + dispatch: (stat: any, action?: any) => void; } export interface Position { diff --git a/src/utils/fileLoad.ts b/src/utils/fileLoader.ts similarity index 100% rename from src/utils/fileLoad.ts rename to src/utils/fileLoader.ts