This commit is contained in:
MuhammadKhalilzadeh committed 2024-05-11 09:59:12 +03:30
commit e4ab6b3e0d
59 files changed
+1735 -5893

No files matched your search

+27 -3
View File
@@ -1,9 +1,33 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
function App() {
return (
<>
<div></div>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.jsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
);
)
}
export default App;
export default App
+42
View File
@@ -0,0 +1,42 @@
import { Avatar as MuiAvatar } from "@mui/material";
import PropTypes from "prop-types";
/**
* @component
* @param {Object} props
* @param {string} props.src - Path to image for avatar
* @param {string} props.firstName - The users first name
* @param {string} props.lastName - The users last name
* @param {boolean} props.small - Specifies if avatar should be large
* @returns {JSX.Element}
* @example
* // Render a red label
* <Avatar src="assets/img" first="Alex" last="Holliday" small />
*/
const Avatar = ({ src, firstName, lastName, small }) => {
const borderColor = "#F0F2F4";
const smallStyle = small ? { width: 32, height: 32 } : {};
return (
<MuiAvatar
alt={`${firstName} ${lastName}`}
src={src}
sx={{
display: "inline-flex",
border: `0.2rem solid ${borderColor}`,
...smallStyle,
}}
>
{src === undefined ? `${firstName[0]}${lastName[0]}` : null}
</MuiAvatar>
);
};
Avatar.propTypes = {
src: PropTypes.string,
firstName: PropTypes.string.isRequired,
lastName: PropTypes.string.isRequired,
small: PropTypes.bool,
};
export default Avatar;
Whitespace-only changes.
Whitespace-only changes.
+49
View File
@@ -0,0 +1,49 @@
import { Button as MuiButton } from "@mui/material";
import PropTypes from "prop-types";
const levelConfig = {
primary: {
variant: "contained",
color: "primary",
},
secondary: {
variant: "outlined",
color: "secondary",
},
tertiary: {
variant: "text",
color: "tertiary",
},
error: {
variant: "contained",
color: "error",
},
};
/**
* @param {Object} props
* @param {'primary' | 'secondary' | 'tertiary' | 'error'} props.level - The level of the button
* @param {string} props.label - The label of the button
* @param {boolean} [props.disabled] - Whether the button is disabled
* @returns {JSX.Element}
* @example
* // Render an error button
* <Button level="error" label="Error" disabled />
*/
const Button = ({ level, label, disabled }) => {
const { variant, color } = levelConfig[level];
return (
<MuiButton variant={variant} color={color} disabled={disabled}>
{label}
</MuiButton>
);
};
Button.propTypes = {
level: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
disabled: PropTypes.bool,
};
export default Button;
+1
View File
@@ -0,0 +1 @@
/* dropdown styles*/
+28
View File
@@ -0,0 +1,28 @@
import PropTypes from 'prop-types';
import Autocomplete from '@mui/material/Autocomplete';
import TextField from '@mui/material/TextField';
const Dropdown = ({ id, label, options, onChange, value }) => {
return (
<Autocomplete
id={id}
options={options}
getOptionLabel={(option) => option.name}
value={value}
onChange={onChange}
renderInput={(params) => <TextField {...params} label={label} />}
/>
);
};
// Define PropTypes for DropDown component
Dropdown.propTypes = {
id: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
options: PropTypes.array.isRequired,
onChange: PropTypes.func.isRequired,
value: PropTypes.object.isRequired,
};
export default Dropdown;
@@ -0,0 +1 @@
/*Dropdown Team Member styles*/
@@ -0,0 +1,39 @@
import { useState } from 'react'
import '@fontsource/roboto/300.css';
import '@fontsource/roboto/400.css';
import '@fontsource/roboto/500.css';
import '@fontsource/roboto/700.css';
// import DropDown from './Dropdown';
import DropDown from '../Dropdown'
const DropdownTeamMember = () => {
const [selectedTeamMember, setSelectedTeamMember] = useState(null);
const teamMembers = [
{ id: 1, name: 'John Doe' },
{ id: 2, name: 'Jane Smith' },
{ id: 3, name: 'Alex Johnson' },
// more team members...
];
const handleTeamMemberChange = (event, value) => {
setSelectedTeamMember(value);
};
return (
<>
<div className="app-container" style={{ width: '500px' }}>
<DropDown
id="team-member-autocomplete"
options={teamMembers}
label="Select team member"
value={selectedTeamMember}
onChange={handleTeamMemberChange}
/>
</div>
</>
);
}
export default DropdownTeamMember
@@ -0,0 +1,7 @@
.label {
border: 1px solid #000;
display: inline-flex;
justify-content: center;
align-items: center;
line-height: normal;
}
+54
View File
@@ -0,0 +1,54 @@
import PropTypes from "prop-types";
import "./BaseLabel.css";
import { useTheme } from "@mui/material";
/**
* @typedef {Object} Styles
* @param {string} [color] - The text color
* @param {string} [backgroundColor] - The background color
* @param {string} [borderColor] - The border color
*/
/**
* @component
* @param {Object} props
* @param {string} props.label - The label of the label
* @param {Styles} props.styles - CSS Styles passed from parent component
* @param {React.ReactNode} children - Children passed from parent component
* @returns {JSX.Element}
*/
const BaseLabel = ({ label, styles, children }) => {
const theme = useTheme();
// Grab the default borderRadius from the theme to match button style
const { borderRadius } = theme.shape;
// Calculate padding for the label to mimic button. Appears to scale correctly, not 100% sure though.
const padding = theme.spacing(1 * 0.75, 2);
return (
<div
className="label"
style={{
borderRadius: borderRadius,
borderColor: theme.palette.tertiary.main,
color: theme.palette.tertiary.main,
padding: padding,
...styles,
}}
>
{children}
{label}
</div>
);
};
BaseLabel.propTypes = {
label: PropTypes.string.isRequired,
styles: PropTypes.shape({
color: PropTypes.string,
backgroundColor: PropTypes.string,
}),
children: PropTypes.node,
};
export default BaseLabel;
@@ -0,0 +1,67 @@
import { useTheme } from "@mui/material";
import { PropTypes } from "prop-types";
import BaseLabel from "./BaseLabel";
// Produces a lighter color based on a hex color and a percent
// lightenColor("#067647", 20) will produce a color 20% lighter than #067647
const lightenColor = (color, percent) => {
let r = parseInt(color.substring(1, 3), 16);
let g = parseInt(color.substring(3, 5), 16);
let b = parseInt(color.substring(5, 7), 16);
const amt = Math.round((255 * percent) / 100);
r = r + amt <= 255 ? r + amt : 255;
g = g + amt <= 255 ? g + amt : 255;
b = b + amt <= 255 ? b + amt : 255;
r = r.toString(16).padStart(2, "0");
g = g.toString(16).padStart(2, "0");
b = b.toString(16).padStart(2, "0");
return `#${r}${g}${b}`;
};
/**
* @component
* @param {Object} props
* @param {string} props.label - The label of the label
* @param {string} props.color - The color of the label, specified in #RRGGBB format
* @returns {JSX.Element}
* @example
* // Render a red label
* <ColoredLabel label="Label" color="#FF0000" />
*/
const ColoredLabel = ({ label, color }) => {
const theme = useTheme();
// If an invalid color is passed, default to the labelGray color
if (
typeof color !== "string" ||
!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(color)
) {
color = theme.palette.labelGray.color;
}
// Calculate lighter shades for border and bg
const borderColor = lightenColor(color, 20);
const bgColor = lightenColor(color, 75);
return (
<BaseLabel
label={label}
styles={{
color: color,
borderColor: borderColor,
backgroundColor: bgColor,
}}
></BaseLabel>
);
};
ColoredLabel.propTypes = {
label: PropTypes.string.isRequired,
color: PropTypes.string.isRequired,
};
export default ColoredLabel;
@@ -0,0 +1,46 @@
import PropTypes from "prop-types";
import BaseLabel from "./BaseLabel";
import { Box } from "@mui/material";
import { useTheme } from "@mui/material";
/**
* @component
* @param {Object} props
* @param {'Seen' | 'Waiting' | 'New' | 'Active'} props.status - The status for the label
* @returns {JSX.Element}
* @example
* // Render an active label
* <StatusLabel status="Active" />
*/
const StatusLabel = ({ status }) => {
const theme = useTheme();
const colorLookup = {
Seen: theme.palette.labelGray.color,
Waiting: theme.palette.labelRed.color,
New: theme.palette.labelOrange.color,
Active: theme.palette.labelGreen.color,
};
// Look up the color for the status, default to labelGray if not found
const color = colorLookup[status] || theme.palette.labelGray.color;
return (
<BaseLabel label={status}>
<Box
width={12}
height={12}
bgcolor={color}
borderRadius="50%"
marginRight={1}
/>
</BaseLabel>
);
};
StatusLabel.propTypes = {
status: PropTypes.oneOf(["Seen", "Waiting", "New", "Active"]),
};
export default StatusLabel;
Whitespace-only changes.
+47
View File
@@ -0,0 +1,47 @@
import { Link as MuiLink, useTheme } from "@mui/material";
import PropTypes from "prop-types";
const Link = ({ level, label, url }) => {
const theme = useTheme();
const levelConfig = {
primary: {},
secondary: {},
tertiary: {
color: theme.palette.tertiary.main,
sx: {
textDecoration: "underline",
textDecorationStyle: "dashed",
textDecorationColor: theme.palette.primary.main,
":hover": {
color: theme.palette.tertiary.main,
textDecorationColor: theme.palette.primary.main,
backgroundColor: theme.palette.tertiary.linkHover,
},
},
},
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}>
{label}
</MuiLink>
);
};
Link.propTypes = {
url: PropTypes.string.isRequired,
level: PropTypes.oneOf(["primary", "secondary", "tertiary", "error"]),
label: PropTypes.string.isRequired,
};
export default Link;
+1
View File
@@ -0,0 +1 @@
/* NavBar Component Styles*/
+10
View File
@@ -0,0 +1,10 @@
import React from 'react'
import './index.css'
const NavBar = () => {
return (
<div>NavBar Component</div>
)
}
export default NavBar
Whitespace-only changes.
@@ -0,0 +1,58 @@
import React from "react";
import { Step, Stepper, StepLabel, Typography } from "@mui/material";
import RadioButtonCheckedIcon from "@mui/icons-material/RadioButtonChecked";
import CheckCircle from "@mui/icons-material/CheckCircle";
import PropTypes from "prop-types";
const CustomStepIcon = (props) => {
const { completed, active } = props;
return completed ? (
<CheckCircle color="primary" />
) : (
<RadioButtonCheckedIcon color={active ? "primary" : "disabled"} />
);
};
CustomStepIcon.propTypes = {
completed: PropTypes.bool.isRequired,
active: PropTypes.bool.isRequired,
};
/**
* @component
* @param {Object} props
* @param {Array} props.steps
*/
const ProgressStepper = ({ steps }) => {
const [activeStep, setActiveStep] = React.useState(1);
return (
<Stepper activeStep={activeStep} alternativeLabel>
{steps.map((step, index) => {
const color = activeStep === index ? "primary" : "inherit";
return (
<Step key={step.label} onClick={() => setActiveStep(index)}>
<StepLabel StepIconComponent={CustomStepIcon}>
<Typography
variant="body1"
color={color}
sx={{ fontWeight: "bold" }}
>
{step.label}
</Typography>
</StepLabel>
<Typography variant="body1" color={color}>
{step.content}
</Typography>
</Step>
);
})}
</Stepper>
);
};
ProgressStepper.propTypes = {
steps: PropTypes.array.isRequired,
};
export default ProgressStepper;
+1
View File
@@ -0,0 +1 @@
/*Homelayout styles*/
+17
View File
@@ -0,0 +1,17 @@
import React from 'react'
import NavBar from '../../Components/NavBar'
import { Outlet } from 'react-router'
import Home from '../../Pages/Home'
import './index.css'
const HomeLayout = () => {
return (
<>
<NavBar />
<Home />
<Outlet />
</>
)
}
export default HomeLayout
View File
Whitespace-only changes.
+230
View File
@@ -0,0 +1,230 @@
import React from "react";
import Button from "../../Components/Button";
import Link from "../../Components/Link";
import ColoredLabel from "../../Components/Label/ColoredLabel";
import {
Box,
useTheme,
Switch,
Checkbox,
FormControl,
FormLabel,
FormControlLabel,
Radio,
RadioGroup,
Tab,
Tabs,
} from "@mui/material";
import StatusLabel from "../../Components/Label/StautsLabel";
import Avatar from "../../Components/Avatar/Avatar";
import ProgressStepper from "../../Components/ProgressStepper/ProgressStepper";
import avatarImage from "../../assets/Images/avatar_placeholder.png";
import { DataGrid } from "@mui/x-data-grid";
import { DatePicker } from "@mui/x-date-pickers/DatePicker";
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
const cols = [
{
field: "name",
headerName: "Name",
renderCell: (params) => {
return (
<div style={{ display: "flex", alignItems: "center" }}>
<Avatar
src={params.value.avatarImage}
firstName={params.value.firstName}
lastName={params.value.lastName}
/>
<div style={{ marginLeft: "1rem" }}>
{params.value.firstName} {params.value.lastName}
</div>
</div>
);
},
flex: 1,
},
{
field: "status",
headerName: "Status",
renderCell: (params) => {
return <StatusLabel status={params.value} />;
},
flex: 1,
},
{ field: "role", headerName: "Role", flex: 1 },
{ field: "team", headerName: "Team", flex: 1 },
{ field: "hireDate", headerName: "Hire date", flex: 1 },
];
const rows = ((count) => {
const arr = [];
for (let i = 0; i < count; i++) {
let row = {
id: i,
name: {
avatarImage: i % 2 === 0 ? avatarImage : null,
firstName: "Placeholder Name",
lastName: i.toString(),
},
status: "Active",
role: "Product Designer",
team: "Marketing",
hireDate: new Date().toLocaleDateString(),
};
arr.push(row);
}
return arr;
})(100);
const steps = [
{ label: "Your details", content: "Please provide your name and email" },
{ label: "Company details", content: "A few details about your company" },
{ label: "Invite your team", content: "Start collaborating with your team" },
];
const Demo = () => {
const [radio, setRadio] = React.useState(1);
const [tab, setTab] = React.useState("departments");
const [date, setDate] = React.useState("Pick a date!");
const handleRadio = (event) => {
setRadio(event.target.value);
};
const handleTab = (event, newValue) => {
setTab(newValue);
};
const handleDate = (newValue) => {
setDate(newValue.toString());
};
const change = (event, type) => {
alert(event.target.checked ? `${type} checked` : `${type} unchecked`);
};
const theme = useTheme();
return (
<div>
<h4>Buttons</h4>
<div>
<Button level="primary" label="Primary" />
<Button level="secondary" label="Secondary" />
<Button level="tertiary" label="Tertiary" />
<Button level="error" label="Error" />
</div>
<h4>Disabled Buttons</h4>
<div>
<Button level="primary" label="Primary" disabled />
<Button level="secondary" label="Secondary" disabled />
<Button level="tertiary" label="Tertiary" disabled />
<Button level="error" label="Error" disabled />
</div>
<div>
<Link
level="tertiary"
label="Tertiary Link"
url={"https://www.google.com"}
/>
</div>
<h4>Labels</h4>
<div>
<ColoredLabel label="Label" color={theme.palette.labelGray.color} />
<ColoredLabel label="Label" color={theme.palette.labelPurple.color} />
<ColoredLabel label="Label" color={theme.palette.labelGreen.color} />
<ColoredLabel label="Label" color={theme.palette.labelOrange.color} />
</div>
<h4>Status Lables</h4>
<div>
<StatusLabel status="Seen" />
<StatusLabel status="Waiting" />
<StatusLabel status="New" />
<StatusLabel status="Active" />
</div>
<h4>Avatar</h4>
<div style={{ display: "flex" }}>
<Avatar src={avatarImage} firstName="Alex" lastName="Holliday" />
<Avatar firstName="Alex" lastName="Holliday" />
<Avatar src={avatarImage} firstName="Alex" lastName="Holliday" small />
<Avatar firstName="Alex" lastName="Holliday" small />
</div>
<h4>Switches</h4>
<div>
<Switch onChange={(event) => change(event, "Switch")} />
<Switch size="small" />
<Switch disabled />
<Switch checked />
</div>
<h4>Checkboxes</h4>
<div>
<Checkbox onChange={(event) => change(event, "Checkbox")} />
<Checkbox size="small" />
<Checkbox disabled />
<Checkbox checked />
</div>
<h4>Radio</h4>
<div>
<FormControl>
<FormLabel>Demo Radio</FormLabel>
<RadioGroup value={radio} onChange={handleRadio}>
<div>
<FormControlLabel value={1} control={<Radio />} label="1" />
<FormControlLabel value={2} control={<Radio />} label="2" />
<FormControlLabel
value={3}
control={<Radio size="small" />}
label="3"
/>
<FormControlLabel
value={4}
control={<Radio disabled />}
label="4"
/>
</div>
</RadioGroup>
</FormControl>
</div>
<h4>Table</h4>
<div style={{ width: "75vw" }}>
<DataGrid
autoHeight
columns={cols}
rows={rows}
initialState={{
pagination: {
paginationModel: { page: 0, pageSize: 10 },
},
}}
pageSizeOptions={[5, 10]}
/>
</div>
<h4>Tabs</h4>
<div style={{ display: "flex", justifyContent: "center" }}>
{" "}
<Tabs value={tab} onChange={handleTab}>
<Tab label="My details" value="details" />
<Tab label="My team" value="team" />
<Tab label="Departments" value="departments" />
<Tab label="Approvals" value="approvals" />
</Tabs>
</div>
<h4>Date Picker</h4>
<div>
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DatePicker onChange={handleDate} />
</LocalizationProvider>
<h4>{date}</h4>
</div>
<h4>Stepper</h4>
<div>
<ProgressStepper steps={steps}></ProgressStepper>
</div>
</div>
);
};
export default Demo;
+1
View File
@@ -0,0 +1 @@
/* Home Page Styles*/
+13
View File
@@ -0,0 +1,13 @@
import DropdownTeamMember from "../../Components/DropdownTeamMember";
import "./index.css";
const Home = () => {
return (
<>
<div>Home</div>
<DropdownTeamMember />
</>
);
};
export default Home;
+1
View File
@@ -0,0 +1 @@
/*Login styles*/
+10
View File
@@ -0,0 +1,10 @@
import React from 'react'
import './index.css'
const Login = () => {
return (
<div>Login</div>
)
}
export default Login
+1
View File
@@ -0,0 +1 @@
/*Notfoundpage styles*/
+10
View File
@@ -0,0 +1,10 @@
import React from 'react'
import './index.css'
const NotFound = () => {
return (
<div>NotFoundPage</div>
)
}
export default NotFound
+1
View File
@@ -0,0 +1 @@
#Pages Folder
+1
View File
@@ -0,0 +1 @@
/*REgister styles*/
+9
View File
@@ -0,0 +1,9 @@
import React from 'react'
const Register = () => {
return (
<div>Register</div>
)
}
export default Register
+1
View File
@@ -0,0 +1 @@
#Utils folder
+45
View File
@@ -0,0 +1,45 @@
import { createTheme } from "@mui/material";
// Colors for MUI theme
const primaryMain = "#1570EF";
const secondaryMain = "#475467";
const tertiaryMain = "#475467";
const tertiaryLinkHover = "#eff8ff";
// Label Colors
const labelOrange = "#F79009";
const labelGray = "#475467";
const labelPurple = "#6941C6";
const labelGreen = "#067647";
const labelRed = "#F04438";
const theme = createTheme({
palette: {
primary: {
main: primaryMain,
},
secondary: {
main: secondaryMain,
},
tertiary: {
main: tertiaryMain,
linkHover: tertiaryLinkHover,
},
labelOrange: {
color: labelOrange,
},
labelGray: {
color: labelGray,
},
labelPurple: {
color: labelPurple,
},
labelGreen: {
color: labelGreen,
},
labelRed: {
color: labelRed,
},
},
});
export default theme;
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

+73
View File
@@ -0,0 +1,73 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
+9 -7
View File
@@ -1,14 +1,16 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App.jsx";
import "@fontsource/roboto/300.css";
import "@fontsource/roboto/400.css";
import "@fontsource/roboto/500.css";
import "@fontsource/roboto/700.css";
import "./index.css";
import { BrowserRouter as Router, HashRouter } from "react-router-dom";
import theme from "./Utils/Theme.js";
import { ThemeProvider } from "@mui/material";
ReactDOM.createRoot(document.getElementById("root")).render(
<React.StrictMode>
<App />
<ThemeProvider theme={theme}>
<Router>
<App />
</Router>
</ThemeProvider>
</React.StrictMode>
);