File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -436,6 +436,8 @@ import { LocationMessage } from 'react-chat-elements'
436436import { SpotifyMessage } from ' react-chat-elements'
437437
438438< SpotifyMessage
439+ theme= ' white'
440+ view= ' coverart'
439441 uri= {' spotify:user:spotify:playlist:3rgsDhGHZxZ9sB9DQWQfuf' }/ >
440442```
441443
@@ -444,6 +446,8 @@ import { SpotifyMessage } from 'react-chat-elements'
444446| prop | default | type | description |
445447| ---- | ---- | ---- | ---- |
446448| uri | none | uri | spotify uri |
449+ | theme | black | string | spotify theme color (black or white) |
450+ | view | list | string | spotify view type (list or coverart) |
447451| data | {} | object | message data |
448452| width | 300 | int | spotify embed width |
449453| height | 380 | int | spotify embed height |
Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ export class App extends Component {
9090 position : ( this . token ( ) >= 1 ? 'right' : 'left' ) ,
9191 forwarded : true ,
9292 type : type ,
93+ theme : 'white' ,
94+ view : 'list' ,
9395 title : loremIpsum ( { count : 2 , units : 'words' } ) ,
9496 titleColor : this . getRandomColor ( ) ,
9597 text : type === 'spotify' ? 'spotify:user:spotify:playlist:3rgsDhGHZxZ9sB9DQWQfuf' : loremIpsum ( { count : 1 , units : 'sentences' } ) ,
Original file line number Diff line number Diff line change @@ -93,6 +93,8 @@ export class MessageBox extends Component {
9393 < SpotifyMessage
9494 width = { this . props . width }
9595 height = { this . props . height }
96+ theme = { this . props . theme }
97+ view = { this . props . view }
9698 data = { this . props . data }
9799 uri = { this . props . uri || this . props . text } />
98100 }
Original file line number Diff line number Diff line change @@ -4,13 +4,29 @@ import './SpotifyMessage.css';
44const classNames = require ( 'classnames' ) ;
55
66export class SpotifyMessage extends Component {
7+ toUrl ( ) {
8+ var formBody = [ ] ;
9+ var data = {
10+ uri : this . props . uri ,
11+ theme : this . props . theme ,
12+ view : this . props . view ,
13+ } ;
14+ for ( var property in data ) {
15+ var encodedKey = encodeURIComponent ( property ) ;
16+ var encodedValue = encodeURIComponent ( data [ property ] ) ;
17+ formBody . push ( encodedKey + "=" + encodedValue ) ;
18+ }
19+ formBody = formBody . join ( "&" ) ;
20+ return formBody ;
21+ }
22+
723 render ( ) {
824 if ( ! this . props . uri )
925 return null ;
1026 return (
1127 < div className = "rce-mbox-spotify" >
1228 < iframe
13- src = { "https://open.spotify.com/embed?uri= " + this . props . uri }
29+ src = { "https://open.spotify.com/embed?" + this . toUrl ( ) }
1430 width = { this . props . width }
1531 height = { this . props . height }
1632 frameBorder = "0"
@@ -21,6 +37,9 @@ export class SpotifyMessage extends Component {
2137}
2238
2339SpotifyMessage . defaultProps = {
40+ uri : '' ,
41+ theme : 'black' ,
42+ view : 'list' ,
2443 width : 300 ,
2544 height : 380 ,
2645}
You can’t perform that action at this time.
0 commit comments