mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
improve compact size item card
This commit is contained in:
@@ -177,6 +177,7 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
gap: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: var(--theme-spacing-xs);
|
padding: var(--theme-spacing-xs);
|
||||||
background-color: alpha(var(--theme-colors-background), 0.5);
|
background-color: alpha(var(--theme-colors-background), 0.5);
|
||||||
|
|||||||
@@ -896,7 +896,7 @@ const PosterItemCard = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getDataRows = (): DataRow[] => {
|
export const getDataRows = (type?: 'compact' | 'default' | 'poster'): DataRow[] => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
format: (data) => {
|
format: (data) => {
|
||||||
@@ -959,7 +959,11 @@ export const getDataRows = (): DataRow[] => {
|
|||||||
artistName={data.albumArtistName}
|
artistName={data.albumArtistName}
|
||||||
artists={data.albumArtists}
|
artists={data.albumArtists}
|
||||||
linkProps={{ fw: 400, isMuted: true }}
|
linkProps={{ fw: 400, isMuted: true }}
|
||||||
rootTextProps={{ fw: 400, isMuted: true, size: 'sm' }}
|
rootTextProps={{
|
||||||
|
fw: 400,
|
||||||
|
isMuted: type === 'compact' ? false : true,
|
||||||
|
size: 'sm',
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,11 @@ import { LibraryItem } from '/@/shared/types/domain-types';
|
|||||||
import { TableColumn } from '/@/shared/types/types';
|
import { TableColumn } from '/@/shared/types/types';
|
||||||
import { ItemListKey } from '/@/shared/types/types';
|
import { ItemListKey } from '/@/shared/types/types';
|
||||||
|
|
||||||
const getDefaultRowsForItemType = (itemType: LibraryItem): DataRow[] => {
|
const getDefaultRowsForItemType = (
|
||||||
const allRows = getDataRows();
|
itemType: LibraryItem,
|
||||||
|
type?: 'compact' | 'default' | 'poster',
|
||||||
|
): DataRow[] => {
|
||||||
|
const allRows = getDataRows(type);
|
||||||
const rowMap = new Map(allRows.map((row) => [row.id, row]));
|
const rowMap = new Map(allRows.map((row) => [row.id, row]));
|
||||||
|
|
||||||
switch (itemType) {
|
switch (itemType) {
|
||||||
@@ -80,16 +83,22 @@ const getRowIdFromTableColumn = (tableColumn: TableColumn): null | string => {
|
|||||||
return columnToRowIdMap[tableColumn] || null;
|
return columnToRowIdMap[tableColumn] || null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useGridRows = (itemType: LibraryItem, listKey?: ItemListKey) => {
|
export const useGridRows = (
|
||||||
|
itemType: LibraryItem,
|
||||||
|
listKey?: ItemListKey,
|
||||||
|
size?: 'compact' | 'default' | 'large',
|
||||||
|
) => {
|
||||||
const gridRowsConfig = useSettingsStore((state) =>
|
const gridRowsConfig = useSettingsStore((state) =>
|
||||||
listKey ? state.lists[listKey]?.grid?.rows : undefined,
|
listKey ? state.lists[listKey]?.grid?.rows : undefined,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const type: 'compact' | 'default' | 'poster' = size === 'compact' ? 'compact' : 'poster';
|
||||||
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
const allRows = getDataRows();
|
const allRows = getDataRows(type);
|
||||||
|
|
||||||
if (!listKey || !gridRowsConfig || gridRowsConfig.length === 0) {
|
if (!listKey || !gridRowsConfig || gridRowsConfig.length === 0) {
|
||||||
const defaultRows = getDefaultRowsForItemType(itemType);
|
const defaultRows = getDefaultRowsForItemType(itemType, type);
|
||||||
return defaultRows.length > 0 ? defaultRows : allRows;
|
return defaultRows.length > 0 ? defaultRows : allRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,5 +119,5 @@ export const useGridRows = (itemType: LibraryItem, listKey?: ItemListKey) => {
|
|||||||
.filter((row): row is NonNullable<typeof row> => row !== null && row !== undefined);
|
.filter((row): row is NonNullable<typeof row> => row !== null && row !== undefined);
|
||||||
|
|
||||||
return configuredRows.length > 0 ? configuredRows : allRows;
|
return configuredRows.length > 0 ? configuredRows : allRows;
|
||||||
}, [itemType, listKey, gridRowsConfig]);
|
}, [itemType, listKey, gridRowsConfig, type]);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export const AlbumListInfiniteGrid = ({
|
|||||||
enabled: saveScrollOffset,
|
enabled: saveScrollOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
const rows = useGridRows(LibraryItem.ALBUM, ItemListKey.ALBUM);
|
const rows = useGridRows(LibraryItem.ALBUM, ItemListKey.ALBUM, size);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemGridList
|
<ItemGridList
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export const AlbumListPaginatedGrid = ({
|
|||||||
enabled: saveScrollOffset,
|
enabled: saveScrollOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
const rows = useGridRows(LibraryItem.ALBUM, ItemListKey.ALBUM);
|
const rows = useGridRows(LibraryItem.ALBUM, ItemListKey.ALBUM, size);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemListWithPagination
|
<ItemListWithPagination
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export const AlbumArtistListInfiniteGrid = ({
|
|||||||
enabled: saveScrollOffset,
|
enabled: saveScrollOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
const rows = useGridRows(LibraryItem.ALBUM_ARTIST, ItemListKey.ALBUM_ARTIST);
|
const rows = useGridRows(LibraryItem.ALBUM_ARTIST, ItemListKey.ALBUM_ARTIST, size);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemGridList
|
<ItemGridList
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export const AlbumArtistListPaginatedGrid = ({
|
|||||||
enabled: saveScrollOffset,
|
enabled: saveScrollOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
const rows = useGridRows(LibraryItem.ALBUM_ARTIST, ItemListKey.ALBUM_ARTIST);
|
const rows = useGridRows(LibraryItem.ALBUM_ARTIST, ItemListKey.ALBUM_ARTIST, size);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemListWithPagination
|
<ItemListWithPagination
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export const ArtistListInfiniteGrid = ({
|
|||||||
enabled: saveScrollOffset,
|
enabled: saveScrollOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
const rows = useGridRows(LibraryItem.ARTIST, ItemListKey.ARTIST);
|
const rows = useGridRows(LibraryItem.ARTIST, ItemListKey.ARTIST, size);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemGridList
|
<ItemGridList
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export const ArtistListPaginatedGrid = ({
|
|||||||
enabled: saveScrollOffset,
|
enabled: saveScrollOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
const rows = useGridRows(LibraryItem.ARTIST, ItemListKey.ARTIST);
|
const rows = useGridRows(LibraryItem.ARTIST, ItemListKey.ARTIST, size);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemListWithPagination
|
<ItemListWithPagination
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export const GenreListInfiniteGrid = ({
|
|||||||
enabled: saveScrollOffset,
|
enabled: saveScrollOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
const rows = useGridRows(LibraryItem.GENRE, ItemListKey.GENRE);
|
const rows = useGridRows(LibraryItem.GENRE, ItemListKey.GENRE, size);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemGridList
|
<ItemGridList
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export const GenreListPaginatedGrid = ({
|
|||||||
enabled: saveScrollOffset,
|
enabled: saveScrollOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
const rows = useGridRows(LibraryItem.GENRE, ItemListKey.GENRE);
|
const rows = useGridRows(LibraryItem.GENRE, ItemListKey.GENRE, size);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemListWithPagination
|
<ItemListWithPagination
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export const PlaylistListInfiniteGrid = ({
|
|||||||
enabled: saveScrollOffset,
|
enabled: saveScrollOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
const rows = useGridRows(LibraryItem.PLAYLIST, ItemListKey.PLAYLIST);
|
const rows = useGridRows(LibraryItem.PLAYLIST, ItemListKey.PLAYLIST, size);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemGridList
|
<ItemGridList
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export const PlaylistListPaginatedGrid = ({
|
|||||||
enabled: saveScrollOffset,
|
enabled: saveScrollOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
const rows = useGridRows(LibraryItem.PLAYLIST, ItemListKey.PLAYLIST);
|
const rows = useGridRows(LibraryItem.PLAYLIST, ItemListKey.PLAYLIST, size);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemListWithPagination
|
<ItemListWithPagination
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export const SongListInfiniteGrid = ({
|
|||||||
enabled: saveScrollOffset,
|
enabled: saveScrollOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
const rows = useGridRows(LibraryItem.SONG, ItemListKey.SONG);
|
const rows = useGridRows(LibraryItem.SONG, ItemListKey.SONG, size);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemGridList
|
<ItemGridList
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export const SongListPaginatedGrid = ({
|
|||||||
serverId,
|
serverId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const rows = useGridRows(LibraryItem.SONG, ItemListKey.SONG);
|
const rows = useGridRows(LibraryItem.SONG, ItemListKey.SONG, size);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemListWithPagination
|
<ItemListWithPagination
|
||||||
|
|||||||
Reference in New Issue
Block a user