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 all 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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Neon Database Create Branch Action
uses: neondatabase/create-branch-action@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:

steps:
- name: Check out Git repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Python3.11
uses: actions/setup-python@v4
Expand All @@ -91,7 +91,7 @@ jobs:
mongodb-port: 27017

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand All @@ -111,10 +111,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validator_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
working-directory: validator
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/versioning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
Expand Down
37 changes: 16 additions & 21 deletions src/components/planner/Sidebar/RecursiveRequirement.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import React, { useMemo, Fragment } from 'react';
import { v4 as uuidv4 } from 'uuid';

import { trpc } from '@/utils/trpc';
Expand Down Expand Up @@ -36,15 +36,14 @@ export function RecursiveRequirement({
>
<>
{req.requirements.map((req2, idx) => (
<>
<Fragment key={req2.metadata.id}>
<div className="h-2 px-2 text-sm">Option {idx + 1}</div>
<RecursiveRequirement
key={idx}
req={req2}
courses={courses}
validCourses={validCourses}
/>
</>
</Fragment>
))}
</>
</Accordion>
Expand All @@ -58,15 +57,13 @@ export function RecursiveRequirement({
filled={req.filled}
>
<>
{req.requirements.map((req2, idx) => (
<>
<RecursiveRequirement
key={idx}
req={req2}
courses={courses}
validCourses={validCourses}
/>
</>
{req.requirements.map((req2) => (
<RecursiveRequirement
key={req2.metadata.id}
req={req2}
courses={courses}
validCourses={validCourses}
/>
))}
</>
</Accordion>
Expand All @@ -85,15 +82,14 @@ export function RecursiveRequirement({
>
<>
{req.requirements.map((req2, idx) => (
<>
<Fragment key={req2.metadata.id}>
<div className="h-2 px-2 text-sm">Option {idx + 1}</div>
<RecursiveRequirement
key={idx}
req={req2}
courses={courses}
validCourses={validCourses}
/>
</>
</Fragment>
))}
</>
</Accordion>
Expand All @@ -112,15 +108,14 @@ export function RecursiveRequirement({
>
<>
{req.requirements.map((req2, idx) => (
<>
<Fragment key={req2.metadata.id}>
<div className="h-2 px-2 text-sm">Option {idx + 1}</div>
<RecursiveRequirement
key={idx}
req={req2}
courses={courses}
validCourses={validCourses}
/>
</>
</Fragment>
))}
</>
</Accordion>
Expand All @@ -140,7 +135,7 @@ export function RecursiveRequirement({
<>
{req.prefix_groups.map((req2, idx) => (
<RecursiveRequirement
key={idx}
key={req2.metadata.id}
req={req2}
courses={courses}
validCourses={validCourses}
Expand All @@ -156,7 +151,7 @@ export function RecursiveRequirement({
return <div>NOT SUPPORTED</div>;
}
};
return <>{getRequirement()}</>;
return getRequirement();
}

function CourseRequirementComponent({
Expand Down
12 changes: 7 additions & 5 deletions src/components/planner/Sidebar/RequirementsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ const getRequirementGroup = (
course: `${c.subject_prefix} ${c.course_number}`,
matcher: 'Course',
filled: courses.includes(`${c.subject_prefix} ${c.course_number}`),
metadata: {},
metadata: {
id: `course-${c.id}`,
},
}))
: [],
filterFunction: filterFunc,
Expand Down Expand Up @@ -200,12 +202,12 @@ const getRequirementGroup = (
};

export const ProgressComponent2 = ({ value, max }: { value: number; max: number }) => {
const heh = `${(value * 100) / max}%`;
const width = `${(value * 100) / max}%`;

return (
<div className="flex w-full flex-col items-center justify-center">
<div className="mt-2 h-1 w-full overflow-hidden rounded-2xl bg-[#F5F5F5] ">
<div style={{ width: heh }} className={`h-full bg-primary`}></div>
<div style={{ width }} className={`h-full bg-primary`}></div>
</div>
</div>
);
Expand All @@ -220,15 +222,15 @@ export const ProgressComponent = ({
max: number;
unit?: string;
}) => {
const heh = `${(value * 100) / max}%`;
const width = `${(value * 100) / max}%`;

return (
<div className="flex w-24 flex-col items-center justify-center">
<div className="w-max text-[10px]">
{value}/{max} {unit}
</div>
<div className="h-3 w-full overflow-hidden rounded-2xl bg-[#F5F5F5]">
<div style={{ width: heh }} className={`h-full bg-primary`}></div>
<div style={{ width }} className={`h-full bg-primary`}></div>
</div>
</div>
);
Expand Down
3 changes: 1 addition & 2 deletions src/components/planner/Sidebar/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type DegreeRequirement = Requirement & {

export interface Requirement {
matcher: string;
metadata: { [key: string]: string };
metadata: { id: string; [key: string]: string };
filled: boolean;
}

Expand All @@ -36,7 +36,6 @@ export type AndRequirementGroup = Requirement & {

export type HoursRequirementGroup = Requirement & {
matcher: 'Hours';
metadata: { [key: string]: string };
required_hours: number;
fulfilled_hours: number;
requirements: RequirementTypes[];
Expand Down
23 changes: 15 additions & 8 deletions src/components/planner/Tiles/SemesterTile.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { UniqueIdentifier, useDroppable } from '@dnd-kit/core';
import React, { FC, forwardRef, useState, useRef } from 'react';
import React, { FC, forwardRef, useState, useRef, useImperativeHandle } from 'react';

import AnalyticsWrapper from '@/components/common/AnalyticsWrapper';
import ChevronIcon from '@/icons/ChevronIcon';
import LockIcon from '@/icons/LockIcon';
import UnlockedIcon from '@/icons/UnlockedIcon';
import useAccordionAnimation from '@/shared/useAccordionAnimation';
import { displaySemesterCode, getSemesterHourFromCourseCode } from '@/utils/utilFunctions';

import DraggableSemesterCourseItem from './SemesterCourseItem';
Expand All @@ -26,11 +27,17 @@ export interface SemesterTileProps {
export const MemoizedSemesterTile = React.memo(
forwardRef<HTMLDivElement, SemesterTileProps>(function SemesterTile(
{ semester, getDragId },
ref,
outerRef,
) {
const [open, setOpen] = useState(true);
const innerRef = useRef<HTMLDivElement>(null);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
useImperativeHandle(outerRef, () => innerRef.current!, []);

const [hoverOpen, setHoverOpen] = useState(false);
const hoverTimer = useRef<ReturnType<typeof setTimeout>>();
const { toggle, open } = useAccordionAnimation(innerRef, () =>
semester.courses.length === 0 ? '140px' : '170px',
);

const {
handleSelectCourses,
Expand Down Expand Up @@ -96,8 +103,8 @@ export const MemoizedSemesterTile = React.memo(
// 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={innerRef}
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 +117,7 @@ export const MemoizedSemesterTile = React.memo(
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={toggle}
/>
</div>
</article>
Expand Down Expand Up @@ -153,8 +160,8 @@ export const MemoizedSemesterTile = React.memo(
/>
)}
<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 ? 'opacity-100' : 'opacity-0'
}`}
>
{semester.courses.map((course) => (
Expand Down
17 changes: 10 additions & 7 deletions src/components/planner/TransferBank.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
import { FC, useState } from 'react';
import { FC, useRef } from 'react';

import ChevronIcon from '@/icons/ChevronIcon';
import useAccordionAnimation from '@/shared/useAccordionAnimation';

interface TransferBankProps {
transferCredits: string[];
}

const TransferBank: FC<TransferBankProps> = ({ transferCredits }) => {
const [open, setOpen] = useState(true);
const bankRef = useRef(null);
const { toggle, open } = useAccordionAnimation(bankRef, () => '50px');

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 flex-shrink-0 overflow-hidden rounded-2xl border border-neutral-200 bg-generic-white px-5 py-3 shadow-sm 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={toggle}
/>
</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
2 changes: 2 additions & 0 deletions src/components/template/CustomPlan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export default function CustomPlan({ onDismiss }: { onDismiss: () => void }) {
}
}
}

// TODO: Consider whether credit was earned or not before adding to credits list
const credits: Credit[] = [];
let isTransfer = true;
Expand Down Expand Up @@ -158,6 +159,7 @@ export default function CustomPlan({ onDismiss }: { onDismiss: () => void }) {
}
}
}

const dedupedCredits = credits.reduce((acc, curr) => {
if (!acc.some((i) => i.courseCode === curr.courseCode)) {
acc.push(curr);
Expand Down
Loading
Loading