mirror of
https://github.com/yusing/godoxy.git
synced 2026-01-11 22:30:47 +01:00
fix(icons): add handling for dark icons for walkxcode
This commit is contained in:
@@ -219,8 +219,7 @@ func HasIcon(icon *IconURL) bool {
|
||||
if common.IsTest {
|
||||
return true
|
||||
}
|
||||
key := NewIconKey(icon.IconSource, icon.Extra.Ref)
|
||||
meta, ok := ListAvailableIcons()[key]
|
||||
meta, ok := ListAvailableIcons()[icon.Extra.Key]
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
@@ -332,6 +331,10 @@ func UpdateWalkxCodeIcons(m IconMap) error {
|
||||
if isLight {
|
||||
f = strings.TrimSuffix(f, "-light")
|
||||
}
|
||||
isDark := strings.HasSuffix(f, "-dark")
|
||||
if isDark {
|
||||
f = strings.TrimSuffix(f, "-dark")
|
||||
}
|
||||
key := NewIconKey(IconSourceWalkXCode, f)
|
||||
icon, ok := m[key]
|
||||
if !ok {
|
||||
@@ -342,6 +345,9 @@ func UpdateWalkxCodeIcons(m IconMap) error {
|
||||
if isLight {
|
||||
icon.Light = true
|
||||
}
|
||||
if isDark {
|
||||
icon.Dark = true
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -10,16 +10,22 @@ const walkxcodeIcons = `{
|
||||
"png": [
|
||||
"app1.png",
|
||||
"app1-light.png",
|
||||
"app2.png"
|
||||
"app2.png",
|
||||
"karakeep.png",
|
||||
"karakeep-dark.png"
|
||||
],
|
||||
"svg": [
|
||||
"app1.svg",
|
||||
"app1-light.svg"
|
||||
"app1-light.svg",
|
||||
"karakeep.svg",
|
||||
"karakeep-dark.svg"
|
||||
],
|
||||
"webp": [
|
||||
"app1.webp",
|
||||
"app1-light.webp",
|
||||
"app2.webp"
|
||||
"app2.webp",
|
||||
"karakeep.webp",
|
||||
"karakeep-dark.webp"
|
||||
]
|
||||
}`
|
||||
|
||||
@@ -98,8 +104,8 @@ func TestListWalkxCodeIcons(t *testing.T) {
|
||||
if err := UpdateWalkxCodeIcons(m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(m) != 2 {
|
||||
t.Fatalf("expect 2 icons, got %d", len(m))
|
||||
if len(m) != 3 {
|
||||
t.Fatalf("expect 3 icons, got %d", len(m))
|
||||
}
|
||||
test := []testCases{
|
||||
{
|
||||
@@ -118,6 +124,15 @@ func TestListWalkxCodeIcons(t *testing.T) {
|
||||
WebP: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
Key: NewIconKey(IconSourceWalkXCode, "karakeep"),
|
||||
IconMeta: IconMeta{
|
||||
SVG: true,
|
||||
PNG: true,
|
||||
WebP: true,
|
||||
Dark: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
runTests(t, m, test)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user