Skip to content

Commit 82efc38

Browse files
committed
Updated example
1 parent 684f31d commit 82efc38

File tree

6 files changed

+49
-19
lines changed

6 files changed

+49
-19
lines changed

package-lock.json

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13-
"@litecode-ide/virtual-file-system": "^1.0.2",
13+
"@litecode-ide/virtual-file-system": "^1.0.4",
1414
"react": "^18.2.0",
1515
"react-dom": "^18.2.0"
1616
},

src/App.tsx

+19-8
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,30 @@ function App() {
2020
};
2121

2222
const getFileContents = (id?: string) => {
23-
if (!id) {
24-
const newID = getSelectedFile();
25-
id = newID;
23+
if (id === "") {
24+
return "";
2625
}
27-
if (!id) return "";
28-
return Object.values(getFileTree()).find(({ id: _id }) => _id === id)
26+
return Object.values(getFileTree()).find(({ id: _id }) => _id === id)!
2927
.content;
3028
};
3129

3230
return (
3331
<div className="flex h-screen w-screen overflow-clip">
3432
<div className="flex flex-col h-full w-1/4">
35-
<SearchInput />
33+
<SearchInput className="bg-neutral-500 text-neutral-300 hover:bg-neutral-600 active:bg-neutral-600 focus:bg-neutral-600" />
3634
<FileExplorer
37-
validExtensions={["js", "css", "html"]}
35+
validExtensions={[
36+
"js",
37+
"ts",
38+
"tsx",
39+
"jsx",
40+
"json",
41+
"md",
42+
"css",
43+
"txt",
44+
"html",
45+
]}
46+
projectName="My awesome project"
3847
onItemSelected={(item) => {
3948
if (item.type === "file") {
4049
setValue(getFileContents(item.id));
@@ -46,7 +55,9 @@ function App() {
4655
<div className="flex flex-col h-full w-1/2">
4756
<TabsList
4857
onTabClick={(id: string) => setValue(getFileContents(id))}
49-
onTabClose={() => setValue(getFileContents())}
58+
onTabClose={() => {
59+
setValue(getFileContents(getSelectedFile()))
60+
}}
5061
/>
5162
<Breadcrumbs
5263
onBreadcrumbFileClick={(id: string) => setValue(getFileContents(id))}

src/assets/json.svg

+2
Loading

src/assets/txt.svg

+7
Loading

src/index.css

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
@tailwind components;
33
@tailwind utilities;
44

5+
/* Some logos, like js, css, ts are provided by default */
6+
57
/* Vite Logo */
68
.vite-logo {
79
background-image: url("../public/vite.svg");
@@ -10,4 +12,12 @@
1012
/* HTML Logo */
1113
.html-logo {
1214
background-image: url("./assets/html.svg");
15+
}
16+
17+
.json-logo {
18+
background-image: url("./assets/json.svg");
19+
}
20+
21+
.txt-logo {
22+
background-image: url("./assets/txt.svg");
1323
}

0 commit comments

Comments
 (0)