From 273778c4cfa6ef8bd3ab421e03c57b6e31f7d925 Mon Sep 17 00:00:00 2001 From: Sergey Krylov Date: Wed, 26 Aug 2026 11:40:36 +0300 Subject: [PATCH] feat: polish stock position cards --- scripts/lazy-route-bundle-baseline.json | 18 +++--- src/pages/account/ui/AccountPage.module.css | 30 ++++++++++ src/pages/account/ui/AccountPage.test.tsx | 30 ++++++++++ .../ui/components/PositionCard.view.tsx | 60 ++++++++++++++++++- .../ui/components/PositionSection.view.tsx | 1 + 5 files changed, 129 insertions(+), 10 deletions(-) diff --git a/scripts/lazy-route-bundle-baseline.json b/scripts/lazy-route-bundle-baseline.json index 624f95f..6838a7f 100644 --- a/scripts/lazy-route-bundle-baseline.json +++ b/scripts/lazy-route-bundle-baseline.json @@ -1,11 +1,11 @@ { - "src/app/routes/ProtectedLayout.tsx": 3077, - "src/pages/account-events/index.ts": 4441, - "src/pages/account-operations/index.ts": 13862, - "src/pages/account/index.ts": 22402, - "src/pages/accounts/index.ts": 6179, - "src/pages/login/index.ts": 667, - "src/pages/not-found/index.ts": 882, - "src/pages/register/index.ts": 673, - "src/pages/settings/index.ts": 39008 + "src/app/routes/ProtectedLayout.tsx": 3057, + "src/pages/account-events/index.ts": 4364, + "src/pages/account-operations/index.ts": 13854, + "src/pages/account/index.ts": 24695, + "src/pages/accounts/index.ts": 6145, + "src/pages/login/index.ts": 662, + "src/pages/not-found/index.ts": 877, + "src/pages/register/index.ts": 668, + "src/pages/settings/index.ts": 38979 } diff --git a/src/pages/account/ui/AccountPage.module.css b/src/pages/account/ui/AccountPage.module.css index c8a92b9..26cff9d 100644 --- a/src/pages/account/ui/AccountPage.module.css +++ b/src/pages/account/ui/AccountPage.module.css @@ -32,6 +32,36 @@ color: var(--mantine-color-red-6); } +.stockCard { + padding: var(--mantine-spacing-md); +} + +.stockMain { + display: grid; + grid-template-columns: auto minmax(0, 1fr) auto; + gap: var(--mantine-spacing-sm); + align-items: center; +} + +.stockIdentity, +.stockValue { + min-width: 0; +} + +.stockIdentifiers { + overflow-wrap: anywhere; +} + +.stockValue { + white-space: nowrap; +} + +.stockMeta { + padding-top: var(--mantine-spacing-xs); + margin-top: var(--mantine-spacing-sm); + border-top: 1px solid var(--mantine-color-gray-2); +} + .mono { font-family: var(--mantine-font-family-monospace); } diff --git a/src/pages/account/ui/AccountPage.test.tsx b/src/pages/account/ui/AccountPage.test.tsx index e87b69c..935e7d9 100644 --- a/src/pages/account/ui/AccountPage.test.tsx +++ b/src/pages/account/ui/AccountPage.test.tsx @@ -214,6 +214,36 @@ describe("AccountPage states", () => { expect(screen.queryByRole("img", { name: "Абра" })).not.toBeInTheDocument(); }); + it("groups stock supporting metrics into quiet single lines", () => { + renderPage( + , + ); + + expect(screen.getByText("Количество: 2 · RU000QUIET1")).not.toHaveAttribute( + "data-line-clamp", + ); + expect( + screen.getByText("Средняя цена: 11 ₽ · Доля: 100 %"), + ).toBeInTheDocument(); + }); + it("renders bond cards with logo, fallback, and signed unlabeled return like stocks", () => { renderPage( = (props) => { - const { position, wide = false } = props; + const { position, wide = false, variant } = props; const { t } = useTranslation(); + const isStock = variant === "stock"; const returnClass = position.returnTone ? classes[position.returnTone] : undefined; @@ -25,6 +27,62 @@ const PositionCard: FC = (props) => { value: position.returnText, }) : null; + const identifierText = [ + t("portfolio.quantity", { value: position.quantity }), + position.isin, + ] + .filter(Boolean) + .join(" · "); + const secondaryText = [ + position.averagePurchasePrice + ? t("portfolio.avgPrice", { + value: formatMoney(position.averagePurchasePrice), + }) + : null, + position.shareText + ? t("portfolio.share", { value: position.shareText }) + : null, + ] + .filter(Boolean) + .join(" · "); + + if (isStock) + return ( + +
+ + + + {position.displayName} + + + {identifierText} + + + + {position.currentValue ? ( + + {formatMoney(position.currentValue)} + + ) : null} + {returnText ? ( + + {returnText} + + ) : null} + +
+ {secondaryText ? ( + + {secondaryText} + + ) : null} +
+ ); return ( diff --git a/src/pages/account/ui/components/PositionSection.view.tsx b/src/pages/account/ui/components/PositionSection.view.tsx index e24973f..6289f26 100644 --- a/src/pages/account/ui/components/PositionSection.view.tsx +++ b/src/pages/account/ui/components/PositionSection.view.tsx @@ -20,6 +20,7 @@ const PositionSection: FC = (props) => { key={`${position.figi}-${position.displayName}-${position.quantity}`} position={position} wide={section.wide} + variant={section.kind === "stocks" ? "stock" : undefined} /> ))}