From 3d5ae417b826700a245850806286cde327686e10 Mon Sep 17 00:00:00 2001 From: ashik-75 Date: Sun, 17 Sep 2023 14:58:17 +0600 Subject: [PATCH 1/3] added --- ui/src/assets/grid.svg | 4 ++ .../General/DropdownDownloadButton/index.tsx | 48 +++++++++++++++++++ .../DropdownDownloadButton/utils/types.ts | 5 ++ .../General/FormComponents/index.tsx | 10 ++++ ui/src/index.css | 5 ++ ui/src/pages/Data/Avatar/index.tsx | 30 ++++++++---- .../ImageGeneratorFromColors.module.scss | 18 +++++++ .../Data/ImageGeneratorFromColors/index.tsx | 11 ++++- ui/src/pages/Data/QRcode/index.tsx | 9 +++- ui/src/pages/Data/QRcode/utils/helper.ts | 4 +- 10 files changed, 129 insertions(+), 15 deletions(-) create mode 100644 ui/src/assets/grid.svg create mode 100644 ui/src/components/General/DropdownDownloadButton/index.tsx create mode 100644 ui/src/components/General/DropdownDownloadButton/utils/types.ts diff --git a/ui/src/assets/grid.svg b/ui/src/assets/grid.svg new file mode 100644 index 00000000..3fcabbb6 --- /dev/null +++ b/ui/src/assets/grid.svg @@ -0,0 +1,4 @@ + + + diff --git a/ui/src/components/General/DropdownDownloadButton/index.tsx b/ui/src/components/General/DropdownDownloadButton/index.tsx new file mode 100644 index 00000000..cc060260 --- /dev/null +++ b/ui/src/components/General/DropdownDownloadButton/index.tsx @@ -0,0 +1,48 @@ +import { MenuProps } from "antd"; +import React from "react"; +import { ResponsiveDropdownButton } from "../FormComponents"; +import Icon from "../Icon"; +import { DropdownDownloadButtonPropsType } from "./utils/types"; +const imageType = { + jpeg: ".jpeg", + png: ".png", +}; + +const DropdownDownloadButton: React.FC = ({ + handleDownload, +}) => { + const handleMenuClick: MenuProps["onClick"] = (e) => { + handleDownload(e.key); + }; + + const items: MenuProps["items"] = [ + { + label: "Download Jpeg", + key: imageType.jpeg, + }, + { + label: "Download Png", + key: imageType.png, + }, + ]; + + const menuProps = { + items, + onClick: handleMenuClick, + }; + + return ( + } + placement="top" + onClick={() => handleDownload(imageType.png)} + > + Download + + ); +}; + +export { imageType }; + +export default DropdownDownloadButton; diff --git a/ui/src/components/General/DropdownDownloadButton/utils/types.ts b/ui/src/components/General/DropdownDownloadButton/utils/types.ts new file mode 100644 index 00000000..bc0f32ec --- /dev/null +++ b/ui/src/components/General/DropdownDownloadButton/utils/types.ts @@ -0,0 +1,5 @@ +interface DropdownDownloadButtonPropsType { + handleDownload: (val: string) => void; +} + +export type { DropdownDownloadButtonPropsType }; diff --git a/ui/src/components/General/FormComponents/index.tsx b/ui/src/components/General/FormComponents/index.tsx index 0983dfcd..d48cf925 100644 --- a/ui/src/components/General/FormComponents/index.tsx +++ b/ui/src/components/General/FormComponents/index.tsx @@ -5,6 +5,7 @@ import { Select, Button as AntButton, ButtonProps, + Dropdown, } from "antd"; import React from "react"; import withLabelSize from "components/Hoc/withLabelSize"; @@ -14,6 +15,7 @@ import { SelectComponentPropsType, } from "./utils/types"; import withSize from "components/Hoc/withSize"; +import { DropdownButtonProps } from "antd/es/dropdown"; const ResponsiveSelect: React.FC = (props) => { return