Skip to content

Commit

Permalink
feat: furniture tab semi-implementation - fix #4 (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
pagoru authored Aug 26, 2024
1 parent b727fb1 commit a36d4ba
Show file tree
Hide file tree
Showing 73 changed files with 1,596 additions and 127 deletions.
2 changes: 1 addition & 1 deletion app/client/src/main.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* {
font-size: 1.6rem;
font-family: monospace;
box-sizing: border-box;
box-sizing: content-box;

button {
border-radius: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const HeaderComponent = () => {
<LinkComponent to="/sprite-sheets">Sprite Sheets</LinkComponent>
<LinkComponent to="/furniture">Furniture</LinkComponent>
<LinkComponent to="/human-clothes">Human and Clothes</LinkComponent>
<LinkComponent to="/public-rooms">Public Rooms</LinkComponent>
</div>
</ContainerComponent>
</header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ import { HomeComponent } from "modules/home";
import { FileManagerComponent } from "modules/file-manager";
import { RedirectComponent } from "shared/components";
import { SpriteSheetsComponent } from "modules/sprite-sheets";
import { FurnitureComponent } from "modules/furniture";

const router = createBrowserRouter([
{
element: <LayoutComponent />,
path: "/",
children: [
{
path: "/furniture",
element: <FurnitureComponent />,
},
{
path: "/sprite-sheets",
element: <SpriteSheetsComponent />,
Expand Down
11 changes: 10 additions & 1 deletion app/client/src/modules/file-manager/file-manager.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, {
} from "react";
import { useData } from "shared/hooks";
import { File } from "shared/types";
import { getBase64FromBody } from "shared/utils";
import { downloadURI, getBase64FromBody } from "shared/utils";
import { parse } from "yaml";
import styles from "./file-manager.module.scss";

Expand Down Expand Up @@ -81,6 +81,12 @@ export const FileManagerComponent: React.FC = () => {
await remove(path + `/${file.name}`);
loadFiles();
};
const onClickDownload = (file: File) => async () => {
downloadURI(
`/api/data/read-file?path=${path + "/" + file.name}`,
file.name,
);
};

const onUploadFiles = async (event: ChangeEvent<HTMLInputElement>) => {
const { files } = event.target;
Expand Down Expand Up @@ -128,6 +134,9 @@ export const FileManagerComponent: React.FC = () => {
{file.isDirectory ? "/" : ""}
{file.name}
</label>
{file.isFile ? (
<button onClick={onClickDownload(file)}>download</button>
) : null}
<button onClick={onClickDeleteFile(file)}>delete</button>
</div>
))}
Expand Down
Loading

0 comments on commit a36d4ba

Please sign in to comment.