From d685d4d9df925fa7956ddb241c7b4b2fb7a61c3c Mon Sep 17 00:00:00 2001
From: Nathan Chu <63111210+nthnchu@users.noreply.github.com>
Date: Tue, 28 Jul 2020 19:32:35 -0400
Subject: [PATCH] Stats card gradient (anuraghazra#218)
---
src/renderStatsCard.js | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/renderStatsCard.js b/src/renderStatsCard.js
index 7e9d0cb..ad78b8f 100644
--- a/src/renderStatsCard.js
+++ b/src/renderStatsCard.js
@@ -54,6 +54,8 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
const lheight = parseInt(line_height);
+ const isGradient = !(bg_color == undefined || bg_color.length == 6 || bg_color.length == 3)
+
// returns theme based colors with proper overrides and defaults
const { titleColor, textColor, iconColor, bgColor } = getCardColors({
title_color,
@@ -63,6 +65,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
theme,
});
+const gradientBgColor = isGradient ? bg_color.split(',') : undefined;
// Meta data for creating text nodes with createTextNode function
const STATS = {
stars: {
@@ -143,12 +146,20 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
width="494"
height="99%"
rx="4.5"
- fill="${bgColor}"
+ fill="${isGradient ? "url('#gradient')" : bgColor}"
stroke="#E4E2E2"
stroke-opacity="${hide_border ? 0 : 1}"
/>
`;
+ const gradient = isGradient ? `
+
+
+
+
+
+ `
+ : undefined
const rankCircle = hide_rank
? ""
: `