mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-19 05:40:44 +00:00
SPRINT-18: fixed to dashboards, removed and moved around all the things
This commit is contained in:
119
src/qqq/components/legacy/MDBadgeDot/index.tsx
Normal file
119
src/qqq/components/legacy/MDBadgeDot/index.tsx
Normal file
@ -0,0 +1,119 @@
|
||||
/* QQQ - Low-code Application Framework for Engineers.
|
||||
* Copyright (C) 2021-2022. Kingsrook, LLC
|
||||
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||
* contact@kingsrook.com
|
||||
* https://github.com/Kingsrook/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Box from "@mui/material/Box";
|
||||
import {FC, forwardRef} from "react";
|
||||
import MDTypography from "qqq/components/legacy/MDTypography";
|
||||
|
||||
// declaring props types for MDBadgeDot
|
||||
interface Props
|
||||
{
|
||||
variant?: "gradient" | "contained";
|
||||
color?: string;
|
||||
size?: "xs" | "sm" | "md" | "lg";
|
||||
badgeContent: string;
|
||||
font?:
|
||||
| {
|
||||
color: string;
|
||||
weight: string;
|
||||
}
|
||||
| any;
|
||||
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
const MDBadgeDot: FC<Props> = forwardRef(
|
||||
({variant, color, size, badgeContent, font = {}, ...rest}, ref) =>
|
||||
{
|
||||
let finalSize;
|
||||
let fontSize: any;
|
||||
let padding;
|
||||
|
||||
if (size === "sm")
|
||||
{
|
||||
finalSize = "0.5rem";
|
||||
fontSize = "caption";
|
||||
padding = "0.45em 0.775em";
|
||||
}
|
||||
else if (size === "lg")
|
||||
{
|
||||
finalSize = "0.625rem";
|
||||
fontSize = "body2";
|
||||
padding = "0.85em 1.375em";
|
||||
}
|
||||
else if (size === "md")
|
||||
{
|
||||
finalSize = "0.5rem";
|
||||
fontSize = "button";
|
||||
padding = "0.65em 1em";
|
||||
}
|
||||
else
|
||||
{
|
||||
finalSize = "0.375rem";
|
||||
fontSize = "caption";
|
||||
padding = "0.45em 0.775em";
|
||||
}
|
||||
|
||||
const validColors = [
|
||||
"primary",
|
||||
"secondary",
|
||||
"info",
|
||||
"success",
|
||||
"warning",
|
||||
"error",
|
||||
"light",
|
||||
"dark",
|
||||
];
|
||||
|
||||
const validColorIndex = validColors.findIndex((el) => el === color);
|
||||
|
||||
return (
|
||||
<Box ref={ref} display="flex" alignItems="center" p={padding} {...rest}>
|
||||
<Box
|
||||
component="i"
|
||||
display="inline-block"
|
||||
width={finalSize}
|
||||
height={finalSize}
|
||||
borderRadius="50%"
|
||||
mr={1}
|
||||
sx={{backgroundColor: validColors[validColorIndex]}}
|
||||
/>
|
||||
<MDTypography
|
||||
variant={fontSize}
|
||||
fontWeight={font.weight ? font.weight : "regular"}
|
||||
color={font.color ? font.color : "dark"}
|
||||
sx={{lineHeight: 0}}
|
||||
>
|
||||
{badgeContent}
|
||||
</MDTypography>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
// Declaring default props for MDBadgeDot
|
||||
MDBadgeDot.defaultProps = {
|
||||
variant: "contained",
|
||||
color: "info",
|
||||
size: "xs",
|
||||
font: {},
|
||||
};
|
||||
|
||||
export default MDBadgeDot;
|
Reference in New Issue
Block a user