Skip to content

Commit

Permalink
fix(minimal-blog): Use function for SpotifyPlayer example component
Browse files Browse the repository at this point in the history
  • Loading branch information
LekoArts committed Jul 9, 2020
1 parent e049142 commit bd2c343
Showing 1 changed file with 13 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @see https://developer.spotify.com/technologies/widgets/spotify-play-button/
*/

import React, { Component } from "react"
import React from "react"

// Size presets, defined by Spotify
const sizePresets = {
Expand All @@ -22,34 +22,18 @@ const sizePresets = {
},
}

/**
* SpotifyPlayer class
*/
class SpotifyPlayer extends Component {
// ------------------------------------------------------
// Render
// ------------------------------------------------------

render() {
const { uri, view, theme } = this.props
let { size } = this.props

if (typeof size === `string`) {
size = sizePresets[size]
}

return (
<iframe
title="Spotify"
className="SpotifyPlayer"
src={`https://embed.spotify.com/?uri=${uri}&view=${view}&theme=${theme}`}
width={size.width}
height={size.height}
frameBorder="0"
allowtransparency="true"
/>
)
}
function SpotifyPlayer({ uri, view, theme, size }) {
return (
<iframe
title="Spotify"
className="SpotifyPlayer"
src={`https://embed.spotify.com/?uri=${uri}&view=${view}&theme=${theme}`}
width={sizePresets[size].width}
height={sizePresets[size].height}
frameBorder="0"
allowtransparency="true"
/>
)
}

export default SpotifyPlayer

0 comments on commit bd2c343

Please sign in to comment.