Skip to content

Commit

Permalink
Add Email card
Browse files Browse the repository at this point in the history
  • Loading branch information
yentsun committed Mar 22, 2024
1 parent 19a52ba commit fa442fd
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 60 deletions.
41 changes: 19 additions & 22 deletions src/components/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@ import React from 'react';
import useFetchData from '../hooks/useFetchData';


export default function Card({ href, thumb, apis, data: staticData }) {

const link = (typeof href === "string") ? href : null;
const clickHandler = (typeof href === "function") ? href : null;
const data = useFetchData({ apis, staticData });

return data === null ? (<div className="card"><h1>Loading...</h1></div>) : (
<div>
<a href={ link } onClick={ clickHandler } className="card">
<div className="thumb" style={{backgroundImage: `url(${thumb})`}}/>
{ data !== false ?
<article>
<h1>{data.major}</h1>
<span>{data.minor}</span>
<p>{data.content}</p>
</article>
:
<article><h1>No data!</h1></article>
}
</a>
</div>
);
export default function Card({ href, thumb, major, minor, content, isLoading }) {

return <div className="card" onClick={ () => window.location = href }>

{ isLoading &&
<h1>Loading...</h1> }

<div className="thumb" style={ { backgroundImage: `url(${ thumb })` } }/>

{ ! isLoading && <>
<article>
<h1>{ major }</h1>
<span>{ minor }</span>
<p>{ content }</p>
</article>

</> }
</div>

}
18 changes: 6 additions & 12 deletions src/components/Cards/Bio.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
export default function Bio() {

return <div className="card">

<div className="thumb" style={ { backgroundImage: 'url(userpic.gif)' } }/>
import Card from '../Card';

<article>
<h1>Maksim Korinets</h1>

<span>freelance software engineer</span>

<p>Embrace simplicity: there is hard work behind it (most of the time).</p>
</article>
export default function Bio() {

</div>
return <Card thumb="userpic.gif"
major="Maksim Korinets"
minor="freelance software engineer"
content="Embrace simplicity: there is hard work behind it (most of the time)." />
}
8 changes: 8 additions & 0 deletions src/components/Cards/Email.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Card from '../Card';


export default function Email() {

return <Card thumb="gmail.gif" major="mkorinets@gmail.com" minor="hangouts on" href="mailto:mkorinets@gmail.com"
content="Its a good way to start communication with an introductory email or message. Respect the working vibe." />
}
33 changes: 7 additions & 26 deletions src/components/Cards/GitHub.jsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
import useGithub from '../../hooks/useGithub';
import Card from '../Card';


export default function GitHub() {

const { yentsun, lastEvent } = useGithub();

return <div className="card" onClick={ () => window.location = 'https://github.com/yentsun' }>

{ ! yentsun &&
<h1>Loading...</h1> }

<div className="thumb" style={{ backgroundImage: 'url(github.gif)' }}/>

<article>
{ yentsun && <>

<h1>repos: { yentsun.public_repos }</h1>

<span>followers: { yentsun.followers }</span>

{ lastEvent &&
<p>
{ lastEvent.name }:
[{ lastEvent.type }] { lastEvent.text }
({ lastEvent.createdAgo } ago)
</p> }

</> }

</article>

</div>
return <Card isLoading={ ! yentsun } thumb="github.gif"
major={`repos: ${yentsun?.public_repos}` }
minor={ `followers: ${yentsun.followers}` }
content={ lastEvent
? `${lastEvent.name}: [${lastEvent.type}] ${lastEvent.text} (${lastEvent.createdAgo} ago)`
: null } />
}
34 changes: 34 additions & 0 deletions src/components/Cards/GitLab.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import useGithub from '../../hooks/useGithub';


export default function GitHub() {

const { yentsun, lastEvent } = useGithub();

return <div className="card" onClick={ () => window.location = 'https://github.com/yentsun' }>

{ ! yentsun &&
<h1>Loading...</h1> }

<div className="thumb" style={{ backgroundImage: 'url(github.gif)' }}/>

<article>
{ yentsun && <>

<h1>repos: { yentsun.public_repos }</h1>

<span>followers: { yentsun.followers }</span>

{ lastEvent &&
<p>
{ lastEvent.name }:
[{ lastEvent.type }] { lastEvent.text }
({ lastEvent.createdAgo } ago)
</p> }

</> }

</article>

</div>
}
2 changes: 2 additions & 0 deletions src/components/Root.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import React from 'react';
import '../index.css';
import GitHub from './Cards/GitHub';
import Bio from './Cards/Bio';
import Email from './Cards/Email';


export default function Root() {

return <div className="band">
<Bio />
<GitHub />
<Email />
</div>
}

0 comments on commit fa442fd

Please sign in to comment.