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

refactor: improve accessibility, maintainability, scalability and UI/UX #228

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
8 changes: 6 additions & 2 deletions web/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extends": "next/core-web-vitals",
"extends": ["next/core-web-vitals", "plugin:jsx-a11y/recommended"],
"plugins": ["eslint-plugin-unused-imports", "eslint-plugin-jsx-a11y"],
"rules": {
"semi": [
"error",
Expand All @@ -8,6 +9,9 @@
"quotes": [
"error",
"single"
]
],
"unused-imports/no-unused-imports": "error",
"jsx-a11y/no-static-element-interactions": "off",
"jsx-a11y/click-events-have-key-events": "off"
}
}
4 changes: 4 additions & 0 deletions web/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "es5"
}
39 changes: 22 additions & 17 deletions web/app/components/AsideButton.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
import Image, { StaticImageData } from 'next/image';

import Button from './Button';

interface AsideButtonPropsType {
image: StaticImageData;
pageName: string;
innerRef?: (node: any) => void;
onClick?: () => void;
image: React.ReactNode;
sluucke marked this conversation as resolved.
Show resolved Hide resolved
pageName: string;
innerRef?: (node: any) => void;
onClick?: () => void;
}


export default function AsideButton({ image, pageName, innerRef, onClick }: AsideButtonPropsType) {
return (
<Button innerRef={innerRef} onClick={onClick} className='z-10 flex-col w-full !gap-1 !pb-2 !shadow-none !text-black' name={pageName}>
<Image
width={25} height={25}
src={image} alt={`ícone da página ${pageName}`}
/>
</Button>
);
}
export default function AsideButton({
image,
pageName,
innerRef,
onClick,
}: AsideButtonPropsType) {
return (
<Button
innerRef={innerRef}
onClick={onClick}
className="z-10 flex-col w-full !gap-1 !pb-2 !shadow-none !text-black"
name={pageName}
sluucke marked this conversation as resolved.
Show resolved Hide resolved
aria-label={`Ir para página ${pageName}`}
>
{image}
</Button>
);
}
99 changes: 0 additions & 99 deletions web/app/components/AsideSchedulePopUp/AsideSchedulePopUp.tsx

This file was deleted.

89 changes: 46 additions & 43 deletions web/app/components/AsideSchedulePopUp/ClassInfoBox.tsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,56 @@
import { ClassType, DisciplineType } from '@/app/utils/api/searchDiscipline';
import { HTMLProps, MouseEventHandler, useEffect, useState } from 'react';

import useSelectedClasses from '@/app/hooks/useSelectedClasses';
import ClassInfo from '../ClassInfo';
import Image from 'next/image';

import addIcon from '@/public/icons/add.jpg';
import removeIcon from '@/public/icons/remove.jpg';
import { twMerge } from 'tailwind-merge';
import { FiPlus, FiMinus } from 'react-icons/fi';

interface ClassInfoBoxPropsType extends HTMLProps<HTMLDivElement> {
currentDiscipline: DisciplineType,
currentClass: ClassType,
currentDiscipline: DisciplineType;
currentClass: ClassType;
}

export default function ClassInfoBox({ currentDiscipline, currentClass, ...props }: ClassInfoBoxPropsType) {
const { classesChange, selectedClasses } = useSelectedClasses();
const [selected, setSelected] = useState(false);
export default function ClassInfoBox({
currentDiscipline,
currentClass,
...props
}: ClassInfoBoxPropsType) {
const { classesChange, selectedClasses } = useSelectedClasses();
const [selected, setSelected] = useState(false);

useEffect(() => {
if (selectedClasses.get(currentDiscipline.id)?.has(currentClass.id)) setSelected(true);
else setSelected(false);
}, [selectedClasses, classesChange, currentDiscipline, currentClass]);
useEffect(() => {
if (selectedClasses.get(currentDiscipline.id)?.has(currentClass.id))
setSelected(true);
else setSelected(false);
}, [selectedClasses, classesChange, currentDiscipline, currentClass]);

return (
<div
className={`grid grid-cols-7 ${selected ? 'bg-primary bg-opacity-40' : 'hover:bg-gray-300'} hover:bg-opacity-40 hover:cursor-pointer rounded-md py-1 px-2 ${props.className || ''}`}
>
<ClassInfo currentClass={{
class: currentClass,
discipline: {
id: currentDiscipline.id,
name: currentDiscipline.name,
code: currentDiscipline.code
}
}} />
<button
onClick={props.onClick as MouseEventHandler<HTMLButtonElement> | undefined}
className='hover:cursor-pointer col-start-7 flex justify-center items-center'>
{selected ?
<Image
width={25} height={25}
src={removeIcon} alt='ícone remover matéria'
/>
: <Image
width={25} height={25}
src={addIcon} alt='ícone adicionar matéria'
/>
}
</button>
</div>
);
}
return (
<div
className={twMerge(
'grid grid-cols-7 hover:bg-opacity-40 hover:cursor-pointer rounded-md py-1 px-2',
selected ? 'bg-primary/40' : 'hover:bg-gray-300',
props.className
)}
>
<ClassInfo
currentClass={{
class: currentClass,
discipline: {
id: currentDiscipline.id,
name: currentDiscipline.name,
code: currentDiscipline.code,
},
}}
/>
<button
onClick={
props.onClick as MouseEventHandler<HTMLButtonElement> | undefined
}
aria-label="Selecionar/Desselecionar aula"
className="hover:cursor-pointer col-start-7 flex justify-center items-center"
>
{selected ? <FiMinus size={24} /> : <FiPlus size={24} />}
sluucke marked this conversation as resolved.
Show resolved Hide resolved
</button>
</div>
);
}
Loading