Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
ashik-75 committed Sep 17, 2023
1 parent b502033 commit 4c08974
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 41 deletions.
4 changes: 2 additions & 2 deletions ui/src/assets/grid.svg → ui/src/assets/grid_back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions ui/src/components/General/DropdownDownloadButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const DropdownDownloadButton: React.FC<DropdownDownloadButtonPropsType> = ({

const items: MenuProps["items"] = [
{
label: "Download Jpeg",
label: "Download JPEG",
key: imageType.jpeg,
},
{
label: "Download Png",
label: "Download PNG",
key: imageType.png,
},
];
Expand All @@ -43,6 +43,4 @@ const DropdownDownloadButton: React.FC<DropdownDownloadButtonPropsType> = ({
);
};

export { imageType };

export default DropdownDownloadButton;
2 changes: 1 addition & 1 deletion ui/src/components/General/FormComponents/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const DropdownButton: React.FC<DropdownButtonProps> = ({
children,
...props
}) => {
return <Dropdown.Button {...props}>Download</Dropdown.Button>;
return <Dropdown.Button {...props}>{children}</Dropdown.Button>;
};
const ResponsiveSelectWithLabel = withLabelSize(ResponsiveSelect);
const ResponsiveSegementWithLabel = withLabelSize(ResponsiveSegment);
Expand Down
15 changes: 4 additions & 11 deletions ui/src/components/General/Warning/Warning.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@

/* Style for the Warning component */
.warning {
display: flex; /* Use flexbox to center content */
align-items: center; /* Center vertically */
justify-content: center; /* Center horizontally */
height: auto; /* Allow the component to adjust its height based on content */
padding: 16px; /* Add padding for spacing */
// background-color: #ffec3d; /* Set background color */
// color: #000; /* Set text color */
// border: 1px solid #f0d500; /* Add a border */
border-radius: 4px; /* Add border-radius for rounded corners */
font-size: 16px; /* Set font size */
text-align: center; /* Center text */
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
10 changes: 4 additions & 6 deletions ui/src/components/General/Warning/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import style from "./Warning.module.scss";
const Warning: React.FC<WarningProps> = ({ text }) => {
return (
<div className={style.warning}>
<div>
<span>
<Icon name="AlertTriangle" size={30} />
</span>
<span>
<Icon name="AlertTriangle" size={30} />
</span>

<p>{text}</p>
</div>
<p>{text}</p>
</div>
);
};
Expand Down
26 changes: 10 additions & 16 deletions ui/src/pages/Data/Avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import { saveAs } from "file-saver";
import { toPng, toJpeg, toSvg } from "html-to-image";
import {
Card,
Form,
Slider,
Avatar as AntAvatar,
Space,
MenuProps,
} from "antd";
import { toPng, toJpeg } from "html-to-image";
import { Card, Form, Slider, Avatar as AntAvatar, Space } from "antd";
import ColorPickerWithInput from "components/General/ColorPickerWithInput";
import WebFont from "webfontloader";
import {
Expand All @@ -25,9 +17,7 @@ import {
} from "./utils/constants";
import InputGrid from "components/Layouts/InputGrid";
import style from "./Avatar.module.scss";
import DropdownDownloadButton, {
imageType,
} from "components/General/DropdownDownloadButton";
import DropdownDownloadButton from "components/General/DropdownDownloadButton";

const Avatar = () => {
const [text, setText] = useState<string>("BT");
Expand All @@ -49,14 +39,18 @@ const Avatar = () => {
if (!domEl.current || text.length === 0) return;
let dataUrl;

if (ext === imageType.jpeg) {
if (ext === ".jpeg") {
dataUrl = await toJpeg(domEl.current);
} else {
dataUrl = await toPng(domEl.current);
}

const blob = await fetch(dataUrl).then((res) => res.blob());
saveAs(blob, `image-${Date.now()}${ext}`);
const a = document.createElement("a");
a.download = `image-${Date.now()}${ext}`;
a.href = dataUrl;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
};

// Load the selected font when it changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}

&__background {
background: url("../../../assets/grid.svg") repeat;
background: url("../../../assets/grid_back.svg") repeat;
position: absolute;
inset: 0;
}
Expand Down

0 comments on commit 4c08974

Please sign in to comment.