generated from wrappid/wrappid-module
-
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.
make toolbar which is like viewers and toolbox Ref #54
- Loading branch information
Showing
6 changed files
with
91 additions
and
0 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,10 @@ | ||
import { ToolbarData } from "./Toolbar.data"; | ||
import ToolbarFactory from "../../../factory/Toolbar.factory"; | ||
|
||
export class HistoryToolData extends ToolbarData{ | ||
constructor(){ | ||
super( | ||
ToolbarFactory.ICONS.HISTORY | ||
); | ||
} | ||
} |
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,10 @@ | ||
import { ToolbarData } from "./Toolbar.data"; | ||
import ToolbarFactory from "../../../factory/Toolbar.factory"; | ||
|
||
export class RequestForReviewToolData extends ToolbarData{ | ||
constructor(){ | ||
super( | ||
ToolbarFactory.ICONS.REQUEST_FOR_REVIEW | ||
); | ||
} | ||
} |
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,10 @@ | ||
import { ToolbarData } from "./Toolbar.data"; | ||
import ToolbarFactory from "../../../factory/Toolbar.factory"; | ||
|
||
export class SaveToolData extends ToolbarData{ | ||
constructor(){ | ||
super( | ||
ToolbarFactory.ICONS.SAVE | ||
); | ||
} | ||
} |
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,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; | ||
} | ||
|
||
} |
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,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> | ||
); | ||
} |
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,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> | ||
)} | ||
</> | ||
); | ||
} |