-
Notifications
You must be signed in to change notification settings - Fork 14
/
ButtonCodePage.tsx
202 lines (199 loc) · 6 KB
/
ButtonCodePage.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
import { DxcFlex, DxcLink, DxcTable } from "@dxc-technology/halstack-react";
import Code from "@/common/Code";
import DocFooter from "@/common/DocFooter";
import QuickNavContainer from "@/common/QuickNavContainer";
import QuickNavContainerLayout from "@/common/QuickNavContainerLayout";
import Example from "@/common/example/Example";
import basicUsage from "./examples/basicUsage";
import icons from "./examples/icons";
import StatusBadge from "@/common/StatusBadge";
import TableCode from "@/common/TableCode";
const sections = [
{
title: "Props",
content: (
<DxcTable>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>label</td>
<td>
<TableCode>string</TableCode>
</td>
<td>Text to be placed in the button.</td>
<td>-</td>
</tr>
<tr>
<td>mode</td>
<td>
<TableCode>'primary' | 'secondary' | 'text'</TableCode>
</td>
<td>The available button modes.</td>
<td>
<TableCode>'primary'</TableCode>
</td>
</tr>
<tr>
<td>
<DxcFlex direction="column" gap="0.25rem" alignItems="baseline">
<StatusBadge label="New" status="Information" />
title
</DxcFlex>
</td>
<td>
<TableCode>string</TableCode>
</td>
<td>
Text representing advisory information related to the button's
action. Under the hood, this prop also serves as an accessible
label for the component.
</td>
<td>-</td>
</tr>
<tr>
<td>type</td>
<td>
<TableCode>'button' | 'reset' | 'submit'</TableCode>
</td>
<td>
Sets the <Code>type</Code> attribute of the <abbr>HTML</abbr>{" "}
button element. See{" "}
<DxcLink
newWindow
href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attributes"
>
MDN
</DxcLink>{" "}
for further information.
</td>
<td>
<TableCode>'button'</TableCode>
</td>
</tr>
<tr>
<td>icon</td>
<td>
<TableCode>
string | {"(React.ReactNode & React.SVGProps <SVGSVGElement>)"}
</TableCode>
</td>
<td>
<DxcLink newWindow href="https://fonts.google.com/icons">
Material Symbol
</DxcLink>{" "}
name or SVG element as the icon that will be placed next to the
label. When using Material Symbols, replace spaces with
underscores. By default they are outlined if you want it to be
filled prefix the symbol name with{" "}
<TableCode>"filled_"</TableCode>.
</td>
<td>-</td>
</tr>
<tr>
<td>iconPosition</td>
<td>
<TableCode>'before' | 'after'</TableCode>
</td>
<td>Whether the icon should appear after or before the label.</td>
<td>
<TableCode>'before'</TableCode>
</td>
</tr>
<tr>
<td>disabled</td>
<td>
<TableCode>boolean</TableCode>
</td>
<td>If true, the component will be disabled.</td>
<td>
<TableCode>false</TableCode>
</td>
</tr>
<tr>
<td>onClick</td>
<td>
<TableCode>{"() => void"}</TableCode>
</td>
<td>
This function will be called when the user clicks the button.
</td>
<td>-</td>
</tr>
<tr>
<td>margin</td>
<td>
<TableCode>
'xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' |
'xxlarge' | Margin
</TableCode>
</td>
<td>
Size of the margin to be applied to the component. You can pass an
object with 'top', 'bottom', 'left' and 'right' properties in
order to specify different margin sizes.
</td>
<td>-</td>
</tr>
<tr>
<td>size</td>
<td>
<TableCode>
'small' | 'medium' | 'large' | 'fillParent' | 'fitContent'
</TableCode>
</td>
<td>Size of the component.</td>
<td>
<TableCode>'fitContent'</TableCode>
</td>
</tr>
<tr>
<td>tabIndex</td>
<td>
<TableCode>number</TableCode>
</td>
<td>
Value of the <Code>tabindex</Code> attribute.
</td>
<td>
<TableCode>0</TableCode>
</td>
</tr>
</tbody>
</DxcTable>
),
},
{
title: "Examples",
subSections: [
{
title: "Basic usage",
content: <Example example={basicUsage} defaultIsVisible />,
},
{
title: "Icons",
content: <Example example={icons} defaultIsVisible />,
},
],
},
];
const ButtonCodePage = () => {
return (
<DxcFlex direction="column" gap="4rem">
<QuickNavContainerLayout>
<QuickNavContainer
sections={sections}
startHeadingLevel={2}
></QuickNavContainer>
</QuickNavContainerLayout>
<DocFooter githubLink="https://github.com/dxc-technology/halstack-react/blob/master/website/screens/components/button/code/ButtonCodePage.tsx" />
</DxcFlex>
);
};
export default ButtonCodePage;