@@ -6,11 +6,13 @@ import { StatusBar } from '@/components/StatusBar'
66import { LoadingOverlay } from '@/components/LoadingOverlay'
77import { NativeSelect } from '@/components/ui/select'
88import { Badge } from '@/components/ui/badge'
9+ import { ToastProvider , toastManager } from '@/components/ui/toast'
910import { useCompiler } from '@/hooks/useCompiler'
1011import { examples , defaultCode } from '@/lib/examples'
1112
1213function App ( ) {
1314 const [ code , setCode ] = useState ( defaultCode )
15+ const [ selectedExample , setSelectedExample ] = useState ( '' )
1416 const compiler = useCompiler ( )
1517
1618 // Load code from URL on mount
@@ -35,79 +37,93 @@ function App() {
3537 const url = window . location . origin + window . location . pathname + '?code=' + encoded
3638
3739 navigator . clipboard . writeText ( url ) . then ( ( ) => {
38- alert ( 'Link copied to clipboard!' )
40+ toastManager . add ( {
41+ title : 'Link copied!' ,
42+ description : 'Share this link with others to share your code.' ,
43+ type : 'success' ,
44+ } )
3945 } ) . catch ( ( ) => {
40- prompt ( 'Copy this link:' , url )
46+ toastManager . add ( {
47+ title : 'Copy failed' ,
48+ description : url ,
49+ type : 'error' ,
50+ } )
4151 } )
4252 } , [ code ] )
4353
4454 const handleExampleChange = useCallback ( ( e : React . ChangeEvent < HTMLSelectElement > ) => {
4555 const name = e . target . value as keyof typeof examples
56+ setSelectedExample ( e . target . value )
4657 if ( examples [ name ] ) {
4758 setCode ( examples [ name ] )
48- e . target . value = ''
4959 }
5060 } , [ ] )
5161
5262 return (
53- < div className = "min-h-screen flex flex-col" >
54- < LoadingOverlay isVisible = { compiler . isLoading } />
63+ < ToastProvider position = "bottom-right" >
64+ < div className = "min-h-screen flex flex-col bg-background" >
65+ < LoadingOverlay isVisible = { compiler . isLoading } />
5566
56- < Header
57- onRun = { handleRun }
58- onShare = { handleShare }
59- isCompiling = { compiler . status === 'compiling' }
60- />
67+ < Header
68+ onRun = { handleRun }
69+ onShare = { handleShare }
70+ isCompiling = { compiler . status === 'compiling' }
71+ />
6172
62- < div className = "flex-1 grid grid-cols-1 md:grid-cols-2 min-h-0" >
63- { /* Editor Panel */ }
64- < div className = "flex flex-col border-r border-border min-h-0" >
65- < div className = "px-4 py-2 bg-secondary flex justify-between items-center border-b border-white/10" >
66- < span className = "font-semibold text-sm" > FratmScript</ span >
67- < Badge variant = "secondary" > v{ compiler . version } </ Badge >
73+ < div className = "flex-1 grid grid-cols-1 md:grid-cols-2 min-h-0" >
74+ { /* Editor Panel */ }
75+ < div className = "flex flex-col border-r border-border min-h-0" >
76+ < div className = "px-4 py-2.5 bg-card flex justify-between items-center border-b border-border" >
77+ < span className = "font-medium text-sm text-foreground" > FratmScript</ span >
78+ < Badge variant = "outline" > v{ compiler . version } </ Badge >
79+ </ div >
80+ < div className = "flex-1 min-h-0 bg-background" >
81+ < Editor
82+ value = { code }
83+ onChange = { setCode }
84+ onRun = { handleRun }
85+ />
86+ </ div >
87+ < div className = "px-4 py-2.5 bg-card border-t border-border flex items-center gap-3" >
88+ < label className = "text-xs text-muted-foreground" > Examples:</ label >
89+ < NativeSelect
90+ value = { selectedExample }
91+ onChange = { handleExampleChange }
92+ className = "w-52"
93+ >
94+ < option value = "" > -- Choose an example --</ option >
95+ < option value = "hello" > Hello World</ option >
96+ < option value = "fibonacci" > Fibonacci</ option >
97+ < option value = "classe" > Pizzaiolo Class</ option >
98+ < option value = "async" > Async/Await</ option >
99+ < option value = "operatori" > Logical Operators</ option >
100+ < option value = "array" > Arrays and Objects</ option >
101+ </ NativeSelect >
102+ </ div >
68103 </ div >
69- < div className = "flex-1 min-h-0 bg-card" >
70- < Editor
71- value = { code }
72- onChange = { setCode }
73- onRun = { handleRun }
74- />
75- </ div >
76- < div className = "px-4 py-2 bg-black/20 flex items-center gap-3" >
77- < label className = "text-xs text-muted-foreground" > Examples:</ label >
78- < NativeSelect onChange = { handleExampleChange } className = "w-48" >
79- < option value = "" > -- Choose an example --</ option >
80- < option value = "hello" > Hello World</ option >
81- < option value = "fibonacci" > Fibonacci</ option >
82- < option value = "classe" > Pizzaiolo Class</ option >
83- < option value = "async" > Async/Await</ option >
84- < option value = "operatori" > Logical Operators</ option >
85- < option value = "array" > Arrays and Objects</ option >
86- </ NativeSelect >
87- </ div >
88- </ div >
89104
90- { /* Output Panel */ }
91- < div className = "flex flex-col min-h-0" >
92- < div className = "px-4 py-2 bg-secondary flex items-center border-b border-white/10" >
93- < span className = "font-semibold text-sm" > Output</ span >
94- </ div >
95- < div className = "flex-1 min-h-0 bg-card overflow-auto" >
96- < OutputPanel
97- jsOutput = { compiler . jsOutput }
98- consoleLogs = { compiler . consoleLogs }
99- error = { compiler . error }
100- />
105+ { /* Output Panel */ }
106+ < div className = "flex flex-col min-h-0" >
107+ < div className = "px-4 py-2.5 bg-card flex items-center border-b border-border" >
108+ < span className = "font-medium text-sm text-foreground" > Output</ span >
109+ </ div >
110+ < div className = "flex-1 min-h-0 bg-background overflow-auto" >
111+ < OutputPanel
112+ jsOutput = { compiler . jsOutput }
113+ consoleLogs = { compiler . consoleLogs }
114+ error = { compiler . error }
115+ />
116+ </ div >
101117 </ div >
102118 </ div >
103- </ div >
104119
105- < StatusBar
106- status = { compiler . status }
107- statusText = { compiler . statusText }
108- compileTime = { compiler . compileTime }
109- />
110- </ div >
120+ < StatusBar
121+ status = { compiler . status }
122+ statusText = { compiler . statusText }
123+ compileTime = { compiler . compileTime }
124+ />
125+ </ div >
126+ </ ToastProvider >
111127 )
112128}
113129
0 commit comments