/
SplitButton.Example.tsx
79 lines (74 loc) · 2.23 KB
/
SplitButton.Example.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import * as React from 'react';
import { SplitButton, ISplitButtonProps } from '@uifabric/experiments';
import { Stack } from 'office-ui-fabric-react';
const menuProps: ISplitButtonProps['menu'] = {
props: {
items: [
{
key: 'a',
name: 'Item a'
},
{
key: 'b',
name: 'Item b'
}
]
}
};
const tokens = {
sectionStack: {
childrenGap: 32
},
headingStack: {
childrenGap: 16
},
buttonStack: {
childrenGap: 12
}
};
const alertClicked = (): void => {
alert('Clicked');
};
const ButtonStack = (props: { children: JSX.Element[] | JSX.Element }) => (
<Stack horizontal disableShrink tokens={tokens.buttonStack}>
{props.children}
</Stack>
);
// tslint:disable:jsx-no-lambda
export class SplitButtonExample extends React.Component<{}, {}> {
public render(): JSX.Element {
return (
<Stack tokens={tokens.sectionStack}>
<Stack tokens={tokens.headingStack} padding={8}>
<div>
<Stack tokens={tokens.buttonStack}>
<ButtonStack>
<SplitButton icon="Add" content="Default split button" menu={menuProps} onClick={alertClicked} />
<SplitButton disabled icon="Add" content="Disabled split button" menu={menuProps} onClick={alertClicked} />
<SplitButton primary icon="Add" content="Primary split button" menu={menuProps} onClick={alertClicked} />
<SplitButton disabled primary icon="Add" content="Disabled primary split button" menu={menuProps} onClick={alertClicked} />
</ButtonStack>
<ButtonStack>
<SplitButton
primaryActionDisabled
icon="Add"
content="First action disabled split button"
menu={menuProps}
onClick={alertClicked}
/>
<SplitButton
primaryActionDisabled
primary
icon="Add"
content="First action disabled primary split button"
menu={menuProps}
onClick={alertClicked}
/>
</ButtonStack>
</Stack>
</div>
</Stack>
</Stack>
);
}
}