Skip to content

Commit b383a29

Browse files
committed
Inline styles on buttons and links
1 parent 4b47806 commit b383a29

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

__tests__/shared/components/__snapshots__/Button.jsx.snap

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ exports[`Matches snapshots when active 1`] = `
55
className="BUTTON_CLASS ACTIVE_CLASS REGULAR_CLASS"
66
onClick={[Function]}
77
onMouseDown={null}
8+
style={Object {}}
89
type="button"
910
>
1011
BUTTON
@@ -16,6 +17,7 @@ exports[`Matches snapshots when active 2`] = `
1617
className="BUTTON_CLASS ACTIVE_CLASS"
1718
onClick={[Function]}
1819
onMouseDown={null}
20+
style={Object {}}
1921
type="button"
2022
>
2123
BUTTON
@@ -25,6 +27,7 @@ exports[`Matches snapshots when active 2`] = `
2527
exports[`Matches snapshots when disabled 1`] = `
2628
<div
2729
className="BUTTON_CLASS XL_CLASS DISABLED_CLASS"
30+
style={Object {}}
2831
>
2932
BUTTON
3033
</div>
@@ -33,6 +36,7 @@ exports[`Matches snapshots when disabled 1`] = `
3336
exports[`Matches snapshots when disabled 2`] = `
3437
<div
3538
className="BUTTON_CLASS XL_CLASS"
39+
style={Object {}}
3640
>
3741
BUTTON
3842
</div>
@@ -46,6 +50,7 @@ exports[`Matches snapshots when rendered as link 1`] = `
4650
onMouseDown={null}
4751
openNewTab={false}
4852
replace={false}
53+
style={Object {}}
4954
to="/SOME/TEST/URL"
5055
>
5156
BUTTON
@@ -60,6 +65,7 @@ exports[`Matches snapshots when rendered as link 2`] = `
6065
onMouseDown={null}
6166
openNewTab={false}
6267
replace={false}
68+
style={Object {}}
6369
to="/SOME/TEST/URL"
6470
>
6571
BUTTON

__tests__/shared/components/__snapshots__/GenericLink.jsx.snap

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ exports[`Absolute link, starting with http:// 1`] = `
88
onClick={null}
99
onMouseDown={null}
1010
rel="noopener noreferrer"
11+
style={Object {}}
1112
target=""
1213
>
1314
ABSOLUTE LINK
@@ -22,6 +23,7 @@ exports[`Absolute link, starting with https:// 1`] = `
2223
onClick={[Function]}
2324
onMouseDown={null}
2425
rel="noopener noreferrer"
26+
style={Object {}}
2527
target=""
2628
>
2729
ABSOLUTE LINK
@@ -36,6 +38,7 @@ exports[`Anchor link 1`] = `
3638
onClick={null}
3739
onMouseDown={null}
3840
rel="noopener noreferrer"
41+
style={Object {}}
3942
target=""
4043
>
4144
ANCHOR LINK
@@ -48,7 +51,7 @@ exports[`Relative link 1`] = `
4851
onClick={[Function]}
4952
type="button"
5053
>
51-
{"to":"http/relative/link","className":null,"disabled":false,"onMouseDown":null,"replace":false,"children":"RELATIVE LINK"}
54+
{"to":"http/relative/link","className":null,"disabled":false,"onMouseDown":null,"replace":false,"style":{},"children":"RELATIVE LINK"}
5255
</button>
5356
`;
5457

@@ -60,6 +63,7 @@ exports[`Relative link, with \`enforceA\` 1`] = `
6063
onClick={null}
6164
onMouseDown={null}
6265
rel="noopener noreferrer"
66+
style={Object {}}
6367
target=""
6468
>
6569
RELATIVE LINK
@@ -74,6 +78,7 @@ exports[`Relative link, with \`openNewTab\` 1`] = `
7478
onClick={null}
7579
onMouseDown={null}
7680
rel="noopener noreferrer"
81+
style={Object {}}
7782
target="_blank"
7883
>
7984
RELATIVE LINL

__tests__/shared/components/__snapshots__/Link.jsx.snap

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ exports[`Matches snapshots 1`] = `
1010
openNewTab={false}
1111
replace={false}
1212
routerLinkType={[Function]}
13+
style={Object {}}
1314
to=""
1415
/>
1516
`;

src/shared/components/Button/index.jsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ export default function Button({
2525
theme,
2626
to,
2727
type,
28+
style,
2829
}) {
2930
let className = theme.button;
3031
if (theme[size]) className += ` ${theme[size]}`;
3132
if (active && theme.active) className += ` ${theme.active}`;
3233
if (disabled) {
3334
if (theme.disabled) className += ` ${theme.disabled}`;
3435
return (
35-
<div className={className}>
36+
<div className={className} style={style}>
3637
{children}
3738
</div>
3839
);
@@ -57,6 +58,7 @@ export default function Button({
5758
openNewTab={openNewTab}
5859
replace={replace}
5960
to={to}
61+
style={style}
6062
>
6163
{children}
6264
</Link>
@@ -73,6 +75,7 @@ export default function Button({
7375
onClick={onClick}
7476
onMouseDown={onMouseDown}
7577
type={type}
78+
style={style}
7679
>
7780
{children}
7881
</button>
@@ -93,6 +96,7 @@ Button.defaultProps = {
9396
theme: defaultTheme,
9497
to: null,
9598
type: 'button',
99+
style: {},
96100
};
97101

98102
Button.propTypes = {
@@ -113,4 +117,5 @@ Button.propTypes = {
113117
}),
114118
to: PT.oneOfType([PT.object, PT.string]),
115119
type: PT.oneOf(['button', 'reset', 'submit']),
120+
style: PT.shape(),
116121
};

src/shared/components/GenericLink/index.jsx

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default function GenericLink(props) {
2626
replace,
2727
routerLinkType,
2828
to,
29+
style,
2930
} = props;
3031

3132
/* Renders Link as <a> element if:
@@ -44,6 +45,7 @@ export default function GenericLink(props) {
4445
rel="noopener noreferrer"
4546
styleName="link"
4647
target={openNewTab ? '_blank' : ''}
48+
style={style}
4749
>
4850
{children}
4951
</a>
@@ -81,6 +83,7 @@ GenericLink.defaultProps = {
8183
openNewTab: false,
8284
replace: false,
8385
to: '',
86+
style: {},
8487
};
8588

8689
GenericLink.propTypes = {
@@ -94,4 +97,5 @@ GenericLink.propTypes = {
9497
replace: PT.bool,
9598
routerLinkType: PT.func.isRequired,
9699
to: PT.oneOfType([PT.object, PT.string]),
100+
style: PT.shape(),
97101
};

0 commit comments

Comments
 (0)