Skip to content

Instantly share code, notes, and snippets.

@NickFoden
Created June 20, 2019 22:04
Show Gist options
  • Save NickFoden/66ce2efb98b4e709344e84c3b73ff416 to your computer and use it in GitHub Desktop.
Save NickFoden/66ce2efb98b4e709344e84c3b73ff416 to your computer and use it in GitHub Desktop.
import * as React from "react";
import socialMeetup from "../assets/social-meetup.svg";
import socialTwitter from "../assets/social-twitter.svg";
interface SocialInterface {
meetup: SocialObject;
twitter: SocialObject;
}
interface SocialObject {
css: string;
icon: string;
title: string;
url: string;
verb: string;
}
const socialObject: SocialInterface = {
meetup: {
css: "follow-btn-meetup",
icon: socialMeetup,
title: "useReactNYC",
url: "https://www.meetup.com/useReactNYC",
verb: "Join"
},
twitter: {
css: "follow-btn-twitter",
icon: socialTwitter,
title: "@useReactNYC",
url: "https://twitter.com/useReactnyc",
verb: "Follow"
}
};
const FollowButton = (social: object ) => {
const selection = social.social: "twitter" | "meetup";
const { css, icon, title, url, verb } = socialObject[selection];
return (
<a href={url} rel="noopener noreferrer" target="_blank">
<button className={`follow-button ${css}`}>
<img src={icon} />{" "}
<span>
{verb}
{title}
</span>
</button>
</a>
);
};
export default FollowButton;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment