Files
big-agi/lib/theme.ts
T
2023-03-27 01:07:51 -07:00

49 lines
1.3 KiB
TypeScript

import createCache from '@emotion/cache';
import { Inter, JetBrains_Mono } from 'next/font/google';
import { extendTheme } from '@mui/joy';
// Theme & Fonts
const inter = Inter({
weight: ['400', '500', '600', '700'],
subsets: ['latin'],
display: 'swap',
fallback: ['Helvetica', 'Arial', 'sans-serif'],
});
const jetBrainsMono = JetBrains_Mono({
weight: ['400', '500', '600', '700'],
subsets: ['latin'],
display: 'swap',
fallback: ['monospace'],
});
export const theme = extendTheme({
fontFamily: {
body: inter.style.fontFamily,
code: jetBrainsMono.style.fontFamily,
},
});
export const bodyFontClassName = inter.className;
// Emotion Cache (with insertion point on the SSR pass)
const isBrowser = typeof document !== 'undefined';
export function createEmotionCache() {
let insertionPoint;
if (isBrowser) {
// On the client side, _document.tsx has a meta tag with the name "emotion-insertion-point" at the top of the <head>.
// This assures that MUI styles are loaded first, and allows allows developers to easily override MUI styles with other solutions like CSS modules.
const emotionInsertionPoint = document.querySelector<HTMLMetaElement>(
'meta[name="emotion-insertion-point"]',
);
insertionPoint = emotionInsertionPoint ?? undefined;
}
return createCache({ key: 'mui-style', insertionPoint });
}