Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/smoother collapsing tiles #739

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3bcc73a
Merge pull request #605 from UTDNebula/develop
akevinge Jul 14, 2023
4200bfe
Merge pull request #613 from UTDNebula/develop
jasonappah Jul 24, 2023
7e0a58e
Merge pull request #621 from UTDNebula/develop
akevinge Jul 29, 2023
170595f
Merge pull request #628 from UTDNebula/develop
akevinge Aug 5, 2023
e2aa260
Merge pull request #672 from UTDNebula/develop
akevinge Sep 18, 2023
c80a150
Merge pull request #684 from UTDNebula/develop
akevinge Sep 26, 2023
8aea9eb
Merge pull request #698 from UTDNebula/develop
akevinge Oct 3, 2023
a269f1b
Update dependencies
ishaanthenerd Oct 6, 2023
c8ef26e
Merge pull request #713 from UTDNebula/develop
akevinge Oct 12, 2023
5311049
Made the collapsing and expanding transitions
ishaanthenerd Nov 27, 2023
f557573
Made the collapsing and expanding transitions
ishaanthenerd Nov 27, 2023
f3ca20a
Remove venv folder
Jake3231 Feb 6, 2024
5fa2a33
Ran eslint --fix and prettier --write
ishaanthenerd Feb 7, 2024
23ffd20
Deleted changes in CustomPlan.tsx
ishaanthenerd Feb 9, 2024
19bbba9
Deleted CustomPlan.tsx changes
ishaanthenerd Feb 9, 2024
cb9c1ca
Remove venv
jasonappah Feb 13, 2024
6cb8291
Merge branch 'main' into feature/smoother-collapsing-tiles
jasonappah Feb 13, 2024
5450b78
Merge branch 'develop' into feature/smoother-collapsing-tiles
jasonappah Feb 13, 2024
bd07e12
Fix lint errors
jasonappah Feb 13, 2024
b744ca8
Bump workflow versions
jasonappah Feb 13, 2024
7fc7fb7
Try to fix secret access
jasonappah Feb 13, 2024
3bfba13
Revert "Try to fix secret access"
jasonappah Feb 13, 2024
9bc5490
Remove unneeded change
jasonappah Feb 13, 2024
7e10c75
Move animation to shared hook
jasonappah Feb 13, 2024
1cd1344
Fix missing key on RecursiveRequirement
jasonappah Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 40 additions & 5 deletions src/components/planner/Tiles/SemesterTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,43 @@
);
};

const outerRef = useRef(null);
function toggleHeight() {
if (open) {
collapseSection(outerRef.current!);
}
else {
expandSection(outerRef.current!);
}
}

function collapseSection(element: HTMLElement) {
var sectionHeight = element.scrollHeight;

Check failure on line 107 in src/components/planner/Tiles/SemesterTile.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint + Prettier

Unexpected var, use let or const instead
setTimeout(() => {
element.style.height = sectionHeight + 'px';
requestAnimationFrame(function() {
element.style.height = ((outerRef.current! as HTMLElement).childNodes[1].lastChild?.textContent === 'Drag courses here') ? '140px' : '170px';
});
}, 100);
}

function expandSection(element: HTMLElement) {
let zero = performance.now();

Check failure on line 117 in src/components/planner/Tiles/SemesterTile.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint + Prettier

'zero' is never reassigned. Use 'const' instead
requestAnimationFrame(animate);
function animate() {
const value = (performance.now() - zero) / 700;
if (value < 1) {
element.style.height = (element.scrollHeight + 8) + 'px';
requestAnimationFrame(animate);
}
}
}

// QUESTION: isValid color?
return (
<div
ref={ref}
className={`tutorial-editor-3 flex h-fit select-none flex-col gap-y-2 overflow-hidden rounded-2xl border border-neutral-300 ${
ref={outerRef}
className={`tutorial-editor-3 flex h-fit select-none flex-col gap-y-2 overflow-hidden rounded-2xl border border-neutral-300 transition-all duration-700 ease-in-out ${
semester.locked ? 'bg-neutral-200' : 'bg-white'
}`}
>
Expand All @@ -110,7 +142,10 @@
open ? '-rotate-90' : 'rotate-90'
} ml-auto h-3 w-3 transform cursor-pointer text-neutral-500 transition-all duration-500`}
fontSize="inherit"
onClick={() => setOpen(!open)}
onClick={(MouseEvent) => {
toggleHeight();
setOpen(!open);
}}
/>
</div>
</article>
Expand Down Expand Up @@ -153,8 +188,8 @@
/>
)}
<article
className={`mb-5 flex flex-col gap-y-4 overflow-hidden transition-all duration-700 ${
open ? 'max-h-[999px]' : 'max-h-0'
className={`mb-5 flex flex-col gap-y-4 overflow-hidden transition-all duration-700 ease-in-out ${
open ? 'h-full' : 'h-0'
}`}
>
{semester.courses.map((course) => (
Expand Down
45 changes: 39 additions & 6 deletions src/components/planner/TransferBank.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, useState } from 'react';
import { FC, useState, useRef } from 'react';

import ChevronIcon from '@/icons/ChevronIcon';

Expand All @@ -9,22 +9,55 @@
const TransferBank: FC<TransferBankProps> = ({ transferCredits }) => {
const [open, setOpen] = useState(true);

const bankRef = useRef(null);
function toggleHeight() {
if (open) {
collapseSection(bankRef.current!);
}
else {
expandSection(bankRef.current!);
}
}

function collapseSection(element: HTMLElement) {
var sectionHeight = element.scrollHeight;

Check failure on line 23 in src/components/planner/TransferBank.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint + Prettier

Unexpected var, use let or const instead
setTimeout(() => {
element.style.height = sectionHeight + 'px';
requestAnimationFrame(function() {
element.style.height = '50px';
});
}, 100);
}

function expandSection(element: HTMLElement) {
let zero = performance.now();

Check failure on line 33 in src/components/planner/TransferBank.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint + Prettier

'zero' is never reassigned. Use 'const' instead
requestAnimationFrame(animate);
function animate() {
const value = (performance.now() - zero) / 1000;
if (value < 1) {
element.style.height = element.scrollHeight + 'px';
requestAnimationFrame(animate);
}
}
}

return (
<section className="w-full rounded-2xl border border-neutral-200 bg-generic-white px-5 py-3 shadow-sm">
<section ref={bankRef} className="w-full rounded-2xl border border-neutral-200 bg-generic-white px-5 py-3 shadow-sm flex-shrink-0 overflow-hidden transition-all duration-1000 ease-in-out">
<article className="flex items-center justify-between">
<h5 className="text-xl font-semibold text-primary-900">Transfer Credits</h5>
<ChevronIcon
className={`${
open ? '-rotate-90' : 'rotate-90'
} h-3 w-3 transform cursor-pointer text-neutral-500 transition-all duration-500`}
fontSize="inherit"
onClick={() => setOpen(!open)}
onClick={() => {
toggleHeight();
setOpen(!open);
}}
/>
</article>
<ol
className={`mt-4 flex flex-wrap gap-x-10 gap-y-3 overflow-hidden transition-all duration-1000 ${
open ? 'max-h-[999px]' : 'max-h-0'
}`}
className={`mt-4 flex flex-wrap gap-x-10 gap-y-3 transition-all duration-1000 ease-in-out`}
>
{transferCredits.map((credit, i) => (
<li
Expand Down
Loading