added skeleton for jacket art

This commit is contained in:
Polaris
2024-08-27 16:57:04 -04:00
parent e22708f98a
commit d5d62572ba
4 changed files with 78 additions and 31 deletions

View File

@ -1,24 +1,11 @@
"use client"; "use client";
import { ColumnDef } from "@tanstack/react-table"; import { ColumnDef } from "@tanstack/react-table";
import { MoreHorizontal } from "lucide-react";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { useState } from "react"; import { useState } from "react";
import { useRouter } from "next/navigation"; import { ArrowUpDown } from "lucide-react";
import { generateShareToken } from "@/app/(sharing)/[token]/token";
import { ArrowUpDown, MoreHorizontalIcon } from "lucide-react";
import { chuni_score_playlog } from "@/prisma/schemas/artemis/generated/artemis"; import { chuni_score_playlog } from "@/prisma/schemas/artemis/generated/artemis";
import { chuni_static_music } from "@/prisma/schemas/artemis/generated/artemis"; import { chuni_static_music } from "@/prisma/schemas/artemis/generated/artemis";
import { chuni_score_best } from "@/prisma/schemas/artemis/generated/artemis";
import { getDifficultyText, getGrade } from "@/lib/helpers"; import { getDifficultyText, getGrade } from "@/lib/helpers";
import { Skeleton } from "../ui/skeleton"; import { Skeleton } from "../ui/skeleton";
import ActionsCell from "./moreAction"; import ActionsCell from "./moreAction";
@ -32,17 +19,29 @@ export const columns: ColumnDef<chunithm>[] = [
cell: ({ row }) => { cell: ({ row }) => {
const jacketPath = row.original.jacketPath?.replace(".dds", ".png"); const jacketPath = row.original.jacketPath?.replace(".dds", ".png");
const [isLoading, setIsLoading] = useState(true);
const handleImageLoad = () => {
setIsLoading(false);
};
const handleImageError = () => {
setIsLoading(false);
};
return ( return (
<div className="flex w-[300px] items-center truncate font-medium"> <div className="flex w-[300px] items-center truncate font-medium">
{!jacketPath ? ( {jacketPath ? (
<Skeleton className="mr-2 inline-block h-8 w-8" />
) : (
<img <img
src={`/jacketArts/${jacketPath}`} src={`/jacketArts/${jacketPath}`}
alt="Jacket" alt="Jacket"
className="mr-2 inline-block h-[70px] w-[70px]" className={`mr-2 inline-block h-[70px] w-[70px] ${
isLoading ? "hidden" : ""
}`}
onLoad={handleImageLoad}
onError={handleImageError}
/> />
) : (
<Skeleton className="mr-2 inline-block h-[70px] w-[70px]" />
)} )}
<span className="truncate">{row.original.title}</span> <span className="truncate">{row.original.title}</span>
</div> </div>

View File

@ -1,5 +1,8 @@
import React, { FC } from "react"; "use client";
import React, { FC, useState } from "react";
import { getDifficultyText } from "@/lib/helpers"; import { getDifficultyText } from "@/lib/helpers";
import { Skeleton } from "../ui/skeleton";
type userRatingBaseList = { type userRatingBaseList = {
title: string; title: string;
@ -32,15 +35,30 @@ export const ChunithmHotPlays: FC<ChunithmProfileHotPlays> = ({
".dds", ".dds",
".png", ".png",
); );
const [isLoading, setIsLoading] = useState(true);
const handleImageLoad = () => {
setIsLoading(false);
};
const handleImageError = () => {
setIsLoading(false);
};
return ( return (
<div key={index} className="flex flex-col items-center p-2"> <div key={index} className="flex flex-col items-center p-2">
<div className="font-bold"></div> <div className="font-bold"></div>
{jacketPath && ( {jacketPath ? (
<img <img
src={`/jacketArts/${jacketPath}`} src={`/jacketArts/${jacketPath}`}
alt="Jacket" alt="Jacket"
className="h-28 w-28" className={`mr-2 inline-block h-[100px] w-[100px] ${
isLoading ? "hidden" : ""
}`}
onLoad={handleImageLoad}
onError={handleImageError}
/> />
) : (
<Skeleton className="mr-2 inline-block h-[100px] w-[100px]" />
)} )}
<div> <div>
<ul className="mt-2 text-center"> <ul className="mt-2 text-center">

View File

@ -1,9 +1,7 @@
import React, { FC } from "react"; "use client";
import { import React, { FC, useState } from "react";
chuni_profile_rating,
chuni_static_music,
} from "@/prisma/schemas/artemis/generated/artemis";
import { getDifficultyText } from "@/lib/helpers"; import { getDifficultyText } from "@/lib/helpers";
import { Skeleton } from "../ui/skeleton";
type userRatingBaseList = { type userRatingBaseList = {
title: string; title: string;
@ -37,15 +35,30 @@ export const ChunithmTopPlays: FC<chunithmTopPlays> = ({
".dds", ".dds",
".png", ".png",
); );
const [isLoading, setIsLoading] = useState(true);
const handleImageLoad = () => {
setIsLoading(false);
};
const handleImageError = () => {
setIsLoading(false);
};
return ( return (
<div key={index} className="flex flex-col items-center p-2"> <div key={index} className="flex flex-col items-center p-2">
<div className="font-bold"></div> <div className="font-bold"></div>
{jacketPath && ( {jacketPath ? (
<img <img
src={`/jacketArts/${jacketPath}`} src={`/jacketArts/${jacketPath}`}
alt="Jacket" alt="Jacket"
className="h-28 w-28" className={`mr-2 inline-block h-[100px] w-[100px] ${
isLoading ? "hidden" : ""
}`}
onLoad={handleImageLoad}
onError={handleImageError}
/> />
) : (
<Skeleton className="mr-2 inline-block h-[100px] w-[100px]" />
)} )}
<ul className="mt-2 text-center"> <ul className="mt-2 text-center">
<li> <li>

View File

@ -1,5 +1,7 @@
import React, { FC } from "react"; "use client";
import React, { FC, useState } from "react";
import { getDifficultyText } from "@/lib/helpers"; import { getDifficultyText } from "@/lib/helpers";
import { Skeleton } from "../ui/skeleton";
type userRatingBaseList = { type userRatingBaseList = {
title: string; title: string;
@ -32,15 +34,30 @@ export const ChunithmNextPlays: FC<ChunithmProfileHotPlays> = ({
".dds", ".dds",
".png", ".png",
); );
const [isLoading, setIsLoading] = useState(true);
const handleImageLoad = () => {
setIsLoading(false);
};
const handleImageError = () => {
setIsLoading(false);
};
return ( return (
<div key={index} className="flex flex-col items-center p-2"> <div key={index} className="flex flex-col items-center p-2">
<div className="font-bold"></div> <div className="font-bold"></div>
{jacketPath && ( {jacketPath ? (
<img <img
src={`/jacketArts/${jacketPath}`} src={`/jacketArts/${jacketPath}`}
alt="Jacket" alt="Jacket"
className="h-28 w-28" className={`mr-2 inline-block h-[100px] w-[100px] ${
isLoading ? "hidden" : ""
}`}
onLoad={handleImageLoad}
onError={handleImageError}
/> />
) : (
<Skeleton className="mr-2 inline-block h-[100px] w-[100px]" />
)} )}
<div> <div>
<ul className="mt-2 text-center"> <ul className="mt-2 text-center">