Skip to content

Commit

Permalink
Fix: added on reload event
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Apr 5, 2024
1 parent 39eb4b6 commit 9df425e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/workspace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ export const Workspace: React.FC<ISTKProps> = (props) => {
)}
{showZoomControls && <Zoom mode={props.mode} options={props.options} styles={props.styles} />}
{showVisibilityControls && <VisibilityControls mode={props.mode} options={props.options} styles={props.styles} />}
{showReloadButton && <Reload mode={props.mode} options={props.options} styles={props.styles} />}
{showReloadButton && (
<Reload mode={props.mode} options={props.options} styles={props.styles} onReload={props.events?.onReload} />
)}
</div>
);
};
Expand Down
7 changes: 6 additions & 1 deletion src/components/workspace/reload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { twMerge } from "tailwind-merge";
import { ids } from "@/constants";
import type { ISTKProps } from "@/types";

const Reloader = (props: Pick<ISTKProps, "mode" | "styles" | "options">) => {
interface IProps extends Pick<ISTKProps, "mode" | "styles" | "options"> {
onReload: () => void;
}

const Reloader = (props: IProps) => {
return (
<div
id={ids.reloader}
Expand All @@ -13,6 +17,7 @@ const Reloader = (props: Pick<ISTKProps, "mode" | "styles" | "options">) => {
props.styles?.reloadButton?.className
)}
style={props.styles?.reloadButton?.properties}
onClick={props?.onReload}
>
<RotateCcw size={20.5} />
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export interface IEvents {
onSectionClick?: (section: ISection) => void;
onExport?: (data: ISTKData) => void;
onWorkspaceLoad?: () => void;
/** Only used when the reload button is enabled */
onReload?: () => void;
}

export interface ISTKData {
Expand Down

0 comments on commit 9df425e

Please sign in to comment.