Add placeholder image where needed
This commit is contained in:
parent
cfc628fa59
commit
b6a77263c8
BIN
src/assets/placeholder-music.jpg
Normal file
BIN
src/assets/placeholder-music.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
@ -1,7 +1,14 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Box, Heading, Image } from 'grommet';
|
import { Box, Heading, Image } from 'grommet';
|
||||||
|
|
||||||
|
import placeholder from '../assets/placeholder-music.jpg';
|
||||||
|
|
||||||
export const Album = ({ image, name }: { image: string; name: string }) => {
|
export const Album = ({ image, name }: { image: string; name: string }) => {
|
||||||
|
// Load placeholder image if none provided
|
||||||
|
if (!image) {
|
||||||
|
image = placeholder;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box round='xxsmall' elevation='small' overflow='hidden'>
|
<Box round='xxsmall' elevation='small' overflow='hidden'>
|
||||||
<Box height='300px'>
|
<Box height='300px'>
|
||||||
|
@ -8,6 +8,7 @@ import { Search } from './Search';
|
|||||||
import { Results } from './Results';
|
import { Results } from './Results';
|
||||||
import { Artists, Artist } from '../interfaces';
|
import { Artists, Artist } from '../interfaces';
|
||||||
|
|
||||||
|
|
||||||
const QUERY_ARTISTS = gql`
|
const QUERY_ARTISTS = gql`
|
||||||
query Artist($byName: String!) {
|
query Artist($byName: String!) {
|
||||||
queryArtists(byName: $byName) {
|
queryArtists(byName: $byName) {
|
||||||
@ -50,7 +51,6 @@ export default function App() {
|
|||||||
|
|
||||||
const handleSelect = (suggestion: string) => {
|
const handleSelect = (suggestion: string) => {
|
||||||
let updatedArtists: Artists = [];
|
let updatedArtists: Artists = [];
|
||||||
|
|
||||||
let suggestedArtists: Artists = data.queryArtists.slice(0, 5);
|
let suggestedArtists: Artists = data.queryArtists.slice(0, 5);
|
||||||
|
|
||||||
// Find the selected artist and move it to index 0
|
// Find the selected artist and move it to index 0
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Box, Heading } from 'grommet';
|
import { Box, Heading } from 'grommet';
|
||||||
|
|
||||||
|
import placeholder from '../assets/placeholder-music.jpg';
|
||||||
|
|
||||||
export const Other = ({
|
export const Other = ({
|
||||||
image,
|
image,
|
||||||
name,
|
name,
|
||||||
@ -10,6 +12,11 @@ export const Other = ({
|
|||||||
name: string;
|
name: string;
|
||||||
handleClick: (name: string) => void;
|
handleClick: (name: string) => void;
|
||||||
}) => {
|
}) => {
|
||||||
|
// Load placeholder image if none provided
|
||||||
|
if (!image) {
|
||||||
|
image = placeholder;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
round='xxsmall'
|
round='xxsmall'
|
||||||
|
@ -4,6 +4,7 @@ import { Box, Grid, ResponsiveContext, Heading } from 'grommet';
|
|||||||
import { Album } from './Album';
|
import { Album } from './Album';
|
||||||
import { Artists, Albums } from '../interfaces';
|
import { Artists, Albums } from '../interfaces';
|
||||||
import { Other } from './Other';
|
import { Other } from './Other';
|
||||||
|
import placeholder from '../assets/placeholder-music.jpg';
|
||||||
|
|
||||||
export const Results = ({
|
export const Results = ({
|
||||||
artists,
|
artists,
|
||||||
@ -12,13 +13,15 @@ export const Results = ({
|
|||||||
artists: Artists;
|
artists: Artists;
|
||||||
handleClick: (name: string) => void;
|
handleClick: (name: string) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const { name: selectedName, image, albums } = artists[0];
|
||||||
name: selectedName,
|
|
||||||
image: selectedImage,
|
|
||||||
albums,
|
|
||||||
} = artists[0];
|
|
||||||
const otherArtists = artists.slice(1, artists.length);
|
const otherArtists = artists.slice(1, artists.length);
|
||||||
let selectedAlbums: Albums = [];
|
let selectedAlbums: Albums = [];
|
||||||
|
let selectedImage: string = image;
|
||||||
|
|
||||||
|
// Load placeholder image if none provided
|
||||||
|
if (!image) {
|
||||||
|
selectedImage = placeholder;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove duplicate albums based on `name`
|
// Remove duplicate albums based on `name`
|
||||||
// Might need to refine this according to the data quality
|
// Might need to refine this according to the data quality
|
||||||
|
Loading…
Reference in New Issue
Block a user