Skip to content

Commit

Permalink
improvements (generally)
Browse files Browse the repository at this point in the history
  • Loading branch information
sphinxrave committed Jan 11, 2025
1 parent 3151872 commit 7a0f86f
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 32 deletions.
20 changes: 20 additions & 0 deletions packages/react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"react-hook-form": "^7.49.2",
"react-i18next": "^15.2.0",
"react-image": "^4.1.0",
"react-linkify-it": "^1.0.8",
"react-player": "^2.16.0",
"react-resizable-panels": "^2.0.20",
"react-rnd": "^10.4.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/about/ContactList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function ContactList() {
{
className:
"border-violet-10 hover:bg-violet-4 hover:border-violet-10 text-violet-10 max-w-xs",
href: "https://discord.gg/A24AbzgvRJ",
href: "https://discord.gg/jctkgHBt4b",
icon: "i-logos:discord-icon",
label: t("about.contact.discord"),
},
Expand Down
6 changes: 2 additions & 4 deletions packages/react/src/components/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ export function Header({ id }: HeaderProps) {
size="icon"
variant="link"
className={clsx(
"h-12 w-12 p-0 opacity-100 transition-all hover:bg-secondaryA-2",
{
"-translate-y-8 duration-200 opacity-0": isSidebarOpen,
},
"h-12 w-12 p-0 opacity-100 transition-all starting:opacity-0 starting:-translate-y-6 duration-1000 hover:bg-secondaryA-2",
isSidebarOpen && "hidden",
)}
asChild
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from "@/shadcn/ui/dropdown-menu";
import { Avatar, AvatarFallback, AvatarImage } from "@/shadcn/ui/avatar";
import { calendarDialogAtom } from "@/hooks/useFrame";
import { Badge } from "@/shadcn/ui/badge";

export function UserMenu() {
const { t } = useTranslation();
Expand Down Expand Up @@ -70,7 +71,8 @@ export function UserMenu() {
</Avatar>
<div className="flex flex-col gap-1 pl-4">
<div className="overflow-hidden text-ellipsis font-semibold">
{user.username}
{user.username}{" "}
<Badge size="sm">{user.role === "user" ? "" : user.role}</Badge>
</div>
<div className="flex flex-row gap-2 text-sm">
<div className={user.discord_id ? "" : "saturate-0"}>
Expand All @@ -86,8 +88,6 @@ export function UserMenu() {
</div> */}
</div>
<div className="flex flex-row capitalize text-primary-11">
{user.role === "user" ? "" : user.role}

<div className="i-mage:stars-c mx-1 animate-pulse"></div>

{user.contribution_count + " " + t("component.mainNav.points")}
Expand Down
20 changes: 18 additions & 2 deletions packages/react/src/components/layout/Frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,24 @@ export function CopyrightNotice() {
<div className="mt-16 text-center text-sm text-base-7">
© 2020-2024 Holodex v{lastTag}.{commitsSinceLastTag}
<small className="ml-2 inline-block opacity-80">
{abbreviatedSha} / {dayjs(new Date(committerDate)).format("lll")}
</small>
b.{abbreviatedSha} / {dayjs(new Date(committerDate)).format("lll")}
</small>{" "}
/{" "}
<a
href="https://discord.gg/jctkgHBt4b"
target="_blank"
className="hover:text-secondary-8 hover:underline"
>
Discord
</a>{" "}
/{" "}
<a
href="https://ko-fi.com/holodex"
target="_blank"
className="hover:text-secondary-8 hover:underline"
>
Ko-fi
</a>
</div>
);
}
Expand Down
7 changes: 6 additions & 1 deletion packages/react/src/components/player/PlayerDescription.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { cn } from "@/lib/utils";
import { Button } from "@/shadcn/ui/button";
import { useState } from "react";
import { LinkItUrl, LinkItTwitter } from "react-linkify-it";

export function PlayerDescription({
description,
Expand All @@ -20,7 +21,11 @@ export function PlayerDescription({
"line-clamp-3": !isExpanded,
})}
>
{description}
<LinkItUrl className="text-primary underline hover:text-primary-12">
<LinkItTwitter className="text-primary underline hover:text-primary-12">
{description}
</LinkItTwitter>
</LinkItUrl>
</div>
{description.split(/\r\n|\r|\n/).length > lines && (
<Button variant="ghost" onClick={() => setIsExpanded(!isExpanded)}>
Expand Down
5 changes: 4 additions & 1 deletion packages/react/src/components/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ export function Sidebar() {
ref={ref}
>
<div className="flex min-h-[100dvh] flex-col bg-base-2">
<div className="flex items-center gap-2 px-4 pb-2 pt-4">
<div
className="flex cursor-pointer items-center gap-2 px-4 pb-2 pt-4"
onClick={() => navigate("/")}
>
<Logo className="ml-1.5 h-8 w-8" />
<h2 className="text-3xl font-semibold tracking-tight">Holodex</h2>
<div className="flex grow" />
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/video/VideoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export function VideoCard({
const videoCardClasses = useMemo(
() => ({
outerLayer: clsx([
"starting:opacity-0 opacity-100 transition-opacity duration-300",
size == "list" && "rounded-sm hover:bg-base-3 @lg:px-2",
(size == "list" || size == "sm") && "group relative flex gap-4 py-2",
(size == "md" || size == "lg") && "group flex w-full flex-col gap-4",
Expand Down
15 changes: 9 additions & 6 deletions packages/react/src/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,25 @@ export function useAuth() {
const client = useClient();

const { data: valid, error } = useQuery({
queryKey: ["login-check"],
queryKey: ["login-check", token],
queryFn: (): Promise<RefreshUser | null> => {
if (!token) return Promise.resolve(null);
if (!client.loggedIn) return Promise.resolve(null);
return client.get<RefreshUser>("/api/v2/user/refresh");
},
enabled: !!token && !!client.loggedIn,
enabled: true,
staleTime: 60 * 60 * 1000, // 1 hour
});

useEffect(() => {
if (error) toast({ title: error.message, variant: "error" });
else if (valid) {
console.log("saved new token", valid);
setToken(valid?.jwt);
setUser(valid?.user);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [valid, error]);
}, [valid, error, token]);

const login = useMutation({
mutationFn: async ({
Expand All @@ -79,7 +82,7 @@ export function useAuth() {
});
setToken(jwt);
setUser(user);
navigate("/settings");
navigate("/settings/user");
} catch (e) {
onFailure(e as Error);
}
Expand All @@ -94,7 +97,7 @@ export function useAuth() {
});
setToken(jwt);
setUser(user);
navigate("/settings");
navigate("/settings/user");
} catch (e) {
onFailure(e as Error);
}
Expand All @@ -110,7 +113,7 @@ export function useAuth() {
});
setToken(jwt);
setUser(user);
navigate("/settings");
navigate("/settings/user");
} catch (e) {
onFailure(e as Error);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/routes/about/general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const QuickLinks = () => {
{
className:
"border-violet-10 hover:bg-violet-4 hover:border-violet-10 text-violet-10",
href: "https://discord.gg/A24AbzgvRJ",
href: "https://discord.gg/jctkgHBt4b",
icon: "i-carbon:logo-discord",
label: t("about.discordBtn"),
},
Expand Down
7 changes: 6 additions & 1 deletion packages/react/src/routes/channel/ChannelAbout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useOutletContext } from "react-router-dom";
import { ChannelOutletContext } from "../channel";
import { useTranslation } from "react-i18next";
import { LinkItTwitter, LinkItUrl } from "react-linkify-it";

export default function ChannelAbout() {
const { t } = useTranslation();
Expand All @@ -9,7 +10,11 @@ export default function ChannelAbout() {
return (
<div className="container flex gap-4 py-4 max-sm:flex-col-reverse">
<div className="w-full whitespace-pre-wrap rounded-lg bg-base-3 p-4">
{channel.description}
<LinkItUrl className="text-primary underline hover:text-primary-12">
<LinkItTwitter className="text-primary underline hover:text-primary-12">
{channel.description}
</LinkItTwitter>
</LinkItUrl>
</div>
<div className="h-fit w-full shrink-0 flex-col divide-y-2 divide-base-5 rounded-lg bg-base-3 p-4 md:w-80 [&>p]:py-2">
<h3 className="pb-2 text-xl font-bold">
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/routes/orgChannels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export function ChannelsOrg() {
<>
<Helmet>
<title>
TODO PUT CURRENT ORG HERE {t("component.mainNav.channels")} - Holodex
{org} - {t("component.mainNav.channels")} - Holodex
</title>
</Helmet>
<div className="h-full w-full px-4 md:p-8">
Expand Down
24 changes: 15 additions & 9 deletions packages/react/src/routes/settings/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,23 @@ export function SettingsUser() {
return (
<div className="flex flex-col">
<div className="my-4 flex items-center gap-6">
<img
className="h-24 w-24 rounded-full"
src={`https://api.dicebear.com/7.x/shapes/svg?seed=${user.id}`}
/>
<div className="flex flex-col items-center">
<img
className="h-24 w-24 rounded-full"
src={`https://api.dicebear.com/7.x/shapes/svg?seed=${user.id}`}
/>
<Badge className="-mt-2">{user.role}</Badge>
</div>
<div className="flex flex-col gap-2">
<div className="text-2xl font-bold md:text-4xl">{user.username}</div>
<div className="capitalize text-base-11">
{user.role} : {user.contribution_count}
{user.contribution_count}
{t("component.mainNav.points")}
</div>
<div className="flex flex-wrap gap-2 text-sm">
<Badge className="border-base text-base-11" variant="outline">
<kbd className="font-bold">#{user.id}</kbd>
</Badge>
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
Expand Down Expand Up @@ -110,7 +116,7 @@ export function SettingsUser() {
</div>
<div className="ml-auto hidden flex-col gap-2 xl:flex">
{user?.role !== "user" && (
<Button variant="outline" asChild>
<Button variant="base-outline" asChild>
<Link
to={
/(en|lol)/.test(i18n.language)
Expand All @@ -119,8 +125,8 @@ export function SettingsUser() {
}
target="_blank"
>
<div className="i-heroicons:information-circle" />
Editor Guide
<div className="i-ion:book" />
Editor's Guide
</Link>
</Button>
)}
Expand Down Expand Up @@ -156,7 +162,7 @@ export function SettingsUser() {
<SettingsItem label="API Key" fullWidth>
<div className="ml-auto flex w-full max-w-md flex-col gap-4">
<div className="flex items-center gap-2">
<Input value={user.api_key} readOnly />
<Input value={user.api_key ?? ""} placeholder="---" readOnly />
<Button
size="icon-lg"
variant="ghost"
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/shadcn/ui/badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"

const badgeVariants = cva(
"inline-flex items-center rounded-md px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2",
"inline-flex items-center rounded-md px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 cursor-default",
{
variants: {
variant: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/shadcn/ui/button.variants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const buttonVariants = cva(
outline:
"border border-primary-5 bg-transparent hover:border-primaryA-6 hover:bg-primaryA-5 focus-visible:ring-primary-7",
primary:
"bg-primary-9 text-base-12 hover:bg-primaryA-4 focus-visible:ring-primary-7",
"bg-primary-9 text-base-12 hover:bg-primary-7 focus-visible:ring-primary-7",
secondary:
"bg-secondary-9 text-base-12 hover:bg-secondaryA-4 focus-visible:ring-secondary-7",
ghost:
Expand Down
4 changes: 4 additions & 0 deletions packages/react/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ const config = {
plugins: [
require("tailwindcss-animate"),
require("@tailwindcss/container-queries"),
/** @type {import('tailwindcss/types/config').PluginCreator} */
({ addVariant }) => {
addVariant("starting", "@starting-style");
},
],
};

Expand Down

0 comments on commit 7a0f86f

Please sign in to comment.