spoti-search/src/components/Results.tsx

62 lines
1.4 KiB
TypeScript
Raw Normal View History

import React from 'react';
2020-07-23 19:17:31 +00:00
import { Box, Grid, Avatar, Image, ResponsiveContext, Heading } from 'grommet';
2020-07-23 09:43:12 +00:00
2020-07-23 19:17:31 +00:00
import { Card as Album } from './Card';
import { Artists } from '../interfaces';
2020-07-23 19:17:31 +00:00
import { size } from 'lodash';
export const Results = ({ artists }: { artists: Artists }) => {
const {
name: selectedName,
image: selectedImage,
albums: selectedAlbums,
} = artists[0];
return (
<Grid
rows={['fit', 'fit']}
columns={['1/4', '3/4']}
gap='small'
areas={[
2020-07-23 19:17:31 +00:00
['artist', 'other'],
['discography', 'discography'],
]}
2020-07-23 09:43:12 +00:00
>
2020-07-23 19:17:31 +00:00
<Box gridArea='artist' height='300px' >
<h1>{selectedName}</h1>
2020-07-23 19:17:31 +00:00
<Image src={selectedImage} fit='cover' />
</Box>
2020-07-23 19:17:31 +00:00
<Box gridArea='other' background='light-2'>
<h3>Other results</h3>
{artists.map((artist) => (
2020-07-23 19:17:31 +00:00
<Box gridArea='artist' key={artist.id}>
<Avatar src={artist.image} />
<h4>{artist.name}</h4>
</Box>
))}
</Box>
2020-07-23 19:17:31 +00:00
<ResponsiveContext.Consumer>
{(size) => (
<Grid
gridArea='discography'
align='start'
columns={{ count: 'fill', size: '300px' }}
gap='medium'
>
<Heading level='1'>
Discography
</Heading>
{selectedAlbums.map((album) => (
<Album
key={album.id}
image={album.image}
name={album.name}
/>
))}
</Grid>
)}
</ResponsiveContext.Consumer>
</Grid>
2020-07-23 09:43:12 +00:00
);
};