-
-
Notifications
You must be signed in to change notification settings - Fork 231
/
Copy pathExpandButton.tsx
38 lines (33 loc) · 1.14 KB
/
ExpandButton.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import classNames from 'classnames';
import React from 'react';
import { MosaicContext, type MosaicRootActions, MosaicWindowContext } from '../contextTypes';
import { OptionalBlueprint } from '../util/OptionalBlueprint';
import { DefaultToolbarButton, type MosaicButtonProps } from './MosaicButton';
export class ExpandButton extends React.PureComponent<MosaicButtonProps> {
static contextType = MosaicWindowContext;
declare context: React.ContextType<typeof MosaicWindowContext>;
render() {
return (
<MosaicContext.Consumer>
{({ mosaicActions }) => (
<DefaultToolbarButton
title="Expand"
className={classNames(
'expand-button',
OptionalBlueprint.getIconClass(this.context.blueprintNamespace, 'MAXIMIZE'),
)}
onClick={this.createExpand(mosaicActions)}
/>
)}
</MosaicContext.Consumer>
);
}
private createExpand(mosaicActions: MosaicRootActions<any>) {
return () => {
mosaicActions.expand(this.context.mosaicWindowActions.getPath());
if (this.props.onClick) {
this.props.onClick();
}
};
}
}