1
1
import React from 'react'
2
2
import { Box , Text , Button , themeGet } from '@primer/react'
3
3
import { Octicon } from '@primer/react/deprecated'
4
- import { Highlight , themes , Prism } from 'prism-react-renderer'
4
+ import { Highlight , Prism } from 'prism-react-renderer'
5
5
import styled from 'styled-components'
6
6
import { CheckIcon , CopyIcon } from '@primer/octicons-react'
7
7
import copyToClipboard from 'copy-to-clipboard'
8
8
import { announce } from '../util/aria-live'
9
+ import { usePrismTheme } from '../hooks/use-prism-theme'
9
10
; ( typeof global !== 'undefined' ? global : window ) . Prism = Prism
10
11
require ( 'prismjs/components/prism-bash' )
11
12
@@ -99,9 +100,10 @@ const CodeBlock = ({children, code, className, style}) => (
99
100
)
100
101
101
102
function Code ( { className = '' , prompt, children} ) {
103
+ const { theme : codeTheme } = usePrismTheme ( )
102
104
if ( prompt ) {
103
105
return (
104
- < CodeBlock style = { themes . github . plain } >
106
+ < CodeBlock style = { codeTheme . plain } >
105
107
< MonoText > { children } </ MonoText >
106
108
</ CodeBlock >
107
109
)
@@ -115,7 +117,7 @@ function Code({className = '', prompt, children}) {
115
117
}
116
118
117
119
return (
118
- < Highlight code = { code } language = { className . replace ( / l a n g u a g e - / , '' ) || 'bash' } theme = { themes . github } >
120
+ < Highlight code = { code } language = { className . replace ( / l a n g u a g e - / , '' ) || 'bash' } theme = { codeTheme } >
119
121
{ ( { className : highlightClassName , style, tokens, getLineProps, getTokenProps} ) => (
120
122
< CodeBlock className = { highlightClassName } style = { style } code = { code } >
121
123
{ tokens . map ( ( line , i ) => (
0 commit comments