From 5d4c303b4af03851574125658dca65d4bb5220b1 Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Thu, 8 Sep 2022 02:10:53 +0200 Subject: [PATCH] Working "hide not selected" overlay button --- index.html | 2 +- src/components/CourseVisibility.jsx | 4 ++-- src/components/EventsView.jsx | 16 ++++++++-------- src/main.jsx | 24 ++++++++++++++++++++---- src/styles/main.scss | 5 ++++- 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index ec81967..53bf0e1 100644 --- a/index.html +++ b/index.html @@ -9,7 +9,7 @@ - + diff --git a/src/components/CourseVisibility.jsx b/src/components/CourseVisibility.jsx index a64ec18..cd5258e 100644 --- a/src/components/CourseVisibility.jsx +++ b/src/components/CourseVisibility.jsx @@ -1,11 +1,11 @@ import { Icon } from './Icon.jsx' -export const ToolOverlay = ({ visibility, toggleVisibility }) => ( +export const ToolOverlay = ({ visibility, toggleVisibility, onClose }) => (
-
diff --git a/src/components/EventsView.jsx b/src/components/EventsView.jsx index f836eb4..3ba109c 100644 --- a/src/components/EventsView.jsx +++ b/src/components/EventsView.jsx @@ -127,8 +127,6 @@ const WorkWeekView = ({ events }) => { const WorkWeekVerticalView = ({ events, selection, setSelection, hideOtherCourses }) => { const selectionSet = new Set(selection) - console.log(hideOtherCourses) - const eventsByWeekday = _.groupBy( !hideOtherCourses ? events : events.filter(e => selectionSet.has(e.name)), event => event.start.getDay() @@ -273,10 +271,14 @@ const WorkWeekVerticalView = ({ events, selection, setSelection, hideOtherCourse ) } -const CourseView = ({ events, selection, setSelection }) => { - const eventsByCourse = _.groupBy(events, 'name') +const CourseView = ({ events, selection, setSelection, hideOtherCourses }) => { const selectionSet = new Set(selection) + const eventsByCourse = _.groupBy( + !hideOtherCourses ? events : events.filter(e => selectionSet.has(e.name)), + 'name' + ) + const [currentlyHovered, setCurrentlyHovered] = useState(null) const element = useRef() @@ -312,7 +314,7 @@ const CourseView = ({ events, selection, setSelection }) => { data-course-id={name} onClick={() => { if (!selectionSet.has(name)) setSelection([...selection, name]) - else setSelection(selection.filter(name => name !== name)) + else setSelection(selection.filter(n => n !== name)) }} >
@@ -351,11 +353,9 @@ const viewModeMap = { export const EventsView = ({ mode, ...viewProps }) => { const Mode = viewModeMap[mode] - const [selectedCourses, setSelectedCourses] = useState([]) - return (
- +
) } diff --git a/src/main.jsx b/src/main.jsx index 4db7ddc..d3e6b27 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -45,11 +45,21 @@ const App = ({}) => { console.log(hideOtherCourses) + const [selectedCourses, setSelectedCourses] = useState([]) + + useEffect(() => { + if (selectedCourses.length === 0) { + setHideOtherCourses(false) + } + }, [selectedCourses]) + return ( <> ({ @@ -65,10 +75,16 @@ const App = ({}) => { ), }))} /> - setHideOtherCourses(s => !s)} - /> + {selectedCourses.length > 0 && ( + setHideOtherCourses(s => !s)} + onClose={() => { + setSelectedCourses([]) + setHideOtherCourses(false) + }} + /> + )} ) } diff --git a/src/styles/main.scss b/src/styles/main.scss index 06b9148..d9172d1 100644 --- a/src/styles/main.scss +++ b/src/styles/main.scss @@ -35,6 +35,7 @@ html { --accent-100: #d6ffc2; --accent-400: #6cc16c; --accent-500: #5aa05a; + --accent-900: #244624; } $device-s-width: 480px; @@ -407,7 +408,7 @@ body { position: relative; display: grid; - grid-template-columns: max-content repeat(5, auto); + grid-template-columns: max-content repeat(5, minmax(auto, 1fr)); height: 100%; @@ -608,6 +609,8 @@ body { font-size: 22px; } + color: var(--accent-900); + box-shadow: 0 0.25rem 0.75rem #00000033; } }