diff --git a/src/components/Sidebar.astro b/src/components/Sidebar.astro index 753f953..66831f6 100644 --- a/src/components/Sidebar.astro +++ b/src/components/Sidebar.astro @@ -11,6 +11,7 @@ import SidebarSection from './sidebar/SidebarSection.astro' import Highlight from './sidebar/Highlight.astro' import AlbumBox from './AlbumBox.astro' import AlbumCount from './sidebar/AlbumCount.astro' +import CommentCarousel from './sidebar/CommentCarousel.astro' const listClass = 'uppercase text-3xl font-semibold w-full text-center py-3 hover:bg-dark-hover hover:text-cyan-400 hover:underline' @@ -48,6 +49,9 @@ const listClass = + + + diff --git a/src/components/sidebar/CommentCarousel.astro b/src/components/sidebar/CommentCarousel.astro new file mode 100644 index 0000000..d638047 --- /dev/null +++ b/src/components/sidebar/CommentCarousel.astro @@ -0,0 +1,27 @@ +--- +import prismaClient from 'utils/prisma-client' +import { Icon } from 'astro-icon/components' + +import SidebarSection from './SidebarSection.astro' +import Looper from './CommentCarousel/Looper' + +const comments = await prismaClient.comments.findMany({ + select: { text: true, albums: { select: { id: true, title: true } } }, + orderBy: { createdAt: 'desc' }, + take: 5 +}) +--- + + + + + + + diff --git a/src/components/sidebar/CommentCarousel/Looper.tsx b/src/components/sidebar/CommentCarousel/Looper.tsx new file mode 100644 index 0000000..66ae6f2 --- /dev/null +++ b/src/components/sidebar/CommentCarousel/Looper.tsx @@ -0,0 +1,58 @@ +import clsx from 'clsx' +import { useEffect, useRef, useState, type ButtonHTMLAttributes, type ReactNode } from 'react' + +interface Props { + comments: { + text: string | null + albums: { + id: number + title: string | null + } | null + }[] +} + +function ArrowButton(props: ButtonHTMLAttributes) { + const { className, ...rest } = props + + return