From 81271909ad52b2abcaac1f5f186242fb4487458c Mon Sep 17 00:00:00 2001 From: Edouard Wautier <4435185+Duncid@users.noreply.github.com> Date: Tue, 14 Jan 2025 14:30:46 +0100 Subject: [PATCH] Trying to fix linting --- sparkle/src/components/DataTable.tsx | 163 +++++++++++++-------------- 1 file changed, 76 insertions(+), 87 deletions(-) diff --git a/sparkle/src/components/DataTable.tsx b/sparkle/src/components/DataTable.tsx index 9c1f9b52218a..1912f6d2af2d 100644 --- a/sparkle/src/components/DataTable.tsx +++ b/sparkle/src/components/DataTable.tsx @@ -15,6 +15,7 @@ import { import React, { ReactNode, useEffect, useState } from "react"; import { + Avatar, Button, DropdownMenu, DropdownMenuContent, @@ -26,7 +27,6 @@ import { Pagination, Tooltip, } from "@sparkle/components"; -import { Avatar } from "@sparkle/components/Avatar"; import { useCopyToClipboard } from "@sparkle/hooks"; import { ArrowDownIcon, @@ -35,7 +35,7 @@ import { ClipboardIcon, MoreIcon, } from "@sparkle/icons"; -import { classNames, cn } from "@sparkle/lib/utils"; +import { cn } from "@sparkle/lib/utils"; import { Icon } from "./Icon"; import { breakpoints, useWindowSize } from "./WindowUtility"; @@ -165,8 +165,8 @@ export function DataTable({ return (
({ column={header.column} key={header.id} onClick={header.column.getToggleSortingHandler()} - className={classNames( + className={cn( header.column.getCanSort() ? "s-cursor-pointer" : "" )} > @@ -207,7 +207,7 @@ export function DataTable({ : ArrowDownIcon } size="xs" - className={classNames( + className={cn( "s-ml-1", header.column.getIsSorted() ? "s-opacity-100" @@ -305,8 +305,8 @@ DataTable.Head = function Head({ }: HeadProps) { const content = ( { + avatarUrl?: string; + avatarTooltipLabel?: string; + icon?: React.ComponentType<{ className?: string }>; + iconClassName?: string; + roundedAvatar?: boolean; + children?: ReactNode; + description?: string; +} + +DataTable.CellContent = function CellContent({ + children, + className, + avatarUrl, + avatarTooltipLabel, + roundedAvatar, + icon, + iconClassName, + description, + ...props +}: CellContentProps) { + return ( +
+ {avatarUrl && avatarTooltipLabel && ( + + } + label={avatarTooltipLabel} + /> + )} + {avatarUrl && !avatarTooltipLabel && ( + + )} + {icon && ( + + )} +
+ + {children} + + {description && ( + + {description} + + )} +
+
+ ); +}; + interface BasicCellContentProps extends React.TdHTMLAttributes { label: string | number; tooltip?: string | number; @@ -525,77 +590,6 @@ DataTable.BasicCellContent = function BasicCellContent({ ); }; -interface CellContentProps extends React.TdHTMLAttributes { - avatarUrl?: string; - avatarTooltipLabel?: string; - icon?: React.ComponentType<{ className?: string }>; - iconClassName?: string; - roundedAvatar?: boolean; - children?: ReactNode; - description?: string; -} - -DataTable.CellContent = function CellContent({ - children, - className, - avatarUrl, - avatarTooltipLabel, - roundedAvatar, - icon, - iconClassName, - description, - ...props -}: CellContentProps) { - return ( -
- {avatarUrl && avatarTooltipLabel && ( - - } - label={avatarTooltipLabel} - /> - )} - {avatarUrl && !avatarTooltipLabel && ( - - )} - {icon && ( - - )} -
- - {children} - - {description && ( - - {description} - - )} -
-
- ); -}; - interface CellContentWithCopyProps { children: React.ReactNode; textToCopy?: string; @@ -620,12 +614,7 @@ DataTable.CellContentWithCopy = function CellContentWithCopy({ }; return ( -
+
{children}