Skip to content

Commit

Permalink
Add placeholder icon for songs without artwork (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
themintchoco authored Mar 12, 2023
1 parent 6b68ad4 commit 85524c1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
Binary file added src/assets/icons/placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

"web_accessible_resources": [
{
"resources": ["*.js"],
"resources": ["*.js", "assets/*"],
"matches": ["*://*.youtube.com/*"]
}
]
Expand Down
9 changes: 9 additions & 0 deletions src/pages/content/SongItem.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
height: 50px;
flex-shrink: 0;
border-radius: 8px;
background-color: var(--yt-spec-10-percent-layer);
background-position: center;
background-repeat: no-repeat;
background-size: cover;

&.placeholder {
background-size: 65%;
filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.5));
}
}

.details {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/content/SongItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface SongItemProps {
const SongItem = ({ song, active, onSelectSong } : SongItemProps) => {
return (
<div className={cx(styles.songItem, { [styles.active]: active })} onClick={() => onSelectSong?.(song)}>
<div className={styles.art} style={{background: 'var(--yt-spec-10-percent-layer)' + (song.art ? ` center/cover url('${song.art}')` : '')}}></div>
<div className={cx(styles.art, { [styles.placeholder]: !song.art })} style={{backgroundImage: `url("${song.art ?? chrome.runtime.getURL('assets/icons/placeholder.png')}")`}}></div>
<div className={styles.details}>
<h3>{song.name}</h3>
<h4 className={styles.secondary}>{song.original_artist}</h4>
Expand Down
4 changes: 4 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ const config = {
{
from: path.join(__dirname, 'icons'),
},
{
from: path.join(__dirname, 'src', 'assets'),
to: 'assets',
},
],
}),
new HtmlWebpackPlugin({
Expand Down

0 comments on commit 85524c1

Please sign in to comment.