Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
Make the label text work for emojis
Browse files Browse the repository at this point in the history
  • Loading branch information
duffey committed Dec 4, 2023
1 parent 4a974fc commit db1d045
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/spicetify-playlist-labels.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,19 @@ function updateTracklist() {
labelColumn = document.createElement("div");
const dummyImgSrc = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';

function getFirstLetters(inputString) {
function getFirstCharacters(inputString) {
// Split the input string into words
const words = inputString.split(' ');

// Extract the first two words
const firstWord = words[0];
const secondWord = words.length > 1 ? words[1] : '';

// Get the first two letters of each word
const firstLetters = (firstWord.slice(0, 1) + secondWord.slice(0, 1)).toUpperCase();
// Get either one emoji or the first two letters
const firstCharacters = Array.from(firstWord).slice(0, 1).join('') +
(secondWord ? Array.from(secondWord).slice(0, 1).join('') : '');

return firstLetters;
return firstCharacters;
}

ReactDOM.render(
Expand Down Expand Up @@ -146,7 +147,7 @@ function updateTracklist() {
color: 'white',
fontSize: 14,
textAlign: 'center',
}}>{getFirstLetters(playlistData.name)}</div>
}}>{getFirstCharacters(playlistData.name)}</div>
: null
}
</div>
Expand Down

0 comments on commit db1d045

Please sign in to comment.