// src/components/ScreenSecond/index.tsx import styled from "styled-components"; import fallbackLogo from "imgs/logo.svg"; import arrowTop from "imgs/arrow_top.svg"; import { s_f_Text18_400, s_Text18_400 as Text18_400, s_Text24_700 as Text24_700, s_Text40_700 as Text40_700, s_Text14_400 as Text14_400, } from "../Typography"; import { useSingleton } from "cms/factory"; import { AsyncReveal } from "../AsyncReveal"; /* ===================== TYPES & GQL ===================== */ type Row = { id: string; value: string; label: string; trend: "none" | "up" | "down"; order: number; }; type Section = { id: string; title?: string | null; description?: string | null; logo?: { url?: string | null } | null; footnote?: string | null; rows: Row[]; }; const SELECTION = ` id title description logo { url } footnote rows(orderBy: { order: asc }) { id value label trend order } `; /* ===================== UTILS ===================== */ function chunkInto(arr: T[], size: number): T[][] { const out: T[][] = []; for (let i = 0; i < arr.length; i += size) out.push(arr.slice(i, i + size)); return out; } /* ===================== STYLES ===================== */ const ScreenSecondBlock = styled.div` width: 100%; max-width: 1380px; padding: 64px 10px; margin: 0 auto; display: flex; justify-content: center; @media (max-width: 768px) { padding: 10px 10px; } `; const ContentCard = styled.div` width: 90%; max-width: 1200px; background: #fff; border-radius: 16px; padding: 64px 0; padding-bottom: 0; display: flex; flex-direction: column; @media (max-width: 768px) { width: 100%; padding: 10px 10px; } `; const HeaderRow = styled.div` display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; @media (max-width: 768px) { flex-direction: column-reverse; align-items: flex-start; gap: 0; } `; const TitleRow = styled.div` display: inline; font-size: 0; /* убираем промежутки у inline-children */ `; const TitleBlock = styled.div` max-width: 720px; display: flex; flex-direction: column; `; const LogoBlock = styled.div` display: flex; align-items: center; height: 100%; margin-left: 30px; img { min-width: 185px; height: 56px; min-height: 56px; } @media (max-width: 768px) { width: 100%; justify-content: center; margin-left: 0; margin-bottom: 32px; } `; const FinanceRow = styled.div` display: flex; justify-content: space-between; text-align: center; margin: 24px 0; @media (max-width: 768px) { flex-direction: row; gap: 16px; } `; const FinanceBlock = styled.div` flex: 1; display: flex; flex-direction: column; align-items: center; @media (max-width: 768px) { width: 100%; } `; const ValueRow = styled.div` display: flex; align-items: center; gap: 8px; padding-bottom: 8px; `; const Divider = styled.div` width: 100%; height: 1px; background: #e5e7eb; margin: 24px 0; `; const Arrow = styled.img` transform: ${({ $down }) => ($down ? "rotate(180deg)" : "none")}; `; /* ===================== COMPONENT ===================== */ function ScreenSecond() { const { data: section, loading, error } = useSingleton( "ScreenSecondSection", SELECTION ); const groups = chunkInto(section?.rows ?? [], 3); const logoSrc = section?.logo?.url || fallbackLogo; return ( {/* Header */} {section?.title && {section.title}} {section?.description && ( {section.description} )} Company logo {/* Rows in groups of 3 with Divider */} {groups.map((group, gi) => (
{group.map((item) => ( {item.value} {item.trend !== "none" && ( )} {item.label} ))} {gi < groups.length - 1 && }
))} {/* Footnote */} {section?.footnote && {section.footnote}}
); } export default ScreenSecond;