Skip to content

Commit 606fa5e

Browse files
authored
Merge pull request #3 from UniversalPython/fonts
Fix fonts and added MUI
2 parents 86b86fc + a2a448b commit 606fa5e

File tree

6 files changed

+383
-85
lines changed

6 files changed

+383
-85
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
"@codemirror/lang-python": "^6.1.1",
1818
"@docusaurus/core": "2.2.0",
1919
"@docusaurus/preset-classic": "2.2.0",
20+
"@emotion/react": "^11.10.6",
21+
"@emotion/styled": "^11.10.6",
2022
"@mdx-js/react": "^1.6.22",
23+
"@mui/material": "^5.11.10",
2124
"@uiw/codemirror-extensions-langs": "^4.19.4",
2225
"@uiw/codemirror-themes": "^4.19.4",
2326
"@uiw/react-codemirror": "^4.19.4",

src/components/CodeEditor/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class CodeEditor extends React.PureComponent {
3737
const { value } = this.state;
3838

3939
return (
40+
4041
<AceEditor
4142
// theme="twilight"
4243
theme="github"

src/css/custom.css

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,14 @@
44
* work well for content-centric websites.
55
*/
66

7-
@font-face {
8-
font-family: 'Kawkab Mono';
9-
src: url(/static/KawkabMono-Regular.ttf) format('truetype');
10-
}
117

12-
@font-face {
13-
font-family: 'Kawkab Mono';
14-
font-weight: 200;
15-
src: url(/static/KawkabMono-Light.ttf) format('truetype');
16-
}
178

18-
@font-face {
19-
font-family: 'Kawkab Mono';
20-
font-weight: 900;
21-
src: url(/static/KawkabMono-Bold.ttf) format('truetype');
22-
}
9+
10+
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300;400&display=swap');
2311

2412
/* You can override the default Infima variables here. */
2513
:root {
26-
/* --ifm-font-family-monospace: "Kawkab Mono Regular"; */
14+
2715
--ifm-color-primary: #2e8555;
2816
--ifm-color-primary-dark: #29784c;
2917
--ifm-color-primary-darker: #277148;
@@ -33,6 +21,8 @@
3321
--ifm-color-primary-lightest: #3cad6e;
3422
--ifm-code-font-size: 95%;
3523
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);
24+
25+
3626
}
3727

3828
/* For readability concerns, you should choose a lighter palette in dark mode. */
@@ -45,5 +35,6 @@
4535
--ifm-color-primary-lighter: #32d8b4;
4636
--ifm-color-primary-lightest: #4fddbf;
4737
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
38+
4839
}
4940

src/pages/index.js

Lines changed: 114 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@ import Head from '@docusaurus/Head';
66
import Layout from '@theme/Layout';
77
import HomepageFeatures from '@site/src/components/HomepageFeatures';
88
import CodeEditor from '@site/src/components/CodeEditor2';
9-
10-
11-
9+
import { Box,TextField,MenuItem } from '@mui/material';
1210
import useGeoLocation from "react-ipgeolocation";
13-
1411
import { useColorMode } from '@docusaurus/theme-common';
15-
16-
17-
import { EditorView } from '@codemirror/view';
18-
12+
import { EditorView } from '@codemirror/view';
1913
import { Blocks } from 'react-loader-spinner'
20-
2114
import useIsBrowser from '@docusaurus/useIsBrowser';
15+
import { ThemeProvider, createTheme } from '@mui/material/styles';
16+
import CssBaseline from '@mui/material/CssBaseline';
2217

2318

2419
export const defaultLightThemeOption = EditorView.theme(
@@ -37,8 +32,9 @@ export const defaultLightThemeOption = EditorView.theme(
3732

3833

3934
import styles from './index.module.css';
35+
import { height } from '@mui/system';
4036

41-
37+
//Array of Languages on right side of code editor
4238
const languages = [
4339

4440
{
@@ -48,9 +44,11 @@ const languages = [
4844
name: "Urdu",
4945
i18nName: "اردو",
5046
direction: "rtl",
51-
fontFamily: "'Kawkab Mono'",
47+
fontFamily: "'Roboto Mono'",
5248
toEnglishDict: "'languages/ur/ur_native.lang.yaml'",
49+
fontWeights: "bold",
5350
style: {
51+
5452
direction: "rtl"
5553
}
5654
},
@@ -61,17 +59,18 @@ const languages = [
6159
code2: "hi",
6260
name: "Hindi",
6361
i18nName: "Hindi",
64-
fontFamily: "'Hack', 'Courier New', monospaced",
62+
fontFamily: "'Roboto Mono'",
63+
6564
toEnglishDict: "'languages/hi/hi_native.lang.yaml'",
6665
},
6766
{
6867
id: "EN",
69-
// default: true,
7068
code3: "eng",
7169
code2: "en",
7270
name: "English",
7371
i18nName: "English",
74-
fontFamily: "'Hack', 'Courier New', monospaced",
72+
fontFamily: "'Roboto Mono'",
73+
7574
}
7675
]
7776

@@ -126,6 +125,7 @@ const IDE = ({basicSetup, ...props}) => {
126125
}
127126

128127
function HomepageHeader() {
128+
129129
const {siteConfig} = useDocusaurusContext();
130130
return (
131131
<header className={clsx('hero hero--primary', styles.heroBanner)}>
@@ -148,7 +148,7 @@ function HomepageHeader() {
148148
const initialCodes = [
149149
{
150150
id: "hello_world",
151-
name: "Simple Hello World",
151+
name: " Simple Hello World",
152152
en: `print("Hello world!")`
153153
},
154154
{
@@ -185,6 +185,9 @@ with open("chad.txt", "r") as f:
185185

186186

187187
export default function Home() {
188+
189+
190+
188191
const {siteConfig} = useDocusaurusContext();
189192

190193
const [editorCode, setEditorCode] = useState(initialCodes[0].en);
@@ -316,6 +319,9 @@ export default function Home() {
316319

317320

318321
</Head>
322+
323+
<MaterialThemeWrapper>
324+
319325
<HomepageHeader />
320326
<main>
321327
{/* <textarea style={{
@@ -327,67 +333,82 @@ export default function Home() {
327333
}}></textarea> */}
328334

329335

336+
{/* *****************************************
337+
********DIV FOR THE TOP SECTION**************
338+
***********************************************
339+
*********************************************** */}
330340

331-
<div style={{
332-
padding: "80px"
333-
}}>
334-
<select style={{
335-
flex: 1,
336-
// width: "100%",
337-
margin: "12px",
341+
<div style={{
342+
padding: "80px"
343+
344+
}}>
338345

339-
}}
340-
341-
onChange={(e) => {
346+
347+
348+
<Box width="250px">
349+
<TextField select fullWidth label="Choose Preset" onChange={(e) => {
342350
console.log("e.target.value:", e.target.value);
343351
console.log(`languages.find(l => l.id === e.target.value)`, initialCodes.find(l => l.id === e.target.value))
344352
setCode(initialCodes.find(l => l.id === e.target.value).en);
345353
}}
354+
style={{
355+
marginLeft: "0.7rem"
356+
}}
346357
value={initialCodes.find(c => {
347358
console.log("c.en === code:", c.en === code);
348359
return c.en === code
349360
})?.id || "custom"}
350361
key={code}
351362
>
352-
{
363+
{
353364
initialCodes.map((l, idx) => {
354365
return (
355-
<option value={l.id}>{l.name}</option>
366+
<MenuItem value={l.id}>{l.name}</MenuItem>
356367
)
357368
})
358-
}
359-
<option value="custom">Custom</option>
360-
</select>
361-
<div style={{
362-
display: "flex",
363-
flexDirection: "row",
364-
}}>
365-
<div
369+
}
370+
<MenuItem value="custom">Custom</MenuItem>
371+
</TextField>
372+
</Box>
373+
374+
{/* *****************************************
375+
********DIV FOR THE LANGUAGE SECTION**********
376+
***********************************************
377+
************************************************/}
378+
379+
380+
<div style={{
381+
display: "flex",
382+
flexDirection: "row",
383+
marginTop: "12px",
384+
}}>
385+
<div
366386
style={{
367387
flex: 1,
368388
}}>
369-
<select style={{
370-
flex: 1,
371-
// width: "100%",
372-
margin: "12px",
373389

374-
}}
375-
376-
onChange={(e) => {
390+
<Box width="250px">
391+
<TextField label="From" fullWidth select onChange={(e) => {
377392
console.log("e.target.value:", e.target.value);
378393
console.log(`languages.find(l => l.id === e.target.value)`, languages.find(l => l.id === e.target.value))
379394
setSourceLanguage(languages.find(l => l.id === e.target.value));
380395
}}
396+
style={{
397+
marginLeft: "0.7rem"
398+
}}
381399
value={sourceLanguage?.id}
382400
>
383-
{
401+
{
384402
languages.map((l, idx) => {
385403
return (
386-
<option value={l.id}>{l.name}</option>
404+
<MenuItem value={l.id}>{l.name}</MenuItem>
387405
)
388406
})
389407
}
390-
</select>
408+
409+
</TextField>
410+
</Box>
411+
391412
<IDE id="python-code-editor1"
392413
value={code}
393414
mode="python"
@@ -410,45 +431,53 @@ export default function Home() {
410431
/>
411432
</div>
412433

434+
{/* IDE convertor button */}
413435
<button style={{
414-
opacity: 0.45
436+
opacity: 0.45,
437+
height:"100%",
438+
backgroundColor: "transparent",
439+
border: "none",
440+
cursor: "pointer",
441+
width: "5%",
442+
fontSize: "1.5rem",
415443
}} onClick={()=>{
416444
setTargetLanguage(sourceLanguage);
417445
setSourceLanguage(targetLanguage);
418446
var element = document.getElementById("python-code-editor2");
419447
setCode(element.innerHTML.replaceAll("<br>", "\n").replaceAll("&nbsp;", " "))
420448
}}>
421-
&#8660;
449+
{/* &#8660; */}
450+
&#8644;
422451
</button>
423452

424-
<div
453+
<div
425454
style={{
426455
flex: 1,
456+
marginLeft: "12px",
427457
}}>
428-
429-
<select style={{
430-
flex: 1,
431-
// width: "100%",
432-
margin: "12px",
433-
434-
}}
435-
436-
onChange={(e) => {
458+
459+
<Box width="250px">
460+
<TextField select label="To" fullWidth onChange={(e) => {
437461
console.log("e.target.value:", e.target.value);
438462
console.log(`languages.find(l => l.id === e.target.value)`, languages.find(l => l.id === e.target.value))
439463
setTargetLanguage(languages.find(l => l.id === e.target.value));
440464
setIsDetected(false);
441465
}}
466+
style={{
467+
marginLeft: "0.7rem"
468+
}}
442469
value={targetLanguage?.id}
443-
>
444-
{
470+
>
471+
{
445472
languages.map((l, idx) => {
446473
return (
447-
<option value={l.id}>{l.name} {targetLanguage?.id === l.id ? isDetected ? " - detected" : "" : ""}</option>
474+
<MenuItem value={l.id}>{l.name} {targetLanguage?.id === l.id ? isDetected ? " - detected" : "" : ""}</MenuItem>
448475
)
449476
})
450477
}
451-
</select>
478+
</TextField>
479+
</Box>
480+
452481
<IDE
453482
id="python-code-editor2"
454483
// value={code
@@ -660,6 +689,30 @@ with open('file', 'w') as sys.stdout:
660689
</div>
661690
{/* <HomepageFeatures /> */}
662691
</main>
692+
</MaterialThemeWrapper>
693+
663694
</Layout>
664695
);
665696
}
697+
698+
699+
const MaterialThemeWrapper = ({children}) => {
700+
701+
const { colorMode } = useColorMode();
702+
const isDarkTheme = colorMode === "dark";
703+
704+
const theme = React.useMemo(
705+
() =>
706+
createTheme({
707+
palette: {
708+
mode: isDarkTheme ? "dark" : "light",
709+
},
710+
}),
711+
[isDarkTheme],
712+
);
713+
714+
return <ThemeProvider theme={theme}>
715+
<CssBaseline />
716+
{children}
717+
</ThemeProvider>
718+
}

0 commit comments

Comments
 (0)