Skip to content

Commit d467d8b

Browse files
committed
permanently dismiss close icon upon click
1 parent fc64180 commit d467d8b

File tree

4 files changed

+458
-1
lines changed

4 files changed

+458
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
import NewFeatureBanner from '../NewFeatureBanner';
3+
4+
const GrafanaBanner: React.FC = () => {
5+
return (
6+
<NewFeatureBanner
7+
featureId="grafana_helm_setup_2025_banner_v1"
8+
title="✨ Brand New: Grafana Helm Setup Guide"
9+
description=""
10+
linkUrl="/docs/concepts/grafana-helm-setup"
11+
linkText="🚀 Explore the Guide"
12+
showDays={365}
13+
/>
14+
);
15+
};
16+
17+
export default GrafanaBanner;
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import React, { useState, useEffect } from 'react';
2+
import { useHistory } from '@docusaurus/router';
3+
import styles from './styles.module.css';
4+
5+
interface NewFeatureBannerProps {
6+
featureId: string;
7+
title: string;
8+
description: string;
9+
linkUrl: string;
10+
linkText: string;
11+
showDays?: number;
12+
}
13+
14+
const NewFeatureBanner: React.FC<NewFeatureBannerProps> = ({
15+
featureId,
16+
title,
17+
description,
18+
linkUrl,
19+
linkText,
20+
showDays = 7,
21+
}) => {
22+
const [isVisible, setIsVisible] = useState(false);
23+
const history = useHistory();
24+
25+
useEffect(() => {
26+
// Check if banner should be shown
27+
const lastShown = localStorage.getItem(`banner_${featureId}_lastShown`);
28+
const dismissed = localStorage.getItem(`banner_${featureId}_dismissed`);
29+
30+
console.log('🚀 Banner check:', { featureId, lastShown, dismissed, showDays });
31+
32+
if (dismissed) {
33+
console.log('✅ Banner dismissed, not showing');
34+
return;
35+
}
36+
37+
const now = new Date().getTime();
38+
39+
if (!lastShown) {
40+
// First time - show banner immediately
41+
console.log('🎯 First time, showing banner immediately');
42+
setIsVisible(true);
43+
localStorage.setItem(`banner_${featureId}_lastShown`, now.toString());
44+
} else {
45+
const daysSinceLastShown = (now - parseInt(lastShown)) / (1000 * 60 * 60 * 24);
46+
console.log('📅 Days since last shown:', daysSinceLastShown);
47+
if (daysSinceLastShown < showDays) {
48+
console.log('✨ Within show period, showing banner immediately');
49+
setIsVisible(true);
50+
} else {
51+
console.log('⏰ Outside show period, not showing banner');
52+
}
53+
}
54+
}, [featureId, showDays]);
55+
56+
const handleDismiss = (e: React.MouseEvent) => {
57+
e.stopPropagation();
58+
// Dismiss both banner and popup
59+
localStorage.setItem(`banner_${featureId}_dismissed`, 'true');
60+
localStorage.setItem(`popup_grafana_helm_setup_2025_ultra_v2_dismissed`, 'true');
61+
setIsVisible(false);
62+
};
63+
64+
const handleNavigate = () => {
65+
history.push(linkUrl);
66+
};
67+
68+
if (!isVisible) {
69+
return null;
70+
}
71+
72+
return (
73+
<div className={styles.banner} onClick={handleNavigate}>
74+
<div className={styles.content}>
75+
{/* NEW FEATURE Badge */}
76+
<div className={styles.badge}>
77+
<div className={styles.badgeInner}>
78+
<span className={styles.badgeText}>NEW FEATURE</span>
79+
</div>
80+
</div>
81+
82+
{/* Title */}
83+
<h3 className={styles.title}>{title}</h3>
84+
85+
{/* Description (only show if not empty) */}
86+
{description && <p className={styles.description}>{description}</p>}
87+
88+
{/* Feature highlights */}
89+
<div className={styles.features}>
90+
<div className={styles.feature}>
91+
<div className={styles.featureIcon}></div>
92+
<span>Quick Setup</span>
93+
</div>
94+
<div className={styles.feature}>
95+
<div className={styles.featureIcon}>📊</div>
96+
<span>Pre-built Dashboards</span>
97+
</div>
98+
<div className={styles.feature}>
99+
<div className={styles.featureIcon}>🔄</div>
100+
<span>Auto ServiceMonitor</span>
101+
</div>
102+
</div>
103+
104+
{/* Click indicator */}
105+
<div className={styles.clickIndicator}>
106+
<span className={styles.clickText}>Click to explore →</span>
107+
</div>
108+
</div>
109+
110+
{/* Close button */}
111+
<button className={styles.closeButton} onClick={handleDismiss} aria-label="Close banner">
112+
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
113+
<path d="M8 6.5l3.5-3.5a1 1 0 111.414 1.414L9.414 8l3.5 3.5a1 1 0 11-1.414 1.414L8 9.414l-3.5 3.5a1 1 0 11-1.414-1.414L6.586 8 3.086 4.5A1 1 0 114.5 3.086L8 6.5z"/>
114+
</svg>
115+
</button>
116+
117+
{/* Maybe later button */}
118+
<button className={styles.maybeButton} onClick={handleDismiss}>
119+
Maybe later
120+
</button>
121+
</div>
122+
);
123+
};
124+
125+
export default NewFeatureBanner;

0 commit comments

Comments
 (0)