|
1 | 1 | import React, { useEffect, useState, useRef } from 'react';
|
| 2 | +import style from '../../components/BrowserWindow/BrowserWindow.module.css'; |
2 | 3 |
|
3 |
| -const BasicEditor: React.FC = () => { |
4 |
| - const [checker, setChecker] = useState({ html: true, css: false, js: false }); |
| 4 | +const BasicEditor= () => { |
| 5 | + const [checker, setChecker] = useState({ html: true, css: false, js: false,settings:false,fontSize:10,fontColor:false,backcolor:false }); |
5 | 6 | const [html, setHtml] = useState("");
|
6 | 7 | const [css, setCss] = useState("");
|
7 | 8 | const [js, setJs] = useState("");
|
@@ -47,11 +48,57 @@ const BasicEditor: React.FC = () => {
|
47 | 48 | <button className={!checker.css ? 'btn_activated css' : 'btn_deactivated'} onClick={() => setChecker({ html: false, css: true, js: false })}>CSS</button>
|
48 | 49 | <button className={!checker.js ? 'btn_activated js' : 'btn_deactivated'} onClick={() => setChecker({ html: false, css: false, js: true })}>JS</button>
|
49 | 50 | </div>
|
50 |
| - <textarea className={checker.html ? 'editor_textarea_activate' : 'editor_textarea_deactivate'} value={html} placeholder="HTML" onChange={(e) => setHtml(e.target.value)}></textarea> |
51 |
| - <textarea className={checker.css ? 'editor_textarea_activate' : 'editor_textarea_deactivate'} value={css} placeholder="CSS" onChange={(e) => setCss(e.target.value)}></textarea> |
52 |
| - <textarea className={checker.js ? 'editor_textarea_activate' : 'editor_textarea_deactivate'} value={js} placeholder="JavaScript" onChange={(e) => setJs(e.target.value)}></textarea> |
| 51 | + <div className='editor_settings_nav'> |
| 52 | + <div className={`editor_settings_menu_con ${checker.settings?"activate_menu":"deactivate_menu"}`}> |
| 53 | + <div className='editor_settings_menu'> |
| 54 | + <p>Font Size</p> |
| 55 | + <button onClick={()=>setChecker(pre=>({...pre,fontSize:pre.fontSize!==30?pre.fontSize+1:pre.fontSize}))}>+</button> |
| 56 | + <p>{checker.fontSize}</p> |
| 57 | + <button onClick={()=>setChecker(pre=>({...pre,fontSize:pre.fontSize!==10?pre.fontSize-1:pre.fontSize}))}>-</button> |
| 58 | + </div> |
| 59 | + <div className='editor_settings_menu'> |
| 60 | + <p>color</p> |
| 61 | + <input |
| 62 | + type="color" |
| 63 | + value={checker.fontColor} |
| 64 | + onChange={(e)=>setChecker(pre=>({...pre,fontColor:e.target.value}))} |
| 65 | + /> |
| 66 | + </div> |
| 67 | + <div className='editor_settings_menu'> |
| 68 | + <p>Bakcground color</p> |
| 69 | + <input |
| 70 | + type="color" |
| 71 | + value={checker.backcolor} |
| 72 | + onChange={(e)=>setChecker(pre=>({...pre,backcolor:e.target.value}))} |
| 73 | + /> |
| 74 | + </div> |
| 75 | + </div> |
| 76 | + <div className='editor_setting_icon'> |
| 77 | + <img src="https://cdn-icons-png.flaticon.com/128/9333/9333993.png" onClick={()=>setChecker(pre => ({...pre, settings: !pre.settings}))} alt='settings'/> |
| 78 | + </div> |
| 79 | + </div> |
| 80 | + <textarea style={{fontSize:`${checker.fontSize}pt`,color:checker.fontColor==false?"unset":checker.fontColor,background:checker.backcolor==false?"transparent":checker.backcolor}} className={checker.html ? 'editor_textarea_activate' : 'editor_textarea_deactivate'} value={html} placeholder="HTML" onChange={(e) => setHtml(e.target.value)}></textarea> |
| 81 | + <textarea style={{fontSize:`${checker.fontSize}pt`,color:checker.fontColor==false?"unset":checker.fontColor,background:checker.backcolor==false?"transparent":checker.backcolor}} className={checker.css ? 'editor_textarea_activate' : 'editor_textarea_deactivate'} value={css} placeholder="CSS" onChange={(e) => setCss(e.target.value)}></textarea> |
| 82 | + <textarea style={{fontSize:`${checker.fontSize}pt`,color:checker.fontColor==false?"unset":checker.fontColor,background:checker.backcolor==false?"transparent":checker.backcolor}} className={checker.js ? 'editor_textarea_activate' : 'editor_textarea_deactivate'} value={js} placeholder="JavaScript" onChange={(e) => setJs(e.target.value)}></textarea> |
| 83 | + </div> |
| 84 | + <div className={style.browserWindow} style={{height:"35.3rem",flex:"1 0 30rem",marginTop:"1.3rem"}}> |
| 85 | + <div className={style.browserWindowHeader}> |
| 86 | + <div className={style.buttons}> |
| 87 | + <span className={style.dot} style={{background: '#f25f58'}} /> |
| 88 | + <span className={style.dot} style={{background: '#fbbe3c'}} /> |
| 89 | + <span className={style.dot} style={{background: '#58cb42'}} /> |
| 90 | + </div> |
| 91 | + <div className={style.browserWindowMenuIcon}> |
| 92 | + <div> |
| 93 | + <span className={style.bar} /> |
| 94 | + <span className={style.bar} /> |
| 95 | + <span className={style.bar} /> |
| 96 | + </div> |
| 97 | + </div> |
53 | 98 | </div>
|
54 |
| - <iframe ref={iframeRef} className='output_container' id="preview"></iframe> |
| 99 | + |
| 100 | + <iframe ref={iframeRef} className='output_container' id="preview"></iframe> |
| 101 | + </div> |
55 | 102 | </div>
|
56 | 103 | );
|
57 | 104 | }
|
|
0 commit comments