forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButtonDemo.tsx
219 lines (204 loc) · 6.81 KB
/
ButtonDemo.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
import React from 'react';
import { Button, ButtonProps, Tooltip } from '@patternfly/react-core';
import PlusCircleIcon from '@patternfly/react-icons/dist/js/icons/plus-circle-icon';
import ExternalLinkAltIcon from '@patternfly/react-icons/dist/js/icons/external-link-alt-icon';
import '@patternfly/react-styles/css/utilities/Spacing/spacing.css';
const href = 'https://www.google.com';
interface ButtonDemoState {
counter: number;
}
export class ButtonDemo extends React.Component<ButtonProps, ButtonDemoState> {
static displayName = 'ButtonDemo';
constructor(props: ButtonProps) {
super(props);
this.state = {
counter: 0
};
}
normalButton: ButtonProps = {
className: 'pf-u-m-sm',
component: 'button',
onClick: () => {
window.location.href = 'https://github.com/patternfly/patternfly-react';
}
};
linkButton: ButtonProps = {
className: 'pf-u-m-sm',
component: 'button',
icon: <PlusCircleIcon />,
onKeyPress: () => {
window.location.href = 'https://github.com/patternfly/patternfly-react';
},
variant: 'link'
};
linkAsButton: ButtonProps = {
className: 'pf-u-m-sm',
component: 'a',
href: 'https://github.com/patternfly/patternfly-react',
icon: <ExternalLinkAltIcon />,
target: '_blank'
};
spanLink: ButtonProps = {
component: 'span',
variant: 'link',
isInline: true
};
myButtonProps: ButtonProps = {
component: 'button',
href,
target: '_blank'
};
incrementCounter = () => {
this.setState(prevState => ({
counter: prevState.counter + 1
}));
};
decrementCounter = () => {
this.setState(prevState => ({
counter: prevState.counter - 1
}));
};
componentDidMount() {
window.scrollTo(0, 0);
}
render() {
return (
<div className="btn-demo-area">
<Button {...this.normalButton} id="normal-btn-1" variant="primary">
Primary
</Button>
<Button {...this.normalButton} id="normal-btn-2" variant="secondary">
Secondary
</Button>
<Button {...this.normalButton} id="normal-btn-2-danger" variant="secondary" isDanger>
Danger secondary
</Button>
<Button {...this.normalButton} id="normal-btn-3" variant="tertiary">
Tertiary
</Button>
<Button {...this.normalButton} id="normal-btn-4" variant="danger">
Danger
</Button>
<Button {...this.normalButton} id="normal-btn-5" variant="link">
Link
</Button>
<Button {...this.normalButton} id="normal-btn-6" variant="plain">
Plain
</Button>
<Button {...this.normalButton} id="normal-btn-7" variant="control">
Control
</Button>
<Button {...this.normalButton} id="normal-btn-8" isDisabled>
Disabled button
</Button>
<Button {...this.normalButton} id="normal-btn-9" isAriaDisabled>
Aria-disabled button
</Button>
<Button {...this.normalButton} id="normal-btn-10" tabIndex={2}>
Button with tabindex set to 2
</Button>
<Tooltip id="button-with-tooltip-1" content="This tooltip content is available to the aria-disabled button">
<Button
{...this.normalButton}
id="normal-btn-11"
isAriaDisabled
onKeyPress={() => {
window.location.href = 'https://github.com/patternfly/patternfly-react';
}}
>
Aria-disabled with tooltip
</Button>
</Tooltip>
<Button {...this.normalButton} id="normal-btn-12" isSmall>
Small button
</Button>
<Button {...this.normalButton} id="normal-btn-13" isLarge>
Large button
</Button>
<Button {...this.normalButton} id="normal-btn-14" variant="warning">
Warning
</Button>
<Button {...this.normalButton} id="normal-btn-15" isLoading>
Loading button
</Button>
<Button {...this.normalButton} id="normal-btn-16" isLoading={false}>
Loader button
</Button>
<Button
id="aria-disabled-btn-1"
onBlur={this.decrementCounter}
onFocus={this.decrementCounter}
onClick={this.incrementCounter}
onKeyPress={this.incrementCounter}
isAriaDisabled
inoperableEvents={['onFocus']}
>
Aria-disabled link button with custom list of prevented events {this.state.counter}
</Button>
<hr className="pf-u-m-md" />
<Button {...this.linkButton} id="link-btn-1">
Link button
</Button>
<Button {...this.linkButton} id="link-btn-2" isInline>
Inline Link Button
</Button>
<Button {...this.linkButton} id="link-btn-1-danger" isDanger>
Danger link button
</Button>
<Button {...this.linkButton} id="link-btn-3" isDisabled>
Disabled link button
</Button>
<Button {...this.linkButton} id="link-btn-4" isAriaDisabled>
Aria-disabled link button
</Button>
<Button {...this.linkButton} id="link-btn-5" tabIndex={-1}>
Button with tabindex set to -1
</Button>
<hr className="pf-u-m-md" />
<Button {...this.linkAsButton} id="link-as-btn-1">
Link as button
</Button>
<Button {...this.linkAsButton} id="link-as-btn-2" isDisabled>
Disabled link as button
</Button>
<Button {...this.linkAsButton} id="link-as-btn-3" isAriaDisabled>
Aria-disabled link as button
</Button>
<Button {...this.linkAsButton} id="link-as-btn-4" tabIndex={4}>
Link as button with tabindex set to 4
</Button>
<Tooltip
id="button-with-tooltip-2"
content="This tooltip content is available to the aria-disabled link as button"
>
<Button {...this.linkAsButton} id="link-as-btn-5" isAriaDisabled>
Aria-disabled link as button with tooltip
</Button>
</Tooltip>
<hr className="pf-u-m-md" />
<Button {...this.spanLink} id="span-link-btn-1">
Span wrapping link
</Button>
<br />
<Button isDisabled {...this.spanLink} id="span-link-btn-2">
Disabled span wrapping link
</Button>
<hr className="pf-u-m-md" />
<div id="tabstop-test" tabIndex={0}>
<Button className="pf-u-m-sm" id="tabstop-test-01">
First tab stop
</Button>
<Button className="pf-u-m-sm" id="tabstop-test-02">
Second tab stop
</Button>
<Button className="pf-u-m-sm" id="tabstop-test-03">
Third tab stop
</Button>
<Button className="pf-u-m-sm" id="tabstop-test-04">
Fourth tab stop
</Button>
</div>
</div>
);
}
}