Spaces:
Running
Running
Upload from GitHub Actions: Merge pull request #14 from datenlabor-bmz/jn-dev
Browse files- frontend/src/App.js +117 -59
frontend/src/App.js
CHANGED
|
@@ -53,13 +53,18 @@ function App () {
|
|
| 53 |
// Create carousel items when data is loaded
|
| 54 |
useEffect(() => {
|
| 55 |
if (data) {
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
}
|
| 64 |
}, [data])
|
| 65 |
|
|
@@ -78,34 +83,38 @@ function App () {
|
|
| 78 |
// Create full-screen carousel items when data or window size changes
|
| 79 |
useEffect(() => {
|
| 80 |
if (data) {
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
}
|
| 110 |
}, [data, windowWidth, windowHeight])
|
| 111 |
|
|
@@ -218,39 +227,88 @@ function App () {
|
|
| 218 |
<div
|
| 219 |
style={{
|
| 220 |
display: 'flex',
|
| 221 |
-
gap: '
|
| 222 |
-
marginBottom: '
|
| 223 |
flexWrap: 'wrap',
|
| 224 |
justifyContent: 'center'
|
| 225 |
}}
|
| 226 |
>
|
| 227 |
-
<
|
| 228 |
-
label='π About this tool'
|
| 229 |
-
className='p-button-text'
|
| 230 |
onClick={() => setAboutVisible(true)}
|
| 231 |
style={{
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
}}
|
| 238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
|
| 240 |
-
<
|
| 241 |
-
label='π Add your model (soon)'
|
| 242 |
-
className='p-button-text'
|
| 243 |
onClick={() => setContributeVisible(true)}
|
| 244 |
-
|
| 245 |
-
tooltipOptions={{ position: 'bottom' }}
|
| 246 |
style={{
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
}}
|
| 253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
</div>
|
| 255 |
|
| 256 |
{data && (
|
|
@@ -320,7 +378,7 @@ function App () {
|
|
| 320 |
/>
|
| 321 |
{carouselItems.length > 0 && (
|
| 322 |
<Carousel
|
| 323 |
-
key={`carousel-${
|
| 324 |
value={carouselItems}
|
| 325 |
numScroll={1}
|
| 326 |
numVisible={1}
|
|
@@ -480,7 +538,7 @@ function App () {
|
|
| 480 |
{fullScreenCarouselItems.length > 0 && (
|
| 481 |
<div style={{ width: '100%', height: '100%' }}>
|
| 482 |
<Carousel
|
| 483 |
-
key={`fs-carousel-${
|
| 484 |
value={fullScreenCarouselItems}
|
| 485 |
numScroll={1}
|
| 486 |
numVisible={1}
|
|
|
|
| 53 |
// Create carousel items when data is loaded
|
| 54 |
useEffect(() => {
|
| 55 |
if (data) {
|
| 56 |
+
// Add a small delay to ensure components are ready
|
| 57 |
+
const timer = setTimeout(() => {
|
| 58 |
+
setCarouselItems([
|
| 59 |
+
<WorldMap key="worldmap-0" data={data.countries} allLanguages={data.language_table} width={750} height={500} />,
|
| 60 |
+
<LanguagePlot key="langplot-1" data={data} width={750} height={500} />,
|
| 61 |
+
<SpeakerPlot key="speakerplot-2" data={data} width={750} height={500} />,
|
| 62 |
+
<HistoryPlot key="histplot-3" data={data} width={750} height={500} />,
|
| 63 |
+
<CostPlot key="costplot-4" data={data} width={750} height={500} />
|
| 64 |
+
]);
|
| 65 |
+
}, 100);
|
| 66 |
+
|
| 67 |
+
return () => clearTimeout(timer);
|
| 68 |
}
|
| 69 |
}, [data])
|
| 70 |
|
|
|
|
| 83 |
// Create full-screen carousel items when data or window size changes
|
| 84 |
useEffect(() => {
|
| 85 |
if (data) {
|
| 86 |
+
const timer = setTimeout(() => {
|
| 87 |
+
setFullScreenCarouselItems([
|
| 88 |
+
<WorldMap
|
| 89 |
+
key="fs-worldmap-0"
|
| 90 |
+
data={data.countries}
|
| 91 |
+
allLanguages={data.language_table}
|
| 92 |
+
width={windowWidth * 0.7}
|
| 93 |
+
height={windowHeight * 0.6}
|
| 94 |
+
/>,
|
| 95 |
+
<LanguagePlot
|
| 96 |
+
key="fs-langplot-1"
|
| 97 |
+
data={data}
|
| 98 |
+
width={windowWidth * 0.7}
|
| 99 |
+
height={windowHeight * 0.6}
|
| 100 |
+
/>,
|
| 101 |
+
<SpeakerPlot
|
| 102 |
+
key="fs-speakerplot-2"
|
| 103 |
+
data={data}
|
| 104 |
+
width={windowWidth * 0.7}
|
| 105 |
+
height={windowHeight * 0.6}
|
| 106 |
+
/>,
|
| 107 |
+
<HistoryPlot
|
| 108 |
+
key="fs-histplot-3"
|
| 109 |
+
data={data}
|
| 110 |
+
width={windowWidth * 0.7}
|
| 111 |
+
height={windowHeight * 0.6}
|
| 112 |
+
/>,
|
| 113 |
+
<CostPlot key="fs-costplot-4" data={data} width={windowWidth * 0.7} height={windowHeight * 0.6} />
|
| 114 |
+
]);
|
| 115 |
+
}, 100);
|
| 116 |
+
|
| 117 |
+
return () => clearTimeout(timer);
|
| 118 |
}
|
| 119 |
}, [data, windowWidth, windowHeight])
|
| 120 |
|
|
|
|
| 227 |
<div
|
| 228 |
style={{
|
| 229 |
display: 'flex',
|
| 230 |
+
gap: '0.75rem',
|
| 231 |
+
marginBottom: '2rem',
|
| 232 |
flexWrap: 'wrap',
|
| 233 |
justifyContent: 'center'
|
| 234 |
}}
|
| 235 |
>
|
| 236 |
+
<button
|
|
|
|
|
|
|
| 237 |
onClick={() => setAboutVisible(true)}
|
| 238 |
style={{
|
| 239 |
+
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
|
| 240 |
+
color: 'white',
|
| 241 |
+
border: 'none',
|
| 242 |
+
padding: '0.75rem 1.5rem',
|
| 243 |
+
borderRadius: '12px',
|
| 244 |
+
fontSize: '0.95rem',
|
| 245 |
+
fontWeight: '500',
|
| 246 |
+
cursor: 'pointer',
|
| 247 |
+
display: 'flex',
|
| 248 |
+
alignItems: 'center',
|
| 249 |
+
gap: '0.5rem',
|
| 250 |
+
boxShadow: '0 4px 15px rgba(102, 126, 234, 0.25)',
|
| 251 |
+
transition: 'all 0.3s ease',
|
| 252 |
+
':hover': {
|
| 253 |
+
transform: 'translateY(-2px)',
|
| 254 |
+
boxShadow: '0 8px 25px rgba(102, 126, 234, 0.35)'
|
| 255 |
+
}
|
| 256 |
}}
|
| 257 |
+
onMouseEnter={(e) => {
|
| 258 |
+
e.target.style.transform = 'translateY(-2px)';
|
| 259 |
+
e.target.style.boxShadow = '0 8px 25px rgba(102, 126, 234, 0.35)';
|
| 260 |
+
}}
|
| 261 |
+
onMouseLeave={(e) => {
|
| 262 |
+
e.target.style.transform = 'translateY(0)';
|
| 263 |
+
e.target.style.boxShadow = '0 4px 15px rgba(102, 126, 234, 0.25)';
|
| 264 |
+
}}
|
| 265 |
+
>
|
| 266 |
+
<span style={{ fontSize: '1.1rem' }}>π</span>
|
| 267 |
+
About this tool
|
| 268 |
+
</button>
|
| 269 |
|
| 270 |
+
<button
|
|
|
|
|
|
|
| 271 |
onClick={() => setContributeVisible(true)}
|
| 272 |
+
title='This feature is on our roadmap and will be available soon.'
|
|
|
|
| 273 |
style={{
|
| 274 |
+
background: 'linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%)',
|
| 275 |
+
color: '#6b46c1',
|
| 276 |
+
border: 'none',
|
| 277 |
+
padding: '0.75rem 1.5rem',
|
| 278 |
+
borderRadius: '12px',
|
| 279 |
+
fontSize: '0.95rem',
|
| 280 |
+
fontWeight: '500',
|
| 281 |
+
cursor: 'pointer',
|
| 282 |
+
display: 'flex',
|
| 283 |
+
alignItems: 'center',
|
| 284 |
+
gap: '0.5rem',
|
| 285 |
+
boxShadow: '0 4px 15px rgba(255, 154, 158, 0.25)',
|
| 286 |
+
transition: 'all 0.3s ease',
|
| 287 |
+
position: 'relative',
|
| 288 |
+
overflow: 'hidden'
|
| 289 |
}}
|
| 290 |
+
onMouseEnter={(e) => {
|
| 291 |
+
e.target.style.transform = 'translateY(-2px)';
|
| 292 |
+
e.target.style.boxShadow = '0 8px 25px rgba(255, 154, 158, 0.35)';
|
| 293 |
+
}}
|
| 294 |
+
onMouseLeave={(e) => {
|
| 295 |
+
e.target.style.transform = 'translateY(0)';
|
| 296 |
+
e.target.style.boxShadow = '0 4px 15px rgba(255, 154, 158, 0.25)';
|
| 297 |
+
}}
|
| 298 |
+
>
|
| 299 |
+
<span style={{ fontSize: '1.1rem' }}>π</span>
|
| 300 |
+
Add your model
|
| 301 |
+
<span style={{
|
| 302 |
+
fontSize: '0.75rem',
|
| 303 |
+
backgroundColor: 'rgba(107, 70, 193, 0.15)',
|
| 304 |
+
padding: '0.2rem 0.5rem',
|
| 305 |
+
borderRadius: '6px',
|
| 306 |
+
marginLeft: '0.5rem',
|
| 307 |
+
fontWeight: '600'
|
| 308 |
+
}}>
|
| 309 |
+
soon
|
| 310 |
+
</span>
|
| 311 |
+
</button>
|
| 312 |
</div>
|
| 313 |
|
| 314 |
{data && (
|
|
|
|
| 378 |
/>
|
| 379 |
{carouselItems.length > 0 && (
|
| 380 |
<Carousel
|
| 381 |
+
key={`main-carousel-${carouselItems.length}-${Date.now()}`}
|
| 382 |
value={carouselItems}
|
| 383 |
numScroll={1}
|
| 384 |
numVisible={1}
|
|
|
|
| 538 |
{fullScreenCarouselItems.length > 0 && (
|
| 539 |
<div style={{ width: '100%', height: '100%' }}>
|
| 540 |
<Carousel
|
| 541 |
+
key={`fs-carousel-${fullScreenCarouselItems.length}-${Date.now()}`}
|
| 542 |
value={fullScreenCarouselItems}
|
| 543 |
numScroll={1}
|
| 544 |
numVisible={1}
|