diff --git a/app/client/src/actions/pageActions.tsx b/app/client/src/actions/pageActions.tsx index cfbc72bec3..f562d4d4ec 100644 --- a/app/client/src/actions/pageActions.tsx +++ b/app/client/src/actions/pageActions.tsx @@ -1,11 +1,8 @@ import { FetchPageRequest } from "../api/PageApi"; import { ResponseMeta } from "../api/ApiResponses"; import { RenderMode } from "../constants/WidgetConstants"; -import { - WidgetProps, - WidgetDynamicProperty, - WidgetDynamicProperties, -} from "../widgets/BaseWidget"; +import { WidgetProps, WidgetOperation } from "../widgets/BaseWidget"; +import { WidgetType } from "../constants/WidgetConstants"; import { ReduxActionTypes, ReduxAction, @@ -96,19 +93,50 @@ export const savePageError = (payload: SavePageErrorPayload) => { }; }; -export const updateWidget = ( - property: WidgetDynamicProperty, - widget: WidgetProps, - payload: any, -) => { - switch (property) { - case WidgetDynamicProperties.CHILDREN: - return; - case WidgetDynamicProperties.EXISTENCE: - return; - case WidgetDynamicProperties.POSITION: - return; - case WidgetDynamicProperties.SIZE: - return; - } +export type WidgetAddChild = { + widgetId: string; + type: WidgetType; + left: number; + top: number; + width: number; + height: number; +}; + +export type WidgetMove = { + widgetId: string; + left: number; + top: number; + /* + If parentWidgetId is different from what we have in redux store, + then we got to delete this, + as it has been dropped in another container somewhere. + + TODO(abhinav): Make sure to handle the scenario where they drop outside the canvas. + */ + parentWidgetId?: string; +}; + +export type WidgetRemoveChild = { + widgetId: string; + childWidgetId: string; +}; + +export type WidgetResize = { + widgetId: string; + width: number; + height: number; +}; + +export const updateWidget = ( + operation: WidgetOperation, + widgetId: string, + payload: any, +): ReduxAction< + WidgetAddChild | WidgetMove | WidgetRemoveChild | WidgetResize +> => { + console.log(operation, widgetId, payload); + return { + type: ReduxActionTypes["WIDGET_" + operation], + payload: { widgetId, ...payload }, + }; }; diff --git a/app/client/src/assets/icons/build.sh b/app/client/src/assets/icons/build.sh index dbbdf7cda1..264bdf205e 100755 --- a/app/client/src/assets/icons/build.sh +++ b/app/client/src/assets/icons/build.sh @@ -10,4 +10,5 @@ do done; # using relative path for now -mv fonts ../../../public/ +cp -rf fonts ../../../public/ +rm -r fonts diff --git a/app/client/src/constants/ReduxActionConstants.tsx b/app/client/src/constants/ReduxActionConstants.tsx index 4976463c80..86d6676eae 100644 --- a/app/client/src/constants/ReduxActionConstants.tsx +++ b/app/client/src/constants/ReduxActionConstants.tsx @@ -1,6 +1,6 @@ import { WidgetProps, WidgetCardProps } from "../widgets/BaseWidget"; -export const ReduxActionTypes = { +export const ReduxActionTypes: { [key: string]: string } = { LOAD_CANVAS_WIDGETS: "LOAD_CANVAS_WIDGETS", FETCH_CANVAS: "FETCH_CANVAS", CLEAR_CANVAS: "CLEAR_CANVAS", @@ -27,6 +27,11 @@ export const ReduxActionTypes = { SAVE_PAGE_SUCCESS: "SAVE_PAGE_SUCCESS", SAVE_PAGE_ERROR: "SAVE_PAGE_ERROR", FETCH_PAGE_ERROR: "FETCH_PAGE_ERROR", + UPDATE_LAYOUT: "UPDATE_LAYOUT", + WIDGET_ADD_CHILD: "WIDGET_ADD_CHILD", + WIDGET_REMOVE_CHILD: "WIDGET_REMOVE_CHILD", + WIDGET_MOVE: "WIDGET_MOVE", + WIDGET_RESIZE: "WIDGET_RESIZE", }; export type ReduxActionType = (typeof ReduxActionTypes)[keyof typeof ReduxActionTypes]; diff --git a/app/client/src/editorComponents/ButtonComponent.tsx b/app/client/src/editorComponents/ButtonComponent.tsx index 2fb5efa485..2bfab3a0fd 100644 --- a/app/client/src/editorComponents/ButtonComponent.tsx +++ b/app/client/src/editorComponents/ButtonComponent.tsx @@ -5,6 +5,7 @@ import { Container } from "./ContainerComponent"; class ButtonComponent extends React.Component { render() { + console.log("button props", this.props); return (