Skip to content

Commit 88e7da1

Browse files
authored
Merge pull request #48 from xeptagondev/update_staging_undp
Update staging undp
2 parents 3c719f0 + b8657f4 commit 88e7da1

File tree

4 files changed

+84
-26
lines changed

4 files changed

+84
-26
lines changed

ui/components/indicator-list.tsx

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Pillar } from "database/ancillary";
22
import { Score } from "database/processed/db";
33
import { roundNumber } from "lib";
4-
import { FaLink, FaSourcetree } from "react-icons/fa";
4+
import { useState } from "react";
5+
import { FaLink } from "react-icons/fa";
56
import useSWR from "swr";
67

78
interface IndicatorListProps {
@@ -178,19 +179,62 @@ const Indicator = ({
178179
year: indicator["Year"],
179180
}))
180181
.filter((indicator) => indicator.source && indicator.link);
181-
const value = +(isShowingRawScores
182-
? indicator.data_col
183-
: indicator.new_rank_score);
184-
const disp_val = (value==0 ? 0 : roundNumber(value,2));
182+
const value = +(isShowingRawScores
183+
? indicator.data_col
184+
: indicator.new_rank_score);
185+
const disp_val = value == 0 ? 0 : roundNumber(value, 2);
186+
const [isHovered, setIsHovered] = useState(false);
187+
188+
const renderValue = () => {
189+
if (isShowingRawScores && indicator.raw_data_col) {
190+
const number = parseFloat(indicator.raw_data_col);
191+
if (!isNaN(number)) {
192+
return number;
193+
}
194+
if (indicator.raw_data_col.length > 3) {
195+
return (
196+
<span
197+
onMouseEnter={() => setIsHovered(true)}
198+
onMouseLeave={() => setIsHovered(false)}
199+
>
200+
{indicator.raw_data_col.substring(0, 3)}...
201+
</span>
202+
);
203+
} else {
204+
return indicator.raw_data_col;
205+
}
206+
} else {
207+
return hasNoData ? "Data unavailable" : disp_val;
208+
}
209+
};
210+
211+
const getWidthClass = () => {
212+
if (indicator.raw_data_col.length <= 7) {
213+
return "w-auto";
214+
}
215+
if (indicator.raw_data_col.length < 20) {
216+
return "sm:w-40 md:w-70 lg:w-128";
217+
}
218+
return "sm:w-80 md:w-80 lg:w-128";
219+
};
220+
185221
return (
186222
<li className={hasNoData ? "text-slate-500" : ""}>
187223
<div className="flex items-center justify-between">
188224
<span className="text-sm">{indicator.Indicator}</span>
189-
<span className="font-mono text-xs ml-4 flex-shrink-0">
190-
{hasNoData ? "Data unavailable" : disp_val}
225+
<span className="font-mono text-xs ml-4 flex-shrink-0 relative">
226+
{renderValue()}
227+
{isHovered && (
228+
<div
229+
className={`absolute right-0 text-center bottom-full mb-2 bg-white shadow-lg border border-gray-200 z-50
230+
${getWidthClass()} p-2`}
231+
>
232+
{indicator.raw_data_col}
233+
</div>
234+
)}
191235
</span>
192236
</div>
193-
{isShowingRawScores && indicator.raw_data_col && (
237+
{/* {isShowingRawScores && indicator.raw_data_col && (
194238
<ul className="mt-1 mb-2 divide-y-1">
195239
<li className="text-slate-600 text-xs mb-3">
196240
<div className="group flex items-center">
@@ -199,7 +243,7 @@ const Indicator = ({
199243
</div>
200244
</li>
201245
</ul>
202-
)}
246+
)} */}
203247
{/* {isShowingRawScores && !indicator.raw_data_col && (
204248
<ul className="mt-1 mb-2 divide-y-1">
205249
<li className="text-slate-600 text-xs mb-3">
@@ -238,4 +282,4 @@ const Indicator = ({
238282
)}
239283
</li>
240284
);
241-
};
285+
};

ui/components/score-ring.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,14 @@ export const ScoreRing = ({
300300
innerRingR[0] + r * 0.1
301301
);
302302
iconPosition[1] -= height / 2;
303-
303+
const pillarsName = pillar == "Digital Public Infrastructure" ? "DPI" : pillar;
304304
return (
305305
<g key={`${pillar}-${index}`}>
306306
<g className="text-sm">
307307
<CircleText
308308
id={`name-${pillar}`}
309309
rotate={midAngle / (Math.PI / 180)}
310-
text={pillar as string}
310+
text={pillarsName as string}
311311
r={innerRingR[1] - r * 0.05}
312312
stroke="white"
313313
strokeWidth={4}
@@ -316,7 +316,7 @@ export const ScoreRing = ({
316316
<CircleText
317317
id={`name-${pillar}`}
318318
rotate={midAngle / (Math.PI / 180)}
319-
text={pillar as string}
319+
text={pillarsName as string}
320320
r={innerRingR[1] - r * 0.05}
321321
fill={color}
322322
className="hidden md:block"
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Pillar,ColorBase,ColorTriple1,ColorTriple2,ColorTriple3,colorMap
22
Overall,#6366f1,"#FFF", "#a2e0f5", "#6366f1","stroke-pillar-overall"
3-
People,#4C9F38,"#FFF", "#9ebcf7", "#0d88e0", "stroke-pillar-people"
4-
Connectivity,#FD6925,"#FFF", "#a2e0f5", "#517Ce8","stroke-pillar-connectivity"
5-
Government,#19486A,"#FFF", "#e7ff87", "#02965d","stroke-pillar-government"
6-
Regulation,#0A97D9,"#FFF", "#ffd796", "#ed4b00","stroke-pillar-regulation"
7-
Economy,#A21942,"#FFF", "#fff566", "#eDa700","stroke-pillar-economy"
3+
People,#4C9F38,"#FFF", "#79ed8a", "#4C9F38", "stroke-pillar-people"
4+
Connectivity,#FD6925,"#FFF", "#edc26d", "#FD6925","stroke-pillar-connectivity"
5+
Government,#19486A,"#FFF", "#54deeb", "#19486A","stroke-pillar-government"
6+
Regulation,#0A97D9,"#FFF", "#12c0c9", "#0A97D9","stroke-pillar-regulation"
7+
Economy,#A21942,"#FFF", "#d67240", "#A21942","stroke-pillar-economy"
88
"Digital Public Infrastructure","#DE1568","#FFF", "#ffab8a", "#DE1568","stroke-pillar-dpinfrastructure"

ui/pages/popupmessage.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from "react";
1+
import React, { useState, useEffect } from "react";
22
import Image from "next/image";
33
import LogoSVG from "../public/undp-logo.svg";
44

@@ -22,15 +22,22 @@ const slides = [
2222
},
2323
{
2424
content: "<b>Elevated User Experience:</b> Enjoy a smoother experience! We've revamped the DDC's visualizations and usability for a more intuitive and informative exploration.",
25-
content1: "We're confident these improvements will make the DDC an even more valuable tool for navigating the ever-evolving digital landscape."
25+
content1: "We're confident these improvements will make the DDC an even more valuable tool for navigating the ever-evolving digital landscape. Stay tuned for further updates!"
2626
},
2727
// Add more slides as needed
2828
];
2929

3030
const PopupMessage = () => {
31-
const [isOpen, setIsOpen] = useState(true);
32-
const [currentPage, setCurrentPage] = useState(0); // Change to index-based state (starting from 0)
33-
const totalPages = slides.length; // Set total pages based on slides length
31+
const [isOpen, setIsOpen] = useState(false);
32+
const [currentPage, setCurrentPage] = useState(0);
33+
const totalPages = slides.length;
34+
35+
useEffect(() => {
36+
const hasSeenPopup = localStorage.getItem('hasSeenPopup');
37+
if (!hasSeenPopup) {
38+
setIsOpen(true);
39+
}
40+
}, []);
3441

3542
const handleNext = () => {
3643
if (currentPage < totalPages - 1) {
@@ -44,6 +51,11 @@ const PopupMessage = () => {
4451
}
4552
};
4653

54+
const handleClose = () => {
55+
setIsOpen(false);
56+
localStorage.setItem('hasSeenPopup', 'true'); // Store the flag in localStorage
57+
};
58+
4759
return (
4860
<div
4961
className={`fixed z-50 top-20 right-3 sm:right-0 sm:top-25 mt-4 mr-4 ${
@@ -62,7 +74,7 @@ const PopupMessage = () => {
6274
<h2 className="ml-1 text-lg">Digital Development Compass</h2>
6375
</div>
6476
<button
65-
onClick={() => setIsOpen(false)}
77+
onClick={handleClose}
6678
className="text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-gray-500 rounded"
6779
>
6880
<span className="text-2xl">&times;</span> {/* Unicode cross character */}
@@ -72,23 +84,25 @@ const PopupMessage = () => {
7284
<h1 className="text-2xl font-bold">
7385
{slides[currentPage].title}
7486
</h1>
75-
<h1 className="text-xl">
87+
<h1 className="text-lg">
7688
{slides[currentPage].title1}
7789
</h1>
78-
<div className="text-gray-600" dangerouslySetInnerHTML={{ __html: slides[currentPage].content }} />
90+
<div className="text-gray-600 pt-1" dangerouslySetInnerHTML={{ __html: slides[currentPage].content }} />
7991
<div className="text-gray-600 pt-3" dangerouslySetInnerHTML={{ __html: slides[currentPage].content1 || "" }} />
8092
</div>
8193
<div className="px-4 py-4 sm:px-6 flex justify-between items-center border-t">
8294
<button
8395
onClick={handleBack}
8496
className="text-gray-800 hover:bg-gray-200 font-bold py-2 px-4 rounded-l focus:outline-none focus:ring-2 focus:ring-gray-300"
97+
disabled={currentPage === 0}
8598
>
8699
Back
87100
</button>
88101
<span className="text-sm text-gray-600">{`${currentPage + 1} of ${totalPages}`}</span>
89102
<button
90103
onClick={handleNext}
91104
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 focus:outline-none focus:ring-2 focus:ring-blue-500"
105+
disabled={currentPage === totalPages - 1}
92106
>
93107
Next
94108
</button>

0 commit comments

Comments
 (0)