11import React , { useContext , useEffect , useRef } from 'react'
22
33import { LiveContext , LiveEditor } from 'react-live'
4+ import { Flex , Tag , Text } from '@wuyangfan/nova-ui'
45
56function lineCount ( code : string ) {
67 if ( ! code ) {
@@ -37,6 +38,7 @@ export function LiveCodeEditor() {
3738
3839 const { code, language } = ctx
3940 const lines = Math . max ( lineCount ( code ) , 1 )
41+ const badge = languageBadge ( language )
4042
4143 const mainRef = useRef < HTMLDivElement > ( null )
4244 const gutterRef = useRef < HTMLDivElement > ( null )
@@ -76,22 +78,25 @@ export function LiveCodeEditor() {
7678 } , [ code ] )
7779
7880 return (
79- < div className = "live-code-editor" >
80- < div className = "live-code-editor-toolbar" >
81- < span className = "live-code-editor-lang" > { languageBadge ( language ) } </ span >
82- </ div >
83- < div className = "live-code-editor-main" ref = { mainRef } >
84- < div className = "live-code-editor-gutter" ref = { gutterRef } aria-hidden = "true" >
81+ < Flex vertical className = "live-code-editor" >
82+ < Flex className = "live-code-editor-toolbar" align = "center" justify = "between" >
83+ < Text className = "live-code-editor-title" > Code</ Text >
84+ < Tag className = "live-code-editor-lang" aria-label = { `${ badge } example code` } >
85+ { badge }
86+ </ Tag >
87+ </ Flex >
88+ < Flex className = "live-code-editor-main" ref = { mainRef } >
89+ < Flex vertical className = "live-code-editor-gutter" ref = { gutterRef } aria-hidden = "true" >
8590 { Array . from ( { length : lines } , ( _ , index ) => (
86- < div key = { index } className = "live-code-editor-gutter-line" >
91+ < Text key = { index } className = "live-code-editor-gutter-line" >
8792 { index + 1 }
88- </ div >
93+ </ Text >
8994 ) ) }
90- </ div >
91- < div className = "live-code-editor-editor" >
95+ </ Flex >
96+ < Flex vertical className = "live-code-editor-editor" >
9297 < LiveEditor className = "live-code-editor-live" />
93- </ div >
94- </ div >
95- </ div >
98+ </ Flex >
99+ </ Flex >
100+ </ Flex >
96101 )
97- }
102+ }
0 commit comments