From 12c0523714a1d8b45cf7e6342b9eba4468c3d084 Mon Sep 17 00:00:00 2001 From: ancoreraj Date: Wed, 2 Mar 2022 16:13:22 +0530 Subject: [PATCH 1/3] feat: created Icon node component --- packages/console/src/nodes/Icon.tsx | 99 ++++++++++++++++++++++++++++ packages/console/src/nodes/index.tsx | 3 + 2 files changed, 102 insertions(+) create mode 100644 packages/console/src/nodes/Icon.tsx diff --git a/packages/console/src/nodes/Icon.tsx b/packages/console/src/nodes/Icon.tsx new file mode 100644 index 00000000..bf4279f5 --- /dev/null +++ b/packages/console/src/nodes/Icon.tsx @@ -0,0 +1,99 @@ +import type { ReactElement } from "react"; + +import { FormGroup, Icon as MuiIcon } from "@mui/material"; + +import { useNode } from "@craftjs/core"; + +import PropertiesForm from "../screens/app-builder/panels/properties-editor/PropertiesForm"; +import type { CraftComponent, IconColor, IconFontSize } from "../types"; + +interface Props { + color?: IconColor; + fontSize?: IconFontSize | string; +} + +export const Icon: CraftComponent = (props: Props): ReactElement => { + const { color, fontSize } = props; + + const { + connectors: { connect, drag }, + } = useNode(); + + return ( +
connect(drag(ref as any))}> +
connect(drag(ref as any))}> + + + +
+
+ ); +}; + +const defaultProps: Props = { + color: "inherit", + fontSize: "24px", +}; + +Icon.craft = { + props: defaultProps, + related: { + settings: () => ( + + ), + }, +}; diff --git a/packages/console/src/nodes/index.tsx b/packages/console/src/nodes/index.tsx index fd77ae34..6f1ac9b4 100644 --- a/packages/console/src/nodes/index.tsx +++ b/packages/console/src/nodes/index.tsx @@ -3,6 +3,7 @@ import { Card, CardBottom, CardTop } from "./Card"; import { Checkbox } from "./Checkbox"; import { Container } from "./Container"; import FlexLayout from "./FlexLayout"; +import { Icon } from "./Icon"; import { Select } from "./Select"; import { Text } from "./Text"; @@ -16,6 +17,7 @@ export const nodeMappings = { FlexLayout, Select, Checkbox, + Icon, }; export * from "./Text"; @@ -25,3 +27,4 @@ export * from "./Card"; export { FlexLayout }; export * from "./Select"; export * from "./Checkbox"; +export * from "./Icon"; From c17062a87cc515dd601768447e2065c012fdc9b5 Mon Sep 17 00:00:00 2001 From: ancoreraj Date: Wed, 2 Mar 2022 16:14:06 +0530 Subject: [PATCH 2/3] feat: added types for Icon node component --- packages/console/src/types/index.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/console/src/types/index.tsx b/packages/console/src/types/index.tsx index 618038cb..e55024b7 100644 --- a/packages/console/src/types/index.tsx +++ b/packages/console/src/types/index.tsx @@ -151,3 +151,7 @@ export interface IBuilderActionsContext { activeTab: string | null; setActiveTab: (activeTab: string) => void; } + +export type IconColor = Color | "action" | "disabled"; + +export type IconFontSize = "inherit" | "large" | "medium" | "small"; From 5822aab073346de28c54eb234f54976f0c6d4025 Mon Sep 17 00:00:00 2001 From: ancoreraj Date: Wed, 2 Mar 2022 16:23:54 +0530 Subject: [PATCH 3/3] feat: added Icon component to app-builder navigation --- .../src/screens/app-builder/navigation/Components.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/console/src/screens/app-builder/navigation/Components.tsx b/packages/console/src/screens/app-builder/navigation/Components.tsx index 8d9cfb24..fed78809 100644 --- a/packages/console/src/screens/app-builder/navigation/Components.tsx +++ b/packages/console/src/screens/app-builder/navigation/Components.tsx @@ -4,6 +4,7 @@ import { styled } from "@mui/material/styles"; import { AddBoxOutlined, AddBoxTwoTone, + Apps, ArrowDropDownCircle, FormatShapes, TextFields, @@ -17,6 +18,7 @@ import { Card, Checkbox, FlexLayout, + Icon, Select, Text, } from "../../../nodes"; @@ -97,6 +99,14 @@ const Components = () => { Select + + connectors.create(ref as any, )} + variant="contained"> + + Icon + + ); };