2020-07-23 12:07:29 +00:00
|
|
|
import React from 'react';
|
2020-07-23 22:12:31 +00:00
|
|
|
import { Box, Grid, ResponsiveContext, Heading } from 'grommet';
|
2020-07-23 09:43:12 +00:00
|
|
|
|
2020-07-23 22:12:31 +00:00
|
|
|
import { Album } from './Album';
|
2020-07-23 12:07:29 +00:00
|
|
|
import { Artists } from '../interfaces';
|
2020-07-23 22:12:31 +00:00
|
|
|
import { Other } from './Other';
|
2020-07-23 12:07:29 +00:00
|
|
|
|
2020-07-23 23:10:57 +00:00
|
|
|
export const Results = ({
|
|
|
|
artists,
|
|
|
|
handleClick,
|
|
|
|
}: {
|
|
|
|
artists: Artists;
|
2020-07-24 11:58:02 +00:00
|
|
|
handleClick: (name: string) => void;
|
2020-07-23 23:10:57 +00:00
|
|
|
}) => {
|
2020-07-23 17:53:47 +00:00
|
|
|
const {
|
|
|
|
name: selectedName,
|
|
|
|
image: selectedImage,
|
|
|
|
albums: selectedAlbums,
|
|
|
|
} = artists[0];
|
2020-07-23 12:07:29 +00:00
|
|
|
|
2020-07-23 14:23:15 +00:00
|
|
|
return (
|
2020-07-23 12:07:29 +00:00
|
|
|
<Grid
|
2020-07-23 22:12:31 +00:00
|
|
|
as='section'
|
2020-07-23 17:53:47 +00:00
|
|
|
rows={['fit', 'fit']}
|
2020-07-23 22:12:31 +00:00
|
|
|
columns={['fit', '2/3']}
|
2020-07-23 12:07:29 +00:00
|
|
|
gap='small'
|
|
|
|
areas={[
|
2020-07-23 22:12:31 +00:00
|
|
|
['artist-title', 'other-title'],
|
2020-07-23 19:17:31 +00:00
|
|
|
['artist', 'other'],
|
2020-07-23 22:12:31 +00:00
|
|
|
['disco-title', 'disco-title'],
|
2020-07-23 12:07:29 +00:00
|
|
|
['discography', 'discography'],
|
|
|
|
]}
|
2020-07-23 09:43:12 +00:00
|
|
|
>
|
2020-07-23 22:12:31 +00:00
|
|
|
<Heading
|
|
|
|
level='1'
|
|
|
|
gridArea='artist-title'
|
|
|
|
margin={{ vertical: 'none' }}
|
|
|
|
>
|
|
|
|
{selectedName}
|
|
|
|
</Heading>
|
2020-07-23 23:10:57 +00:00
|
|
|
<Grid gridArea='artist' margin={{ bottom: 'medium' }}>
|
2020-07-23 22:12:31 +00:00
|
|
|
<Box
|
|
|
|
round='full'
|
|
|
|
background={{
|
|
|
|
repeat: 'no-repeat',
|
|
|
|
size: 'cover',
|
|
|
|
image: `url(${selectedImage})`,
|
|
|
|
}}
|
|
|
|
height='300px'
|
|
|
|
width='300px'
|
|
|
|
/>
|
|
|
|
</Grid>
|
|
|
|
<Heading
|
|
|
|
level='2'
|
|
|
|
gridArea='other-title'
|
|
|
|
margin={{ vertical: 'none' }}
|
|
|
|
alignSelf='end'
|
2020-07-23 23:10:57 +00:00
|
|
|
size='small'
|
2020-07-23 22:12:31 +00:00
|
|
|
>
|
|
|
|
Other results
|
|
|
|
</Heading>
|
|
|
|
<ResponsiveContext.Consumer>
|
|
|
|
{(size) => (
|
|
|
|
<Box gridArea='other' direction='row' wrap>
|
|
|
|
{artists.slice(1, artists.length).map((artist) => (
|
|
|
|
<Other
|
|
|
|
key={artist.id}
|
|
|
|
image={artist.image}
|
|
|
|
name={artist.name}
|
2020-07-23 23:10:57 +00:00
|
|
|
handleClick={handleClick}
|
2020-07-23 22:12:31 +00:00
|
|
|
/>
|
|
|
|
))}
|
2020-07-23 17:53:47 +00:00
|
|
|
</Box>
|
2020-07-23 22:12:31 +00:00
|
|
|
)}
|
|
|
|
</ResponsiveContext.Consumer>
|
|
|
|
<Heading level='2' gridArea='disco-title' size='large'>
|
|
|
|
Discography
|
|
|
|
</Heading>
|
2020-07-23 19:17:31 +00:00
|
|
|
<ResponsiveContext.Consumer>
|
|
|
|
{(size) => (
|
|
|
|
<Grid
|
|
|
|
gridArea='discography'
|
|
|
|
align='start'
|
|
|
|
columns={{ count: 'fill', size: '300px' }}
|
2020-07-23 22:12:31 +00:00
|
|
|
gap='large'
|
2020-07-23 19:17:31 +00:00
|
|
|
>
|
|
|
|
{selectedAlbums.map((album) => (
|
|
|
|
<Album
|
|
|
|
key={album.id}
|
|
|
|
image={album.image}
|
|
|
|
name={album.name}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</Grid>
|
|
|
|
)}
|
|
|
|
</ResponsiveContext.Consumer>
|
2020-07-23 12:07:29 +00:00
|
|
|
</Grid>
|
2020-07-23 09:43:12 +00:00
|
|
|
);
|
|
|
|
};
|