Skip to content

Instantly share code, notes, and snippets.

@EileenJuergens
Last active March 1, 2021 11:06
Show Gist options
  • Save EileenJuergens/732113c55f61fc718f623b8076fd590f to your computer and use it in GitHub Desktop.
Save EileenJuergens/732113c55f61fc718f623b8076fd590f to your computer and use it in GitHub Desktop.
KPI Card Logic
import React from "react";
import MediaQuery from "react-responsive";
import Icon from "./icon.js";
function KPICard({ title, value, icon, iconColor }) {
return (
<div className="kpi-card">
{/* Mobile view */}
<MediaQuery maxWidth={576}>
<div className="kpi-card__mobile__align kpi-card__style">
<p className="kpi-card__mobile__title">
{title}
</p>
<p className="kpi-card__mobile__value">
{value}
</p>
</div>
</MediaQuery>
{/* Web view */}
<MediaQuery minWidth={576}>
<div className="kpi-card__web__align kpi-card__style">
<div className="kpi-card__web__icon-text-container">
<Icon icon={icon} color={iconColor} iconSize={24} />
<p className="kpi-card__web__title">
{title}
</p>
</div>
<p className="kpi-card__web__value">
{value}
</p>
</div>
</MediaQuery>
</div>
);
}
export default KPICard;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment