@@ -3,6 +3,8 @@ import Markdown from 'react-markdown';
3
3
import { ThemeProvider } from './context/ThemeContext' ;
4
4
import ThemeToggle from './components/presentational/ThemeToggle' ;
5
5
import MarkdownEditor from './components/MarkdownEditor' ;
6
+ import { saveAsFile } from './utils/fileHelpers' ;
7
+
6
8
import './App.css' ;
7
9
8
10
function App ( ) {
@@ -13,29 +15,47 @@ function App() {
13
15
return ( ) => clearTimeout ( timeout ) ;
14
16
} ;
15
17
18
+ const handleSave = ( ) => {
19
+ saveAsFile ( userMarkdown , 'markdown-content.md' , 'text/markdown' ) ;
20
+ } ;
21
+
16
22
return (
17
23
< ThemeProvider >
18
- < main className = "flex flex-col h-screen bg-white dark:bg-[#212424] text-gray-800 dark:text-gray-200 transition-colors duration-200" >
19
- < div className = "container mx-auto px-4 py-8 " >
20
- < div className = "flex justify-between items-center mb-6 " >
21
- < h1 className = "text-4xl font-bold text-gray-900 dark:text-white" > Markdown Online Formatter </ h1 >
24
+ < div className = "flex flex-col h-screen bg-white dark:bg-[#212424] text-gray-800 dark:text-gray-200 transition-colors duration-200" >
25
+ < nav className = "bg-gray-100 dark:bg-gray-800 shadow-md " >
26
+ < div className = "container mx-auto px-4 py-3 flex justify-between items-center" >
27
+ < h1 className = "text-2xl font-bold text-gray-900 dark:text-white" > MarkItDown </ h1 >
22
28
< ThemeToggle />
23
29
</ div >
24
- < p className = "text-lg mb-6 text-gray-600 dark:text-gray-300 text-left" >
25
- This tool allows you to format text in real-time as you type. Enter your text in the field provided, and the
26
- corresponding Markdown will be generated automatically. To apply formatting, simply select the text and
27
- click the desired style button.
28
- </ p >
29
- </ div >
30
-
31
- < div className = "flex-grow flex flex-col md:flex-row gap-4 px-4 pb-4" >
32
- < MarkdownEditor onTextChange = { handleTextChange } />
33
-
34
- < div className = "flex-1 p-4 bg-gray-100 dark:bg-gray-800 border border-gray-300 dark:border-gray-700 overflow-auto" >
35
- < Markdown className = "prose dark:prose-invert max-w-none markdown-custom" > { userMarkdown } </ Markdown >
30
+ </ nav >
31
+
32
+ < main className = "flex-grow flex flex-col overflow-hidden" >
33
+ < div className = "container mx-auto px-4 py-6" >
34
+ < h2 className = "text-xl font-semibold mb-2" > Markdown Online Formatter</ h2 >
35
+ < p className = "text-sm mb-4 text-gray-600 dark:text-gray-300" >
36
+ This tool allows you to format text in real-time as you type. Enter your text in the field provided, and
37
+ the corresponding Markdown will be generated automatically. To apply formatting, simply select the text
38
+ and click the desired style button.
39
+ </ p >
40
+
41
+ < button
42
+ className = "flex items-center justify-center flex-grow basis-0 min-w-[40px] h-8 bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-white font-medium rounded-md hover:bg-gray-300 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-opacity-50 transition-colors duration-200 p-2"
43
+ onClick = { handleSave }
44
+ >
45
+ Save as File
46
+ </ button >
47
+ </ div >
48
+
49
+ < div className = "flex-grow flex flex-col md:flex-row gap-4 px-4 pb-4 overflow-auto" >
50
+ < MarkdownEditor onTextChange = { handleTextChange } />
51
+
52
+ < div className = "flex-1 p-4 bg-gray-100 dark:bg-gray-800 border border-gray-300 dark:border-gray-700 overflow-auto" >
53
+ < h3 className = "dark:bg-gray-700 bg-gray-200 -m-4 mb-6 p-2 dark:text-gray-300 font-semibold" > Preview</ h3 >
54
+ < Markdown className = "prose dark:prose-invert max-w-none markdown-custom" > { userMarkdown } </ Markdown >
55
+ </ div >
36
56
</ div >
37
- </ div >
38
- </ main >
57
+ </ main >
58
+ </ div >
39
59
</ ThemeProvider >
40
60
) ;
41
61
}
0 commit comments