Skip to content

Commit

Permalink
Make statistics that are not displayed grey in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
skycube19 committed Sep 29, 2024
1 parent 69daa75 commit f28e544
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/components/NowPlaying.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class NowPlaying extends React.Component<{}, {audioFeatures: AudioFeaturesRespon
songURI: "", // URI of the currently playing song
recTarget: "songs", // Recommendations based on either songs or artist
songMetrics: [], // Current song metric information
metricsToDisplay: [], // Current metric information types
metricsToDisplay: ["Danceability", "Energy", "Acousticness", "Loudness", "Key", "Tempo"], // Current metric information types
}

componentDidMount = () => {
Expand Down Expand Up @@ -49,13 +49,16 @@ class NowPlaying extends React.Component<{}, {audioFeatures: AudioFeaturesRespon

// Sets the song metric information based on the type of information that the user wants to be displayed
setSongMetrics = () => {
// this.setState({
// metricsToDisplay: ["Danceability", "Energy", "Acousticness", "Loudness", "Key", "Tempo", "Instrumentalness", "Liveness", "Mode", "Speechiness", "Time_Signature", "Valence"] // TODO: Change so that we get the metrics we want to display dynamically
// }, () => {
// this.setState({
// songMetrics: getSongMetrics((this.state.audioFeatures as AudioFeaturesResponse), this.state.metricsToDisplay)
// });
// })
this.setState({
metricsToDisplay: ["Danceability", "Energy", "Acousticness", "Loudness", "Key", "Tempo", "Instrumentalness", "Liveness", "Mode", "Speechiness", "Time_Signature", "Valence"] // TODO: Change so that we get the metrics we want to display dynamically
}, () => {
this.setState({
songMetrics: getSongMetrics((this.state.audioFeatures as AudioFeaturesResponse), this.state.metricsToDisplay)
});
})
songMetrics: getSongMetrics((this.state.audioFeatures as AudioFeaturesResponse), this.state.metricsToDisplay)
});
}

// Change the recommendation target
Expand Down Expand Up @@ -175,7 +178,7 @@ class NowPlaying extends React.Component<{}, {audioFeatures: AudioFeaturesRespon
<div className={styles.settingContainer}>
<span className={styles.settingLabel}>{"Displayed statistics: "}</span>
{allMetrics.map((metric: string, i) => {
return <button className={styles.recommendationTarget} style={{marginLeft: "5px", fontSize: "15px"}}>{metric}</button>
return <button className={styles.recommendationTarget} style={{marginLeft: "5px", fontSize: "15px", backgroundColor: this.state.metricsToDisplay.includes(metric) ? "rgb(81, 126, 97)" : "rgb(105,105,105)"}}>{metric}</button>
})}
{/* <button onClick={this.changeRecTarget} className={styles.recommendationTarget}
disabled={false} style={{marginLeft: "10px", marginTop: "0px"}}>
Expand Down

0 comments on commit f28e544

Please sign in to comment.