Skip to content

Commit

Permalink
✴: Update improving some files
Browse files Browse the repository at this point in the history
  • Loading branch information
TeaByte committed Jan 13, 2024
1 parent 6066872 commit 5598f31
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 25 deletions.
18 changes: 10 additions & 8 deletions components/Courses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ export default function Courses(
);
}
})}
<p class="mt-4 text-2xl">نعمل على الدروس القادما...</p>
<a
href="https://github.com/TeaByte/NakhlahJS"
class="text-gray-500 hover:underline"
target="_blank"
>
هل تود المساهمه في الموقع ؟
</a>
<div>
<p class="mt-3 text-2xl">نعمل على الدروس القادما...</p>
<a
href="https://github.com/TeaByte/NakhlahJS"
class="text-gray-500 hover:underline"
target="_blank"
>
هل تود المساهمه في الموقع ؟
</a>
</div>
</section>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion components/EditorSplit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function EditorSplit(props: { slug: string }) {
const testcases = getTestCase(props.slug);
return (
<>
<div class="mt-4">
<div class="mt-2">
<div class="mx-2 border-[6px] border-base-300 rounded-btn pb-2">
<div
class="h-[400px] rounded-box"
Expand Down
2 changes: 1 addition & 1 deletion components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function NavBar() {
</a>
</div>
</div>
<div class="flex gap-3 items-center">
<div class="flex gap-2 items-center">
<ThemeToggle />
<Drawer courses={cache.courses} />
</div>
Expand Down
12 changes: 7 additions & 5 deletions islands/Editor.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from "preact/hooks";
import { useLayoutEffect, useState } from "preact/hooks";
import { useToast } from "./useToast.ts";
import { doTests } from "./DoTest.ts";

Expand All @@ -13,9 +13,8 @@ interface Window {
}

export default function Editor(props: CounterProps) {
const [output, setOutput] = useState<string>("");
const { showToast } = useToast();
useEffect(() => {
// FIX ( useEffect, useLayoutEffect ) both don't load the preCode for some reason IDK why..
useLayoutEffect(() => {
const initializeEditor = () => {
if (window.editor) {
window.editor.setValue(props.preCode);
Expand All @@ -27,6 +26,9 @@ export default function Editor(props: CounterProps) {
};
}, []);

const [output, setOutput] = useState<string>("");
const { showToast } = useToast();

function handleCodeClear() {
window.editor.setValue("");
setOutput("");
Expand Down Expand Up @@ -107,7 +109,7 @@ export default function Editor(props: CounterProps) {
اختبار
</button>
</div>
<pre className=" bg-base-300 overflow-y-scroll rounded-box p-4 mb-4 grow">
<pre className=" bg-base-300 overflow-y-scroll rounded-box p-4 mb-2 grow">
{output}
</pre>
</div>
Expand Down
21 changes: 11 additions & 10 deletions islands/ThemeToggle.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
import { useEffect } from "preact/hooks";

declare var window: Window & typeof globalThis;

interface Window {
monaco: any;
}

export default function ThemeToggle() {
useEffect(() => {
const storedTheme = localStorage.getItem("selectedTheme");
if (storedTheme) {
document.documentElement.setAttribute("data-theme", storedTheme);
updateMarkdownTheme(storedTheme);
}
}, []);

const updateMarkdownTheme = (theme: string) => {
const documentDiv = document.getElementById("document");
if (documentDiv) {
if (theme === "dracula") {
documentDiv.setAttribute("data-color-mode", "dark");
documentDiv.setAttribute("data-dark-theme", "dark");
window.monaco.editor.setTheme("vs-dark");
window.monaco && window.monaco.editor.setTheme("vs-dark");
} else {
documentDiv.setAttribute("data-color-mode", "light");
documentDiv.setAttribute("data-light-theme", "light");
window.monaco.editor.setTheme("vs-light");
window.monaco && window.monaco.editor.setTheme("vs-light");
}
}
};

useEffect(() => {
const storedTheme = localStorage.getItem("selectedTheme");
if (storedTheme) {
document.documentElement.setAttribute("data-theme", storedTheme);
updateMarkdownTheme(storedTheme);
}
}, []);

const handleThemeChange = () => {
const storedTheme = localStorage.getItem("selectedTheme");
const newTheme = storedTheme === "nord" ? "dracula" : "nord";
Expand Down

0 comments on commit 5598f31

Please sign in to comment.