diff --git a/components/contributions-table/row.tsx b/components/contributions-table/row.tsx index 9d9c7ac..25a48a0 100644 --- a/components/contributions-table/row.tsx +++ b/components/contributions-table/row.tsx @@ -13,9 +13,9 @@ interface IProjectProps { } export const Project = ({ avatarSrc, name, repository }: IProjectProps) => { return ( -
+
-
+

{name}

{repository}

@@ -47,12 +47,22 @@ Project.Avatar = Avatar; interface IContentProps { title: string; + project: string; + repository: string; language: string; //TODO: make it an enum type with available languages from filters } -export const Content = ({ title, language }: IContentProps) => { +export const Content = ({ + title, + project, + repository, + language, +}: IContentProps) => { return ( -
-

{title}

+
+

+ {title} +

+ {`${project} / ${repository}`} {language} diff --git a/components/contributions-table/table.tsx b/components/contributions-table/table.tsx index bf19642..973253b 100644 --- a/components/contributions-table/table.tsx +++ b/components/contributions-table/table.tsx @@ -1,5 +1,6 @@ "use client"; import React from "react"; +import { useMediaQuery } from "react-responsive"; import { Table as NuiTable, TableHeader, @@ -14,6 +15,7 @@ import { Contribution, PaginatedContributions } from "@/types/contribution"; import { ExternalLink, Content, Labels, Time, Project } from "./row"; import { useContributions } from "@/hooks/useContributions"; import { KudosQueryParameters } from "@/lib/notion/types"; +import { isNotNull } from "@/utils/type-guard"; interface ITableProps { items: PaginatedContributions; @@ -34,6 +36,16 @@ export const Table = ({ items, queries = {} }: ITableProps) => { return results?.pages.flatMap((page) => page.data) || []; }, [results]); + const isMobile = useMediaQuery({ maxWidth: 639 }); // tailwind lg default: 640px + const isLaptop = useMediaQuery({ minWidth: 1024 }); // tailwind lg default: 1024px + const COLUMNS = [ + { name: "PROJECT", uid: "project" }, + { name: "CONTENT", uid: "content" }, + isLaptop ? { name: "LABELS", uid: "labels" } : null, + { name: "DATE", uid: "date" }, + isMobile ? null : { name: "ACTIONS", uid: "actions" }, + ].filter(isNotNull); + const renderCell = React.useCallback( (item: Contribution, columnKey: React.Key) => { const cellValue = item[columnKey as keyof Contribution]; @@ -48,11 +60,25 @@ export const Table = ({ items, queries = {} }: ITableProps) => { /> ); case "content": - return ; + return ( + + ); case "labels": return ; case "date": - return