forked from deephaven/web-client-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtons.tsx
More file actions
145 lines (134 loc) · 3.96 KB
/
Copy pathButtons.tsx
File metadata and controls
145 lines (134 loc) · 3.96 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
import React, { Component, ReactElement } from 'react';
import classNames from 'classnames';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { ButtonOld, SocketedButton } from '@deephaven/components';
import { dhTruck } from '@deephaven/icons';
interface ButtonsState {
toggle: boolean;
}
class Buttons extends Component<Record<string, never>, ButtonsState> {
static renderButtonBrand(type: string, brand: string): ReactElement {
const className = type.length ? `btn-${type}-${brand}` : `btn-${brand}`;
return (
<ButtonOld
key={brand}
className={className}
style={{ marginBottom: '1rem', marginRight: '1rem' }}
>
{brand}
</ButtonOld>
);
}
static renderButtons(type: string): ReactElement {
const brands = [
'primary',
'secondary',
'success',
'info',
'danger',
].map((brand: string) => Buttons.renderButtonBrand(type, brand));
return (
<div key={type}>
<h5>{type.length ? 'Outline' : 'Regular'}</h5>
{brands}
</div>
);
}
static renderSocketedButtons(): ReactElement {
return (
<div>
<h5>Socketed Buttons (for linker)</h5>
<SocketedButton style={{ marginBottom: '1rem', marginRight: '1rem' }}>
Unlinked
</SocketedButton>
<SocketedButton
style={{ marginBottom: '1rem', marginRight: '1rem' }}
isLinked
>
Linked
</SocketedButton>
<SocketedButton
style={{ marginBottom: '1rem', marginRight: '1rem' }}
isLinkedSource
>
Linked Source
</SocketedButton>
<SocketedButton
style={{ marginBottom: '1rem', marginRight: '1rem' }}
isLinked
isInvalid
>
Error
</SocketedButton>
<SocketedButton
style={{ marginBottom: '1rem', marginRight: '1rem' }}
disabled
>
Disabled
</SocketedButton>
</div>
);
}
constructor(props: Record<string, never>) {
super(props);
this.state = {
toggle: true,
};
}
renderInlineButtons(): ReactElement {
const { toggle } = this.state;
return (
<div style={{ padding: '1rem 0' }}>
<h5>Inline Buttons</h5>
Regular btn-inline:
<ButtonOld className="btn-inline mx-2">
<FontAwesomeIcon icon={dhTruck} />
</ButtonOld>
Toggle button (class active):
<ButtonOld
className={classNames('btn-inline mx-2', { active: toggle })}
onClick={() => {
this.setState({ toggle: !toggle });
}}
>
<FontAwesomeIcon icon={dhTruck} />
</ButtonOld>
Disabled:
<ButtonOld className="btn-inline mx-2" disabled>
<FontAwesomeIcon icon={dhTruck} />
</ButtonOld>
<br />
<br />
<span>btn-link-icon (no text):</span>
<ButtonOld className="btn-link btn-link-icon px-2">
{/* pad and margin horizontally as appropriate for icon shape and spacing,
needs btn-link and btn-link-icon classes. */}
<FontAwesomeIcon icon={dhTruck} />
</ButtonOld>
<span className="mx-2">btn-link:</span>
<ButtonOld className="btn-link">Text Button</ButtonOld>
<span className="mx-2">btn-link (text w/ optional with icon):</span>
<ButtonOld className="btn-link">
<FontAwesomeIcon icon={dhTruck} />
Add Item
</ButtonOld>
</div>
);
}
render(): React.ReactElement {
const buttons = ['', 'outline'].map(type => Buttons.renderButtons(type));
const inlineButtons = this.renderInlineButtons();
const socketedButtons = Buttons.renderSocketedButtons();
return (
<div>
<h2 className="ui-title">Buttons</h2>
<div style={{ padding: '1rem 0' }}>
{buttons}
{inlineButtons}
{socketedButtons}
</div>
</div>
);
}
}
export default Buttons;