|
| 1 | +import React from 'react'; |
| 2 | +import Modal from 'react-modal'; |
| 3 | + |
| 4 | + |
| 5 | +Modal.setAppElement('#___gatsby'); |
| 6 | + |
| 7 | +interface MyModalProps { |
| 8 | + isOpen: boolean; |
| 9 | + onClose: () => void; |
| 10 | +} |
| 11 | + |
| 12 | +const MyModal: React.FC<MyModalProps> = ({ isOpen, onClose }) => { |
| 13 | + const isMobile = |
| 14 | + typeof window !== 'undefined' && window.innerWidth <= 600; |
| 15 | + const isSmallMobile = |
| 16 | + typeof window !== 'undefined' && window.innerWidth <= 300; |
| 17 | + |
| 18 | + const overlayStyle: React.CSSProperties = { |
| 19 | + backgroundColor: 'rgba(0, 0, 0, 0.6)', |
| 20 | + position: 'fixed', |
| 21 | + inset: 0, |
| 22 | + zIndex: 9999, |
| 23 | + }; |
| 24 | + |
| 25 | + |
| 26 | + const contentStyle: React.CSSProperties = { |
| 27 | + position: 'fixed', |
| 28 | + top: 0, |
| 29 | + left: 0, |
| 30 | + right: 0, |
| 31 | + bottom: 0, |
| 32 | + margin: 0, |
| 33 | + border: 'none', |
| 34 | + padding: 0, |
| 35 | + background: 'transparent', |
| 36 | + overflow: 'hidden', |
| 37 | + display: 'flex', |
| 38 | + justifyContent: 'center', |
| 39 | + alignItems: 'center', |
| 40 | + }; |
| 41 | + |
| 42 | + |
| 43 | + const boxStyle: React.CSSProperties = { |
| 44 | + position: 'relative', |
| 45 | + background: '#bc079a', |
| 46 | + borderRadius: 30, |
| 47 | + boxSizing: 'border-box', |
| 48 | + width: isMobile ? '82vw' : 720, |
| 49 | + maxWidth: '100%', |
| 50 | + maxHeight: isMobile ? '85vh' : '90vh', |
| 51 | + overflowY: 'auto', |
| 52 | + padding: isMobile ? '20px 16px' : '40px 32px', |
| 53 | + color: '#ffffff', |
| 54 | + textAlign: 'center', |
| 55 | + }; |
| 56 | + |
| 57 | + |
| 58 | + const mainHeadingStyle: React.CSSProperties = { |
| 59 | + fontSize: isSmallMobile ? '1.1rem' : isMobile ? '1.9rem' : '2.8rem', |
| 60 | + fontWeight: 700, |
| 61 | + marginBottom: isSmallMobile ? '0.9rem' : '1.2rem', |
| 62 | + }; |
| 63 | + |
| 64 | + const paragraphStyle: React.CSSProperties = { |
| 65 | + fontSize: isSmallMobile ? '0.9rem' : isMobile ? '0.95rem' : '1.15rem', |
| 66 | + lineHeight: 1.45, |
| 67 | + margin: '0.3rem 0', |
| 68 | + }; |
| 69 | + |
| 70 | + const highlightYellow: React.CSSProperties = { |
| 71 | + color: '#FCFF59', |
| 72 | + fontWeight: 700, |
| 73 | + }; |
| 74 | + |
| 75 | + const buttonWrapperStyle: React.CSSProperties = { |
| 76 | + marginTop: isMobile ? '1.5rem' : '2.5rem', |
| 77 | + marginBottom: isMobile ? '1.5rem' : '2.5rem', |
| 78 | + display: 'flex', |
| 79 | + justifyContent: 'center', |
| 80 | + }; |
| 81 | + |
| 82 | + |
| 83 | + const buttonStyle: React.CSSProperties = { |
| 84 | + backgroundColor: '#ffffff', |
| 85 | + color: '#000000', |
| 86 | + padding: isSmallMobile ? '8px 20px' : isMobile ? '9px 28px' : '10px 64px', |
| 87 | + minWidth: isSmallMobile ? 210 : isMobile ? 240 : 420, |
| 88 | + border: 'none', |
| 89 | + borderRadius: 999, |
| 90 | + fontSize: isSmallMobile ? '1rem' : isMobile ? '1.05rem' : '1.3rem', |
| 91 | + fontWeight: 700, |
| 92 | + cursor: 'pointer', |
| 93 | + boxShadow: '0 4px 10px rgba(0,0,0,0.25)', |
| 94 | + display: 'inline-flex', |
| 95 | + alignItems: 'center', |
| 96 | + justifyContent: 'center', |
| 97 | + gap: 8, |
| 98 | + }; |
| 99 | + |
| 100 | + |
| 101 | + const bottomInfoStyle: React.CSSProperties = { |
| 102 | + fontSize: isMobile ? '0.95rem' : '1.05rem', |
| 103 | + lineHeight: 1.5, |
| 104 | + marginTop: '0.6rem', |
| 105 | + }; |
| 106 | + |
| 107 | + const bottomHighlight: React.CSSProperties = { |
| 108 | + fontWeight: 700, |
| 109 | + textDecoration: 'underline', |
| 110 | + }; |
| 111 | + |
| 112 | + const handleClick = () => { |
| 113 | + window.open( |
| 114 | + 'https://www.pola-app.pl/1-5-podatku-na-aplikacje-pola', |
| 115 | + '_blank', |
| 116 | + 'noopener,noreferrer' |
| 117 | + ); |
| 118 | + onClose(); |
| 119 | + }; |
| 120 | + |
| 121 | + const closeButtonStyle: React.CSSProperties = { |
| 122 | + position: 'absolute', |
| 123 | + top: isMobile ? 10 : 14, |
| 124 | + right: isMobile ? 10 : 18, |
| 125 | + width: 32, |
| 126 | + height: 32, |
| 127 | + borderRadius: '50%', |
| 128 | + border: 'none', |
| 129 | + background: 'rgba(255, 255, 255, 0.2)', |
| 130 | + color: '#ffffff', |
| 131 | + fontSize: 20, |
| 132 | + lineHeight: 1, |
| 133 | + cursor: 'pointer', |
| 134 | + display: 'flex', |
| 135 | + alignItems: 'center', |
| 136 | + justifyContent: 'center', |
| 137 | + boxShadow: '0 2px 6px rgba(0,0,0,0.25)', |
| 138 | + }; |
| 139 | + |
| 140 | + |
| 141 | + return ( |
| 142 | + <Modal |
| 143 | + isOpen={isOpen} |
| 144 | + onRequestClose={onClose} |
| 145 | + shouldCloseOnOverlayClick |
| 146 | + contentLabel="Odpisz darowiznę od podatku PIT" |
| 147 | + style={{ overlay: overlayStyle, content: contentStyle }} |
| 148 | + > |
| 149 | + <div style={boxStyle}> |
| 150 | + <button |
| 151 | + type="button" |
| 152 | + aria-label="Zamknij" |
| 153 | + style={closeButtonStyle} |
| 154 | + onClick={onClose} |
| 155 | + > |
| 156 | + × |
| 157 | + </button> |
| 158 | + <h2 style={mainHeadingStyle}> |
| 159 | + Odpisz darowiznę od podatku PIT! |
| 160 | + </h2> |
| 161 | + |
| 162 | + <p style={paragraphStyle}> |
| 163 | + Przy wypełnianiu PIT, pamiętaj o uwzględnianiu darowizn za 2025 r. |
| 164 | + </p> |
| 165 | + |
| 166 | + <div style={{ marginTop: '1.5rem', marginBottom: '1rem' }}> |
| 167 | + <p |
| 168 | + style={{ |
| 169 | + ...paragraphStyle, |
| 170 | + fontSize: isMobile ? '1.05rem' : '1.25rem', |
| 171 | + fontWeight: 600, |
| 172 | + }} |
| 173 | + > |
| 174 | + Nie pamiętasz, jaka kwota została przekazana na Polę? |
| 175 | + </p> |
| 176 | + <p style={paragraphStyle}> |
| 177 | + Napisz do nas —{' '} |
| 178 | + <span style={highlightYellow}> |
| 179 | + podamy Ci łączną sumę Twoich wpłat. |
| 180 | + </span> |
| 181 | + </p> |
| 182 | + </div> |
| 183 | + |
| 184 | + <div style={buttonWrapperStyle}> |
| 185 | + <button |
| 186 | + type="button" |
| 187 | + style={buttonStyle} |
| 188 | + onClick={handleClick} |
| 189 | + > |
| 190 | + Wspieram |
| 191 | + </button> |
| 192 | + </div> |
| 193 | + |
| 194 | + <div> |
| 195 | + <p style={bottomInfoStyle}> |
| 196 | + 1,5% dla Poli KRS:{' '} |
| 197 | + <span style={highlightYellow}> 0000128315</span> |
| 198 | + </p> |
| 199 | + <p style={bottomInfoStyle}> |
| 200 | + Cel szczegółowy:{' '} |
| 201 | + <span style={highlightYellow}>Aplikacja Pola</span> |
| 202 | + </p> |
| 203 | + </div> |
| 204 | + </div> |
| 205 | + </Modal> |
| 206 | + ); |
| 207 | +}; |
| 208 | + |
| 209 | +export default MyModal; |
0 commit comments