Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: redesign accordions of fcs and ipc #138

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 31 additions & 12 deletions src/components/Cards/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
'use client';

import { Card, CardBody, CardHeader, Image } from '@nextui-org/react';
import { Card, CardBody } from '@nextui-org/react';
import React from 'react';
import { v4 as uuid } from 'uuid';

import { CardProps } from '@/domain/props/CardProps';

export default function CustomCard({ title, content }: CardProps) {
return (
<Card className="w-fit h-auto min-w-[210px] justify-evenly m-2.5 dark:primary white:bg-white">
<CardHeader className="flex flex-col items-center p-[5px] overflow-visible">
<h2 className="text-large break-words text-pretty"> {title} </h2>
</CardHeader>
<Card className="w-fit h-auto min-w-[200px] justify-evenly m-2.5 dark:primary white:bg-white">
<CardBody className="flex flex-col items-center justify-center overflow-visible overflow-y-auto max-h-[300px] py-2">
<div className="flex flex-row gap-6 overflow-y-auto">
<div className="flex flex-row flex-wrap gap-6 overflow-y-auto">
{content.map((item) => (
<div key={uuid()} className="flex flex-col gap-1 items-center">
<div key={uuid()} className="flex flex-row gap-4 items-start">
{item.svgIcon ? (

Check warning on line 16 in src/components/Cards/Card.tsx

View workflow job for this annotation

GitHub Actions / lint-and-format

Do not nest ternary expressions
<div className="svg-icon w-[90px]">{item.svgIcon}</div>
) : (
<Image alt={item.altText} className="w-[102px] h-[75px]" src={item.imageSrc} />
<div className="svg-icon w-[70px] h-[70px] object-contain">{item.svgIcon}</div>
) : item.imageSrc ? (
<img alt={item.altText || ''} className="w-[70px] h-[70px] -mt-4" src={item.imageSrc} />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use next Image

) : null}
<div className="flex flex-col">
{title && <h2 className="text-lg text-center">{title}</h2>}
{item.text && <h2 className={`text-center ${item.textClass || 'text-xs'}`}>{item.text}</h2>}
{item.value && (
<p className="text-sm/[2rem] text-center">
{typeof item.value === 'number' ? `${item.value.toFixed(2)} M` : item.value || 'N/A'}
</p>
)}
</div>
{/* Additional Content (Time-based data) */}
{item.changeValues && (
<div className="flex flex-row space-x-3">
{item.changeValues.map((delta) => (
<div key={uuid()} className="flex flex-col items-center gap-2">
<img src={delta.imageSrc} alt={delta.altText} className="w-6 h-6" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next Image

<div className="text-center">
<p className="text-sm font-medium whitespace-nowrap">{delta.text}</p>
<p className="text-xs text-gray-600">{delta.timeText}</p>
</div>
</div>
))}
</div>
)}
<h1 className="text-base text-center mt-2">{item.text}</h1>
{item.timeText && <h1 className="text-xs text-[#888888] text-center break-words">{item.timeText}</h1>}
</div>
))}
</div>
Expand Down
199 changes: 0 additions & 199 deletions src/components/Map/FcsAccordion.tsx

This file was deleted.

43 changes: 43 additions & 0 deletions src/components/Map/FcsMap/FcsAccordion.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import FcsAccordionProps from '@/domain/props/FcsAccordionProps';
import { useMediaQuery } from '@/utils/resolution.ts';

import AccordionContainer from '../../Accordions/AccordionContainer';
import FcsFoodSecurityAccordion from './FcsFoodSecurityAccordion';
import FcsMacroEconomicAccordion from './FcsMacroEconomicAccordion';

export default function FcsAccordion({ countryData, loading, countryIso3Data, countryName }: FcsAccordionProps) {
const isMobile = useMediaQuery('(max-width: 700px)');
const foodSecurityAccordion = FcsFoodSecurityAccordion({ countryData });
const macroEconomicAccordion = FcsMacroEconomicAccordion({ countryData, countryIso3Data });

return (
<>
{!isMobile ? (
bohdangarchu marked this conversation as resolved.
Show resolved Hide resolved
<div className="absolute w-[370px] left-[108px] top-4 z-9999">
<AccordionContainer
bohdangarchu marked this conversation as resolved.
Show resolved Hide resolved
loading={loading}
title={countryName ?? undefined}
bohdangarchu marked this conversation as resolved.
Show resolved Hide resolved
accordionModalActive
maxWidth={600}
items={foodSecurityAccordion}
/>
</div>
) : (
<div className="absolute w-[350px] left-[108px] top-4 z-9999">
<AccordionContainer
loading={loading}
title={countryName ?? undefined}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

accordionModalActive
maxWidth={600}
items={[...foodSecurityAccordion, ...macroEconomicAccordion]}
/>
</div>
)}
{!isMobile && (
<div className="absolute w-[370px] right-[1rem] inset-y-20 z-9999">
<AccordionContainer loading={loading} accordionModalActive maxWidth={600} items={macroEconomicAccordion} />
</div>
)}
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import FcsChoroplethProps from '@/domain/props/FcsChoroplethProps';
import FcsChoroplethOperations from '@/operations/map/FcsChoroplethOperations';
import { MapOperations } from '@/operations/map/MapOperations';

import CountryLoadingLayer from './CountryLoading';
import CountryLoadingLayer from '../CountryLoading';
import FscCountryChoropleth from './FcsCountryChoropleth';

export default function FcsChoropleth({
Expand Down
Loading
Loading