react-magic-portal 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/.commitlintrc +5 -0
  2. package/.github/dependabot.yml +11 -0
  3. package/.github/workflows/cd.yml +85 -0
  4. package/.github/workflows/ci.yml +65 -0
  5. package/.husky/commit-msg +1 -0
  6. package/.husky/pre-commit +1 -0
  7. package/.prettierrc +6 -0
  8. package/.releaserc +13 -0
  9. package/CHANGELOG.md +13 -0
  10. package/LICENSE +21 -0
  11. package/README.md +186 -0
  12. package/__tests__/eslint.config.ts +25 -0
  13. package/__tests__/package.json +42 -0
  14. package/__tests__/src/MagicPortal.test.tsx +506 -0
  15. package/__tests__/tsconfig.json +23 -0
  16. package/__tests__/vite.config.ts +11 -0
  17. package/eslint.config.mts +16 -0
  18. package/package.json +64 -0
  19. package/packages/component/.prettierrc +6 -0
  20. package/packages/component/README.md +6 -0
  21. package/packages/component/dist/index.d.ts +27 -0
  22. package/packages/component/dist/index.d.ts.map +1 -0
  23. package/packages/component/dist/index.js +2 -0
  24. package/packages/component/dist/index.js.map +1 -0
  25. package/packages/component/eslint.config.ts +25 -0
  26. package/packages/component/package.json +70 -0
  27. package/packages/component/src/index.ts +123 -0
  28. package/packages/component/tsconfig.json +27 -0
  29. package/packages/example/.prettierrc +6 -0
  30. package/packages/example/README.md +6 -0
  31. package/packages/example/eslint.config.ts +25 -0
  32. package/packages/example/index.html +13 -0
  33. package/packages/example/package.json +32 -0
  34. package/packages/example/pnpm-lock.yaml +2098 -0
  35. package/packages/example/public/vite.svg +1 -0
  36. package/packages/example/src/App.css +332 -0
  37. package/packages/example/src/App.tsx +82 -0
  38. package/packages/example/src/assets/react.svg +1 -0
  39. package/packages/example/src/components/portal-content.tsx +33 -0
  40. package/packages/example/src/index.css +68 -0
  41. package/packages/example/src/main.tsx +13 -0
  42. package/packages/example/src/vite-env.d.ts +1 -0
  43. package/packages/example/tsconfig.json +25 -0
  44. package/packages/example/vite.config.ts +7 -0
  45. package/pnpm-workspace.yaml +3 -0
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,332 @@
1
+ body {
2
+ margin: 0;
3
+ padding: 0;
4
+ min-height: 100vh;
5
+ background: white;
6
+ font-family:
7
+ -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
8
+ display: flex;
9
+ justify-content: center;
10
+ align-items: flex-start;
11
+ padding-top: 2rem;
12
+ }
13
+
14
+ .app {
15
+ max-width: 900px;
16
+ padding: 3rem;
17
+ font-family: inherit;
18
+ }
19
+
20
+ h1 {
21
+ color: #2d3748;
22
+ text-align: center;
23
+ margin-bottom: 3rem;
24
+ font-size: 2.5rem;
25
+ font-weight: 700;
26
+ background: linear-gradient(135deg, #667eea, #764ba2);
27
+ -webkit-background-clip: text;
28
+ -webkit-text-fill-color: transparent;
29
+ background-clip: text;
30
+ }
31
+
32
+ h2 {
33
+ color: #4a5568;
34
+ margin-top: 2rem;
35
+ margin-bottom: 1rem;
36
+ font-size: 1.5rem;
37
+ font-weight: 600;
38
+ }
39
+
40
+ .controls {
41
+ display: flex;
42
+ gap: 1rem;
43
+ flex-wrap: wrap;
44
+ margin-top: 1.5rem;
45
+ margin-bottom: 3rem;
46
+ justify-content: center;
47
+ }
48
+
49
+ .controls button {
50
+ background: linear-gradient(135deg, #667eea, #764ba2);
51
+ color: white;
52
+ border: none;
53
+ padding: 1rem 2rem;
54
+ border-radius: 0.75rem;
55
+ cursor: pointer;
56
+ font-size: 1rem;
57
+ font-weight: 500;
58
+ box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
59
+ transition: all 0.3s ease;
60
+ position: relative;
61
+ overflow: hidden;
62
+ }
63
+
64
+ .controls button::before {
65
+ content: "";
66
+ position: absolute;
67
+ top: 0;
68
+ left: -100%;
69
+ width: 100%;
70
+ height: 100%;
71
+ background: linear-gradient(
72
+ 90deg,
73
+ transparent,
74
+ rgba(255, 255, 255, 0.2),
75
+ transparent
76
+ );
77
+ transition: left 0.5s;
78
+ }
79
+
80
+ .controls button:hover::before {
81
+ left: 100%;
82
+ }
83
+
84
+ .controls button:hover:not(:disabled) {
85
+ transform: translateY(-2px);
86
+ box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
87
+ }
88
+
89
+ .controls button:disabled {
90
+ background: linear-gradient(135deg, #a0aec0, #718096);
91
+ cursor: not-allowed;
92
+ transform: none;
93
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
94
+ }
95
+
96
+ .dynamic-anchor {
97
+ background: linear-gradient(145deg, #ffffff, #f7fafc);
98
+ border: 2px solid #667eea;
99
+ border-radius: 0.75rem;
100
+ padding: 1.5rem;
101
+ text-align: center;
102
+ font-weight: 600;
103
+ color: #2d3748;
104
+ position: relative;
105
+ margin: 1rem 0;
106
+ opacity: 0;
107
+ animation: anchorAppear 0.4s ease-out 0.2s forwards;
108
+ box-shadow: 0 4px 15px rgba(102, 126, 234, 0.1);
109
+ transition: all 0.3s ease;
110
+ }
111
+
112
+ .dynamic-anchor:hover {
113
+ transform: translateY(-2px);
114
+ box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
115
+ }
116
+
117
+ .portal-content {
118
+ padding: 1rem 1.5rem;
119
+ margin: 0.75rem 0;
120
+ border-radius: 0.75rem;
121
+ font-size: 0.95rem;
122
+ font-weight: 500;
123
+ border: 2px solid;
124
+ position: relative;
125
+ opacity: 0;
126
+ animation: portalAppear 0.4s ease-out 1s forwards;
127
+ box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
128
+ transition: all 0.3s ease;
129
+ }
130
+
131
+ .portal-content:hover {
132
+ transform: translateY(-2px);
133
+ box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
134
+ }
135
+
136
+ .portal-content.append {
137
+ background: linear-gradient(135deg, #d4edda, #c3e6cb);
138
+ border-color: #28a745;
139
+ color: #155724;
140
+ animation: portalAppearFromRight 0.4s ease-out 1s forwards;
141
+ }
142
+
143
+ .portal-content.prepend {
144
+ background: linear-gradient(135deg, #cce5ff, #b8daff);
145
+ border-color: #007bff;
146
+ color: #004085;
147
+ animation: portalAppearFromLeft 0.4s ease-out 1s forwards;
148
+ }
149
+
150
+ .portal-content.before {
151
+ background: linear-gradient(135deg, #fff3cd, #ffeaa7);
152
+ border-color: #ffc107;
153
+ color: #856404;
154
+ animation: portalAppearFromLeft 0.4s ease-out 1s forwards;
155
+ }
156
+
157
+ .portal-content.after {
158
+ background: linear-gradient(135deg, #f8d7da, #f1b0b7);
159
+ border-color: #dc3545;
160
+ color: #721c24;
161
+ animation: portalAppearFromRight 0.4s ease-out 1s forwards;
162
+ }
163
+
164
+ .portal-content.dynamic {
165
+ background-color: #ffeaa7;
166
+ border-color: #fdcb6e;
167
+ color: #6c5ce7;
168
+ font-weight: bold;
169
+ }
170
+
171
+ .portal-preview {
172
+ height: 400px;
173
+ display: flex;
174
+ flex-direction: column;
175
+ align-items: center;
176
+ justify-content: center;
177
+ border: 3px dashed #667eea;
178
+ border-radius: 1rem;
179
+ background: linear-gradient(145deg, #f7fafc, #edf2f7);
180
+ padding: 1.5rem;
181
+ position: relative;
182
+ overflow: hidden;
183
+ }
184
+
185
+ .portal-preview::after {
186
+ content: "";
187
+ position: absolute;
188
+ top: 0;
189
+ left: 0;
190
+ right: 0;
191
+ bottom: 0;
192
+ background: linear-gradient(
193
+ 45deg,
194
+ transparent 30%,
195
+ rgba(102, 126, 234, 0.03) 50%,
196
+ transparent 70%
197
+ );
198
+ pointer-events: none;
199
+ }
200
+
201
+ .portal-preview:empty::before {
202
+ content: "📍 Target anchor is hidden. Portal content will not appear.";
203
+ opacity: 0.8;
204
+ font-weight: 500;
205
+ color: #4a5568;
206
+ text-align: center;
207
+ font-size: 1.1rem;
208
+ }
209
+
210
+ .instructions {
211
+ margin-top: 2rem;
212
+ padding: 2.5rem;
213
+ background: linear-gradient(145deg, #f7fafc, #edf2f7);
214
+ border-radius: 1rem;
215
+ border: 1px solid rgba(102, 126, 234, 0.2);
216
+ box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
217
+ }
218
+
219
+ .instructions ul {
220
+ margin: 1rem 0;
221
+ padding-left: 2rem;
222
+ }
223
+
224
+ .instructions li {
225
+ margin: 0.5rem 0;
226
+ line-height: 1.5;
227
+ }
228
+
229
+ .instructions strong {
230
+ color: #646cff;
231
+ font-family: monospace;
232
+ background-color: #f1f3f4;
233
+ padding: 0.125rem 0.25rem;
234
+ border-radius: 0.25rem;
235
+ }
236
+
237
+ .instructions p {
238
+ margin-top: 1rem;
239
+ color: #6c757d;
240
+ font-style: italic;
241
+ }
242
+
243
+ /* Responsive design */
244
+ @media (max-width: 768px) {
245
+ .app {
246
+ padding: 1rem;
247
+ }
248
+
249
+ .controls {
250
+ flex-direction: column;
251
+ }
252
+
253
+ .controls button {
254
+ width: 100%;
255
+ }
256
+ }
257
+
258
+ /* Animation for anchor and portal content */
259
+ @keyframes anchorAppear {
260
+ from {
261
+ opacity: 0;
262
+ transform: translateY(-10px);
263
+ }
264
+ to {
265
+ opacity: 1;
266
+ transform: translateY(0);
267
+ }
268
+ }
269
+
270
+ @keyframes portalAppear {
271
+ from {
272
+ opacity: 0;
273
+ transform: translateY(-10px);
274
+ }
275
+ to {
276
+ opacity: 1;
277
+ transform: translateY(0);
278
+ }
279
+ }
280
+
281
+ @keyframes portalAppearFromLeft {
282
+ from {
283
+ opacity: 0;
284
+ transform: translateX(-30px);
285
+ }
286
+ to {
287
+ opacity: 1;
288
+ transform: translateX(0);
289
+ }
290
+ }
291
+
292
+ @keyframes portalAppearFromRight {
293
+ from {
294
+ opacity: 0;
295
+ transform: translateX(30px);
296
+ }
297
+ to {
298
+ opacity: 1;
299
+ transform: translateX(0);
300
+ }
301
+ }
302
+
303
+ /* Visual indicators for different positions */
304
+ .portal-content::before {
305
+ content: "Portal";
306
+ position: absolute;
307
+ top: -0.75rem;
308
+ left: 1rem;
309
+ background: linear-gradient(135deg, #667eea, #764ba2);
310
+ color: white;
311
+ padding: 0.25rem 0.75rem;
312
+ font-size: 0.75rem;
313
+ font-weight: 600;
314
+ border-radius: 1rem;
315
+ z-index: 1;
316
+ box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
317
+ }
318
+
319
+ .dynamic-anchor::before {
320
+ content: "Anchor";
321
+ position: absolute;
322
+ top: -0.75rem;
323
+ left: 1rem;
324
+ background: linear-gradient(135deg, #48bb78, #38a169);
325
+ color: white;
326
+ padding: 0.25rem 0.75rem;
327
+ font-size: 0.75rem;
328
+ font-weight: 600;
329
+ border-radius: 1rem;
330
+ z-index: 1;
331
+ box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
332
+ }
@@ -0,0 +1,82 @@
1
+ import { useState } from 'react'
2
+ import MagicPortal from 'react-magic-portal'
3
+ import PortalContent from './components/portal-content'
4
+ import './App.css'
5
+
6
+ function App() {
7
+ const [showAnchor, setShowAnchor] = useState(false)
8
+
9
+ const handleMount = (anchor: Element, portal: HTMLElement) => {
10
+ console.log('Portal mounted:', { anchor, portal })
11
+ }
12
+
13
+ const handleUnmount = (anchor: Element, portal: HTMLElement) => {
14
+ console.log('Portal unmounted:', { anchor, portal })
15
+ }
16
+
17
+ return (
18
+ <div className="app">
19
+ <h1>MagicPortal Example</h1>
20
+
21
+ <h2>Target Anchor</h2>
22
+ <div className="portal-preview">
23
+ {showAnchor && (
24
+ <div className="dynamic-anchor" id="dynamic-anchor">
25
+ Target Content
26
+ </div>
27
+ )}
28
+ </div>
29
+ <div className="controls">
30
+ <button onClick={() => setShowAnchor(!showAnchor)}>{showAnchor ? 'Hide Anchor' : 'Show Anchor'}</button>
31
+ </div>
32
+
33
+ {/* Target anchor examples */}
34
+ <MagicPortal anchor="#dynamic-anchor" position="append" onMount={handleMount} onUnmount={handleUnmount}>
35
+ <PortalContent position="append" />
36
+ </MagicPortal>
37
+
38
+ <MagicPortal anchor="#dynamic-anchor" position="prepend" onMount={handleMount} onUnmount={handleUnmount}>
39
+ <PortalContent position="prepend" />
40
+ </MagicPortal>
41
+
42
+ <MagicPortal anchor="#dynamic-anchor" position="before" onMount={handleMount} onUnmount={handleUnmount}>
43
+ <PortalContent position="before" />
44
+ </MagicPortal>
45
+
46
+ <MagicPortal anchor="#dynamic-anchor" position="after" onMount={handleMount} onUnmount={handleUnmount}>
47
+ <PortalContent position="after" />
48
+ </MagicPortal>
49
+
50
+ <h2>Instructions</h2>
51
+ <div className="instructions">
52
+ <ul>
53
+ <li>
54
+ <strong>append</strong>: Adds content inside the anchor element at the end
55
+ </li>
56
+ <li>
57
+ <strong>prepend</strong>: Adds content inside the anchor element at the beginning
58
+ </li>
59
+ <li>
60
+ <strong>before</strong>: Adds content as a sibling before the target anchor
61
+ </li>
62
+ <li>
63
+ <strong>after</strong>: Adds content as a sibling after the target anchor
64
+ </li>
65
+ </ul>
66
+
67
+ <p>
68
+ <strong>💡 Key Feature:</strong> Notice how MagicPortal automatically detects when the target anchor appears
69
+ or disappears. When you toggle the anchor visibility, the portal content automatically mounts and unmounts
70
+ without any manual intervention.
71
+ </p>
72
+
73
+ <p>
74
+ Open the browser console to see mount/unmount events. Try toggling the target anchor visibility to see how
75
+ MagicPortal responds to DOM changes in real-time.
76
+ </p>
77
+ </div>
78
+ </div>
79
+ )
80
+ }
81
+
82
+ export default App
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
@@ -0,0 +1,33 @@
1
+ import { useEffect } from 'react'
2
+
3
+ interface PortalContentProps {
4
+ position: string
5
+ }
6
+
7
+ function PortalContent({ position }: PortalContentProps) {
8
+ useEffect(() => {
9
+ console.log(`✅ ${position} Portal useEffect mounted`)
10
+ return () => {
11
+ console.log(`❌ ${position} Portal useEffect unmounted`)
12
+ }
13
+ }, [position])
14
+
15
+ const getContentText = () => {
16
+ switch (position) {
17
+ case 'append':
18
+ return 'Appended Content (inside target, at end)'
19
+ case 'prepend':
20
+ return 'Prepended Content (inside target, at beginning)'
21
+ case 'before':
22
+ return 'Before Content (sibling, before target)'
23
+ case 'after':
24
+ return 'After Content (sibling, after target)'
25
+ default:
26
+ return `${position} Content`
27
+ }
28
+ }
29
+
30
+ return <div className={`portal-content ${position}`}>{getContentText()}</div>
31
+ }
32
+
33
+ export default PortalContent
@@ -0,0 +1,68 @@
1
+ :root {
2
+ font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
3
+ line-height: 1.5;
4
+ font-weight: 400;
5
+
6
+ color-scheme: light dark;
7
+ color: rgba(255, 255, 255, 0.87);
8
+ background-color: #242424;
9
+
10
+ font-synthesis: none;
11
+ text-rendering: optimizeLegibility;
12
+ -webkit-font-smoothing: antialiased;
13
+ -moz-osx-font-smoothing: grayscale;
14
+ }
15
+
16
+ a {
17
+ font-weight: 500;
18
+ color: #646cff;
19
+ text-decoration: inherit;
20
+ }
21
+ a:hover {
22
+ color: #535bf2;
23
+ }
24
+
25
+ body {
26
+ margin: 0;
27
+ display: flex;
28
+ place-items: center;
29
+ min-width: 320px;
30
+ min-height: 100vh;
31
+ }
32
+
33
+ h1 {
34
+ font-size: 3.2em;
35
+ line-height: 1.1;
36
+ }
37
+
38
+ button {
39
+ border-radius: 8px;
40
+ border: 1px solid transparent;
41
+ padding: 0.6em 1.2em;
42
+ font-size: 1em;
43
+ font-weight: 500;
44
+ font-family: inherit;
45
+ background-color: #1a1a1a;
46
+ cursor: pointer;
47
+ transition: border-color 0.25s;
48
+ }
49
+ button:hover {
50
+ border-color: #646cff;
51
+ }
52
+ button:focus,
53
+ button:focus-visible {
54
+ outline: 4px auto -webkit-focus-ring-color;
55
+ }
56
+
57
+ @media (prefers-color-scheme: light) {
58
+ :root {
59
+ color: #213547;
60
+ background-color: #ffffff;
61
+ }
62
+ a:hover {
63
+ color: #747bff;
64
+ }
65
+ button {
66
+ background-color: #f9f9f9;
67
+ }
68
+ }
@@ -0,0 +1,13 @@
1
+ import { StrictMode } from 'react'
2
+ import { createRoot } from 'react-dom/client'
3
+ import './index.css'
4
+ import App from './App.tsx'
5
+
6
+ const rootElement = document.getElementById('root')
7
+ if (rootElement) {
8
+ createRoot(rootElement).render(
9
+ <StrictMode>
10
+ <App />
11
+ </StrictMode>
12
+ )
13
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "lib": ["ESNext", "DOM", "DOM.Iterable", "WebWorker"],
7
+ "skipLibCheck": true,
8
+
9
+ /* Bundler mode */
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "isolatedModules": true,
13
+ "moduleDetection": "force",
14
+ "noEmit": true,
15
+ "jsx": "react-jsx",
16
+
17
+ /* Linting */
18
+ "strict": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "noFallthroughCasesInSwitch": true,
22
+ "noUncheckedSideEffectImports": true
23
+ },
24
+ "include": ["src", "eslint.config.ts", "vite.config.ts"]
25
+ }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+
4
+ // https://vite.dev/config/
5
+ export default defineConfig({
6
+ plugins: [react()]
7
+ })
@@ -0,0 +1,3 @@
1
+ packages:
2
+ - "__tests__"
3
+ - "packages/*"