From 16056abc273124668c924ddb971caba82bdd25ac Mon Sep 17 00:00:00 2001 From: wrzesinski-hubert Date: Fri, 16 Oct 2020 18:53:34 +0200 Subject: [PATCH] debounce i css --- package-lock.json | 13 +++++++++---- package.json | 2 ++ src/components/CourseCard.tsx | 13 +++++++++---- src/components/Rightbar.tsx | 8 +++++--- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index c6001fa..8848d71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1808,6 +1808,11 @@ "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.5.tgz", "integrity": "sha512-7+2BITlgjgDhH0vvwZU/HZJVyk+2XUlvxXe8dFMedNX/aMkaOq++rMAFXc0tM7ij15QaWlbdQASBR9dihi+bDQ==" }, + "@types/lodash": { + "version": "4.14.162", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.162.tgz", + "integrity": "sha512-alvcho1kRUnnD1Gcl4J+hK0eencvzq9rmzvFPRmP5rPHx9VVsJj6bKLTATPVf9ktgv4ujzh7T+XWKp+jhuODig==" + }, "@types/minimatch": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", @@ -2056,7 +2061,7 @@ "dependencies": { "semver": { "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "resolved": "https://npm.mlabs.pl:443/semver/-/semver-7.3.2.tgz", "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", "dev": true } @@ -8090,9 +8095,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==" }, "lodash._reinterpolate": { "version": "3.0.0", diff --git a/package.json b/package.json index f8e9576..9720188 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.5.0", "@testing-library/user-event": "^7.2.1", + "@types/lodash": "^4.14.162", "axios": "^0.19.2", + "lodash": "^4.17.20", "react": "^16.13.1", "react-dom": "^16.13.1", "react-scripts": "3.4.1", diff --git a/src/components/CourseCard.tsx b/src/components/CourseCard.tsx index 6c0bb0c..cf3a267 100644 --- a/src/components/CourseCard.tsx +++ b/src/components/CourseCard.tsx @@ -57,11 +57,16 @@ const ClassExandIconStyled = styled.img` `; const TypeClass = styled.div` + 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) => ( onGroupClick(group, course.id)}> - {group.type==="CLASS"? "(Ćw.)" : "(Wyk.)"} + {group.type==="CLASS"? "Ćw." : "Wyk."}

{group.time} {group.room}

{group.lecturer}

diff --git a/src/components/Rightbar.tsx b/src/components/Rightbar.tsx index 83a8db2..881b915 100644 --- a/src/components/Rightbar.tsx +++ b/src/components/Rightbar.tsx @@ -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) => ( ))} - + Zapisano plan!