11import React from 'react' ;
2- import PropTypes from 'prop-types' ;
32import { useSelector } from 'react-redux' ;
43import { Helmet } from 'react-helmet' ;
54import { useTranslation } from 'react-i18next' ;
65import { Link } from 'react-router-dom' ;
76
7+ import type { TFunction } from 'react-i18next' ;
88import {
99 AboutPageContent ,
1010 Intro ,
@@ -27,8 +27,34 @@ import packageData from '../../../../package.json';
2727import HeartIcon from '../../../images/heart.svg' ;
2828import AsteriskIcon from '../../../images/p5-asterisk.svg' ;
2929import LogoIcon from '../../../images/p5js-square-logo.svg' ;
30+ import { RootState } from '../../../reducers' ;
3031
31- const AboutSection = ( { section, t } ) => (
32+ export interface AboutSectionInfoItem {
33+ url : string ;
34+ title : string ;
35+ description : string ;
36+ }
37+ export interface AboutSectionInfoSection {
38+ header : string ;
39+ items : AboutSectionInfoItem [ ] ;
40+ }
41+ export interface ContactSectionLink {
42+ label : string ;
43+ href : string ;
44+ }
45+
46+ export interface AboutSectionProps {
47+ section : AboutSectionInfoSection ;
48+ t : TFunction < 'translation' > ;
49+ }
50+
51+ const AboutSection = ( {
52+ section,
53+ t
54+ } : {
55+ section : AboutSectionInfoSection ;
56+ t : TFunction < 'translation' > ;
57+ } ) => (
3258 < Section >
3359 < h2 > { t ( section . header ) } </ h2 >
3460 < SectionContainer >
@@ -47,11 +73,15 @@ const AboutSection = ({ section, t }) => (
4773 </ Section >
4874) ;
4975
50- const About = ( ) => {
76+ export const About = ( ) => {
5177 const { t } = useTranslation ( ) ;
5278
53- const p5version = useSelector ( ( state ) => {
54- const index = state . files . find ( ( file ) => file . name === 'index.html' ) ;
79+ const p5version = useSelector ( ( state : RootState ) => {
80+ const index = state . files . find (
81+ ( file : {
82+ name : string /** TODO: update once files types are defined in server */ ;
83+ } ) => file . name === 'index.html'
84+ ) ;
5585 return index ?. content . match ( / \/ p 5 @ ( [ \d . ] + ) \/ / ) ?. [ 1 ] ;
5686 } ) ;
5787
@@ -91,7 +121,11 @@ const About = () => {
91121 </ Intro >
92122
93123 { AboutSectionInfo . map ( ( section ) => (
94- < AboutSection key = { t ( section . header ) } section = { section } t = { t } />
124+ < AboutSection
125+ key = { t ( section . header ) as string }
126+ section = { section }
127+ t = { t }
128+ />
95129 ) ) }
96130
97131 < Contact >
@@ -152,19 +186,3 @@ const About = () => {
152186 </ RootPage >
153187 ) ;
154188} ;
155-
156- AboutSection . propTypes = {
157- section : PropTypes . shape ( {
158- header : PropTypes . string . isRequired ,
159- items : PropTypes . arrayOf (
160- PropTypes . shape ( {
161- url : PropTypes . string . isRequired ,
162- title : PropTypes . string . isRequired ,
163- description : PropTypes . string . isRequired
164- } )
165- ) . isRequired
166- } ) . isRequired ,
167- t : PropTypes . func . isRequired
168- } ;
169-
170- export default About ;
0 commit comments