visuddhinanda 2 anos atrás
pai
commit
c18f811ae0
1 arquivos alterados com 43 adições e 0 exclusões
  1. 43 0
      dashboard/src/components/template/Toggle.tsx

+ 43 - 0
dashboard/src/components/template/Toggle.tsx

@@ -0,0 +1,43 @@
+import { Tree } from "antd";
+import { Children } from "react";
+
+interface IToggleCtlWidget {
+  children?: React.ReactNode | React.ReactNode[];
+}
+const ToggleCtl = ({ children }: IToggleCtlWidget) => {
+  const arrayChildren = Children.toArray(children);
+  if (arrayChildren.length === 0) {
+    return <></>;
+  } else {
+    return (
+      <Tree
+        treeData={[
+          {
+            title: arrayChildren[0],
+            key: "root",
+            children: Children.map(arrayChildren, (child, index) => {
+              if (index === 0) {
+                return undefined;
+              } else {
+                return {
+                  title: child as React.ReactElement,
+                  key: index,
+                };
+              }
+            }),
+          },
+        ]}
+      />
+    );
+  }
+};
+
+interface IWidget {
+  props?: string;
+  children?: React.ReactNode | React.ReactNode[];
+}
+const ToggleWidget = ({ props, children }: IWidget) => {
+  return <ToggleCtl>{children}</ToggleCtl>;
+};
+
+export default ToggleWidget;