@@ -43,6 +43,11 @@ export const InlineCode = styled.code`
43
43
background-color: ${ themeGet ( 'colors.neutral.muted' ) } ;
44
44
border-radius: ${ themeGet ( 'radii.2' ) } ;
45
45
`
46
+ const colorMap = {
47
+ 'token comment' : '#747458' ,
48
+ 'token function' : '#cf3846' ,
49
+ 'token parameter variable' : '#277d7b' ,
50
+ }
46
51
47
52
const MonoText = props => < Text sx = { { fontFamily : 'mono' , fontSize : 1 } } { ...props } />
48
53
@@ -113,18 +118,14 @@ function Code({className = '', prompt, children}) {
113
118
< CodeBlock className = { highlightClassName } style = { style } code = { code } >
114
119
{ tokens . map ( ( line , i ) => (
115
120
< Box key = { i } { ...getLineProps ( { line, key : i } ) } >
116
- { line . map ( ( token , key ) => (
117
- < MonoText
118
- key = { key }
119
- { ...{
120
- ...getTokenProps ( { token, key} ) ,
121
- style :
122
- getTokenProps ( { token, key} ) . className === 'token comment'
123
- ? { ...getTokenProps ( { token, key} ) . style , color : '#747458' }
124
- : getTokenProps ( { token, key} ) . style ,
125
- } }
126
- />
127
- ) ) }
121
+ { line . map ( ( token , key ) => {
122
+ const tokenProps = getTokenProps ( { token, key} )
123
+ const tokenStyle = colorMap [ tokenProps . className ]
124
+ ? { ...tokenProps . style , color : colorMap [ tokenProps . className ] }
125
+ : tokenProps . style
126
+
127
+ return < MonoText key = { key } { ...tokenProps } style = { tokenStyle } />
128
+ } ) }
128
129
</ Box >
129
130
) ) }
130
131
</ CodeBlock >
0 commit comments