Skip to content

Commit

Permalink
fix: theme color (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
rqbazan authored Nov 19, 2024
1 parent e901b8b commit 2c27191
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 8 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ pnpm-debug.log*
.idea/

# vercel output directory
.vercel/
.vercel/

# yalc
.yalc/
yalc.lock
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"[javascriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
},
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit",
"source.organizeImports.biome": "explicit"
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@astrojs/sitemap": "^3.2.0",
"@astrojs/tailwind": "^5.1.2",
"@astrojs/vercel": "8.0.0-beta.2",
"@rqbazan/set-initial-color-mode": "^1.2.1",
"@rqbazan/set-initial-color-mode": "^1.3.0",
"@unpic/astro": "^0.0.46",
"@unpic/pixels": "^1.2.2",
"@unpic/placeholder": "^0.1.2",
Expand Down
1 change: 0 additions & 1 deletion public/site.webmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"type": "image/png"
}
],
"theme_color": "#101010",
"background_color": "#101010",
"display": "standalone"
}
44 changes: 39 additions & 5 deletions src/layouts/default/components/seo.astro
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,44 @@ const canonicalUrl = getCanonicalUrl(Astro.url);
<link rel="canonical" href={canonicalUrl} />
<link rel="sitemap" href="/sitemap-index.xml" />

<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png">
<link
rel="apple-touch-icon"
sizes="180x180"
href="/images/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/images/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/images/favicon-16x16.png"
/>
<link rel="icon" href="/favicon.ico" />

<meta name="apple-mobile-web-app-title" content="rcrd">
<link rel="manifest" href="/site.webmanifest">
<meta name="apple-mobile-web-app-title" content="rcrd" />
<link rel="manifest" href="/site.webmanifest" />

<meta name="theme-color" />

<script is:inline>
const { STORAGE_KEY, CUSTOM_EVENT_NAME, DARK } = __COLOR_MODE__;

const themeColorEl = document.querySelector("meta[name=theme-color]");

function onColorModeChange(colorMode) {
const newContent = colorMode === DARK ? "#101010" : "#FFF6E3";
themeColorEl.setAttribute("content", newContent);
}

document.addEventListener(CUSTOM_EVENT_NAME, (e) => {
onColorModeChange(e.detail.colorMode);
});

const colorMore = localStorage.getItem(STORAGE_KEY);
onColorModeChange(colorMore);
</script>

0 comments on commit 2c27191

Please sign in to comment.