extract DevSummary type

This commit is contained in:
Ruidy Nemausat 2020-05-12 12:56:56 +02:00
parent e103c8a354
commit 1a16800e1e
3 changed files with 38 additions and 23 deletions

View file

@ -1,21 +1,18 @@
import React, {FC} from 'react';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faCheck} from '@fortawesome/free-solid-svg-icons';
import DevSummary from '../models/DevSummary';
interface IProps {
name: string;
description: string;
location: string;
skills: string[];
}
const DevProfile: FC<IProps> = ({name, description, location, skills}) => (
const DevProfile: FC<DevSummary> = ({
id,
name,
picture,
description,
location,
skills,
}) => (
<div className="profile bg-light">
<img
src="https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=200"
alt="Some guy"
className="round-img"
/>
<img src={picture} alt={name} className="round-img" />
<div>
<h2>{name}</h2>
<p>{description}</p>

10
src/models/DevSummary.ts Normal file
View file

@ -0,0 +1,10 @@
interface DevSummary {
id: string;
name: string;
picture: string;
description: string;
location: string;
skills: string[];
}
export default DevSummary;

View file

@ -1,20 +1,33 @@
import React, {FC} from 'react';
import Header from '../components/Header';
import DevProfile from '../components/DevProfile';
import DevSummary from '../models/DevSummary';
// interface IProps {
// developers: []
// developers: DevSummary[]
// }
// const Developers: FC<IProps> = ({developers}) => (
const Developers: FC = () => {
const developers = [
const developers: DevSummary[] = [
{
id: '0',
name: 'John Doe',
picture:
'https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=200',
description: 'Developer at Microsoft',
location: 'Seattle, WA',
skills: ['HTML', 'CSS', 'JavaScript', 'Python'],
},
{
id: '42',
name: 'Ruidy Nemausat',
picture:
'https://lh3.googleusercontent.com/a-/AOh14GhncH95MWKwPR3TRKy4eVd4n6w0-fobe4dhiam2xA',
description: 'Frontend Engineer at DESY',
location: 'Hamburg, DE',
skills: ['React', 'TypeScript', 'Redux', 'GraphQL'],
},
];
return (
@ -25,14 +38,9 @@ const Developers: FC = () => {
icon="connectdevelop"
/>
<div className="profiles">
{developers.map((dev, i) => (
<DevProfile
key={i}
name={dev.name}
description={dev.description}
location={dev.location}
skills={dev.skills}
/>
{developers.map(dev => (
// use spread operator to pass props
<DevProfile key={dev.id} {...dev} />
))}
</div>
</section>