diff --git a/src/app/me/AboutMe.module.css b/src/app/me/AboutMe.module.css index 96369e5..35c2ba9 100644 --- a/src/app/me/AboutMe.module.css +++ b/src/app/me/AboutMe.module.css @@ -58,29 +58,6 @@ height: 100%; } -/* the !importants here piss me off but it wouldn't accept the property otherwise */ -.progress { - background: linear-gradient( - to right, - var(--fg-darker) 50%, - var(--bg-dark) 50% - ) !important; - background-size: 200% 100% !important; - background-position: right bottom !important; - transition: all 0s linear !important; - - border: 0; - border-radius: 0.15rem; - cursor: pointer; - padding: 0.5em 1em; -} - -/* when clicked */ -.progress:active { - transition: all 3s linear !important; - background-position: left bottom !important; -} - .multiButtons { margin: 1rem 0; white-space: nowrap; diff --git a/src/app/me/AboutMe.tsx b/src/app/me/AboutMe.tsx index 9069d59..60c2cfe 100644 --- a/src/app/me/AboutMe.tsx +++ b/src/app/me/AboutMe.tsx @@ -5,7 +5,7 @@ import { UserInfo } from "@/ldap"; import React from "react"; import styles from "./AboutMe.module.css"; import AvatarChanger from "@/components/AvatarChanger"; -import Input, { Label } from "@/components/Input"; +import Input, { Hint, Label } from "@/components/Input"; import { Form, Formik, FormikHelpers } from "formik"; import { AboutMeFormValues, @@ -204,6 +204,8 @@ export default function AboutMe({
+ Click to link, hold to unlink. + JSX.Element; }) { const router = useRouter(); - const [changing, setChanging] = React.useState(false); - // TODO: Reimplement hold-to-unlink. + const holdTime = authState?.connected ? 3000 : 0; + const interval = React.useRef(); - async function handleClick(event: React.MouseEvent) { - event.preventDefault(); - - if (unavailable) return; - - const provider = service.toLowerCase(); - if (authState?.connected === false) { - setChanging(true); - router.push(`/oauth/${provider}/login`); + const execute = async () => { + const name = authState?.name.toLowerCase(); + if (!authState?.connected) { + router.push(`/oauth/${name}/login`); } else { - setChanging(true); - if (confirm(`Unlink your ${service} account?`)) { - await fetch(`/api/unlink?provider=${provider}`, { method: "POST" }); - window.location.reload(); - } else { - setChanging(false); - } + await fetch(`/api/unlink?provider=${name}`, { method: "POST" }); + router.refresh(); } - } + }; + + const mouseDown = (e: React.MouseEvent) => { + e.preventDefault(); + interval.current = setTimeout(execute, holdTime); + }; + + const mouseUp = (e: React.MouseEvent) => { + e.preventDefault(); + if (interval.current) clearTimeout(interval.current); + }; return (