debounce i css

This commit is contained in:
wrzesinski-hubert
2020-10-16 18:53:34 +02:00
parent 0c7fe6348f
commit 16056abc27
4 changed files with 25 additions and 11 deletions

View File

@ -57,11 +57,16 @@ const ClassExandIconStyled = styled.img<ClassExandIconProps>`
`;
const TypeClass = styled.div<ClassGroupProps>`
font-size:12px;
position:absolute;
min-width:55px;
padding:1px;
border-radius:15px;
background-color:#00506B;
border:2px solid;
min-width:45px;
top:5px;
border-radius:1px;
left:5px;
color:white;
font-weight:bold;
`;
const useStyles = makeStyles({
@ -114,7 +119,7 @@ export const CourseCard = ({ course }: CourseCardProps) => {
.sort((a, b) => b.type.localeCompare(a.type))
.map((group, index) => (
<ClassGroupStyled key={index} onClick={() => onGroupClick(group, course.id)}>
<TypeClass groupType={group.type}>{group.type==="CLASS"? "(Ćw.)" : "(Wyk.)"}</TypeClass>
<TypeClass groupType={group.type}>{group.type==="CLASS"? "Ćw." : "Wyk."}</TypeClass>
<p>
{group.time} {group.room} <br></br> {group.lecturer}
</p>

View File

@ -4,6 +4,7 @@ import { CourseCard } from './CourseCard';
import { coursesContext } from '../contexts/CoursesProvider';
import MuiAlert, { AlertProps } from '@material-ui/lab/Alert';
import styled from 'styled-components';
import { debounce } from "lodash";
const RightbarStyled = styled.div`
padding-top: 10px;
@ -65,10 +66,11 @@ export const Rightbar = () => {
const filteredCourses = getBasketGroups();
const save = () => {
const save = debounce(() => {
saveBasket();
setOpen(true);
};
console.log("chujec")
},500);
const handleClose = (event?: React.SyntheticEvent, reason?: string) => {
if (reason === 'clickaway') {
@ -91,7 +93,7 @@ export const Rightbar = () => {
{filteredCourses.map((course, index) => (
<CourseCard course={course} key={index} />
))}
<Snackbar open={open} autoHideDuration={6000} onClose={handleClose}>
<Snackbar open={open} autoHideDuration={5000} onClose={handleClose}>
<Alert onClose={handleClose} severity="success">
Zapisano plan!
</Alert>