Merge branch 'bluewave-labs:master' into syncings_2

This commit is contained in:
Mohammad Khalilzadeh authored and GitHub committed 2024-05-12 21:35:47 +03:30
commit 5388678859
10 files changed
+335 -30

No files matched your search

@@ -18,23 +18,47 @@ const levelConfig = {
variant: "contained",
color: "error",
},
imagePrimary: {
color: "primary",
variant: "text",
},
imageSecondary: {
color: "secondary",
variant: "text",
},
imageTertiary: {
color: "tertiary",
variant: "text",
},
};
/**
* @component
* @param {Object} props
* @param {'primary' | 'secondary' | 'tertiary' | 'error'} props.level - The level of the button
* @param {'primary' | 'secondary' | 'tertiary' | 'error' | 'imagePrimary' | 'imageSecondary' | 'imageTertiary'} props.level - The level of the button
* @param {string} props.label - The label of the button
* @param {React.ReactNode} props.img - Image for button
* @param {boolean} [props.disabled] - Whether the button is disabled
* @param {Object} prps.sx - Styles for the button
* @returns {JSX.Element}
* @example
* // Render an error button
* <Button level="error" label="Error" disabled />
* <Button level="error" label="Error" disabled sx={{marginTop: "1rem"}}/>
*/
const Button = ({ level, label, disabled }) => {
const Button = ({ level, label, disabled, img, sx }) => {
const { variant, color } = levelConfig[level];
return (
<MuiButton variant={variant} color={color} disabled={disabled}>
<MuiButton
variant={variant}
color={color}
disabled={disabled}
sx={{
textTransform: "none",
...sx,
}}
>
{img && img}
{label}
</MuiButton>
);
@@ -43,6 +67,8 @@ const Button = ({ level, label, disabled }) => {
Button.propTypes = {
level: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
img: PropTypes.node,
sx: PropTypes.object,
disabled: PropTypes.bool,
};
File renamed without changes.
@@ -1,6 +1,15 @@
import { Link as MuiLink, useTheme } from "@mui/material";
import PropTypes from "prop-types";
/**
* @component
* @param {Object} props
* @param {'primary' | 'secondary' | 'tertiary' | 'error'} props.level - The level of the link
* @param {string} props.label - The label of the link
* @param {string} props.url - The URL of the link
* @returns {JSX.Element}
*/
const Link = ({ level, label, url }) => {
const theme = useTheme();
@@ -22,14 +31,6 @@ const Link = ({ level, label, url }) => {
},
error: {},
};
/**
* @typedef {Object} Props
* @property {'primary' | 'secondary' | 'tertiary' | 'error'} level - The level of the link
* @property {string} label - The label of the link
* @property {string} url - The URL of the link
*/
const { sx, color } = levelConfig[level];
return (
<MuiLink href={url} sx={sx} color={color}>
Whitespace-only changes.
+49
View File
@@ -0,0 +1,49 @@
import Autocomplete from '@mui/material/Autocomplete';
import TextField from '@mui/material/TextField';
import Chip from '@mui/material/Chip';
import Box from '@mui/material/Box';
import { useTheme } from "@mui/material";
const teamMembers = [
{ title: 'John Doe'},
{ title: 'Jane Smith'},
{ title: 'Alex Johnson'},
];
/**
* @component
* @returns {JSX.Element}
*/
export default function Search()
{
const theme = useTheme();
return (
<Box padding={theme.spacing(2)}> {/* Add padding to the container */}
<Autocomplete
multiple
id="tags-outlined"
options={teamMembers}
getOptionLabel={(option) => option.title}
filterSelectedOptions
renderInput={(params) => (
<TextField
{...params}
label="Team Members"
placeholder="Favorites"
/>
)}
renderTags={(value, getTagProps) =>
value.map((option) => (
<Chip
key={option.title}
variant="outlined"
label={option.title}
{...getTagProps({ option })}
/>
))
}
/>
</Box>
);
}
+133
View File
@@ -0,0 +1,133 @@
import PropTypes from "prop-types";
import { useState, useEffect } from "react";
import {
Box,
Container,
useTheme,
Typography,
TextField,
Switch,
} from "@mui/material";
import MenuIcon from "@mui/icons-material/Menu";
import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
import Button from "../Button/Button";
import AddIcon from "@mui/icons-material/Add";
/**
* @component
* @param {Object} props
* @param { Array} props.montitors - Array of monitors associated with the section
* @returns {JSX.Element}
* @example
* // Renders a section component with a list of monitors
* <Section monitors={monitors} />
*/
const Section = ({ monitors }) => {
const [monitorStates, setMonitorStates] = useState(
monitors.map((monitor) => monitor.isActive)
);
useEffect(() => {
console.log("Monitor states updated", monitorStates);
// Update DB here
}, [monitorStates]);
const handleMonitor = (monitorIndex) => {
setMonitorStates((prevStates) => {
const newStates = [...prevStates];
newStates[monitorIndex] = !newStates[monitorIndex];
return newStates;
// Need to update DB with new monitor state
});
};
const theme = useTheme();
return (
<>
<Container
disableGutters
sx={{
border: `1px solid ${theme.palette.section.borderColor}`,
borderRadius: `${theme.shape.borderRadius}px`,
}}
>
<Box
sx={{
textAlign: "left",
padding: `${theme.spacing(2)}`,
bgcolor: `${theme.palette.section.bgColor}`,
borderBottom: `1px solid ${theme.palette.section.borderColor}`,
}}
>
<Typography>Section Name</Typography>
<TextField
placeholder="Service Name"
sx={{
"& input": {
width: "320px",
height: "34px",
padding: "10px 14px 10px 14px",
},
}}
/>
</Box>
<Box
sx={{
display: "flex",
flexDirection: "column",
alignItems: "start",
textAlign: "left",
padding: `${theme.spacing(2)}`,
gap: 2,
}}
>
<Typography>Servers List</Typography>
<Button level="primary" label="Add new" />
{monitors.map((monitor, index) => {
return (
<Box
key={monitor.id}
sx={{
boxSizing: "border-box",
width: "100%",
padding: "10px 14px 10px 14px",
display: "flex",
alignItems: "center",
justifyContent: "space-between",
border: `1px solid ${theme.palette.section.borderColor}`,
borderRadius: `${theme.shape.borderRadius}px`,
bgcolor: `${theme.palette.section.bgColor}`,
}}
>
<MenuIcon
sx={{ color: `${theme.palette.section.borderColor}` }}
/>
<Switch
checked={monitorStates[index]}
onChange={() => handleMonitor(index)}
/>
<Typography sx={{ flexGrow: 1 }}>{monitor.name}</Typography>
<DeleteOutlineIcon
sx={{ color: `${theme.palette.section.borderColor}` }}
/>
</Box>
);
})}
</Box>
</Container>
<Button
sx={{ marginTop: theme.spacing(2) }}
level="imageSecondary"
label="Add new section"
img={<AddIcon />}
/>
</>
);
};
Section.propTypes = {
monitors: PropTypes.array,
};
export default Section;