Skip to content

Commit

Permalink
chore: remove double timer
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRodrigues10 committed Jan 21, 2024
2 parents 512b7ae + ee42771 commit 57d31f0
Show file tree
Hide file tree
Showing 104 changed files with 1,267 additions and 832 deletions.
85 changes: 72 additions & 13 deletions components/Badge/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,77 @@
import Link from "next/link";
import { AllHTMLAttributes, ReactEventHandler, useState } from "react";

interface BadgeProps
extends Omit<AllHTMLAttributes<HTMLDivElement>, "id" | "name" | "type"> {
name: string;
id: string | number;
avatar: string;
tokens: string | number;
owned?: boolean;
disableLink?: boolean;
disableOwnedHighlight?: boolean;
}

const Badge: React.FC<BadgeProps> = ({
name,
id,
avatar,
tokens,
owned,
disableLink = false,
disableOwnedHighlight = false,
...rest
}) => {
const [badgeLoaded, setBadgeLoaded] = useState(false);
const [fallbackRan, setFallbackRan] = useState(false);

const highlightBadge = owned || !disableOwnedHighlight || !badgeLoaded;

const imageOnError: ReactEventHandler<HTMLImageElement> = (e) => {
// prevent infinite loop fallback
if (fallbackRan) {
setBadgeLoaded(true);
return;
}

setBadgeLoaded(false);
e.currentTarget.src = "/images/badges/badge-not-found.svg";
setFallbackRan(true);
};

export default function Badge({ name, id, avatar, tokens, owned }) {
return (
<Link
href={`/badge/${id}`}
className={`h-full w-full ${owned ? "opacity-100" : "opacity-30"}`}
<div
className={`h-full w-full ${
highlightBadge ? "opacity-100" : "opacity-30"
}`}
id={id.toString()}
{...rest}
>
<div>
<img src={avatar} alt={name}></img>
</div>
<div className="flex flex-col justify-items-center text-center font-iregular">
<div>{name}</div>
<div>{tokens} 💰 </div>
</div>
</Link>
<Link href={disableLink ? "" : `/badge/${id}`}>
<div className="flex aspect-square w-full select-none items-center justify-center">
{!badgeLoaded && <BadgeSkeleton />}

<img
src={avatar}
alt={name}
onLoad={() => setBadgeLoaded(true)}
onError={imageOnError}
/>
</div>

<div className="flex flex-col justify-items-center text-center font-iregular">
<div>{name}</div>
<div>{tokens} 💰 </div>
</div>
</Link>
</div>
);
}
};

export default Badge;

const BadgeSkeleton = () => {
return (
<div className="aspect-square w-10/12 animate-pulse rounded-full bg-gray-500 opacity-5" />
);
};
2 changes: 1 addition & 1 deletion components/BadgeFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function BadgeFilter({ onChange }) {
<select
id="location"
name="location"
className="mt-1 block w-full rounded-full border-2 border-quinary bg-white py-2 pl-3 pr-10 text-black ring-quinary focus:border-quinary"
className="mt-1 block w-full select-none rounded-full border-2 border-quinary bg-white py-2 pl-3 pr-10 text-black ring-quinary focus:border-quinary"
defaultValue="All"
onChange={(e) => {
const badge = badgeTypes.find(
Expand Down
4 changes: 3 additions & 1 deletion components/Balance/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export default function Balance({ token_balance, badge_count }) {
return (
<div className="text-white lg:grid lg:grid-cols-3">
<span className="col-span-1 font-ibold text-xl sm:text-2xl">Balance</span>
<span className="col-span-1 select-none font-ibold text-xl sm:text-2xl">
Balance
</span>
<div className="col-span-2 flex gap-x-4 lg:flex-row-reverse">
<span className="text-md font-iregular sm:text-lg">
💰 {token_balance} tokens
Expand Down
17 changes: 4 additions & 13 deletions components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { ButtonHTMLAttributes, ReactNode } from "react";
interface Props extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "title"> {
title: ReactNode;
description?: string;
customStyle?: string;
bold?: boolean;
disabled?: boolean;
}

interface ButtonTitleProps {
Expand All @@ -16,22 +14,15 @@ interface ButtonTitleProps {
export default function Button({
title,
description,
type,
disabled,
onClick,
customStyle,
bold,
bold = false,
...rest
}: Props) {
return (
<button
{...rest}
onClick={onClick}
type={type}
disabled={disabled}
className={`${
customStyle || ""
} m-auto block rounded-full hover:opacity-75 disabled:bg-gray-400 disabled:opacity-75`}
className={`m-auto block select-none rounded-full hover:opacity-75 disabled:bg-gray-400 disabled:opacity-75 ${
rest.className || ""
}`}
>
<ButtonTitle title={title} bold={bold} />
<p className="font-iregular">{description}</p>
Expand Down
6 changes: 3 additions & 3 deletions components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function Footer(props: IFooterProps) {
ref={observe}
>
<div className="flex flex-col justify-between gap-16 py-10 lg:flex-row">
<div className="flex items-start justify-center font-ibold lg:justify-start">
<div className="flex select-none items-start justify-center font-ibold lg:justify-start">
<Image
src="/images/sei-logo.svg"
width={100}
Expand All @@ -101,7 +101,7 @@ export default function Footer(props: IFooterProps) {
</p>
</div>

<div className="mx-2 mt-20 hidden justify-center pb-10 lg:flex">
<div className="mx-2 mt-20 hidden select-none justify-center pb-10 lg:flex">
<Animation
text={
props.footerAnimationText != undefined ? (
Expand All @@ -116,7 +116,7 @@ export default function Footer(props: IFooterProps) {
</div>

<div className="flex-2">
<div className="grid grid-rows-2 justify-items-center gap-8 whitespace-nowrap font-iregular text-sm text-white lg:grid-cols-2 lg:justify-items-start">
<div className="grid select-none grid-rows-2 justify-items-center gap-8 whitespace-nowrap font-iregular text-sm text-white lg:grid-cols-2 lg:justify-items-start">
<Link
href="https://2022.seium.org/"
className="text-white hover:underline"
Expand Down
35 changes: 35 additions & 0 deletions components/GoToTop/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { faArrowUp } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useEffect, useState } from "react";

export default function GoToTop() {
const [showButton, setShowButton] = useState(false);

useEffect(() => {
window.addEventListener("scroll", () => {
if (window.scrollY > 400) {
setShowButton(true);
} else {
setShowButton(false);
}
});
}, []);

const goToTop = () => {
window.scrollTo({
top: 0,
behavior: "smooth",
});
};

return (
<button
className={`transition-translate fixed right-5 bottom-5 h-12 w-12 cursor-pointer rounded-full bg-white duration-300 ${
showButton ? "" : "translate-y-52"
}`}
onClick={goToTop}
>
<FontAwesomeIcon icon={faArrowUp} className="text-3xl text-black" />
</button>
);
}
2 changes: 1 addition & 1 deletion components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Head from "next/head";
export default function Header() {
return (
<Head>
<title>SEI 2023</title>
<title>SEI 2024</title>
<link
rel="apple-touch-icon"
sizes="180x180"
Expand Down
2 changes: 1 addition & 1 deletion components/Heading/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function Heading({ text, children }: IHeadingProps) {
return (
<div className="border-b-solid mb-5 w-full grid-cols-2 overflow-hidden border-b-2 border-slate-400 pb-3">
<div className="col-span-1 float-left flex h-full font-ibold">
<p className="inline-block align-middle font-ibold text-2xl font-bold text-white">
<p className="inline-block select-none align-middle font-ibold text-2xl font-bold text-white">
{text}
</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/Input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function InputBase({
<div>
<label
htmlFor={id}
className={`pl-6 font-iregular text-${fgColor} mt-5 block text-sm`}
className={`pl-6 font-iregular text-${fgColor} mt-5 block select-none text-sm`}
>
{text}
</label>
Expand Down
2 changes: 1 addition & 1 deletion components/JoinUs/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default function JoinUs(props) {
return (
<a
href="https://sei23.eventbrite.pt"
className={`flex h-28 w-28 flex-shrink-0 rotate-15 transform items-center justify-center font-ibold text-xl text-${props.fgColor} bg-${props.button} translate-x-0 rounded-full`}
className={`flex h-28 w-28 flex-shrink-0 rotate-15 transform items-center justify-center font-ibold text-xl text-${props.fgColor} bg-${props.button} translate-x-0 select-none rounded-full`}
>
Join us 👋
</a>
Expand Down
8 changes: 4 additions & 4 deletions components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function Layout({ title, description, children }: LayoutProps) {
/>

{/* NAVBAR */}
<aside className="inset-y-0 hidden w-72 overflow-y-scroll border-r-2 bg-secondary px-8 py-5 lg:fixed lg:flex lg:flex-col">
<aside className="inset-y-0 hidden w-72 select-none overflow-y-scroll border-r-2 bg-secondary px-8 py-5 lg:fixed lg:flex lg:flex-col">
<div className="flex flex-1">
<nav className="mt-8 flex flex-col">
<Link href="/" className="pb-8">
Expand Down Expand Up @@ -107,7 +107,7 @@ export default function Layout({ title, description, children }: LayoutProps) {

{/* CONTENT */}
<main className="w-full px-4 pb-6 pt-20 lg:ml-72 lg:px-20">
<h2 className="font-ibold text-5xl">{title}</h2>
<h2 className="select-none font-ibold text-5xl">{title}</h2>
<p className="mt-2 font-iregular text-lg">{description}</p>

{children}
Expand Down Expand Up @@ -160,7 +160,7 @@ function MobileNavbar({
leaveTo="-translate-x-full"
className="z-1 absolute h-full w-full justify-between bg-secondary p-8 "
>
<aside className="flex h-full flex-col justify-between">
<aside className="flex h-full select-none flex-col justify-between">
<div>
<div className="flex items-center justify-between">
<Link href="/" className="font-iregular text-quinary">
Expand All @@ -174,7 +174,7 @@ function MobileNavbar({

<button type="button" onClick={onClose} className="h-12 w-12">
<span className="sr-only">Close sidebar</span>
title={<FontAwesomeIcon icon={faTimes} />}
<FontAwesomeIcon icon={faTimes} />
</button>
</div>

Expand Down
6 changes: 3 additions & 3 deletions components/Navbar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function Navbar({ bgColor, fgColor, button, children }) {
<div className="relative z-50 flex flex-auto">
<div className="grid w-full grid-cols-4">
<Link href="/">
<div className={`${styles.logo} pt-4 lg:pt-8`}>
<div className={`${styles.logo} select-none pt-4 lg:pt-8`}>
<Image
className="cursor-pointer opacity-60 hover:opacity-100"
src="/images/sei-logo.svg"
Expand All @@ -64,7 +64,7 @@ export default function Navbar({ bgColor, fgColor, button, children }) {
</div>
</Link>
<div className="col-span-3 hidden justify-self-end lg:block">
<div className="flex">
<div className="flex select-none">
<div className="mr-6 grid grid-cols-3 gap-y-4 gap-x-20 pt-4">
{navigation.map((item) => (
<Link
Expand Down Expand Up @@ -160,7 +160,7 @@ export default function Navbar({ bgColor, fgColor, button, children }) {
</div>

<Disclosure.Panel className={`lg:hidden bg-${bgColor}`}>
<div className="relative z-50 min-h-screen object-cover px-2 pt-12">
<div className="relative z-50 select-none object-cover px-2 pt-12">
{navigation.map((item) => (
<Disclosure.Button
key={item.slug}
Expand Down
21 changes: 9 additions & 12 deletions components/Notification/Notification.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import { useState, useEffect } from "react";
import React, { useEffect } from "react";

interface INotificationProps {
title: string;
onClose: () => void;
}

export default function Notification({ title }: INotificationProps) {
const [visible, setVisible] = useState(true);

const Notification: React.FC<INotificationProps> = ({ title, onClose }) => {
useEffect(() => {
const timer = setTimeout(() => {
setVisible(false);
onClose();
}, 2500);

return () => clearTimeout(timer);
}, []);

if (!visible) {
return null;
}
}, [onClose]);

return (
<div className="fixed right-4 top-0 z-50 h-16 w-72">
Expand All @@ -30,7 +25,7 @@ export default function Notification({ title }: INotificationProps) {
</div>
<div className="ml-4 flex flex-shrink-0">
<button
onClick={() => setVisible(false)}
onClick={onClose}
className="inline-flex rounded-md bg-quinary text-white hover:text-primary focus:outline-none"
>
<span className="sr-only">Close</span>
Expand All @@ -42,4 +37,6 @@ export default function Notification({ title }: INotificationProps) {
</div>
</div>
);
}
};

export default Notification;
19 changes: 12 additions & 7 deletions components/PasswordInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { forwardRef, useState } from "react";

import { InputBase, InputDefaultProps } from "@components/Input";

import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faEye, faEyeSlash } from "@fortawesome/free-solid-svg-icons";
import { EyeIcon, EyeOffIcon } from "@heroicons/react/solid";

export default forwardRef<HTMLInputElement, InputDefaultProps>(
function PasswordInput(
Expand Down Expand Up @@ -34,11 +33,17 @@ export default forwardRef<HTMLInputElement, InputDefaultProps>(
ref={ref}
{...rest}
/>
<FontAwesomeIcon
className="mx-2 cursor-pointer"
onClick={togglePasswordVisibility}
icon={isPasswordVisible ? faEyeSlash : faEye}
/>
{isPasswordVisible ? (
<EyeOffIcon
className="mx-2 h-5 cursor-pointer"
onClick={togglePasswordVisibility}
/>
) : (
<EyeIcon
className="mx-2 h-5 cursor-pointer"
onClick={togglePasswordVisibility}
/>
)}
</InputBase>
);
}
Expand Down
Loading

0 comments on commit 57d31f0

Please sign in to comment.