MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / useCodeMirrorTheme

Function useCodeMirrorTheme

packages/web/src/hooks/useCodeMirrorTheme.ts:14–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12import tailwind from "@/tailwind";
13
14export const useCodeMirrorTheme = () => {
15 const { theme } = useThemeNormalized();
16 const highlightStyle = useCodeMirrorHighlighter();
17
18 const cmTheme = useMemo(() => {
19 const {
20 background,
21 foreground,
22 caret,
23 selection,
24 selectionMatch,
25 gutterBackground,
26 gutterForeground,
27 gutterBorder,
28 gutterActiveForeground,
29 lineHighlight,
30 } = tailwind.theme.colors.editor;
31
32 return [
33 createThemeExtension({
34 theme: theme === 'dark' ? 'dark' : 'light',
35 settings: {
36 background,
37 foreground,
38 caret,
39 selection,
40 selectionMatch,
41 gutterBackground,
42 gutterForeground,
43 gutterBorder,
44 gutterActiveForeground,
45 lineHighlight,
46 fontFamily: tailwind.theme.fontFamily.editor,
47 fontSize: tailwind.theme.fontSize.editor,
48 }
49 }),
50 syntaxHighlighting(highlightStyle)
51 ]
52 }, [highlightStyle, theme]);
53
54 return cmTheme;
55}
56
57
58// @see: https://github.com/uiwjs/react-codemirror/blob/e365f7d1f8a0ec2cd88455b7a248f6338c859cc7/themes/theme/src/index.tsx

Callers 3

CodePreviewFunction · 0.90
PureCodePreviewPanelFunction · 0.90

Calls 3

useThemeNormalizedFunction · 0.90
useCodeMirrorHighlighterFunction · 0.90
createThemeExtensionFunction · 0.85

Tested by

no test coverage detected