Instantly share code, notes, and snippets.

Embed
What would you like to do?
import React from "react";
const ForkEvent = ({ created_at: eventDate, repo, org, actor, payload }) => {
const { display_login: login, url: actorURL } = actor;
const { name: repoName, url: repoURL } = repo;
return (
<div class="event">
<h3>
Fork - (<small>{eventDate.toString()}</small>)
</h3>
<p>
<a href={actorURL}>{login}</a> has forked{" "}
<a href={repoURL}>{repoName}</a>
</p>
</div>
);
};
export default ForkEvent;
import { lazy } from "react";
const ForkEvent = lazy(() => import(`./ForkEvent`));
const NullEvent = lazy(() => import(`./NullEvent`));
const PushEvent = lazy(() => import(`./PushEvent`));
const WatchEvent = lazy(() => import(`./WatchEvent`));
export { ForkEvent, NullEvent, PushEvent, WatchEvent };
import React from "react";
// Null object pattern
const NullEvent = () => {
return <div />;
};
export default NullEvent;
import React from "react";
import shortid from "shortid";
const PushEvent = ({ created_at: eventDate, repo, org, actor, payload }) => {
const { display_login: login, url: actorURL } = actor;
const { commits } = payload;
const { name: repoName, url: repoURL } = repo;
return (
<div class="event">
<h3>
Push - (<small>{eventDate}</small>)
</h3>
<div>
<a href={actorURL}>{login}</a> has pushed to{" "}
<a href={repoURL}>{repoName}</a>
<Commits commits={commits} />
</div>
</div>
);
};
const Commits = ({ commits }) => {
return (
<ol>
{commits.map(commit => (
<li key={shortid.generate()}>
{commit.author.name} has commited with message "{commit.message}"
</li>
))}
</ol>
);
};
export default PushEvent;
import React from "react";
const WatchEvent = ({ created_at: eventDate, repo, org, actor, payload }) => {
const { display_login: login, url: actorURL } = actor;
const { action } = payload;
const { name: repoName, url: repoURL } = repo;
return (
<div class="event">
<h3>
Watch - (<small>{eventDate.toString()}</small>)
</h3>
<p>
<a href={actorURL}>{login}</a> has {action} following{" "}
<a href={repoURL}>{repoName}</a>
</p>
</div>
);
};
export default WatchEvent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment