Skip to content

Commit

Permalink
test(global): 🎉 make toolbar
Browse files Browse the repository at this point in the history
make toolbar which is like viewers and toolbox

Ref #54
  • Loading branch information
PritamBag committed Jan 3, 2025
1 parent 712ff1f commit 31c56e6
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/components/data/toolbar/HistoryTool.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ToolbarData } from "./Toolbar.data";
import ToolbarFactory from "../../../factory/Toolbar.factory";

export class HistoryToolData extends ToolbarData{
constructor(){
super(
ToolbarFactory.ICONS.HISTORY
);
}
}
10 changes: 10 additions & 0 deletions app/components/data/toolbar/RequestForReviewTool.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ToolbarData } from "./Toolbar.data";
import ToolbarFactory from "../../../factory/Toolbar.factory";

export class RequestForReviewToolData extends ToolbarData{
constructor(){
super(
ToolbarFactory.ICONS.REQUEST_FOR_REVIEW
);
}
}
10 changes: 10 additions & 0 deletions app/components/data/toolbar/SaveTool.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ToolbarData } from "./Toolbar.data";
import ToolbarFactory from "../../../factory/Toolbar.factory";

export class SaveToolData extends ToolbarData{
constructor(){
super(
ToolbarFactory.ICONS.SAVE
);
}
}
16 changes: 16 additions & 0 deletions app/components/data/toolbar/Toolbar.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import ToolbarFactory from "../../../factory/Toolbar.factory";

export abstract class ToolbarData {
readonly toolbarIconTitle: typeof ToolbarFactory.ICONS[keyof typeof ToolbarFactory.ICONS];

constructor(
toolbarIconTitle: typeof ToolbarFactory.ICONS[keyof typeof ToolbarFactory.ICONS]
) {
this.toolbarIconTitle = toolbarIconTitle;
}

getToolbarIconTitle(): string {
return this.toolbarIconTitle;
}

}
19 changes: 19 additions & 0 deletions app/components/toolbar/Toolbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";

import { CoreIconButton, CoreIcon } from "@wrappid/core";

import { ToolbarData } from "../data/toolbar/Toolbar.data";

type ToolbarType<T extends ToolbarData> = {toolbarData: T};

export default function Toolbar<T extends ToolbarData>(props: ToolbarType<T>) {
const { toolbarData } = props;

Object.setPrototypeOf(toolbarData, ToolbarData.prototype);

return (
<CoreIconButton>
<CoreIcon icon={toolbarData.getToolbarIconTitle()} />
</CoreIconButton>
);
}
26 changes: 26 additions & 0 deletions app/components/toolbar/ToolbarGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";

import { CoreTypographyBody1, CoreClasses } from "@wrappid/core";

import Toolbar from "./Toolbar";
import { ToolbarData } from "../data/toolbar/Toolbar.data";

type ToolbarGroupType = { toolbarData: ToolbarData[] };

export default function ToolbarGroup(props: ToolbarGroupType) {
const { toolbarData } = props;

return (
<>
{toolbarData && toolbarData.length > 0 ? (
toolbarData.map((eachToolbarData, index) => (
<Toolbar key={index} toolbarData={eachToolbarData} />
))
) : (
<CoreTypographyBody1 styleClasses={[CoreClasses.PADDING.PY5]}>
No toolbar data available.
</CoreTypographyBody1>
)}
</>
);
}

0 comments on commit 31c56e6

Please sign in to comment.