@@ -8,21 +8,17 @@ import styles from './Button.module.css'
8
8
/**
9
9
* Render the common inner part of the button component.
10
10
*
11
- * @param {object } props The props object.
12
- * @param {string } props.icon Optional icon.
13
- * @param {boolean } props.iconOnly Whether this button is an icon only.
14
- * @param {string } props.iconPosition Position to render the icon.
15
- * @param {string } props.text Button text or aria-label.
16
- * @return {Element } The inside of the Button component.
11
+ * @param {object } props The props object.
12
+ * @param {string } props.icon Optional icon.
13
+ * @param {boolean } props.iconOnly Whether this button is an icon only.
14
+ * @param {string } props.text Button text or aria-label.
15
+ * @return {Element } The inside of the Button component.
17
16
*/
18
- function ButtonInner ( { icon, iconOnly, iconPosition , text} ) {
17
+ function ButtonInner ( { icon, iconOnly, text} ) {
19
18
return (
20
19
< >
21
- { icon && iconPosition === 'left' && (
22
- < Icon icon = { icon } title = { text } ariaHidden = { text ? true : false } />
23
- ) }
24
20
{ ! iconOnly && < span className = { styles . text } > { text } </ span > }
25
- { icon && iconPosition === 'right' && (
21
+ { icon && (
26
22
< Icon icon = { icon } title = { text } ariaHidden = { text ? true : false } />
27
23
) }
28
24
</ >
@@ -32,27 +28,26 @@ function ButtonInner({icon, iconOnly, iconPosition, text}) {
32
28
ButtonInner . propTypes = {
33
29
icon : PropTypes . string ,
34
30
iconOnly : PropTypes . bool ,
35
- iconPosition : PropTypes . bool ,
36
31
text : PropTypes . string
37
32
}
38
33
39
34
/**
40
- * @param {object } props The props object.
41
- * @param {string } props.attributes Optional attributes to add to the button.
42
- * @param {string } props.tag The wrapper tag.
43
- * @param {string } props.className Optional classNames.
44
- * @param {boolean } props.disabled Whether the button is disabled.
45
- * @param {boolean } props.fluid Whether the button should be full width.
46
- * @param {string } props.icon Icon to render inside the button.
47
- * @param {boolean } props.iconOnly Whether this button should render as an icon only button.
48
- * @param {string } props.iconPosition Position to render the icon.
49
- * @param {Function } props.onClick Button onClick function.
50
- * @param {string } props.size Button size.
51
- * @param {string } props.text Button text.
52
- * @param {string } props.type Button type.
53
- * @param {string } props.url Button link url.
54
- * @param {boolean } props.urlExternal Whether the url on this button links to an external site.
55
- * @return {Element } The button component.
35
+ * @param {object } props The props object.
36
+ * @param {string } props.attributes Optional attributes to add to the button.
37
+ * @param {string } props.tag The wrapper tag.
38
+ * @param {string } props.className Optional classNames.
39
+ * @param {boolean } props.disabled Whether the button is disabled.
40
+ * @param {boolean } props.fluid Whether the button should be full width.
41
+ * @param {string } props.icon Icon to render inside the button.
42
+ * @param {boolean } props.iconOnly Whether this button should render as an icon only button.
43
+ * @param {string } props.iconLeft Whether to render the icon on the left .
44
+ * @param {Function } props.onClick Button onClick function.
45
+ * @param {string } props.size Button size.
46
+ * @param {string } props.text Button text.
47
+ * @param {string } props.type Button type.
48
+ * @param {string } props.url Button link url.
49
+ * @param {boolean } props.urlExternal Whether the url on this button links to an external site.
50
+ * @return {Element } The button component.
56
51
*/
57
52
export default function Button ( {
58
53
attributes,
@@ -62,7 +57,7 @@ export default function Button({
62
57
fluid,
63
58
icon,
64
59
iconOnly,
65
- iconPosition ,
60
+ iconLeft ,
66
61
onClick,
67
62
size,
68
63
text,
@@ -74,6 +69,7 @@ export default function Button({
74
69
styles . button ,
75
70
className ,
76
71
iconOnly && styles . iconOnly ,
72
+ iconLeft && styles . iconLeft ,
77
73
fluid && styles . fluid ,
78
74
disabled && styles . disabled ,
79
75
styles [ size ] ,
@@ -91,7 +87,7 @@ export default function Button({
91
87
< ButtonInner
92
88
icon = { icon }
93
89
iconOnly = { iconOnly }
94
- iconPosition = { iconPosition }
90
+ iconLeft = { iconLeft }
95
91
text = { text }
96
92
/>
97
93
</ a >
@@ -101,7 +97,7 @@ export default function Button({
101
97
< ButtonInner
102
98
icon = { icon }
103
99
iconOnly = { iconOnly }
104
- iconPosition = { iconPosition }
100
+ iconLeft = { iconLeft }
105
101
text = { text }
106
102
/>
107
103
</ a >
@@ -122,7 +118,7 @@ export default function Button({
122
118
< ButtonInner
123
119
icon = { icon }
124
120
iconOnly = { iconOnly }
125
- iconPosition = { iconPosition }
121
+ iconLeft = { iconLeft }
126
122
text = { text }
127
123
/>
128
124
)
@@ -137,7 +133,7 @@ Button.propTypes = {
137
133
fluid : PropTypes . bool ,
138
134
icon : PropTypes . string ,
139
135
iconOnly : PropTypes . bool ,
140
- iconPosition : PropTypes . oneOf ( [ 'left' , 'right' ] ) ,
136
+ iconLeft : PropTypes . bool ,
141
137
onClick : PropTypes . func ,
142
138
size : PropTypes . oneOf ( [ 'sm' , 'md' , 'lg' ] ) ,
143
139
tag : PropTypes . string ,
@@ -150,7 +146,7 @@ Button.propTypes = {
150
146
Button . defaultProps = {
151
147
disabled : false ,
152
148
iconOnly : false ,
153
- iconPosition : 'left' ,
149
+ iconLeft : false ,
154
150
size : 'md' ,
155
151
tag : 'button' ,
156
152
type : 'primary' ,
0 commit comments