-
-
Notifications
You must be signed in to change notification settings - Fork 231
/
Copy pathSplitButton.tsx
36 lines (32 loc) · 1 KB
/
SplitButton.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
import classNames from 'classnames';
import { noop } from 'lodash-es';
import React from 'react';
import { MosaicWindowContext } from '../contextTypes';
import { OptionalBlueprint } from '../util/OptionalBlueprint';
import { DefaultToolbarButton, MosaicButtonProps } from './MosaicButton';
export class SplitButton extends React.PureComponent<MosaicButtonProps> {
static contextType = MosaicWindowContext;
declare context: React.ContextType<typeof MosaicWindowContext>;
render() {
return (
<DefaultToolbarButton
title="Split Window"
className={classNames(
'split-button',
OptionalBlueprint.getIconClass(this.context.blueprintNamespace, 'ADD_COLUMN_RIGHT'),
)}
onClick={this.split}
/>
);
}
private split = () => {
this.context.mosaicWindowActions
.split()
.then(() => {
if (this.props.onClick) {
this.props.onClick();
}
})
.catch(noop); // Swallow rejections (i.e. on user cancel)
};
}