Skip to content

Commit 3338691

Browse files
committed
feat: replace use this image button with a download button right in image
1 parent 53db025 commit 3338691

File tree

1 file changed

+29
-40
lines changed

1 file changed

+29
-40
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,53 +2145,41 @@ function RemoteFunctions(config = {}) {
21452145
opacity: 0.85 !important;
21462146
}
21472147
2148-
.phoenix-use-image-btn {
2148+
.phoenix-download-icon {
21492149
position: absolute !important;
2150-
top: 6px !important;
2151-
right: 6px !important;
2152-
background: rgba(0,0,0,0.55) !important;
2150+
top: 50% !important;
2151+
left: 50% !important;
2152+
transform: translate(-50%, -50%) !important;
2153+
background: rgba(0,0,0,0.7) !important;
21532154
border: none !important;
2154-
color: white !important;
2155-
border-radius: 20px !important;
2156-
height: 26px !important;
2155+
color: #eee !important;
2156+
border-radius: 50% !important;
2157+
width: 21px !important;
2158+
height: 21px !important;
2159+
padding: 4px !important;
21572160
display: flex !important;
21582161
align-items: center !important;
21592162
justify-content: center !important;
21602163
cursor: pointer !important;
2161-
font-size: 12px !important;
2164+
font-size: 16px !important;
21622165
z-index: 2147483647 !important;
2163-
padding: 0 8px !important;
2164-
white-space: nowrap !important;
2165-
opacity: 0 !important;
21662166
transition: all 0.2s ease !important;
2167+
pointer-events: none !important;
2168+
opacity: 0 !important;
21672169
}
21682170
2169-
.phoenix-use-image-btn i {
2170-
margin-right: 0 !important;
2171-
transition: margin 0.2s !important;
2172-
}
2173-
2174-
.phoenix-use-image-btn span {
2175-
display: none !important;
2176-
font-size: 11px !important;
2177-
font-weight: 500 !important;
2178-
}
2179-
2180-
.phoenix-ribbon-thumb:hover .phoenix-use-image-btn {
2171+
.phoenix-ribbon-thumb:hover .phoenix-download-icon {
21812172
opacity: 1 !important;
2173+
pointer-events: auto !important;
21822174
}
21832175
2184-
.phoenix-use-image-btn:hover {
2185-
background: rgba(0,0,0,0.8) !important;
2186-
padding: 0 10px !important;
2187-
}
2188-
2189-
.phoenix-use-image-btn:hover i {
2190-
margin-right: 4px !important;
2176+
.phoenix-download-icon:hover {
2177+
background: rgba(0,0,0,0.9) !important;
2178+
transform: translate(-50%, -50%) scale(1.1) !important;
21912179
}
21922180
2193-
.phoenix-use-image-btn:hover span {
2194-
display: inline !important;
2181+
.phoenix-ribbon-thumb {
2182+
cursor: pointer !important;
21952183
}
21962184
</style>
21972185
<div class="phoenix-image-ribbon">
@@ -2530,14 +2518,15 @@ function RemoteFunctions(config = {}) {
25302518
attribution.appendChild(photographer);
25312519
attribution.appendChild(source);
25322520

2533-
// use image button
2534-
const useImageBtn = window.document.createElement('button');
2535-
useImageBtn.className = 'phoenix-use-image-btn';
2536-
useImageBtn.innerHTML = '⬇<span>Use this image</span>';
2521+
// download icon
2522+
const downloadIcon = window.document.createElement('div');
2523+
downloadIcon.className = 'phoenix-download-icon';
2524+
downloadIcon.innerHTML = `<svg viewBox="0 0 640 640" fill="currentColor">
2525+
<path d="M352 96C352 78.3 337.7 64 320 64C302.3 64 288 78.3 288 96L288 306.7L246.6 265.3C234.1 252.8 213.8 252.8 201.3 265.3C188.8 277.8 188.8 298.1 201.3 310.6L297.3 406.6C309.8 419.1 330.1 419.1 342.6 406.6L438.6 310.6C451.1 298.1 451.1 277.8 438.6 265.3C426.1 252.8 405.8 252.8 393.3 265.3L352 306.7L352 96zM160 384C124.7 384 96 412.7 96 448L96 480C96 515.3 124.7 544 160 544L480 544C515.3 544 544 515.3 544 480L544 448C544 412.7 515.3 384 480 384L433.1 384L376.5 440.6C345.3 471.8 294.6 471.8 263.4 440.6L206.9 384L160 384zM464 440C477.3 440 488 450.7 488 464C488 477.3 477.3 488 464 488C450.7 488 440 477.3 440 464C440 450.7 450.7 440 464 440z"/>
2526+
</svg>`;
25372527

2538-
// when use image button is clicked, we first generate the file name by which we need to save the image
2539-
// and then we add the image to project
2540-
useImageBtn.addEventListener('click', (e) => {
2528+
// when the image is clicked we download the image
2529+
thumbDiv.addEventListener('click', (e) => {
25412530
e.stopPropagation();
25422531
e.preventDefault();
25432532
const filename = this._generateFilename(image);
@@ -2547,7 +2536,7 @@ function RemoteFunctions(config = {}) {
25472536

25482537
thumbDiv.appendChild(img);
25492538
thumbDiv.appendChild(attribution);
2550-
thumbDiv.appendChild(useImageBtn);
2539+
thumbDiv.appendChild(downloadIcon);
25512540
rowElement.appendChild(thumbDiv);
25522541
});
25532542

0 commit comments

Comments
 (0)