mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-07-17 18:45:32 -04:00
cache hex-to-rgba outputs
This commit is contained in:
@@ -5,10 +5,6 @@ import comicNeueLatin400NormalWoff from "@fontsource/comic-neue/files/comic-neue
|
||||
import comicNeueLatin400NormalWoff2 from "@fontsource/comic-neue/files/comic-neue-latin-400-normal.woff2";
|
||||
import comicNeueLatin700NormalWoff from "@fontsource/comic-neue/files/comic-neue-latin-700-normal.woff";
|
||||
import comicNeueLatin700NormalWoff2 from "@fontsource/comic-neue/files/comic-neue-latin-700-normal.woff2";
|
||||
import comicNeueLatin400ItalicWoff from "@fontsource/comic-neue/files/comic-neue-latin-400-italic.woff";
|
||||
import comicNeueLatin400ItalicWoff2 from "@fontsource/comic-neue/files/comic-neue-latin-400-italic.woff2";
|
||||
import comicNeueLatin700ItalicWoff from "@fontsource/comic-neue/files/comic-neue-latin-700-italic.woff";
|
||||
import comicNeueLatin700ItalicWoff2 from "@fontsource/comic-neue/files/comic-neue-latin-700-italic.woff2";
|
||||
|
||||
export const name = {
|
||||
regular: "Comic Neue",
|
||||
@@ -31,18 +27,4 @@ export const family: AtRule.FontFace[] = [
|
||||
fontWeight: 700,
|
||||
src: `url(${comicNeueLatin700NormalWoff2}) format("woff2"), url(${comicNeueLatin700NormalWoff}) format("woff")`,
|
||||
},
|
||||
{
|
||||
fontFamily: name.regular,
|
||||
fontStyle: "italic",
|
||||
fontDisplay: "swap",
|
||||
fontWeight: 400,
|
||||
src: `url(${comicNeueLatin400ItalicWoff2}) format("woff2"), url(${comicNeueLatin400ItalicWoff}) format("woff")`,
|
||||
},
|
||||
{
|
||||
fontFamily: name.regular,
|
||||
fontStyle: "italic",
|
||||
fontDisplay: "swap",
|
||||
fontWeight: 700,
|
||||
src: `url(${comicNeueLatin700ItalicWoff2}) format("woff2"), url(${comicNeueLatin700ItalicWoff}) format("woff")`,
|
||||
},
|
||||
];
|
||||
|
@@ -7,16 +7,9 @@ import robotoMonoLatin500NormalWoff from "@fontsource/roboto-mono/files/roboto-m
|
||||
import robotoMonoLatin500NormalWoff2 from "@fontsource/roboto-mono/files/roboto-mono-latin-500-normal.woff2";
|
||||
import robotoMonoLatin700NormalWoff from "@fontsource/roboto-mono/files/roboto-mono-latin-700-normal.woff";
|
||||
import robotoMonoLatin700NormalWoff2 from "@fontsource/roboto-mono/files/roboto-mono-latin-700-normal.woff2";
|
||||
import robotoMonoLatin400ItalicWoff from "@fontsource/roboto-mono/files/roboto-mono-latin-400-italic.woff";
|
||||
import robotoMonoLatin400ItalicWoff2 from "@fontsource/roboto-mono/files/roboto-mono-latin-400-italic.woff2";
|
||||
import robotoMonoLatin500ItalicWoff from "@fontsource/roboto-mono/files/roboto-mono-latin-500-italic.woff";
|
||||
import robotoMonoLatin500ItalicWoff2 from "@fontsource/roboto-mono/files/roboto-mono-latin-500-italic.woff2";
|
||||
import robotoMonoLatin700ItalicWoff from "@fontsource/roboto-mono/files/roboto-mono-latin-700-italic.woff";
|
||||
import robotoMonoLatin700ItalicWoff2 from "@fontsource/roboto-mono/files/roboto-mono-latin-700-italic.woff2";
|
||||
|
||||
// Variable
|
||||
import robotoMonoLatinVarWghtOnlyNormalWoff2 from "@fontsource/roboto-mono/files/roboto-mono-latin-variable-wghtOnly-normal.woff2";
|
||||
import robotoMonoLatinVarWghtOnlyItalicWoff2 from "@fontsource/roboto-mono/files/roboto-mono-latin-variable-wghtOnly-italic.woff2";
|
||||
|
||||
export const name = {
|
||||
regular: "Roboto Mono",
|
||||
@@ -53,27 +46,6 @@ export const family: AtRule.FontFace[] = [
|
||||
fontWeight: 700,
|
||||
src: `url(${robotoMonoLatin700NormalWoff2}) format("woff2"), url(${robotoMonoLatin700NormalWoff}) format("woff")`,
|
||||
},
|
||||
{
|
||||
fontFamily: name.regular,
|
||||
fontStyle: "italic",
|
||||
fontDisplay: "swap",
|
||||
fontWeight: 400,
|
||||
src: `url(${robotoMonoLatin400ItalicWoff2}) format("woff2"), url(${robotoMonoLatin400ItalicWoff}) format("woff")`,
|
||||
},
|
||||
{
|
||||
fontFamily: name.regular,
|
||||
fontStyle: "italic",
|
||||
fontDisplay: "swap",
|
||||
fontWeight: 500,
|
||||
src: `url(${robotoMonoLatin500ItalicWoff2}) format("woff2"), url(${robotoMonoLatin500ItalicWoff}) format("woff")`,
|
||||
},
|
||||
{
|
||||
fontFamily: name.regular,
|
||||
fontStyle: "italic",
|
||||
fontDisplay: "swap",
|
||||
fontWeight: 700,
|
||||
src: `url(${robotoMonoLatin700ItalicWoff2}) format("woff2"), url(${robotoMonoLatin700ItalicWoff}) format("woff")`,
|
||||
},
|
||||
{
|
||||
fontFamily: name.variable,
|
||||
fontStyle: "normal",
|
||||
@@ -81,11 +53,4 @@ export const family: AtRule.FontFace[] = [
|
||||
fontWeight: "100 700",
|
||||
src: `url(${robotoMonoLatinVarWghtOnlyNormalWoff2}) format("woff2")`,
|
||||
},
|
||||
{
|
||||
fontFamily: name.variable,
|
||||
fontStyle: "italic",
|
||||
fontDisplay: "swap",
|
||||
fontWeight: "100 700",
|
||||
src: `url(${robotoMonoLatinVarWghtOnlyItalicWoff2}) format("woff2")`,
|
||||
},
|
||||
];
|
||||
|
@@ -2,7 +2,7 @@ import { createStitches } from "@stitches/react";
|
||||
import type * as Stitches from "@stitches/react";
|
||||
|
||||
// misc. helpers
|
||||
import hexToRgba from "hex-to-rgba";
|
||||
import hexToRgba from "./utils/hex-to-rgba";
|
||||
import normalizeStyles from "./utils/normalize";
|
||||
|
||||
// web fonts
|
||||
|
9
lib/styles/utils/hex-to-rgba.ts
Normal file
9
lib/styles/utils/hex-to-rgba.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import hexToRgba from "hex-to-rgba";
|
||||
import mem from "mem";
|
||||
|
||||
// removes spaces from default hex-to-rgba output and caches the result
|
||||
const memoized = mem((color: string, alpha?: number) => hexToRgba(color, alpha).replace(/\s/g, ""), {
|
||||
cacheKey: (arguments_) => arguments_.join(","), // https://github.com/sindresorhus/mem#caching-strategy
|
||||
});
|
||||
|
||||
export default memoized;
|
Reference in New Issue
Block a user