forked from elastic/eui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton_example.js
More file actions
247 lines (233 loc) 路 7.71 KB
/
Copy pathbutton_example.js
File metadata and controls
247 lines (233 loc) 路 7.71 KB
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
import React from 'react';
import { renderToHtml } from '../../services';
import {
GuideSectionTypes,
} from '../../components';
import {
EuiButton,
EuiButtonEmpty,
EuiButtonIcon,
EuiCode,
EuiButtonGroup,
EuiButtonToggle,
EuiLink,
} from '../../../../src/components';
import Button from './button';
const buttonSource = require('!!raw-loader!./button');
const buttonHtml = renderToHtml(Button);
import ButtonWithIcon from './button_with_icon';
const buttonWithIconSource = require('!!raw-loader!./button_with_icon');
const buttonWithIconHtml = renderToHtml(Button);
import ButtonOption from './button_empty';
const buttonOptionSource = require('!!raw-loader!./button_empty');
const buttonOptionHtml = renderToHtml(ButtonOption);
import ButtonOptionFlush from './button_empty_flush';
const buttonOptionFlushSource = require('!!raw-loader!./button_empty_flush');
const buttonOptionFlushHtml = renderToHtml(ButtonOptionFlush);
import ButtonIcon from './button_icon';
const buttonIconSource = require('!!raw-loader!./button_icon');
const buttonIconHtml = renderToHtml(ButtonIcon);
import ButtonGhost from './button_ghost';
const buttonGhostSource = require('!!raw-loader!./button_ghost');
const buttonGhostHtml = renderToHtml(ButtonGhost);
import ButtonAsLink from './button_as_link';
const buttonAsLinkSource = require('!!raw-loader!./button_as_link');
const buttonAsLinkHtml = renderToHtml(ButtonAsLink);
import ButtonLoading from './button_loading';
const buttonLoadingSource = require('!!raw-loader!./button_loading');
const buttonLoadingHtml = renderToHtml(ButtonLoading);
import ButtonToggle from './button_toggle';
const buttonToggleSource = require('!!raw-loader!./button_toggle');
const buttonToggleHtml = renderToHtml(ButtonToggle);
import ButtonGroup from './button_group';
const buttonGroupSource = require('!!raw-loader!./button_group');
const buttonGroupHtml = renderToHtml(ButtonGroup);
export const ButtonExample = {
title: 'Button',
sections: [{
source: [{
type: GuideSectionTypes.JS,
code: buttonSource,
}, {
type: GuideSectionTypes.HTML,
code: buttonHtml,
}],
props: { EuiButton },
demo: <Button />,
}, {
title: 'Buttons can also be links',
source: [{
type: GuideSectionTypes.JS,
code: buttonAsLinkSource,
}, {
type: GuideSectionTypes.HTML,
code: buttonAsLinkHtml,
}],
text: (
<p>
Buttons will use an <EuiCode>{'<a>'}</EuiCode> tag
if there is a <EuiCode>href</EuiCode> prop present.
</p>
),
demo: <ButtonAsLink />,
}, {
title: 'Button with Icon',
source: [{
type: GuideSectionTypes.JS,
code: buttonWithIconSource,
}, {
type: GuideSectionTypes.HTML,
code: buttonWithIconHtml,
}],
text: (
<p>
The passed icon needs to come from our list of svg icons. Can be flipped {
// eslint-disable-next-line react/no-unescaped-entities
} to the other side by passing <EuiCode>iconSide="right"</EuiCode>.
</p>
),
demo: <ButtonWithIcon />,
}, {
title: 'Loading state',
source: [{
type: GuideSectionTypes.JS,
code: buttonLoadingSource,
}, {
type: GuideSectionTypes.HTML,
code: buttonLoadingHtml,
}],
text: (
<p>
Setting the <EuiCode>isLoading</EuiCode> prop to true will add the loading spinner or
swap the existing icon for the loading spinner and set the button to disabled. It is good
practice to also rename the button to "Loading…".
</p>
),
demo: <ButtonLoading />,
}, {
title: 'ButtonEmpty',
source: [{
type: GuideSectionTypes.JS,
code: buttonOptionSource,
}, {
type: GuideSectionTypes.HTML,
code: buttonOptionHtml,
}],
text: (
<p>
<EuiCode>EuiButtonEmpty</EuiCode> is used when you want to make
a button look like a regular link, but still want to align it to
the rest of the buttons.
</p>
),
props: { EuiButtonEmpty },
demo: <ButtonOption />,
}, {
title: 'Flush ButtonEmpty',
source: [{
type: GuideSectionTypes.JS,
code: buttonOptionFlushSource,
}, {
type: GuideSectionTypes.HTML,
code: buttonOptionFlushHtml,
}],
text: (
<p>
When aligning <EuiCode>EuiButtonEmpty</EuiCode> components to the left or the right,
you should make sure they’re flush with the edge of their container, so that they’re
horizontally-aligned with the other content in the container.
</p>
),
demo: <ButtonOptionFlush />,
}, {
title: 'Button Icon',
source: [{
type: GuideSectionTypes.JS,
code: buttonIconSource,
}, {
type: GuideSectionTypes.HTML,
code: buttonIconHtml,
}],
text: (
<p>
Button icons are buttons that only contain an icon
(no text). <strong>Note:</strong> the
the dark background on the <EuiCode>ghost</EuiCode> example is used
only for illustrative purposes.
</p>
),
props: { EuiButtonIcon },
demo: <ButtonIcon />,
}, {
title: 'Toggle buttons',
source: [{
type: GuideSectionTypes.JS,
code: buttonToggleSource,
}, {
type: GuideSectionTypes.HTML,
code: buttonToggleHtml,
}],
text: (
<div>
<p>
This is a specialized component that combines <EuiCode>EuiButton</EuiCode> and <EuiCode>EuiToggle</EuiCode> to
create a button with an on/off state. You can pass all the same parameters to it as you
can to <EuiCode>EuiButton</EuiCode>. The main difference is that, it does not accept any children,
but a <EuiCode>label</EuiCode> prop instead. This is for the handling of accessiblity with
the <EuiCode>EuiToggle</EuiCode>.
</p>
<p>
The <EuiCode>EuiButtonToggle</EuiCode> does not have any inherit visual state differences.
These you must apply in your implementation.
</p>
</div>
),
demo: <ButtonToggle />,
props: { EuiButtonToggle },
}, {
title: 'Groups',
source: [{
type: GuideSectionTypes.JS,
code: buttonGroupSource,
}, {
type: GuideSectionTypes.HTML,
code: buttonGroupHtml,
}],
text: (
<div>
<p>
Button groups are handled similarly to the way checkbox and radio groups are
handled but made to look like buttons. They group multiple <EuiCode>EuiButtonToggle</EuiCode>s
and utilize the <EuiCode>type="single"</EuiCode> or <EuiCode>"multi"</EuiCode> prop
to determine whether multiple or only single selections are allowed per group.
</p>
<p>
Stylistically, all button groups are the size of small buttons, do not stretch to fill the container
and typically should only be <EuiCode>color="text"</EuiCode> (default)
or <EuiCode>"primary"</EuiCode>.
If your just displaying a group of icons, add the prop <EuiCode>isIconOnly</EuiCode>.
</p>
</div>
),
demo: <ButtonGroup />,
props: { EuiButtonGroup },
}, {
title: 'Ghost',
source: [{
type: GuideSectionTypes.JS,
code: buttonGhostSource,
}, {
type: GuideSectionTypes.HTML,
code: buttonGhostHtml,
}],
text: (
<p>
For buttons on dark color backgrounds, you can pass <EuiCode>color='ghost'</EuiCode> to
any of the button styles on this page. These should be used extremely rarely, and are
only for placing buttons on top of dark or image-based backgrounds.
A good example of their use is in the <EuiLink href="/#/layout/bottom-bar">EuiBottomBar</EuiLink> component.
</p>
),
demo: <ButtonGhost />,
}],
};