Compare commits

...

4 Commits

Author SHA1 Message Date
autumn
f9828879d1
Merge 8c3dad15e03ac3fa7ec504874206f08720a6dd32 into 32ec711767401c93605b7631f03eee47dea1cada 2025-02-09 22:35:39 +09:00
dependabot[bot]
32ec711767
chore(deps-dev): bump @types/node in the production-dependencies group (#1751)
Some checks failed
Build and Test / build-and-test (macos-latest) (push) Has been cancelled
Build and Test / build-and-test (ubuntu-latest) (push) Has been cancelled
Build and Test / build-and-test (windows-latest) (push) Has been cancelled
Build and Test / publish-tag (push) Has been cancelled
Docker build & push image / build (push) Has been cancelled
Bumps the production-dependencies group with 1 update: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node).


Updates `@types/node` from 22.12.0 to 22.13.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: production-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-05 05:07:14 -05:00
Autumn
8c3dad15e0
style: prettier 2024-10-10 18:09:33 -05:00
Autumn
c933b93db2
feat: more advanced font specification 2024-10-10 14:18:04 -05:00
3 changed files with 50 additions and 12 deletions

8
package-lock.json generated
View File

@ -79,7 +79,7 @@
"@types/d3": "^7.4.3",
"@types/hast": "^3.0.4",
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.12.0",
"@types/node": "^22.13.0",
"@types/pretty-time": "^1.1.5",
"@types/source-map-support": "^0.5.10",
"@types/ws": "^8.5.14",
@ -1914,9 +1914,9 @@
}
},
"node_modules/@types/node": {
"version": "22.12.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.12.0.tgz",
"integrity": "sha512-Fll2FZ1riMjNmlmJOdAyY5pUbkftXslB5DgEzlIuNaiWhXd00FhWxVC/r4yV/4wBb9JfImTu+jiSvXTkJ7F/gA==",
"version": "22.13.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.0.tgz",
"integrity": "sha512-ClIbNe36lawluuvq3+YYhnIN2CELi+6q8NpnM7PYp4hBn/TatfboPgVSm2rwKRfnV2M+Ty9GWDFI64KEe+kysA==",
"dev": true,
"license": "MIT",
"dependencies": {

View File

@ -102,7 +102,7 @@
"@types/d3": "^7.4.3",
"@types/hast": "^3.0.4",
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.12.0",
"@types/node": "^22.13.0",
"@types/pretty-time": "^1.1.5",
"@types/source-map-support": "^0.5.10",
"@types/ws": "^8.5.14",

View File

@ -15,11 +15,19 @@ interface Colors {
darkMode: ColorScheme
}
interface FontInfo {
/**
* e.g. "ital,wght@0,400;1,200"
*/
features: string
}
export interface Theme {
fonts?: Record<string, FontInfo>
typography: {
header: string
body: string
code: string
header: string | string[]
body: string | string[]
code: string | string[]
}
cdnCaching: boolean
colors: Colors
@ -32,9 +40,39 @@ const DEFAULT_SANS_SERIF =
'-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif'
const DEFAULT_MONO = "ui-monospace, SFMono-Regular, SF Mono, Menlo, monospace"
function makeFamilySection(theme: Theme, family: string | string[], defaultFeatures: string) {
const families = Array.isArray(family) ? family : [family]
return (
"family=" +
families
.map((f) => {
const features = theme.fonts?.[f]?.features ?? defaultFeatures
if (features === "") {
return `${f}:wght@400` // matches unplugin-fonts; should be a sane default
} else {
return `${f}:${features}`
}
})
.join("&family=")
)
}
export function googleFontHref(theme: Theme) {
const { code, header, body } = theme.typography
return `https://fonts.googleapis.com/css2?family=${code}&family=${header}:wght@400;700&family=${body}:ital,wght@0,400;0,600;1,400;1,600&display=swap`
const codeSection = makeFamilySection(theme, code, "")
const headerSection = makeFamilySection(theme, header, "wght@400;700")
const bodySection = makeFamilySection(theme, body, "ital,wght@0,400;0,600;1,400;1,600")
return `https://fonts.googleapis.com/css2?${codeSection}&${headerSection}&${bodySection}&display=swap`
}
function renderFonts(fonts: string | string[]) {
if (Array.isArray(fonts)) {
return fonts.map((s) => `"${s}"`).join(", ")
} else {
return `"${fonts}"`
}
}
export function joinStyles(theme: Theme, ...stylesheet: string[]) {
@ -52,9 +90,9 @@ ${stylesheet.join("\n\n")}
--highlight: ${theme.colors.lightMode.highlight};
--textHighlight: ${theme.colors.lightMode.textHighlight};
--headerFont: "${theme.typography.header}", ${DEFAULT_SANS_SERIF};
--bodyFont: "${theme.typography.body}", ${DEFAULT_SANS_SERIF};
--codeFont: "${theme.typography.code}", ${DEFAULT_MONO};
--headerFont: ${renderFonts(theme.typography.header)}, ${DEFAULT_SANS_SERIF};
--bodyFont: ${renderFonts(theme.typography.body)}, ${DEFAULT_SANS_SERIF};
--codeFont: ${renderFonts(theme.typography.code)}, ${DEFAULT_MONO};
}
:root[saved-theme="dark"] {