frontend/src/components/Rightbar.tsx

64 lines
1.5 KiB
TypeScript
Raw Normal View History

2020-10-04 17:21:51 +02:00
import React, { useContext } from 'react';
import { CourseCard } from './CourseCard';
import { coursesContext } from '../contexts/CoursesProvider';
2020-08-17 20:14:19 +02:00
import styled from 'styled-components';
2020-11-21 04:02:38 +01:00
import { debounce } from '../utils/index';
2020-06-09 20:07:54 +02:00
2020-11-26 01:53:07 +01:00
const RightbarWrapper = styled.div`
padding: 15px;
2020-08-17 20:14:19 +02:00
text-align: center;
height: 100%;
2020-11-25 04:10:03 +01:00
width: 350px;
2020-08-17 20:14:19 +02:00
overflow-y: scroll;
::-webkit-scrollbar-track {
border-radius: 10px;
}
::-webkit-scrollbar {
2020-11-22 17:22:13 +01:00
width: 5px;
2020-11-25 04:10:03 +01:00
border-style: none;
2020-08-17 20:14:19 +02:00
}
::-webkit-scrollbar-thumb {
border-radius: 10px;
2020-11-22 17:22:13 +01:00
background-color: #4b4b4b;
2020-08-17 20:14:19 +02:00
}
2020-11-08 18:05:21 +01:00
background-color: white;
border-radius: 5px;
box-shadow: 3px 3px 3px -2px rgba(0, 0, 0, 0.59);
2020-08-17 20:14:19 +02:00
`;
2020-09-28 20:16:54 +02:00
const SaveButton = styled.div`
display: flex;
justify-content: center;
align-items: center;
2020-11-08 14:54:54 +01:00
user-select: none;
2020-11-26 01:53:07 +01:00
background-color: #43a047;
2020-09-28 20:16:54 +02:00
border-radius: 10px;
cursor: pointer;
height: 40px;
margin-bottom: 10px;
2020-10-01 20:06:38 +02:00
&:hover {
2020-11-26 01:53:07 +01:00
color: #ffffff;
box-shadow: 0px 5px 4px 0px rgba(0, 0, 0, 0.24);
2020-10-01 20:06:38 +02:00
}
2020-11-26 01:53:07 +01:00
&:active {
background-color: #54c457;
}
2020-12-10 21:26:09 +01:00
box-shadow: 3px 3px 3px 0px rgba(0, 0, 0, 0.75);
2020-09-28 20:16:54 +02:00
`;
2020-08-17 23:56:34 +02:00
export const Rightbar = () => {
2020-12-10 21:26:09 +01:00
const { selectBasketCourses, saveBasket, userekID } = useContext(coursesContext)!;
2020-06-30 22:09:13 +02:00
2020-11-21 04:02:38 +01:00
const basketCourses = selectBasketCourses();
2020-12-10 21:26:09 +01:00
const handleSave = debounce(() => saveBasket(userekID), 500);
2020-07-24 18:59:45 +02:00
return (
2020-11-26 01:53:07 +01:00
<RightbarWrapper>
2020-11-01 21:41:16 +01:00
<SaveButton onClick={handleSave}>ZAPISZ</SaveButton>
2020-11-26 01:53:07 +01:00
{basketCourses.map((course) => (
<CourseCard course={course} key={course.id} />
2020-07-24 18:59:45 +02:00
))}
2020-11-26 01:53:07 +01:00
</RightbarWrapper>
2020-07-24 18:59:45 +02:00
);
2020-08-17 23:56:34 +02:00
};