Skip to content

Commit

Permalink
feat: ui widgets editable name
Browse files Browse the repository at this point in the history
  • Loading branch information
fgarrec0397 committed Jan 3, 2023
1 parent 80fecc5 commit bc09ea4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ const styles: EditWidgetModalStyles = {

const EditWidgetModal: FC<EditWidgetModalProps> = ({ widget, iconWidth = 18 }) => {
const [displayNameValue, setDisplayNameValue] = useState("");
const { displayWidgetName, getWidgetDictionaryFromWidget, selectedWidgets, updateWidgetV2 } =
useWidgets();
const { displayWidgetName, getWidgetDictionaryFromWidget, updateWidgetV2 } = useWidgets();

const onDisplayNameInputChange = ({ target }: ChangeEvent<HTMLInputElement>) => {
setDisplayNameValue(target.value);
};

const onSave = () => {
updateWidgetV2(selectedWidgets[0].id, {
...getWidgetDictionaryFromWidget(selectedWidgets[0].id),
updateWidgetV2(widget.id, {
...getWidgetDictionaryFromWidget(widget.id),
displayName: displayNameValue,
});
clearInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getColor, getTypography, pxToRem } from "@themes/utils";
import { FC } from "react";
import { css } from "styled-components";

import EditWidgetModal from "../EditorCommon/EditWidgetModal";
import EditorItemsList from "./EditorItemsList";

type EditorWidgetsUIListStyles = {
Expand Down Expand Up @@ -38,7 +39,7 @@ const styles: EditorWidgetsUIListStyles = {
};

const EditorWidgetsUIList: FC = () => {
const { addWidget, widgetsUI, removeWidget } = useWidgets();
const { addWidget, displayWidgetName, widgetsUI, removeWidget } = useWidgets();
const { widgetsUIModules } = useWidgetsModules();

const handleClickMenuItem = (widget: WidgetDictionaryItem): void => {
Expand All @@ -55,6 +56,8 @@ const EditorWidgetsUIList: FC = () => {
title="UI Widgets"
noItemsText="No UI widget on the scene."
triggerButtonText="Add UI Widget"
editModal={(row) => <EditWidgetModal widget={widgetsUI[row.id]} iconWidth={12} />}
displayItemName={displayWidgetName}
handleClickRemove={handleClickRemove}
cancelButton={{
text: "Cancel and close",
Expand Down
10 changes: 1 addition & 9 deletions app/src/Features/Widgets/EndScreen/EndScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { StyledWrapper, Typography } from "@app/Common/components/Html";
import Button from "@app/Common/components/Html/Button/Button";
import useScenes from "@app/Scenes/_actions/hooks/useScenes";
import createWidget from "@app/Widgets/_actions/utilities/createWidget";
import { FieldType, WidgetType } from "@app/Widgets/_actions/widgetsConstants";
import { WidgetType } from "@app/Widgets/_actions/widgetsConstants";
import { FC } from "react";
import { css } from "styled-components";

Expand Down Expand Up @@ -52,12 +52,4 @@ export const widget = createWidget({
reducer: null,
type: WidgetType.UI,
name: "End Screen",
options: [
{
name: "translateXOnPlay",
displayName: "Translate X on play",
fieldType: FieldType.Checkbox,
defaultValue: false,
},
],
});

0 comments on commit bc09ea4

Please sign in to comment.