1+ import Editor from '@monaco-editor/react'
12import clsx from 'clsx'
23import { useState } from 'react'
34import FlipMove from 'react-flip-move'
@@ -10,23 +11,48 @@ import { copyText } from '@/utils/index'
1011function ResultSection ( props : {
1112 themeChange : ( ) => void
1213 isDarkTheme ?: boolean
13- prefix : string
14- setPrefix : ( v : string ) => void
14+ config : TranslatorConfigCopy
15+ setConfig : ( v : TranslatorConfigCopy ) => void
1516 computedResultVals : ComputedResultCode [ ]
1617} ) {
17- const { themeChange, isDarkTheme, computedResultVals, prefix , setPrefix } = props
18+ const { themeChange, isDarkTheme, computedResultVals, config , setConfig } = props
1819 const [ configShow , setConfigShow ] = useState < boolean > ( false )
1920 return (
2021 < section className = 'font-[Consolas,_"Courier_New",_monospace] lgx:col-start-2 relative lgx:h-full max-lgx:h-1/2 overflow-y-auto text-[#111827] dark:text-[#abb2bf]' >
2122 < div className = "absolute right-[16px] top-[16px] flex items-center" >
2223 < div className = "mr-[16px] relative z-10" >
23- < button onClick = { ( ) => setConfigShow ( v => ! v ) } className = "h-[32px] rounded-[16px] px-[12px] text-[18px ] font-bold border-solid border-[1px] dark:border-[rgba(82,82,89,.68)] dark:bg-[#313136] border-[rgba(60,60,67,.29)] bg-[#eeeeee] filter hover:brightness-105 active:enabled:brightness-95" >
24+ < button onClick = { ( ) => setConfigShow ( v => ! v ) } className = "h-[32px] rounded-[16px] px-[12px] text-[16px ] font-bold border-solid border-[1px] dark:border-[rgba(82,82,89,.68)] dark:bg-[#313136] border-[rgba(60,60,67,.29)] bg-[#eeeeee] filter hover:brightness-105 active:enabled:brightness-95" >
2425 SetConfig
2526 </ button >
26- < ul className = { clsx ( 'absolute right-[0] -bottom-[16px] transform translate-y-full dark:border-[#454545] border-[#c8c8c8] border-solid border-[1px] dark:bg-[#1e1e1e] bg-[#f3f3f3] rounded-[8px] p -[16px]' , configShow ? 'opacity-100' : 'opacity-0 pointer-events-none' ) } >
27- < li className = "flex items-center" >
27+ < ul className = { clsx ( 'absolute left-1/2 -bottom-[16px] transform translate-y-full -translate-x-1/2 dark:border-[#454545] border-[#c8c8c8] border-solid border-[1px] dark:bg-[#1e1e1e] bg-[#f3f3f3] rounded-[8px] pt -[16px] px-[16px] pb-[8px] before:content-[""] before:w-[8px] before:h-[8px] before:bg-inherit before:block before:absolute before:-top-[4px] before:[border:inherit] before:!border-b-transparent before:!border-r-transparent before:left-1/2 before:transform before:-translate-x-1/2 before:rotate-45 [&>li]:mb-[8px ]' , configShow ? 'opacity-100' : 'opacity-0 pointer-events-none' ) } >
28+ < li className = "flex items-center w-[300px] " >
2829 < span > prefix:</ span >
29- < input value = { prefix } onChange = { e => setPrefix ( e . target . value ) } type = "text" className = "ml-[8px] py-[2px] px-[4px] dark:bg-[#0f0f0f] bg-[#ffffff] rounded-[4px] text-inherit" />
30+ < input value = { config . prefix } onChange = { e => setConfig ( { ...config , prefix : e . target . value } ) } type = "text" className = "w-[220px] ml-[8px] py-[2px] px-[4px] dark:bg-[#0f0f0f] bg-[#ffffff] rounded-[4px] text-inherit outline-none border-[1px] border-solid border-transparent dark:focus:border-[#f3f3f3] focus:border-[#454545]" />
31+ </ li >
32+ < li className = "flex items-center" >
33+ < span > useAllDefaultValues:</ span >
34+ < input checked = { config . useAllDefaultValues } onChange = { e => setConfig ( { ...config , useAllDefaultValues : e . target . checked } ) } type = "checkbox" className = "w-[20px] h-[20px] ml-[8px]" />
35+ </ li >
36+ < li className = "flex flex-col" >
37+ < span > customTheme:</ span >
38+ < div >
39+ < Editor
40+ className = "text-inherit outline-none border-[1px] border-solid dark:border-[#454545] border-[#c8c8c8]"
41+ width = { '100%' }
42+ height = { 300 }
43+ language = "json"
44+ theme = { isDarkTheme ? 'vs-dark' : 'light' }
45+ onChange = { v => setConfig ( { ...config , customTheme : v ?? '' } ) }
46+ defaultValue = { config . customTheme }
47+ options = { {
48+ fontSize : 18 ,
49+ lineNumbers : 'off' ,
50+ minimap : {
51+ enabled : false
52+ }
53+ } }
54+ />
55+ </ div >
3056 </ li >
3157 </ ul >
3258 </ div >
0 commit comments