Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use MosaicRootActions in customtoolbar controls? #219

Closed
MrRainesE opened this issue Jan 21, 2025 · 2 comments
Closed

How to use MosaicRootActions in customtoolbar controls? #219

MrRainesE opened this issue Jan 21, 2025 · 2 comments

Comments

@MrRainesE
Copy link

<MosaicWindow
            path={path}
            title={`Window ${id}`}
            toolbarControls={[
                <MyOtherButtons............. />

                // here de default for expand and remove
                <Button key="maximize" onClick={() => { >>>**expand action here**<<<}>
                    <Expand />
                </Button>,
                <Button key="close" onClick={() =>{ >>>**remove action here**<<<}>
                    <Close />
                </Button>
            ]}
        >
@dannmartens
Copy link

Use a context component to wrap your component.

Access MosaicContext.mosaicActions from there.

See Advanced API for more information.

interface MyMosaicWindowProps {
  id: string;
  path: MosaicBranch[];
}

const MyMosaicWindow: React.FC<MyMosaicWindowProps> = (props) => {
  const { id, path } = props;
  const mosaic = useContext(MosaicContext); 
  // use mosaic.mosaicActions: MosaicRootActions<T>;
  ...
  return (
    <MosaicWindow
      path={path}
      ...
    >
      ...
    </MosaicWindow>
  );
};

@MrRainesE
Copy link
Author

@dannmartens thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants