Song Card: Rework Layout for responsivity
This commit is contained in:
committed by
Clément Le Bihan
parent
d5b15cee13
commit
3ca2bdaa90
@@ -2,23 +2,20 @@ import React from 'react';
|
||||
import SongCard from './SongCard';
|
||||
import { FlatGrid } from 'react-native-super-grid';
|
||||
import { Heading, VStack } from 'native-base';
|
||||
import { RequireExactlyOne } from 'type-fest';
|
||||
|
||||
type SongCardGrid = {
|
||||
songs: Parameters<typeof SongCard>[0][];
|
||||
heading?: JSX.Element,
|
||||
} & RequireExactlyOne<{
|
||||
maxItemsPerRow: number,
|
||||
itemDimension: number,
|
||||
}>
|
||||
maxItemsPerRow?: number,
|
||||
style?: Parameters<typeof FlatGrid>[0]['additionalRowStyle']
|
||||
}
|
||||
|
||||
const SongCardGrid = (props: SongCardGrid) => {
|
||||
return <VStack space={5}>
|
||||
<Heading>{props.heading}</Heading>
|
||||
<FlatGrid
|
||||
maxItemsPerRow={props.maxItemsPerRow}
|
||||
itemDimension={props.itemDimension ?? (props.maxItemsPerRow ? undefined : 150)}
|
||||
additionalRowStyle={{ justifyContent: 'flex-start' }}
|
||||
additionalRowStyle={props.style ?? { justifyContent: 'flex-start' }}
|
||||
data={props.songs}
|
||||
renderItem={({ item }) => <SongCard {...item} /> }
|
||||
spacing={10}
|
||||
|
||||
Reference in New Issue
Block a user