mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
feat: make download icon theme aware
This commit is contained in:
@@ -90,7 +90,26 @@
|
|||||||
<button
|
<button
|
||||||
title="Download"
|
title="Download"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
downloadSvg(typeof svgInfo.route !== 'string' ? svgInfo.route.dark : svgInfo.route);
|
const svgHasTheme = typeof svgInfo.route !== 'string';
|
||||||
|
|
||||||
|
if (!svgHasTheme) {
|
||||||
|
downloadSvg(
|
||||||
|
typeof svgInfo.route === 'string'
|
||||||
|
? svgInfo.route
|
||||||
|
: "Something went wrong. Couldn't copy the SVG."
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dark = document.documentElement.classList.contains('dark');
|
||||||
|
|
||||||
|
downloadSvg(
|
||||||
|
typeof svgInfo.route !== 'string'
|
||||||
|
? dark
|
||||||
|
? svgInfo.route.dark
|
||||||
|
: svgInfo.route.light
|
||||||
|
: svgInfo.route
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
class="flex items-center space-x-2 rounded-md p-2 duration-100 hover:bg-neutral-200 dark:hover:bg-neutral-700/40"
|
class="flex items-center space-x-2 rounded-md p-2 duration-100 hover:bg-neutral-200 dark:hover:bg-neutral-700/40"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user