-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add the react-context state management for the app
- Loading branch information
Showing
14 changed files
with
1,133 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
tested, ran into issues | ||
https://github.com/vantezzen/autoform/issues/138 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { AutoForm } from "@autoform/mui"; | ||
import { ZodProvider } from "@autoform/zod"; | ||
import { z } from "zod"; | ||
|
||
const userSchema = z.object({ | ||
name: z.string(), | ||
birthday: z.coerce.date(), | ||
email: z.string().email(), | ||
}); | ||
|
||
const schemaProvider = new ZodProvider(userSchema); | ||
|
||
export function MyForm() { | ||
return ( | ||
<AutoForm | ||
schema={schemaProvider} | ||
onSubmit={(data) => { | ||
console.log(data); | ||
}} | ||
withSubmit | ||
/> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
apps/gda-scan-definition/app/components/BIgComponentWithContext.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Grid } from "@mui/material"; | ||
|
||
export function BigComponentWithContext() { | ||
return <Grid container spacing={2}></Grid>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use client"; | ||
import React from "react"; | ||
import { useIDEState, useIDEDispatch } from "./ideState"; | ||
|
||
const Editor: React.FC = () => { | ||
const { openTabs, activeTab } = useIDEState(); | ||
const dispatch = useIDEDispatch(); | ||
|
||
const activeTabData = openTabs.find((tab) => tab.id === activeTab); | ||
|
||
if (!activeTabData) { | ||
return <div className="editor">No file selected</div>; | ||
} | ||
|
||
const handleContentChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => { | ||
dispatch({ | ||
type: "EDIT_TAB_CONTENT", | ||
payload: { id: activeTabData.id, content: e.target.value }, | ||
}); | ||
}; | ||
|
||
return ( | ||
<textarea | ||
value={activeTabData.content} | ||
onChange={handleContentChange} | ||
className="editor" | ||
/> | ||
); | ||
}; | ||
|
||
export default Editor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use client"; | ||
import React from "react"; | ||
import { useIDEState, useIDEDispatch, FileItem } from "./ideState"; | ||
|
||
const FileExplorer: React.FC = () => { | ||
const { fileSystem, selectedFile } = useIDEState(); | ||
const dispatch = useIDEDispatch(); | ||
|
||
const handleFileClick = (file: FileItem) => { | ||
dispatch({ type: "SELECT_FILE", payload: file.id }); | ||
if (file.type === "file") { | ||
dispatch({ type: "OPEN_TAB", payload: file }); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="file-explorer"> | ||
{fileSystem.map((file) => ( | ||
<div | ||
key={file.id} | ||
className={`file-item ${selectedFile === file.id ? "selected" : ""}`} | ||
onClick={() => handleFileClick(file)} | ||
> | ||
{file.name} | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default FileExplorer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React from "react"; | ||
import FileExplorer from "./FileExplorer"; | ||
import Tabs from "./Tabs"; | ||
import Editor from "./Editor"; | ||
import { IDEProvider } from "./ideState"; | ||
import { Box, Button, ButtonGroup, Grid, Typography } from "@mui/material"; | ||
|
||
const IDE: React.FC = () => { | ||
return ( | ||
<IDEProvider> | ||
<div className="ide"> | ||
{/* Main grid container */} | ||
<Grid | ||
container | ||
direction="column" | ||
spacing={2} | ||
style={{ height: "100vh" }} | ||
> | ||
{/* Horizontal bar for potential buttons */} | ||
<Grid item> | ||
<ButtonGroup | ||
sx={{ | ||
width: "100%", | ||
height: "40px", | ||
backgroundColor: "#f5f5f5", // Light gray background for the bar | ||
borderBottom: "1px solid #ddd", // Thin border to define the bar | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
}} | ||
> | ||
{/* Buttons or controls can go here */} | ||
<Button>Null Button</Button> | ||
</ButtonGroup> | ||
</Grid> | ||
|
||
{/* Main layout grid: File Explorer, Tabs, and Editor */} | ||
<Grid container item spacing={2} flex={1}> | ||
{/* File Explorer */} | ||
<Grid item xs={3}> | ||
<FileExplorer /> | ||
</Grid> | ||
|
||
{/* Tabs and Editor */} | ||
<Grid item xs={9}> | ||
<Grid | ||
container | ||
direction="column" | ||
spacing={2} | ||
style={{ height: "100%" }} | ||
> | ||
{/* Tabs */} | ||
<Grid item> | ||
<Tabs /> | ||
</Grid> | ||
|
||
{/* Editor */} | ||
<Grid item flex={1}> | ||
<Editor /> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</div> | ||
</IDEProvider> | ||
); | ||
}; | ||
|
||
export default IDE; |
Oops, something went wrong.