Skip to content

Commit

Permalink
Add downloading image text
Browse files Browse the repository at this point in the history
  • Loading branch information
palinkiewicz committed Aug 4, 2024
1 parent a09d558 commit 5d74661
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
13 changes: 11 additions & 2 deletions classes/DOMHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const SELECTION_ANIMATION_DELAY = 300;
const NEXT_LINE_ANIMATION_DELAY = 30;
const SEARCHING_FOR_SONG = "Searching for your song...";
const SEARCHING_FOR_LYRICS = "Searching for song's lyrics...";
const DOWNLOADING = "Downloading lyrics image...";
const NO_LYRICS_FOUND =
"No lyrics found<br>You can still type your own lyrics by clicking here :)";
const NO_LYRICS_SELECTED =
Expand Down Expand Up @@ -394,8 +395,12 @@ class DOMHandler {
* Downloads song image by generating canvas from its DOM elements
*/
async downloadSongImage() {
this.displaySearching(DOWNLOADING);

const song = this.songs[this.selectedSongIndex];
const downloadName = `${song.artists.map(artist => artist.name).join(', ')} - ${song.name}.png`
const downloadName = `${song.artists
.map((artist) => artist.name)
.join(", ")} - ${song.name}.png`;

let canvas = await html2canvas(this.songImage, {
backgroundColor: null,
Expand All @@ -413,6 +418,7 @@ class DOMHandler {
canvas.toBlob((blob) => {
window.saveAs(blob, downloadName);
});
this.hideSearching();
}

/**
Expand Down Expand Up @@ -490,7 +496,10 @@ class DOMHandler {
margin + shadowOffsetX,
margin + shadowOffsetY + canvas.height - borderRadius
);
shadowContext.lineTo(margin + shadowOffsetX, margin + shadowOffsetY + borderRadius);
shadowContext.lineTo(
margin + shadowOffsetX,
margin + shadowOffsetY + borderRadius
);
shadowContext.quadraticCurveTo(
margin + shadowOffsetX,
margin + shadowOffsetY,
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ <h2>Select lines</h2>
<h2>Song image</h2>
<button class="material-symbols-outlined" id="download">download</button>
</header>
<div class="searching hidden"></div>
<div class="song-image">
<div class="header">
<img src="" alt="album-cover">
Expand Down
8 changes: 8 additions & 0 deletions styles/wizard.css
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,14 @@
margin-bottom: 1rem;
}

.final-options .searching {
margin-bottom: 1rem;
}

.final-options .searching.hidden {
margin-bottom: 0;
}

.color-selection {
display: flex;
flex-wrap: wrap;
Expand Down

0 comments on commit 5d74661

Please sign in to comment.