Skip to content

Commit f8d5ad8

Browse files
committed
refactor(Clients): port to typescript
1 parent cfd09fd commit f8d5ad8

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

lib/ui/templates/HomeTpl.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ const HomeTpl = (props: PageProps<Queries.HomeTplQuery>) => {
4242
title={frontmatter?.projectsTitle}
4343
/>
4444
<Clients
45-
title={frontmatter?.clientsTitle}
46-
subtitle={frontmatter?.clientsSubtitle}
45+
title={frontmatter?.clientsTitle ?? ""}
46+
subtitle={frontmatter?.clientsSubtitle ?? ""}
4747
clients={clients.edges}
4848
/>
4949
<Services

lib/ui/templates/ofHome/Clients.js renamed to lib/ui/templates/ofHome/Clients.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { array, string } from "prop-types";
2-
import { GatsbyImage } from "gatsby-plugin-image";
31
import React from "react";
2+
import { GatsbyImage } from "gatsby-plugin-image";
43
import styled from "styled-components";
54

65
import { Tile } from "ui/components";
@@ -43,8 +42,15 @@ const ItemText = styled.div`
4342
}
4443
`;
4544

46-
function Clients(props) {
45+
interface ClientsProps {
46+
clients: Queries.HomeTplQuery["clients"]["edges"];
47+
subtitle: string;
48+
title: string;
49+
}
50+
51+
function Clients(props: ClientsProps) {
4752
const { clients, title, subtitle } = props;
53+
4854
return (
4955
<Element as="section">
5056
<div className="el">
@@ -59,9 +65,14 @@ function Clients(props) {
5965
<Item key={node.id}>
6066
<Tile href={client.link} target="_blank" as="a">
6167
<ItemTitle>
62-
<GatsbyImage image={client.logo.childImageSharp.gatsbyImageData} alt={client.name} />
68+
<GatsbyImage
69+
image={client.logo.childImageSharp.gatsbyImageData}
70+
alt={client?.name ?? ""}
71+
/>
6372
</ItemTitle>
64-
<ItemText dangerouslySetInnerHTML={{ __html: node.html }} />
73+
<ItemText
74+
dangerouslySetInnerHTML={{ __html: node.html ?? "" }}
75+
/>
6576
</Tile>
6677
</Item>
6778
);
@@ -72,10 +83,4 @@ function Clients(props) {
7283
);
7384
}
7485

75-
Clients.propTypes = {
76-
clients: array.isRequired,
77-
subtitle: string.isRequired,
78-
title: string.isRequired
79-
};
80-
8186
export default Clients;

0 commit comments

Comments
 (0)