|
| 1 | +import React, { useEffect, useState } from 'react' |
| 2 | + |
| 3 | +const STORAGE_KEY = 'framna_announcement_shown_at' |
| 4 | +const THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1000 |
| 5 | + |
| 6 | +function shouldShowPopup(): boolean { |
| 7 | + try { |
| 8 | + const shown = localStorage.getItem(STORAGE_KEY) |
| 9 | + if (!shown) return true |
| 10 | + return Date.now() - parseInt(shown, 10) > THIRTY_DAYS_MS |
| 11 | + } catch { |
| 12 | + return false |
| 13 | + } |
| 14 | +} |
| 15 | + |
| 16 | +function isAfterLaunchDate(): boolean { |
| 17 | + const isStaging = process.env.GATSBY_ACTIVE_ENV === 'staging' |
| 18 | + if (isStaging) return true |
| 19 | + const launchDate = new Date('2026-03-18T00:00:00') |
| 20 | + return new Date() >= launchDate |
| 21 | +} |
| 22 | + |
| 23 | +const FramnaAnnouncementPopup: React.FC = () => { |
| 24 | + const [visible, setVisible] = useState(false) |
| 25 | + |
| 26 | + useEffect(() => { |
| 27 | + if (!isAfterLaunchDate()) return |
| 28 | + if (!shouldShowPopup()) return |
| 29 | + |
| 30 | + const show = () => { |
| 31 | + setTimeout(() => { |
| 32 | + setVisible(true) |
| 33 | + try { |
| 34 | + localStorage.setItem(STORAGE_KEY, String(Date.now())) |
| 35 | + } catch { |
| 36 | + // ignore |
| 37 | + } |
| 38 | + }, 500) |
| 39 | + } |
| 40 | + |
| 41 | + if (document.readyState === 'complete') { |
| 42 | + show() |
| 43 | + } else { |
| 44 | + window.addEventListener('load', show, { once: true }) |
| 45 | + return () => window.removeEventListener('load', show) |
| 46 | + } |
| 47 | + }, []) |
| 48 | + |
| 49 | + if (!visible) return null |
| 50 | + |
| 51 | + return ( |
| 52 | + <div |
| 53 | + style={{ |
| 54 | + position: 'fixed', |
| 55 | + inset: 0, |
| 56 | + backgroundColor: 'rgba(0,0,0,0.5)', |
| 57 | + display: 'flex', |
| 58 | + alignItems: 'center', |
| 59 | + justifyContent: 'center', |
| 60 | + zIndex: 9999, |
| 61 | + }} |
| 62 | + onClick={() => setVisible(false)} |
| 63 | + > |
| 64 | + <div |
| 65 | + style={{ |
| 66 | + display: 'flex', |
| 67 | + maxWidth: 680, |
| 68 | + width: '90%', |
| 69 | + borderRadius: 16, |
| 70 | + overflow: 'hidden', |
| 71 | + position: 'relative', |
| 72 | + }} |
| 73 | + onClick={e => e.stopPropagation()} |
| 74 | + > |
| 75 | + {/* Left green panel */} |
| 76 | + <div |
| 77 | + style={{ |
| 78 | + backgroundColor: '#1BC866', |
| 79 | + flex: '0 0 45%', |
| 80 | + display: 'flex', |
| 81 | + alignItems: 'center', |
| 82 | + justifyContent: 'center', |
| 83 | + padding: '40px 32px', |
| 84 | + }} |
| 85 | + > |
| 86 | + <img |
| 87 | + src='/images/framna.svg' |
| 88 | + alt='Framna' |
| 89 | + style={{ maxWidth: 180, width: '100%' }} |
| 90 | + /> |
| 91 | + </div> |
| 92 | + |
| 93 | + {/* Right white panel */} |
| 94 | + <div |
| 95 | + style={{ |
| 96 | + backgroundColor: '#ffffff', |
| 97 | + flex: '0 0 55%', |
| 98 | + padding: '48px 40px 40px', |
| 99 | + display: 'flex', |
| 100 | + flexDirection: 'column', |
| 101 | + justifyContent: 'center', |
| 102 | + }} |
| 103 | + > |
| 104 | + <button |
| 105 | + onClick={() => setVisible(false)} |
| 106 | + style={{ |
| 107 | + position: 'absolute', |
| 108 | + top: 16, |
| 109 | + right: 16, |
| 110 | + background: 'none', |
| 111 | + border: 'none', |
| 112 | + cursor: 'pointer', |
| 113 | + fontSize: 20, |
| 114 | + lineHeight: 1, |
| 115 | + padding: 4, |
| 116 | + }} |
| 117 | + aria-label='Close' |
| 118 | + > |
| 119 | + ✕ |
| 120 | + </button> |
| 121 | + |
| 122 | + <h2 |
| 123 | + style={{ |
| 124 | + fontSize: '1.75rem', |
| 125 | + fontWeight: 700, |
| 126 | + marginBottom: 16, |
| 127 | + marginTop: 0, |
| 128 | + lineHeight: 1.2, |
| 129 | + }} |
| 130 | + > |
| 131 | + Bright Inventions is now Framna |
| 132 | + </h2> |
| 133 | + |
| 134 | + <p style={{ marginBottom: 24, marginTop: 0, lineHeight: 1.6, color: '#333' }}> |
| 135 | + We partner with industry leaders (and those about to be) to create digital products that |
| 136 | + define markets, reshape industries, and drive meaningful growth. |
| 137 | + </p> |
| 138 | + |
| 139 | + <a |
| 140 | + href='https://framna.com/' |
| 141 | + target='_blank' |
| 142 | + rel='noopener noreferrer' |
| 143 | + style={{ |
| 144 | + display: 'inline-block', |
| 145 | + backgroundColor: '#0d0d0d', |
| 146 | + color: '#ffffff', |
| 147 | + padding: '14px 28px', |
| 148 | + borderRadius: 999, |
| 149 | + textDecoration: 'none', |
| 150 | + fontWeight: 600, |
| 151 | + fontSize: '0.95rem', |
| 152 | + alignSelf: 'flex-start', |
| 153 | + }} |
| 154 | + > |
| 155 | + Visit Framna |
| 156 | + </a> |
| 157 | + </div> |
| 158 | + </div> |
| 159 | + </div> |
| 160 | + ) |
| 161 | +} |
| 162 | + |
| 163 | +export default FramnaAnnouncementPopup |
0 commit comments