-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(homeworks) : add better homeworks with ony session content handl…
…ing.
- Loading branch information
1 parent
8811f40
commit 3851f09
Showing
12 changed files
with
397 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
src/components/app/Homeworks/DetailedSessionContent.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
.detailed-session-content { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 5px; | ||
flex-shrink: 0; | ||
} | ||
|
||
.session-content-header { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
gap: 10px; | ||
} | ||
|
||
.session-content-header h4 { | ||
font-size: var(--font-size-16); | ||
} | ||
|
||
.session-content-subtitle { | ||
display: flex; | ||
flex-flow: row nowrap; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
|
||
.detailed-session-content .add-date { | ||
display: inline-block; | ||
color: rgb(var(--text-color-alt)); | ||
font-size: var(--font-size-14); | ||
} | ||
|
||
.detailed-session-content .session-content-content { | ||
margin-block: 5px; | ||
padding: 15px; | ||
padding-right: 45px; | ||
border-radius: 10px; | ||
position: relative; | ||
max-height: 120px; | ||
transition: .2s; | ||
overflow: hidden; | ||
cursor: pointer; | ||
} | ||
|
||
.detailed-session-content .session-content-content:is(:hover, :focus-visible) { | ||
max-height: 150px; | ||
} | ||
|
||
.detailed-session-content .session-content-content::after { | ||
content: ""; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.dark .detailed-session-content .session-content-content { | ||
background-color: rgba(var(--text-color-main-reverse), 0.15); | ||
} | ||
|
||
.dark .detailed-session-content .session-content-content::after{ | ||
background-image: linear-gradient(0deg, #333350, transparent 60px); | ||
} | ||
|
||
.light .detailed-session-content .session-content-content { | ||
background-color: rgba(var(--text-color-main-reverse), 0.3); | ||
} | ||
|
||
.light .detailed-session-content .session-content-content::after{ | ||
background-image: linear-gradient(0deg, #b0b0e1, transparent 60px); | ||
} | ||
|
||
.detailed-session-content .session-content-content .copy-button { | ||
position: absolute; | ||
top: 7px; | ||
right: 7px; | ||
opacity: 0; | ||
transition: .1s; | ||
} | ||
|
||
.detailed-session-content .session-content-content:is(:hover, :focus-within) .copy-button { | ||
opacity: 1; | ||
} | ||
|
||
/* change session-content content items appearance */ | ||
.detailed-session-content .session-content-content a { | ||
word-break: break-all; | ||
} | ||
|
||
.detailed-session-content .session-content-content a:is(:hover, :focus-visible) { | ||
opacity: .8; | ||
} | ||
|
||
.detailed-session-content .session-content-content a:active { | ||
opacity: .6; | ||
} | ||
|
||
.session-content-footer { | ||
display: flex; | ||
flex-flow: row nowrap; | ||
justify-content: space-between; | ||
gap: 10px; | ||
} | ||
|
||
.session-content-footer .session-content-footer-button { | ||
padding: 8px; | ||
border-radius: 10px; | ||
flex: 1; | ||
background-color: rgba(var(--background-color-3), .5); | ||
color: rgb(var(--text-color-alt)); | ||
|
||
display: flex; | ||
align-items: center; | ||
transition: .1s; | ||
cursor: pointer; | ||
text-decoration: none; | ||
} | ||
|
||
.session-content-footer .session-content-footer-button.disabled { | ||
pointer-events: none; | ||
filter: brightness(0.6); | ||
} | ||
|
||
.light .session-content-footer .session-content-footer-button.disabled { | ||
pointer-events: none; | ||
filter: opacity(0.4); | ||
} | ||
|
||
.session-content-footer .session-content-footer-button:is(:hover, :focus-visible) { | ||
background-color: rgb(var(--background-color-3)); | ||
} | ||
|
||
.session-content-footer .session-content-footer-button:active { | ||
background-color: rgb(var(--background-color-3), .7); | ||
} | ||
|
||
.session-content-footer .session-content-footer-button .download-icon { | ||
height: 20px; | ||
margin-right: 10px; | ||
} | ||
.session-content-footer .session-content-footer-button .session-content-icon { | ||
height: 20px; | ||
scale: 1.5; | ||
margin-right: 7px; | ||
} | ||
.session-content-footer .session-content-footer-button svg * { | ||
stroke: rgb(var(--text-color-alt)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { useEffect, useRef, useContext } from "react" | ||
import ContentLoader from "react-content-loader" | ||
import EncodedHTMLDiv from "../../generic/CustomDivs/EncodedHTMLDiv" | ||
import CheckBox from "../../generic/UserInputs/CheckBox" | ||
import { AppContext } from "../../../App" | ||
import { applyZoom } from "../../../utils/zoom"; | ||
import { Link, useLocation, useNavigate } from "react-router-dom" | ||
import DownloadIcon from "../../graphics/DownloadIcon" | ||
|
||
import { clearHTML } from "../../../utils/html" | ||
|
||
import "./DetailedSessionContent.css" | ||
|
||
export default function DetailedSessionContent({ sessionContent, userHomeworks, day, sessionContentIndex, ...props }) { | ||
const navigate = useNavigate() | ||
|
||
const detailedTaskRef = useRef(null); | ||
const { actualDisplayTheme, fetchHomeworksDone, useUserSettings } = useContext(AppContext) | ||
const settings = useUserSettings(); | ||
const homeworks = userHomeworks.get() | ||
|
||
const contentLoadersRandomValues = useRef({ labelWidth: Math.floor(Math.random() * 100) + 200, contentHeight: Math.floor(Math.random() * 200) + 50 }) | ||
const location = useLocation(); | ||
const oldLocationHash = useRef(null); | ||
|
||
function scrollIntoViewNearestParent(element) { | ||
const parent = element.parentElement; | ||
const parentBounds = parent.getBoundingClientRect(); | ||
const bounds = element.getBoundingClientRect(); | ||
|
||
parent.scrollTo(0, bounds.y - parentBounds.y + parent.scrollTop - 20) | ||
} | ||
|
||
useEffect(() => { | ||
if (oldLocationHash.current === location.hash) { | ||
return; | ||
} | ||
|
||
oldLocationHash.current = location.hash; | ||
|
||
if (["#patch-notes", "#policy", "#feedback"].includes(location.hash)) { | ||
return; | ||
} | ||
|
||
const anchors = location.hash.split(";"); | ||
|
||
if (anchors.length < 2) { | ||
return; | ||
} | ||
|
||
const sessionContentId = parseInt(anchors[1]); | ||
|
||
if (isNaN(sessionContentId)) { | ||
return; | ||
} | ||
|
||
if (sessionContentId === sessionContent.id && detailedTaskRef.current) { | ||
setTimeout(() => scrollIntoViewNearestParent(detailedTaskRef.current), 200); | ||
} | ||
|
||
}, [location, detailedTaskRef.current, homeworks]) | ||
|
||
return <div ref={detailedTaskRef} onClick={(e) => { navigate(`#${day};${sessionContent.id}`); e.stopPropagation() }} className={`detailed-session-content ${sessionContent.isDone ? "done" : ""}`} id={"session-content-" + sessionContent.id} {...props} > | ||
<div className="session-content-header"> | ||
<h4> | ||
{sessionContent.subject.replace(". ", ".").replace(".", ". ")} | ||
</h4> | ||
</div> | ||
<div className="session-content-subtitle"> | ||
{sessionContent.addDate && <span className="add-date">Donné le {(new Date(sessionContent.addDate)).toLocaleDateString()} par {settings.get("isStreamerModeEnabled") ? "M. -------" : sessionContent.teacher}</span>} | ||
{sessionContent.isInterrogation && <span className="interrogation-alert">évaluation</span>} | ||
</div> | ||
<Link to={`#${day};${sessionContent.id};s`} onClick={(e) => e.stopPropagation()} replace={true} > | ||
<EncodedHTMLDiv className="session-content-content" backgroundColor={actualDisplayTheme === "dark" ? "#40405b" : "#e4e4ff"} >{sessionContent.sessionContent}</EncodedHTMLDiv> | ||
</Link> | ||
<div className="session-content-footer"> | ||
<Link to={`#${day};${sessionContent.id};f`} onClick={(e) => e.stopPropagation()} replace={true} className={`session-content-footer-button ${sessionContent.sessionContentFiles.length === 0 ? "disabled" : ""}`}><DownloadIcon className="download-icon" />Fichiers</Link> | ||
</div> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
height: 100%; | ||
} | ||
|
||
.session-content { | ||
.bottomsheet-session-content { | ||
margin-bottom: 15px; | ||
} | ||
|
||
|
Oops, something went wrong.