Add generic to CardRow type

squash cardrow type

squash cardrow type
This commit is contained in:
jeffvli 2022-12-24 13:35:27 -08:00
parent 747633fb25
commit 6eb08243b7
4 changed files with 10 additions and 8 deletions

View file

@ -9,6 +9,7 @@ import { Text } from '/@/renderer/components/text';
import type { LibraryItem, CardRow, CardRoute, Play, PlayQueueAddOptions } from '/@/renderer/types'; import type { LibraryItem, CardRow, CardRoute, Play, PlayQueueAddOptions } from '/@/renderer/types';
import { Skeleton } from '/@/renderer/components/skeleton'; import { Skeleton } from '/@/renderer/components/skeleton';
import { CardControls } from '/@/renderer/components/card/card-controls'; import { CardControls } from '/@/renderer/components/card/card-controls';
import { Album } from '/@/renderer/api/types';
const CardWrapper = styled.div<{ const CardWrapper = styled.div<{
link?: boolean; link?: boolean;
@ -102,7 +103,7 @@ const Row = styled.div<{ $secondary?: boolean }>`
interface BaseGridCardProps { interface BaseGridCardProps {
controls: { controls: {
cardRows: CardRow[]; cardRows: CardRow<Album>[];
itemType: LibraryItem; itemType: LibraryItem;
playButtonBehavior: Play; playButtonBehavior: Play;
route: CardRoute; route: CardRoute;
@ -178,7 +179,7 @@ export const AlbumCard = ({
</ControlsContainer> </ControlsContainer>
</ImageSection> </ImageSection>
<DetailSection> <DetailSection>
{cardRows.map((row: CardRow, index: number) => { {cardRows.map((row: CardRow<Album>, index: number) => {
if (row.arrayProperty && row.route) { if (row.arrayProperty && row.route) {
return ( return (
<Row <Row
@ -294,7 +295,7 @@ export const AlbumCard = ({
<ImageSection /> <ImageSection />
</Skeleton> </Skeleton>
<DetailSection style={{ width: '100%' }}> <DetailSection style={{ width: '100%' }}>
{cardRows.map((_row: CardRow, index: number) => ( {cardRows.map((_row: CardRow<Album>, index: number) => (
<Skeleton <Skeleton
visible visible
height={15} height={15}

View file

@ -12,7 +12,7 @@ import { AlbumCard } from '/@/renderer/components/card';
import { useHandlePlayQueueAdd } from '/@/renderer/features/player/hooks/use-handle-playqueue-add'; import { useHandlePlayQueueAdd } from '/@/renderer/features/player/hooks/use-handle-playqueue-add';
interface GridCarouselProps { interface GridCarouselProps {
cardRows: CardRow[]; cardRows: CardRow<any>[];
children: React.ReactElement; children: React.ReactElement;
containerWidth: number; containerWidth: number;
data: any[] | undefined; data: any[] | undefined;

View file

@ -7,7 +7,7 @@ import type { CardRoute, CardRow, LibraryItem, PlayQueueAddOptions } from '/@/re
import { CardDisplayType } from '/@/renderer/types'; import { CardDisplayType } from '/@/renderer/types';
interface VirtualGridProps extends Omit<FixedSizeListProps, 'children' | 'itemSize'> { interface VirtualGridProps extends Omit<FixedSizeListProps, 'children' | 'itemSize'> {
cardRows: CardRow[]; cardRows: CardRow<any>[];
display?: CardDisplayType; display?: CardDisplayType;
fetchFn: (options: { columnCount: number; skip: number; take: number }) => Promise<any>; fetchFn: (options: { columnCount: number; skip: number; take: number }) => Promise<any>;
handlePlayQueueAdd?: (options: PlayQueueAddOptions) => void; handlePlayQueueAdd?: (options: PlayQueueAddOptions) => void;

View file

@ -1,3 +1,4 @@
import { Album, AlbumArtist, Artist } from '/@/renderer/api/types';
import { AppRoute } from '/@/renderer/router/routes'; import { AppRoute } from '/@/renderer/router/routes';
export type RouteSlug = { export type RouteSlug = {
@ -12,9 +13,9 @@ export type CardRoute = {
export type TableType = 'nowPlaying' | 'sideQueue' | 'sideDrawerQueue' | 'songs'; export type TableType = 'nowPlaying' | 'sideQueue' | 'sideDrawerQueue' | 'songs';
export type CardRow = { export type CardRow<T> = {
arrayProperty?: string; arrayProperty?: string;
property: string; property: keyof T;
route?: CardRoute; route?: CardRoute;
}; };
@ -161,7 +162,7 @@ export type PlayQueueAddOptions = {
export type GridCardData = { export type GridCardData = {
cardControls: any; cardControls: any;
cardRows: CardRow[]; cardRows: CardRow<Album | AlbumArtist | Artist>[];
columnCount: number; columnCount: number;
display: CardDisplayType; display: CardDisplayType;
handlePlayQueueAdd: (options: PlayQueueAddOptions) => void; handlePlayQueueAdd: (options: PlayQueueAddOptions) => void;