flip image buttons added with - bug present

This commit is contained in:
Artur AGH
2023-11-01 12:14:00 +01:00
parent 53e8e16191
commit df33d4a3b8
4 changed files with 120 additions and 16 deletions

View File

@@ -22,7 +22,15 @@ const defaultTextConfig = {
fontFamily: "Roboto",
};
const defaultImageConfig = {};
const defaultImageConfig = {
x: 50,
y: 50,
opacity: 1,
offsetX: 0,
offsetY: 0,
scaleX: 1,
scaleY: 1,
};
export const appSlice = createSlice({
name: "app",
@@ -35,17 +43,27 @@ export const appSlice = createSlice({
id: textId,
...defaultTextConfig,
});
console.log(current(state.texts));
},
addImage: (state, action: PayloadAction<ChangeEvent<HTMLInputElement>>) => {
const file = action.payload.target.files?.[0];
addImage: (
state,
action: PayloadAction<{
imageUrl: string;
width: number;
height: number;
}>,
) => {
const file = action.payload;
if (!file) return;
const imageId = v1();
const imageUrl = URL.createObjectURL(file);
state.images.push({ imageUrl, id: imageId });
console.log(current(state.images));
state.images.push({
imageUrl: action.payload.imageUrl,
id: imageId,
width: action.payload.width,
height: action.payload.height,
...defaultImageConfig,
});
},
selectItem: (state, action: PayloadAction<string>) => {