Skip to content

Commit 9e9cc40

Browse files
committed
refactor: mass-resolve console warnings
1 parent afcc62f commit 9e9cc40

File tree

32 files changed

+1042
-1853
lines changed

32 files changed

+1042
-1853
lines changed
Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { bool, oneOfType, array, object, string } from "prop-types";
2+
import PropTypes from "prop-types";
33
import { withTheme } from "styled-components";
44

55
import Button from "./Button";
@@ -9,7 +9,7 @@ import withObfuscation from "./withObfuscation";
99
const ObfButton = withObfuscation(Button);
1010
const ObfLink = withObfuscation(Link);
1111

12-
const Action = props => {
12+
function Action(props) {
1313
const { obfuscated, button, ...restProps } = props;
1414
if (obfuscated) {
1515
if (button) {
@@ -21,20 +21,11 @@ const Action = props => {
2121
return <Button {...restProps} />;
2222
}
2323
return <Link {...restProps} />;
24-
};
24+
}
2525

2626
Action.propTypes = {
27-
button: bool,
28-
children: oneOfType([array, object, string]),
29-
href: string,
30-
obfuscated: bool
31-
};
32-
33-
Action.defaultProps = {
34-
button: null,
35-
children: null,
36-
href: null,
37-
obfuscated: null
27+
button: PropTypes.bool,
28+
obfuscated: PropTypes.bool
3829
};
3930

4031
export default withTheme(Action);
Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint jsx-a11y/anchor-has-content: 0 */
2-
/* eslint react/button-has-type: 0 */
31
import { array, func, object, oneOfType, shape, string } from "prop-types";
42
import { Link as GatsbyButton } from "gatsby";
53
import React from "react";
@@ -11,11 +9,11 @@ import { setSpace } from "ui/mixins";
119

1210
const ButtonEl = styled.a`
1311
${setSpace("pam")};
14-
background-color: ${({ theme, primary }) =>
15-
primary ? theme.actionColor : `transparent`};
12+
background-color: ${({ theme, $primary }) =>
13+
$primary ? theme.actionColor || defaultThm.actionColor : `transparent`};
1614
border: 2px solid ${({ theme }) => theme.decor};
17-
color: ${({ primary, theme }) =>
18-
primary ? theme.background : theme.actionColor};
15+
color: ${({ $primary, theme }) =>
16+
$primary ? theme.background || defaultThm.background : theme.actionColor || defaultThm.actionColor};
1917
cursor: pointer;
2018
display: inline-block;
2119
font-family: ${font.sans};
@@ -36,16 +34,16 @@ const ButtonEl = styled.a`
3634
}
3735
`;
3836

39-
const Button = props => {
40-
const { onClick, to } = props;
37+
function Button(props) {
38+
const { onClick, to, primary = false, ...restProps } = props;
4139
if (to) {
42-
return <ButtonEl as={GatsbyButton} {...props} theme={null} />;
40+
return <ButtonEl as={GatsbyButton} to={to} theme={null} $primary={primary} {...restProps} />;
4341
}
4442
if (onClick) {
45-
return <ButtonEl as="button" type="button" {...props} />;
43+
return <ButtonEl as="button" type="button" onClick={onClick} $primary={primary} {...restProps} />;
4644
}
47-
return <ButtonEl {...props} />;
48-
};
45+
return <ButtonEl $primary={primary} {...restProps} />;
46+
}
4947

5048
Button.propTypes = {
5149
children: oneOfType([array, object, string]),
@@ -57,15 +55,4 @@ Button.propTypes = {
5755
to: string
5856
};
5957

60-
Button.defaultProps = {
61-
children: null,
62-
href: "",
63-
onClick: null,
64-
theme: {
65-
background: defaultThm.background,
66-
actionColor: defaultThm.actionColor
67-
},
68-
to: null
69-
};
70-
7158
export default Button;

lib/ui/components/actions/Link.js

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint jsx-a11y/anchor-has-content: 0 */
2-
/* eslint react/button-has-type: 0 */
3-
import { array, func, object, oneOfType, shape, string } from "prop-types";
2+
import PropTypes from "prop-types";
43
import { Link as GatsbyLink } from "gatsby";
54
import React from "react";
65
import styled from "styled-components";
@@ -15,7 +14,7 @@ const LinkEl = styled.a`
1514
border-color: ${({ theme }) => theme.actionColorLt};
1615
border-style: solid;
1716
border-width: 0 0 2px;
18-
color: ${({ theme }) => theme.actionColor};
17+
color: ${({ theme }) => theme.actionColor ?? defaultThm.actionColor};
1918
cursor: pointer;
2019
display: inline-block;
2120
font-family: ${font.sans};
@@ -28,46 +27,41 @@ const LinkEl = styled.a`
2827
transition: border ${time.s}, transform ${time.s};
2928
white-space: nowrap;
3029
&:hover {
31-
border-color: ${({ theme }) => theme.actionColor};
30+
border-color: ${({ theme }) => theme.actionColor ?? defaultThm.actionColor};
3231
transform: translateX(-1px) translateY(-1px);
3332
}
34-
${({ isActive, theme }) =>
35-
isActive
33+
${({ $isActive, theme }) =>
34+
$isActive
3635
? `
37-
border-color: ${theme.actionColor};
36+
border-color: ${theme.actionColor ?? defaultThm.actionColor};
3837
`
3938
: ``};
4039
`;
4140

42-
const Link = props => {
43-
const { onClick, to } = props;
41+
function Link(props) {
42+
const { onClick, to, isActive, ...restProps } = props;
4443
if (to) {
45-
return <LinkEl as={GatsbyLink} {...props} theme={null} />;
44+
return <LinkEl to={to} as={GatsbyLink} $isActive={isActive} {...restProps} theme={null} />;
4645
}
4746
if (onClick) {
48-
return <LinkEl as="a" {...props} />;
47+
return <LinkEl onClick={onClick} as="a" $isActive={isActive} {...restProps} />;
4948
}
50-
return <LinkEl {...props} />;
51-
};
49+
return <LinkEl $isActive={isActive} {...restProps} />;
50+
}
5251

5352
Link.propTypes = {
54-
children: oneOfType([array, object, string]),
55-
href: string,
56-
onClick: func,
57-
theme: shape({
58-
actionColor: string
53+
children: PropTypes.oneOfType([
54+
PropTypes.array,
55+
PropTypes.object,
56+
PropTypes.string
57+
]),
58+
href: PropTypes.string,
59+
onClick: PropTypes.func,
60+
theme: PropTypes.shape({
61+
actionColor: PropTypes.string
5962
}),
60-
to: string
61-
};
62-
63-
Link.defaultProps = {
64-
children: null,
65-
href: "",
66-
onClick: null,
67-
theme: {
68-
actionColor: defaultThm.actionColor
69-
},
70-
to: null
63+
to: PropTypes.string,
64+
isActive: PropTypes.bool
7165
};
7266

7367
export default Link;

lib/ui/components/brandmarks/Logo.js

Lines changed: 17 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ui/components/brandmarks/Symbol.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ import { defaultThm } from "ui/themes";
66
import { setHeight } from "ui/mixins";
77

88
const SVG = styled.svg`
9-
${({ size }) => setHeight(size)};
9+
${({ $size = 'm' }) => setHeight($size)};
1010
`;
1111

1212
const BrandmarkSymbol = ({ size, theme }) => (
1313
<SVG
1414
xmlns="http://www.w3.org/2000/svg"
1515
viewBox="0 0 449.91 252.52"
16-
size={size}
16+
$size={size}
1717
>
1818
<title id="BrandmarkSymbol">Bad Idea Factory</title>
1919
<path
20-
fill={theme.svgFill}
20+
fill={theme.svgFill ?? defaultThm.svgFill}
2121
fillRule="nonzero"
2222
d="M37 28.53L0 238.38l16.81 14.14 91.77-33.4 22.13-26.37L141 134.23l-13.83-11.63 20.14-24 10.32-58.52-46.1-38.67zm98.72 107.62l-9.6 54.47L105.69 215l-85.26 31L55.49 47.2l10.34 8.68L52.06 134l38.57-14 10.37 8.6-51.28 18.66-14.26 80.85 58.47-21.29 22.13-26.36 9.34-53zM69 52.15l-10.38-8.68 48.61-17.7 10.35 8.68zM119.24 39l-5.79 32.87L93 96.26l-31.36 11.41 9-50.95zm-16.6 94.15L96.85 166 76.4 190.41 45 201.82l9-50.95zM152.34 42l-9.6 54.46-19.3 23-10.92-9.17 20.14-24 9.34-53zm-24.25 42.18l-22.43 26.73 14.65 12.29.79.67-9.61 54.46L91 202.7l-49.32 18 2.34-13.3 35.23-12.82 22.12-26.36 7-39.69-16.8-14.09-33.25 12.06 2.34-13.29 35.23-12.82L118 74l7-39.69-16.8-14.09-56.53 20.6-36 204.35-10.39-8.71L41.33 32.14l69.23-25.2 27.14 22.78zM210.65 8.75l-17.19 14.42 37.87 214.76 21.09 7.67 17.19-14.42-37.87-214.76zm25.09 225.48L198.87 25.14l10.58-8.88L248.72 239zm17.88 3.86L214.35 15.4l13 4.72 36.85 209.09zM446.18 34.94l3.73-21.14L433.46 0 343 32.94l-36.26 205.43 16.44 13.79 20.17-7.34 16.24-92.14 52.76-19.2 3.73-21.14-16.45-13.8-32.58 11.86 8.81-50zM376.81 55l2.28-12.92 50.17-18.26 10.12 8.49zm57.81-47.82l10.12 8.5-2.3 13-10.12-8.48zM322 245l-10.13-8.49 35.27-200L359.59 32zm86.11-115l-47.59 17.32 2.3-13 47.61-17.51zm-47.19-12.3l37.76-13.7 10 8.37-50 18.39-19.5 110.57-12.41 4.52 38-215.73 65.16-23.76-2.3 13-52.75 19.2z"
2323
/>
@@ -31,11 +31,4 @@ BrandmarkSymbol.propTypes = {
3131
})
3232
};
3333

34-
BrandmarkSymbol.defaultProps = {
35-
size: "m",
36-
theme: {
37-
svgFill: defaultThm.svgFill
38-
}
39-
};
40-
4134
export default BrandmarkSymbol;

lib/ui/components/galleries/Gallery.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Gallery extends Component {
4040
if (images && images.length > 0) {
4141
return <>
4242
<Image>
43-
<GatsbyImage image={images[current]} />
43+
<GatsbyImage image={images[current]} alt="" />
4444
</Image>
4545
<Thumbs>
4646
{images.length > 1
@@ -50,7 +50,7 @@ class Gallery extends Component {
5050
onClick={() => this.setState({ current: i })}
5151
role="button"
5252
>
53-
<GatsbyImage image={image} />
53+
<GatsbyImage image={image} alt="" />
5454
</Thumb>
5555
))
5656
: null}
@@ -59,7 +59,7 @@ class Gallery extends Component {
5959
}
6060
return (
6161
<Image>
62-
<GatsbyImage image={defaultImage} />
62+
<GatsbyImage image={defaultImage} alt="" />
6363
</Image>
6464
);
6565
}

0 commit comments

Comments
 (0)