|
1 | | -import * as React from "react"; |
2 | | -import queryString from "query-string"; |
3 | | -import { Highlight, themes } from "prism-react-renderer"; |
4 | 1 | import type { Language } from "prism-react-renderer"; |
| 2 | +import { Highlight } from "prism-react-renderer"; |
| 3 | +import queryString from "query-string"; |
| 4 | +import * as React from "react"; |
5 | 5 | import { useHotkeys } from "react-hotkeys-hook"; |
6 | 6 | import { |
7 | | - storySource, |
8 | 7 | stories, |
| 8 | + storySource, |
9 | 9 | StorySourceHeader, |
10 | 10 | } from "virtual:generated-list"; |
11 | | -import { AddonProps, GlobalState, ActionType } from "../../../shared/types"; |
| 11 | +import { ActionType, AddonProps, GlobalState } from "../../../shared/types"; |
| 12 | +import config from "../get-config"; |
12 | 13 | import { Source } from "../icons"; |
13 | 14 | import { Modal } from "../ui"; |
14 | | -import config from "../get-config"; |
15 | 15 |
|
16 | 16 | export const getQuery = (locationSearch: string) => { |
17 | 17 | const urlVal = queryString.parse(locationSearch).source; |
@@ -41,17 +41,16 @@ export const CodeHighlight = ({ |
41 | 41 |
|
42 | 42 | if (match) { |
43 | 43 | language = match[1] as Language; |
| 44 | + |
44 | 45 | return ( |
45 | 46 | <Highlight |
46 | 47 | code={children.trim()} |
47 | 48 | language={language} |
48 | | - theme={{ |
49 | | - ...(theme === "dark" ? themes.nightOwl : themes.github), |
50 | | - plain: { |
51 | | - ...(theme === "dark" ? themes.nightOwl : themes.github).plain, |
52 | | - backgroundColor: "var(--ladle-bg-color-secondary)", |
53 | | - }, |
54 | | - }} |
| 49 | + theme={ |
| 50 | + theme === "dark" |
| 51 | + ? config.addons.source.themeDark |
| 52 | + : config.addons.source.themeLight |
| 53 | + } |
55 | 54 | > |
56 | 55 | {({ className, style, tokens, getTokenProps }) => ( |
57 | 56 | <div |
@@ -81,13 +80,11 @@ export const CodeHighlight = ({ |
81 | 80 | <Highlight |
82 | 81 | code={children.trim()} |
83 | 82 | language={language} |
84 | | - theme={{ |
85 | | - ...(theme === "dark" ? themes.nightOwl : themes.github), |
86 | | - plain: { |
87 | | - ...(theme === "dark" ? themes.nightOwl : themes.github).plain, |
88 | | - backgroundColor: "var(--ladle-bg-color-secondary)", |
89 | | - }, |
90 | | - }} |
| 83 | + theme={ |
| 84 | + theme === "dark" |
| 85 | + ? config.addons.source.themeDark |
| 86 | + : config.addons.source.themeLight |
| 87 | + } |
91 | 88 | > |
92 | 89 | {({ className, style, tokens, getLineProps, getTokenProps }) => ( |
93 | 90 | <pre |
|
0 commit comments