mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-26 14:08:29 -04:00
15 lines
518 B
TypeScript
15 lines
518 B
TypeScript
import hash from "@emotion/hash";
|
|
|
|
// a little hacky-hack to have react combine all of these css var declarations into a single <style> tag up top. see:
|
|
// https://react.dev/reference/react-dom/components/style#rendering-an-inline-css-stylesheet
|
|
export const setRootCssVariables = (vars: Record<string, string>) => {
|
|
const root = Object.entries(vars)
|
|
.map(([key, value]) => `--${key}:${value}`)
|
|
.join(";");
|
|
|
|
return {
|
|
href: hash(root),
|
|
dangerouslySetInnerHTML: { __html: `:root{${root}}` },
|
|
};
|
|
};
|