migrate images

This commit is contained in:
Miao Wang 2024-04-10 01:50:50 +08:00
parent be2e31503f
commit 3fb7919da8
12 changed files with 50 additions and 44 deletions

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View File

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

View File

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 90 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 88 KiB

47
_src/styles/_utils.scss Normal file
View File

@ -0,0 +1,47 @@
@use "sass:map";
@use "sass:list";
@mixin dark {
@if map.get(jekyll-config(), "issue") {
@content;
} @else {
@media (prefers-color-scheme: dark) {
@content;
}
}
}
@mixin noissue {
@if map.get(jekyll-config(), "issue") {
} @else {
@content;
}
}
@mixin imgurl($img, $style: "light", $scales: 4, $ext: "png") {
background-image: url("#{getimgName($img, $style, 1, $ext)}");
$imgset: ();
@for $scale from 1 through $scales {
$imgset: list.append(
$imgset,
url("#{getimgName($img, $style, $scale, $ext)}") #{$scale}x,
comma
);
}
@each $pfx in ("-webkit-", "") {
background-image: #{$pfx}image-set($imgset);
}
}
@function getimgName($img, $style, $scale, $ext) {
@if $scale == 1 {
$scale: "";
} @else {
$scale: "@#{$scale}x";
}
@if $style == "light" {
$style: "";
} @else {
$style: "-#{$style}";
}
@return "#{$img}#{$style}#{$scale}.#{$ext}";
}

View File

@ -26,37 +26,13 @@
@include utils.noissue {
opacity: 0.5;
filter: grayscale(0.2);
background-image: url(/static/img/missing.png);
background-image: -webkit-image-set(
url("/static/img/missing.png") 1x,
url("/static/img/missing@2x.png") 2x,
url("/static/img/missing@3x.png") 3x,
url("/static/img/missing@4x.png") 4x
);
background-image: image-set(
url("/static/img/missing.png") 1x,
url("/static/img/missing@2x.png") 2x,
url("/static/img/missing@3x.png") 3x,
url("/static/img/missing@4x.png") 4x
);
@include utils.imgurl("../imgs/missing", "light");
}
@include utils.dark {
opacity: 1;
filter: none;
background-image: url(/static/img/missing-dark.png);
background-image: -webkit-image-set(
url("/static/img/missing-dark.png") 1x,
url("/static/img/missing-dark@2x.png") 2x,
url("/static/img/missing-dark@3x.png") 3x,
url("/static/img/missing-dark@4x.png") 4x
);
background-image: image-set(
url("/static/img/missing-dark.png") 1x,
url("/static/img/missing-dark@2x.png") 2x,
url("/static/img/missing-dark@3x.png") 3x,
url("/static/img/missing-dark@4x.png") 4x
);
@include utils.imgurl("../imgs/missing", "dark");
}
}

View File

@ -1,17 +0,0 @@
@use "sass:map";
@mixin dark {
@if map.get(jekyll-config(), "issue") {
@content;
} @else {
@media (prefers-color-scheme: dark) {
@content;
}
}
}
@mixin noissue {
@if map.get(jekyll-config(), "issue") {
} @else {
@content;
}
}

View File

@ -3,7 +3,7 @@
"private": true,
"homepage": "https://github.com/tuna/mirror-web",
"scripts": {
"format": "prettier --write \"_src/**\""
"format": "prettier --write \"_src/**/*.vue\" \"_src/**/*.html\" \"_src/**/*.js\" \"_src/**/*.scss\""
},
"dependencies": {
"@vitejs/plugin-legacy": "^5.3.2",