From 20e6abb48cada5348ddf921ac778c1fd1f45d11c Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Sat, 5 Oct 2024 15:31:30 -0700 Subject: improve channel card component design --- components.json | 16 ----- src/components/ChannelCard/ChannelCard.tsx | 94 ++++++++++++++++++++++++++++++ src/components/Divider/Divider.tsx | 2 +- src/components/channel-card.tsx | 84 -------------------------- src/components/ui/avatar.tsx | 50 ---------------- src/components/ui/badge.tsx | 36 ------------ src/components/ui/card.tsx | 86 --------------------------- src/lib/utils.ts | 6 -- src/pages/stats/[slug].tsx | 84 +++++++++++++------------- 9 files changed, 137 insertions(+), 321 deletions(-) delete mode 100644 components.json create mode 100644 src/components/ChannelCard/ChannelCard.tsx delete mode 100644 src/components/channel-card.tsx delete mode 100644 src/components/ui/avatar.tsx delete mode 100644 src/components/ui/badge.tsx delete mode 100644 src/components/ui/card.tsx delete mode 100644 src/lib/utils.ts diff --git a/components.json b/components.json deleted file mode 100644 index 2fceff5..0000000 --- a/components.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "https://ui.shadcn.com/schema.json", - "style": "default", - "rsc": true, - "tsx": true, - "tailwind": { - "config": "tailwind.config.ts", - "css": "src/app/globals.css", - "baseColor": "gray", - "cssVariables": false - }, - "aliases": { - "utils": "@/lib/utils", - "components": "@/components" - } -} \ No newline at end of file diff --git a/src/components/ChannelCard/ChannelCard.tsx b/src/components/ChannelCard/ChannelCard.tsx new file mode 100644 index 0000000..83471f2 --- /dev/null +++ b/src/components/ChannelCard/ChannelCard.tsx @@ -0,0 +1,94 @@ +import React from 'react'; +import Image from 'next/image'; + +type ChannelCardProps = { + channel_id: string; + name: string; + avatarUrl: string; + subscriberCount: number; + videoCount: number; + viewCount: number; + suborg?: string; + nextMilestone: string; + nextMilestoneDays: string; + nextMilestoneDate: string; +}; + +const ChannelCard: React.FC = ({ + channel_id, + name, + avatarUrl, + subscriberCount, + videoCount, + viewCount, + suborg, + nextMilestone, + nextMilestoneDays, + nextMilestoneDate, +}) => { + return ( +
+
+ {name} +
+

+ {name} +

+ {suborg && ( +

+ {suborg} +

+ )} +
+
+
+
+

+ {subscriberCount.toLocaleString()} +

+

+ Subscribers +

+
+
+

+ {videoCount.toLocaleString()} +

+

+ Videos +

+
+
+

+ {viewCount.toLocaleString()} +

+

+ Views +

+
+
+
+

+ Next Milestone: {Number(nextMilestone).toLocaleString()} +

+

+ Estimated in {nextMilestoneDays} days ({nextMilestoneDate}) +

+
+ +
+ ); +}; + +export default ChannelCard; \ No newline at end of file diff --git a/src/components/Divider/Divider.tsx b/src/components/Divider/Divider.tsx index e2ef41b..ef6b30b 100644 --- a/src/components/Divider/Divider.tsx +++ b/src/components/Divider/Divider.tsx @@ -4,7 +4,7 @@ interface DividerProps { const Divider = (props: DividerProps) => { return ( -
+
{props.text}
diff --git a/src/components/channel-card.tsx b/src/components/channel-card.tsx deleted file mode 100644 index c19f492..0000000 --- a/src/components/channel-card.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; -import { Badge } from "@/components/ui/badge"; -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; - -interface ChannelCardProps { - channel_id: string; - name: string; - avatarUrl: string; - subscriberCount: number; - videoCount: number; - viewCount: number; - suborg: string; - nextMilestone: string; - nextMilestoneDays: string; - nextMilestoneDate: string; -} - -export function ChannelCard(props: ChannelCardProps) { - const { - channel_id, - name, - avatarUrl, - subscriberCount, - videoCount, - viewCount, - suborg, - nextMilestone, - nextMilestoneDays, - nextMilestoneDate, - } = props; - return ( - - -
- - - PR - -
- - {name} - - {suborg} -
-
-
- -
- Subscribers - - {Number(subscriberCount).toLocaleString()} - -
-
- Videos - {videoCount} -
-
- View Count - - {Number(viewCount).toLocaleString()} - -
-
- Next Milestone - - {Number(nextMilestone).toLocaleString()} - -
- - {nextMilestoneDays} days - - - {nextMilestoneDate} - -
-
-
-
- ); -} diff --git a/src/components/ui/avatar.tsx b/src/components/ui/avatar.tsx deleted file mode 100644 index 3c884e8..0000000 --- a/src/components/ui/avatar.tsx +++ /dev/null @@ -1,50 +0,0 @@ -"use client"; - -import * as AvatarPrimitive from "@radix-ui/react-avatar"; -import * as React from "react"; - -import { cn } from "@/lib/utils"; - -const Avatar = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); -Avatar.displayName = AvatarPrimitive.Root.displayName; - -const AvatarImage = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); -AvatarImage.displayName = AvatarPrimitive.Image.displayName; - -const AvatarFallback = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); -AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName; - -export { Avatar, AvatarImage, AvatarFallback }; diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx deleted file mode 100644 index f38976c..0000000 --- a/src/components/ui/badge.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { type VariantProps, cva } from "class-variance-authority"; -import type * as React from "react"; - -import { cn } from "@/lib/utils"; - -const badgeVariants = cva( - "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", - { - variants: { - variant: { - default: - "border-transparent bg-primary text-primary-foreground hover:bg-primary/80", - secondary: - "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", - destructive: - "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", - outline: "text-foreground", - }, - }, - defaultVariants: { - variant: "default", - }, - }, -); - -export interface BadgeProps - extends React.HTMLAttributes, - VariantProps {} - -function Badge({ className, variant, ...props }: BadgeProps) { - return ( -
- ); -} - -export { Badge, badgeVariants }; diff --git a/src/components/ui/card.tsx b/src/components/ui/card.tsx deleted file mode 100644 index 2681236..0000000 --- a/src/components/ui/card.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import * as React from "react"; - -import { cn } from "@/lib/utils"; - -const Card = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
-)); -Card.displayName = "Card"; - -const CardHeader = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
-)); -CardHeader.displayName = "CardHeader"; - -const CardTitle = React.forwardRef< - HTMLParagraphElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -

-)); -CardTitle.displayName = "CardTitle"; - -const CardDescription = React.forwardRef< - HTMLParagraphElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -

-)); -CardDescription.displayName = "CardDescription"; - -const CardContent = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -

-)); -CardContent.displayName = "CardContent"; - -const CardFooter = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
-)); -CardFooter.displayName = "CardFooter"; - -export { - Card, - CardHeader, - CardFooter, - CardTitle, - CardDescription, - CardContent, -}; diff --git a/src/lib/utils.ts b/src/lib/utils.ts deleted file mode 100644 index ac680b3..0000000 --- a/src/lib/utils.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { type ClassValue, clsx } from "clsx"; -import { twMerge } from "tailwind-merge"; - -export function cn(...inputs: ClassValue[]) { - return twMerge(clsx(inputs)); -} diff --git a/src/pages/stats/[slug].tsx b/src/pages/stats/[slug].tsx index dfd63e4..685d01b 100644 --- a/src/pages/stats/[slug].tsx +++ b/src/pages/stats/[slug].tsx @@ -4,7 +4,7 @@ import CompactTable from "@/components/CompactTable/CompactTable"; import DataChart from "@/components/DataChart/DataChart"; import Divider from "@/components/Divider/Divider"; import Footer from "@/components/Footer/Footer"; -import { ChannelCard } from "@/components/channel-card"; +import ChannelCard from "@/components/ChannelCard/ChannelCard" import Head from "next/head"; import TitleBar from "../../components/TitleBar/TitleBar"; @@ -93,48 +93,48 @@ function Page({ showHomeButton backgroundColor="black" /> -
-
- -
+
+
- -
-
- -
-
- -
- -
- -

For intervals which we did not record any data, the closest recorded datapoint is chosen

+
+ +
+
+ +
+
+ +
+ +
+ +

For intervals which we did not record any data, the closest recorded datapoint is chosen

+