Spaces:
Running
Running
Upload from GitHub Actions: trying to fix figure again
Browse files- frontend/src/App.js +68 -45
frontend/src/App.js
CHANGED
|
@@ -23,6 +23,10 @@ function App () {
|
|
| 23 |
const [dialogVisible, setDialogVisible] = useState(false)
|
| 24 |
const [aboutVisible, setAboutVisible] = useState(false)
|
| 25 |
const [contributeVisible, setContributeVisible] = useState(false)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
useEffect(() => {
|
| 28 |
fetch('/api/data', {
|
|
@@ -46,8 +50,22 @@ function App () {
|
|
| 46 |
})
|
| 47 |
}, [selectedLanguages])
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
const [windowWidth, setWindowWidth] = useState(window.innerWidth)
|
| 50 |
const [windowHeight, setWindowHeight] = useState(window.innerHeight)
|
|
|
|
| 51 |
useEffect(() => {
|
| 52 |
const handleResize = () => {
|
| 53 |
setWindowWidth(window.innerWidth)
|
|
@@ -57,6 +75,40 @@ function App () {
|
|
| 57 |
return () => window.removeEventListener('resize', handleResize)
|
| 58 |
}, [])
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
return (
|
| 61 |
<PrimeReactProvider>
|
| 62 |
<div
|
|
@@ -266,21 +318,18 @@ function App () {
|
|
| 266 |
color: '#666'
|
| 267 |
}}
|
| 268 |
/>
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
activeIndex={0}
|
| 282 |
-
style={{ width: '100%', minHeight: '650px' }}
|
| 283 |
-
/>
|
| 284 |
</div>
|
| 285 |
</>
|
| 286 |
)}
|
|
@@ -428,37 +477,11 @@ function App () {
|
|
| 428 |
modal
|
| 429 |
header={null}
|
| 430 |
>
|
| 431 |
-
{
|
| 432 |
<div style={{ width: '100%', height: '100%' }}>
|
| 433 |
<Carousel
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
data={data.countries}
|
| 437 |
-
allLanguages={data.language_table}
|
| 438 |
-
width={windowWidth * 0.7}
|
| 439 |
-
height={windowHeight * 0.6}
|
| 440 |
-
/>,
|
| 441 |
-
<LanguagePlot
|
| 442 |
-
data={data}
|
| 443 |
-
width={windowWidth * 0.7}
|
| 444 |
-
height={windowHeight * 0.6}
|
| 445 |
-
/>,
|
| 446 |
-
<SpeakerPlot
|
| 447 |
-
data={data}
|
| 448 |
-
width={windowWidth * 0.7}
|
| 449 |
-
height={windowHeight * 0.6}
|
| 450 |
-
/>,
|
| 451 |
-
<HistoryPlot
|
| 452 |
-
data={data}
|
| 453 |
-
width={windowWidth * 0.7}
|
| 454 |
-
height={windowHeight * 0.6}
|
| 455 |
-
/>,
|
| 456 |
-
<CostPlot
|
| 457 |
-
data={data}
|
| 458 |
-
width={windowWidth * 0.7}
|
| 459 |
-
height={windowHeight * 0.6}
|
| 460 |
-
/>
|
| 461 |
-
]}
|
| 462 |
numScroll={1}
|
| 463 |
numVisible={1}
|
| 464 |
itemTemplate={item => item}
|
|
@@ -474,4 +497,4 @@ function App () {
|
|
| 474 |
)
|
| 475 |
}
|
| 476 |
|
| 477 |
-
export default App
|
|
|
|
| 23 |
const [dialogVisible, setDialogVisible] = useState(false)
|
| 24 |
const [aboutVisible, setAboutVisible] = useState(false)
|
| 25 |
const [contributeVisible, setContributeVisible] = useState(false)
|
| 26 |
+
|
| 27 |
+
// Add state for carousel items
|
| 28 |
+
const [carouselItems, setCarouselItems] = useState([])
|
| 29 |
+
const [fullScreenCarouselItems, setFullScreenCarouselItems] = useState([])
|
| 30 |
|
| 31 |
useEffect(() => {
|
| 32 |
fetch('/api/data', {
|
|
|
|
| 50 |
})
|
| 51 |
}, [selectedLanguages])
|
| 52 |
|
| 53 |
+
// Create carousel items when data is loaded
|
| 54 |
+
useEffect(() => {
|
| 55 |
+
if (data) {
|
| 56 |
+
setCarouselItems([
|
| 57 |
+
<WorldMap key="0" data={data.countries} allLanguages={data.language_table} width={750} height={500} />,
|
| 58 |
+
<LanguagePlot key="1" data={data} width={750} height={500} />,
|
| 59 |
+
<SpeakerPlot key="2" data={data} width={750} height={500} />,
|
| 60 |
+
<HistoryPlot key="3" data={data} width={750} height={500} />,
|
| 61 |
+
<CostPlot key="4" data={data} width={750} height={500} />
|
| 62 |
+
]);
|
| 63 |
+
}
|
| 64 |
+
}, [data])
|
| 65 |
+
|
| 66 |
const [windowWidth, setWindowWidth] = useState(window.innerWidth)
|
| 67 |
const [windowHeight, setWindowHeight] = useState(window.innerHeight)
|
| 68 |
+
|
| 69 |
useEffect(() => {
|
| 70 |
const handleResize = () => {
|
| 71 |
setWindowWidth(window.innerWidth)
|
|
|
|
| 75 |
return () => window.removeEventListener('resize', handleResize)
|
| 76 |
}, [])
|
| 77 |
|
| 78 |
+
// Create full-screen carousel items when data or window size changes
|
| 79 |
+
useEffect(() => {
|
| 80 |
+
if (data) {
|
| 81 |
+
setFullScreenCarouselItems([
|
| 82 |
+
<WorldMap
|
| 83 |
+
key="fs-0"
|
| 84 |
+
data={data.countries}
|
| 85 |
+
allLanguages={data.language_table}
|
| 86 |
+
width={windowWidth * 0.7}
|
| 87 |
+
height={windowHeight * 0.6}
|
| 88 |
+
/>,
|
| 89 |
+
<LanguagePlot
|
| 90 |
+
key="fs-1"
|
| 91 |
+
data={data}
|
| 92 |
+
width={windowWidth * 0.7}
|
| 93 |
+
height={windowHeight * 0.6}
|
| 94 |
+
/>,
|
| 95 |
+
<SpeakerPlot
|
| 96 |
+
key="fs-2"
|
| 97 |
+
data={data}
|
| 98 |
+
width={windowWidth * 0.7}
|
| 99 |
+
height={windowHeight * 0.6}
|
| 100 |
+
/>,
|
| 101 |
+
<HistoryPlot
|
| 102 |
+
key="fs-3"
|
| 103 |
+
data={data}
|
| 104 |
+
width={windowWidth * 0.7}
|
| 105 |
+
height={windowHeight * 0.6}
|
| 106 |
+
/>,
|
| 107 |
+
<CostPlot key="fs-4" data={data} width={windowWidth * 0.7} height={windowHeight * 0.6} />
|
| 108 |
+
]);
|
| 109 |
+
}
|
| 110 |
+
}, [data, windowWidth, windowHeight])
|
| 111 |
+
|
| 112 |
return (
|
| 113 |
<PrimeReactProvider>
|
| 114 |
<div
|
|
|
|
| 318 |
color: '#666'
|
| 319 |
}}
|
| 320 |
/>
|
| 321 |
+
{carouselItems.length > 0 && (
|
| 322 |
+
<Carousel
|
| 323 |
+
key={`carousel-${data ? 'loaded' : 'loading'}`}
|
| 324 |
+
value={carouselItems}
|
| 325 |
+
numScroll={1}
|
| 326 |
+
numVisible={1}
|
| 327 |
+
itemTemplate={item => item}
|
| 328 |
+
circular
|
| 329 |
+
activeIndex={0}
|
| 330 |
+
style={{ width: '100%', minHeight: '650px' }}
|
| 331 |
+
/>
|
| 332 |
+
)}
|
|
|
|
|
|
|
|
|
|
| 333 |
</div>
|
| 334 |
</>
|
| 335 |
)}
|
|
|
|
| 477 |
modal
|
| 478 |
header={null}
|
| 479 |
>
|
| 480 |
+
{fullScreenCarouselItems.length > 0 && (
|
| 481 |
<div style={{ width: '100%', height: '100%' }}>
|
| 482 |
<Carousel
|
| 483 |
+
key={`fs-carousel-${data ? 'loaded' : 'loading'}`}
|
| 484 |
+
value={fullScreenCarouselItems}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 485 |
numScroll={1}
|
| 486 |
numVisible={1}
|
| 487 |
itemTemplate={item => item}
|
|
|
|
| 497 |
)
|
| 498 |
}
|
| 499 |
|
| 500 |
+
export default App
|