Skip to content

Commit

Permalink
Add output component
Browse files Browse the repository at this point in the history
  • Loading branch information
JeelRajodiya committed May 24, 2024
1 parent 8fef52c commit f323e10
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 7 deletions.
7 changes: 5 additions & 2 deletions app/[...markdownPath]/page.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
.mainArea {
display: flex;
flex-direction: row;
flex: 9;
flex: 12;
height: 100%;
overflow-y: auto;
gap: 8px;
}
.navBar {
flex: 1;
display: flex;
flex-direction: column;
flex-direction: row;
height: min-content;
gap: 16px;
align-items: center;
}
8 changes: 5 additions & 3 deletions app/[...markdownPath]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import styles from "./page.module.css";

import React, { Suspense } from "react";
import NavigationBtn from "../components/NavigationBtn";
import { Button, Flex } from "@chakra-ui/react";
import { Box, Button, Flex } from "@chakra-ui/react";
import Link from "next/link";
import ContentViewer from "../components/ContentViewer/ContentViewer";
import CodeEditor from "../components/CodeEditor/CodeEditor";
import { parseMdxFile } from "@/lib/functions";
import Output from "../components/Output/Output";
import EditorNOutput from "../components/EditorNOutput/EditorNOutput";

export default async function Content({
params,
Expand Down Expand Up @@ -41,7 +43,7 @@ export default async function Content({
<NavigationBtn path={previousStepPath} direction="prev" />
<NavigationBtn path={nextStepPath} direction="next" />
</div>
<Flex gap={4} height={"100%"}>
<Flex gap={4}>
<span>
Chapter {chapterIndex + 1}: {chapterTitle} (
{((chapterIndex + 1) / totalChapters) * 100}%)
Expand All @@ -58,7 +60,7 @@ export default async function Content({
<ContentViewer>
<Page />
</ContentViewer>
<CodeEditor code={codeFile.code} />
<EditorNOutput codeFile={codeFile} />
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion app/components/CodeEditor/CodeEditor.module.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.codeEditor {
overflow-y: auto;
border-radius: 5px;
flex: 1;
padding: 8px;
border: 1px solid rgba(0, 0, 0, 0.334);
border-radius: 16px;
height: 100%;
}
1 change: 0 additions & 1 deletion app/components/CodeEditor/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Editor from "@monaco-editor/react";

export default function CodeEditor({ code }: { code: Object }) {
const codeString = JSON.stringify(code, null, 2);
console.log(codeString);
return (
<div className={ctx(styles.codeEditor, GeistMono.className)}>
<Editor language="jsonc" defaultValue={codeString} />
Expand Down
7 changes: 7 additions & 0 deletions app/components/EditorNOutput/EditorNOutput.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.codeEditorNOutput {
flex: 1;
height: 100%;
display: flex;
flex-direction: column;
gap: 8px;
}
19 changes: 19 additions & 0 deletions app/components/EditorNOutput/EditorNOutput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import CodeEditor from "../CodeEditor";
import styles from "./EditorNOutput.module.css";
import { Box } from "@chakra-ui/react";
import Output from "../Output";
import { CodeFile } from "@/lib/types";

export default function EditorNOutput({ codeFile }: { codeFile: CodeFile }) {
return (
<div className={styles.codeEditorNOutput}>
<Box flex={7}>
<CodeEditor code={codeFile.code} />
</Box>
<Box flex={3}>
<Output />
</Box>
</div>
);
}
1 change: 1 addition & 0 deletions app/components/EditorNOutput/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as default } from "./EditorNOutput";
8 changes: 8 additions & 0 deletions app/components/Output/Output.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.output {
overflow-y: auto;
border-radius: 5px;
padding: 8px;
border: 1px solid rgba(0, 0, 0, 0.334);
border-radius: 16px;
height: 100%;
}
6 changes: 6 additions & 0 deletions app/components/Output/Output.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from "react";
import styles from "./Output.module.css";

export default function Output() {
return <div className={styles.output}>Output</div>;
}
1 change: 1 addition & 0 deletions app/components/Output/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as default } from "./Output";
9 changes: 9 additions & 0 deletions content/01-introduction/01-Your-First-Schema/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ function validationLogicFunction() {
console.log("Doing some validation logic here");
}

const validationSchema = {
type: "object",
properties: {
type: {
type: "string",
},
},
};

module.exports = {
code,
validationLogicFunction,
Expand Down

0 comments on commit f323e10

Please sign in to comment.