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