Compare commits

...

10 Commits

14 changed files with 431 additions and 487 deletions

View File

@ -1,5 +1,7 @@
import { useEffect } from 'react';
import { useSearchParams } from 'react-router-dom';
import { Box } from '@mui/material';
import { Heading, Text } from '@moex-vibe/design-system';
import {
BROKER_OPERATION_TYPE_OPTIONS,
isBrokerOperationType,
@ -32,7 +34,9 @@ export function BrokerOperationsPage() {
}
const history = operations.error ? (
<p role="alert">Не удалось загрузить историю операций</p>
<Text component="p" tone="negative" role="alert">
Не удалось загрузить историю операций
</Text>
) : (
<BrokerOperationsTable
title="История операций"
@ -53,13 +57,15 @@ export function BrokerOperationsPage() {
);
return (
<section aria-labelledby="broker-operations-heading">
<div className="broker-operations__toolbar">
<h2 id="broker-operations-heading" style={{ fontSize: 20, margin: 0 }}>
<Box component="section" aria-labelledby="broker-operations-heading">
<Box
sx={{ display: 'flex', alignItems: 'end', justifyContent: 'space-between', gap: 2, mb: 2 }}
>
<Heading level={2} id="broker-operations-heading">
Операции
</h2>
<label>
<span>Тип операции</span>
</Heading>
<Box component="label" sx={{ display: 'grid', gap: 0.5, color: 'text.secondary' }}>
<Text variant="label">Тип операции</Text>
<select value={selectedType} onChange={handleTypeChange}>
<option value="">Все операции</option>
{BROKER_OPERATION_TYPE_OPTIONS.map((option) => (
@ -68,9 +74,9 @@ export function BrokerOperationsPage() {
</option>
))}
</select>
</label>
</div>
</Box>
</Box>
{history}
</section>
</Box>
);
}

View File

@ -1,3 +1,5 @@
import { Box } from '@mui/material';
import { Heading, Text } from '@moex-vibe/design-system';
import { useBrokerPositions } from '@/entities/broker-position';
import { useBrokerAccountContext } from '@/widgets/broker-account-layout';
import { BrokerPositionTable } from '@/widgets/broker-positions-table';
@ -15,14 +17,14 @@ export function BrokerPositionsPage({ type, title }: BrokerPositionsPageProps) {
if (positions.error) {
return (
<section aria-labelledby={`broker-${type}-heading`}>
<h2 id={`broker-${type}-heading`} style={{ fontSize: 20, margin: 0 }}>
<Box component="section" aria-labelledby={`broker-${type}-heading`}>
<Heading level={2} id={`broker-${type}-heading`}>
{title}
</h2>
<p role="alert">
</Heading>
<Text component="p" tone="negative" role="alert">
{type === 'share' ? 'Не удалось загрузить акции' : 'Не удалось загрузить облигации'}
</p>
</section>
</Text>
</Box>
);
}

View File

@ -1,20 +0,0 @@
export function SkeletonBlock({
width,
height,
borderRadius = 4,
}: {
width?: string | number;
height?: string | number;
borderRadius?: number;
}) {
return (
<div
className="skeleton"
style={{
width: width ?? '100%',
height: height ?? 16,
borderRadius,
}}
/>
);
}

View File

@ -1,4 +1,4 @@
import { SkeletonBlock } from '@/shared/ui/SkeletonBlock';
import { Skeleton } from '@moex-vibe/design-system';
const tdStyle = {
borderBottom: '1px solid #eeeeee',
@ -15,7 +15,7 @@ export function TableSkeleton({ rows = 5, columns }: { rows?: number; columns: C
<tr key={i}>
{columns.map((col, j) => (
<td key={j} style={tdStyle}>
<SkeletonBlock height={12} width={col.width} />
<Skeleton height={12} width={col.width} shape="text" />
</td>
))}
</tr>

View File

@ -1,2 +1 @@
export { SkeletonBlock } from './SkeletonBlock';
export { TableSkeleton } from './TableSkeleton';

View File

@ -16,12 +16,6 @@
--color-negative: #c62828;
--border-radius: 8px;
--shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
--broker-overview-bg: linear-gradient(180deg, #f1f5ef 0%, #f7f2e8 100%);
--broker-overview-panel: rgba(15, 51, 36, 0.93);
--broker-overview-panel-soft: rgba(255, 255, 255, 0.09);
--broker-overview-border: rgba(21, 61, 43, 0.12);
--broker-overview-accent: #98c484;
--broker-overview-gold: #d7b268;
}
.pnl-cell {
@ -94,47 +88,6 @@ a {
z-index: 1;
}
.broker-allocation ul {
list-style: none;
display: grid;
gap: 8px;
}
.broker-allocation {
display: flex;
align-items: center;
gap: 20px;
}
.broker-allocation svg {
width: 160px;
max-width: 40%;
flex: 0 0 auto;
}
.broker-allocation figcaption {
display: grid;
gap: 12px;
}
.broker-allocation li {
display: flex;
align-items: center;
gap: 8px;
}
.broker-allocation__swatch {
width: 12px;
height: 12px;
border: 1px solid color-mix(in srgb, var(--color-text) 20%, transparent);
border-radius: 2px;
flex: 0 0 auto;
}
.broker-allocation__negative {
color: var(--color-negative);
}
@media (prefers-reduced-motion: reduce) {
.loading-spinner,
.skeleton {
@ -143,42 +96,4 @@ a {
}
}
.broker-operations__toolbar {
display: flex;
align-items: end;
justify-content: space-between;
gap: 16px;
margin-bottom: 20px;
}
.broker-operations__toolbar label {
display: grid;
gap: 6px;
color: var(--color-text-secondary);
font-size: 13px;
}
.broker-operations__toolbar select {
min-width: 240px;
padding: 8px 10px;
border: 1px solid #d8d8d8;
border-radius: var(--border-radius);
background: var(--color-surface);
color: var(--color-text);
}
.broker-operations__toolbar select:focus-visible {
outline: 3px solid color-mix(in srgb, var(--color-primary) 35%, transparent);
outline-offset: 2px;
}
@media (max-width: 720px) {
.broker-operations__toolbar {
align-items: stretch;
flex-direction: column;
}
.broker-operations__toolbar select {
width: 100%;
min-width: 0;
}
}

View File

@ -1,4 +1,6 @@
import type { BrokerPortfolio } from '@/shared/api/responses';
import { Box } from '@mui/material';
import { Text } from '@moex-vibe/design-system';
import { buildBrokerAllocation } from '@/entities/broker-position';
import { formatBrokerCurrencyValue } from '@/shared/lib/formatters';
@ -26,7 +28,7 @@ export function BrokerAllocationChart({ portfolio }: { portfolio: BrokerPortfoli
});
return (
<figure className="broker-allocation">
<Box component="figure" sx={{ display: 'flex', alignItems: 'center', gap: 3 }}>
<svg role="img" aria-label="Структура брокерского портфеля" viewBox="0 0 120 120">
<title>Структура брокерского портфеля</title>
{arcs.map((sector) => (
@ -44,40 +46,50 @@ export function BrokerAllocationChart({ portfolio }: { portfolio: BrokerPortfoli
/>
))}
</svg>
<figcaption>
<Box component="figcaption" sx={{ display: 'grid', gap: 1.5 }}>
{sectors.length === 0 ? (
<p>Нет данных для распределения</p>
<Text tone="muted">Нет данных для распределения</Text>
) : (
<ul>
<Box component="ul" sx={{ listStyle: 'none', display: 'grid', gap: 1 }}>
{sectors.map((sector) => (
<li key={sector.key}>
<span
className="broker-allocation__swatch"
<Box
component="li"
key={sector.key}
sx={{ display: 'flex', alignItems: 'center', gap: 1 }}
>
<Box
sx={{
width: 2,
height: 2,
borderRadius: 0.25,
background: sector.color,
flexShrink: 0,
}}
aria-hidden="true"
style={{ background: sector.color }}
/>
<span>
<Box component="span">
{sector.label}: {formatBrokerCurrencyValue(currency, sector.value)} ·{' '}
{sector.percent.toFixed(1)}%
</span>
</li>
</Box>
</Box>
))}
</ul>
</Box>
)}
{negative.length > 0 && (
<ul
className="broker-allocation__negative"
<Box
component="ul"
aria-label="Отрицательные значения распределения"
sx={{ listStyle: 'none', display: 'grid', gap: 1 }}
>
{negative.map((item) => (
<li key={item.key}>
<Box component="li" key={item.key}>
{item.label}: отрицательное значение{' '}
{formatBrokerCurrencyValue(currency, item.value)}
</li>
</Box>
))}
</ul>
</Box>
)}
</figcaption>
</figure>
</Box>
</Box>
);
}

View File

@ -1,6 +1,8 @@
import { Link } from 'react-router-dom';
import type { ReactNode } from 'react';
import type { BrokerOperation, BrokerOperationsPage } from '@/shared/api/responses';
import { Box } from '@mui/material';
import { Button, Heading, Skeleton, Text } from '@moex-vibe/design-system';
import { TableSkeleton } from '@/shared/ui/TableSkeleton';
import {
getBrokerOperationImpact,
@ -10,42 +12,33 @@ import {
import { getBrokerInstrumentPath } from '@/entities/broker-position';
import { formatBrokerSignedMoney } from '@/shared/lib/formatters';
const tableStyle = {
const tableSx = {
width: '100%',
borderCollapse: 'collapse',
fontSize: 14,
} satisfies React.CSSProperties;
} as const;
const thStyle = {
borderBottom: '1px solid #e0e0e0',
color: 'var(--color-text-secondary)',
const thSx = {
borderBottom: '1px solid',
borderColor: 'divider',
color: 'text.secondary',
fontWeight: 600,
padding: '10px 8px',
} satisfies React.CSSProperties;
p: 1,
textAlign: 'left',
} as const;
const tdStyle = {
borderBottom: '1px solid #eeeeee',
padding: '10px 8px',
const tdSx = {
borderBottom: '1px solid',
borderColor: 'divider',
p: 1,
verticalAlign: 'top',
} satisfies React.CSSProperties;
textAlign: 'left',
} as const;
const pagButtonStyle = {
padding: '6px 14px',
borderRadius: 6,
border: '1px solid #e0e0e0',
background: 'var(--color-surface)',
color: 'var(--color-text)',
fontSize: 14,
fontWeight: 600,
cursor: 'pointer',
lineHeight: 1.4,
} satisfies React.CSSProperties;
const pagButtonDisabledStyle = {
...pagButtonStyle,
opacity: 0.35,
cursor: 'not-allowed',
} satisfies React.CSSProperties;
const tdSxRight = {
...tdSx,
textAlign: 'right',
} as const;
function formatDate(value: string | null) {
if (!value) return '-';
@ -53,11 +46,10 @@ function formatDate(value: string | null) {
return new Date(value).toLocaleString('ru-RU');
}
function moneyColor(impact: BrokerOperationImpact): string {
if (impact === 'adds') return 'var(--color-positive)';
if (impact === 'reduces') return 'var(--color-negative)';
return 'var(--color-text)';
function operationTone(impact: BrokerOperationImpact) {
if (impact === 'adds') return 'positive' as const;
if (impact === 'reduces') return 'negative' as const;
return 'primary' as const;
}
function OperationInstrument({ operation }: { operation: BrokerOperation }) {
@ -69,19 +61,23 @@ function OperationInstrument({ operation }: { operation: BrokerOperation }) {
});
const name = operation.name || operation.description;
if (!path && !name) return <span>-</span>;
if (!path) return <span>{name}</span>;
if (!path && !name) return <Text>-</Text>;
if (!path) return <Text>{name}</Text>;
if (!ticker || ticker === '-') return <Link to={path}>{name}</Link>;
return (
<div style={{ display: 'grid', gap: 2 }}>
<Link to={path} style={{ fontWeight: 700 }}>
{ticker}
<Box sx={{ display: 'grid', gap: 0.5 }}>
<Link to={path}>
<Box component="span" sx={{ fontWeight: 700 }}>
{ticker}
</Box>
</Link>
{name && name !== ticker && (
<span style={{ color: 'var(--color-text-secondary)', fontSize: 12 }}>{name}</span>
<Text variant="caption" tone="secondary">
{name}
</Text>
)}
</div>
</Box>
);
}
@ -103,146 +99,156 @@ export function BrokerOperationsTable({
return (
<section aria-busy={isFetching}>
<div
style={{
<Box
sx={{
display: 'flex',
alignItems: 'center',
gap: 12,
gap: 1.5,
justifyContent: 'space-between',
marginBottom: 12,
mb: 1.5,
}}
>
<h2 style={{ fontSize: 20, margin: 0 }}>{title}</h2>
<Heading level={2}>{title}</Heading>
{headerAction}
{pagination && (
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<button
type="button"
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
<Button
variant="secondary"
size="small"
aria-label="Предыдущая страница"
onClick={onPrevious}
disabled={!canGoBack || isFetching}
style={canGoBack && !isFetching ? pagButtonStyle : pagButtonDisabledStyle}
>
{isFetching ? (
<span
className="loading-spinner"
style={{ width: 14, height: 14, display: 'block' }}
/>
) : (
'←'
)}
</button>
<span
style={{
{isFetching ? <Skeleton shape="circular" width={14} height={14} /> : '←'}
</Button>
<Box
sx={{
minWidth: 20,
textAlign: 'center',
color: 'var(--color-text-secondary)',
color: 'text.secondary',
fontSize: 14,
fontWeight: 600,
}}
>
{pageNumber}
</span>
<button
type="button"
</Box>
<Button
variant="secondary"
size="small"
aria-label="Следующая страница"
onClick={onNext}
disabled={!canGoForward || isFetching}
style={canGoForward && !isFetching ? pagButtonStyle : pagButtonDisabledStyle}
>
{isFetching ? (
<span
className="loading-spinner"
style={{ width: 14, height: 14, display: 'block' }}
/>
) : (
'→'
)}
</button>
</div>
{isFetching ? <Skeleton shape="circular" width={14} height={14} /> : '→'}
</Button>
</Box>
)}
</div>
</Box>
{isLoading ? (
<div style={{ overflowX: 'auto', background: 'var(--color-surface)' }}>
<table style={tableStyle}>
<thead>
<tr>
<th align="left" style={thStyle}>
<Box sx={{ overflowX: 'auto', bgcolor: 'surface.default' }}>
<Box component="table" sx={tableSx}>
<Box component="thead">
<Box component="tr">
<Box component="th" sx={thSx}>
Дата
</th>
<th align="left" style={thStyle}>
</Box>
<Box component="th" sx={thSx}>
Тип
</th>
<th align="left" style={thStyle}>
</Box>
<Box component="th" sx={thSx}>
Инструмент
</th>
<th align="right" style={thStyle}>
</Box>
<Box component="th" sx={{ ...thSx, textAlign: 'right' }}>
Сумма
</th>
</tr>
</thead>
</Box>
</Box>
</Box>
<TableSkeleton
rows={5}
columns={[{ width: '35%' }, { width: '30%' }, { width: '40%' }, { width: '25%' }]}
/>
</table>
</div>
</Box>
</Box>
) : operations.length === 0 && !isFetching ? (
<p style={{ color: 'var(--color-text-secondary)' }}>{emptyMessage}</p>
<Text component="p" tone="muted">
{emptyMessage}
</Text>
) : (
<div className="table-container">
<div style={{ overflowX: 'auto', background: 'var(--color-surface)' }}>
<table style={tableStyle}>
<thead>
<tr>
<th align="left" style={thStyle}>
<Box sx={{ position: 'relative' }}>
<Box sx={{ overflowX: 'auto', bgcolor: 'surface.default' }}>
<Box component="table" sx={tableSx}>
<Box component="thead">
<Box component="tr">
<Box component="th" sx={thSx}>
Дата
</th>
<th align="left" style={thStyle}>
</Box>
<Box component="th" sx={thSx}>
Тип
</th>
<th align="left" style={thStyle}>
</Box>
<Box component="th" sx={thSx}>
Инструмент
</th>
<th align="right" style={thStyle}>
</Box>
<Box component="th" sx={{ ...thSx, textAlign: 'right' }}>
Сумма
</th>
</tr>
</thead>
<tbody>
</Box>
</Box>
</Box>
<Box component="tbody">
{operations.map((operation) => {
const impact = getBrokerOperationImpact(operation);
return (
<tr key={operation.cursor || operation.id}>
<td style={tdStyle}>{formatDate(operation.date)}</td>
<td style={tdStyle}>
<span>{getBrokerOperationTypeLabel(operation)}</span>
</td>
<td style={tdStyle}>
<Box component="tr" key={operation.cursor || operation.id}>
<Box component="td" sx={tdSx}>
{formatDate(operation.date)}
</Box>
<Box component="td" sx={tdSx}>
<Text>{getBrokerOperationTypeLabel(operation)}</Text>
</Box>
<Box component="td" sx={tdSx}>
<OperationInstrument operation={operation} />
</td>
<td
</Box>
<Box
component="td"
sx={{
...tdSxRight,
color:
operationTone(impact) === 'positive'
? 'success.main'
: operationTone(impact) === 'negative'
? 'error.main'
: 'text.primary',
fontWeight: 700,
}}
align="right"
style={{ ...tdStyle, color: moneyColor(impact), fontWeight: 700 }}
>
{formatBrokerSignedMoney(operation.payment)}
</td>
</tr>
</Box>
</Box>
);
})}
</tbody>
</table>
</div>
</Box>
</Box>
</Box>
{isFetching && (
<div className="table-loading-overlay" role="status">
<div className="loading-spinner" aria-hidden="true" />
<span style={{ fontSize: 13, color: 'var(--color-text-secondary)' }}>
<Box
sx={{
position: 'absolute',
inset: 0,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: 1,
bgcolor: 'rgba(255,255,255,0.7)',
}}
>
<Box className="loading-spinner" />
<Text variant="caption" tone="secondary">
{pagination ? `Загрузка страницы ${pageNumber}` : 'Обновление операций…'}
</span>
</div>
</Text>
</Box>
)}
</div>
</Box>
)}
</section>
);

View File

@ -1,44 +1,36 @@
import type { BrokerPositionsPage as BrokerPositionsPageData } from '@/shared/api/responses';
import { TableSkeleton } from '@/shared/ui/TableSkeleton';
import { Box } from '@mui/material';
import { Button, Heading, Skeleton, Text } from '@moex-vibe/design-system';
import { formatBrokerMoney as formatMoney } from '@/shared/lib/formatters';
import { PositionTicker } from './PositionTicker';
const tableStyle = {
const tableSx = {
width: '100%',
borderCollapse: 'collapse',
fontSize: 14,
} satisfies React.CSSProperties;
} as const;
const thStyle = {
borderBottom: '1px solid #e0e0e0',
color: 'var(--color-text-secondary)',
const thSx = {
borderBottom: '1px solid',
borderColor: 'divider',
color: 'text.secondary',
fontWeight: 600,
padding: '10px 8px',
} satisfies React.CSSProperties;
p: 1,
textAlign: 'left',
} as const;
const tdStyle = {
borderBottom: '1px solid #eeeeee',
padding: '10px 8px',
const tdSx = {
borderBottom: '1px solid',
borderColor: 'divider',
p: 1,
verticalAlign: 'top',
} satisfies React.CSSProperties;
textAlign: 'right',
} as const;
const pagButtonStyle = {
padding: '6px 14px',
borderRadius: 6,
border: '1px solid #e0e0e0',
background: 'var(--color-surface)',
color: 'var(--color-text)',
fontSize: 14,
fontWeight: 600,
cursor: 'pointer',
lineHeight: 1.4,
} satisfies React.CSSProperties;
const pagButtonDisabledStyle = {
...pagButtonStyle,
opacity: 0.35,
cursor: 'not-allowed',
} satisfies React.CSSProperties;
const tdSxLeft = {
...tdSx,
textAlign: 'left',
} as const;
function formatQuantity(value: number | null | undefined) {
return value == null ? '-' : value.toLocaleString('ru-RU');
@ -69,127 +61,127 @@ export function BrokerPositionTable({
return (
<section aria-labelledby={`broker-${title.toLowerCase()}-heading`}>
<div
style={{
<Box
sx={{
display: 'flex',
alignItems: 'center',
gap: 12,
gap: 1.5,
justifyContent: 'space-between',
marginBottom: 10,
mb: 1.5,
}}
>
<h2 id={`broker-${title.toLowerCase()}-heading`} style={{ fontSize: 20, margin: 0 }}>
<Heading level={2} id={`broker-${title.toLowerCase()}-heading`}>
{title}
</h2>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<button
type="button"
</Heading>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
<Button
variant="secondary"
size="small"
aria-label="Предыдущая страница"
onClick={onPrevious}
disabled={!canGoBack || isFetching}
style={canGoBack && !isFetching ? pagButtonStyle : pagButtonDisabledStyle}
>
{isFetching ? (
<span
className="loading-spinner"
style={{ width: 14, height: 14, display: 'block' }}
/>
) : (
'←'
)}
</button>
<span
style={{
{isFetching ? <Skeleton shape="circular" width={14} height={14} /> : '←'}
</Button>
<Box
sx={{
minWidth: 20,
textAlign: 'center',
color: 'var(--color-text-secondary)',
color: 'text.secondary',
fontSize: 14,
fontWeight: 600,
}}
>
{pageNumber}
</span>
<button
type="button"
</Box>
<Button
variant="secondary"
size="small"
aria-label="Следующая страница"
onClick={onNext}
disabled={!canGoForward || isFetching}
style={canGoForward && !isFetching ? pagButtonStyle : pagButtonDisabledStyle}
>
{isFetching ? (
<span
className="loading-spinner"
style={{ width: 14, height: 14, display: 'block' }}
/>
) : (
'→'
)}
</button>
</div>
</div>
{isFetching ? <Skeleton shape="circular" width={14} height={14} /> : '→'}
</Button>
</Box>
</Box>
{isLoading ? (
<div style={{ overflowX: 'auto', background: 'var(--color-surface)' }}>
<table style={tableStyle}>
<thead>
<tr>
<th align="left" style={thStyle}>
<Box sx={{ overflowX: 'auto', bgcolor: 'surface.default' }}>
<Box component="table" sx={tableSx}>
<Box component="thead">
<Box component="tr">
<Box component="th" sx={thSx} align="left">
Тикер
</th>
<th align="left" style={thStyle}>
</Box>
<Box component="th" sx={thSx} align="left">
Название
</th>
<th align="right" style={thStyle}>
</Box>
<Box component="th" sx={thSx} align="right">
Количество
</th>
<th align="right" style={thStyle}>
</Box>
<Box component="th" sx={thSx} align="right">
Цена
</th>
<th align="right" style={thStyle}>
</Box>
<Box component="th" sx={thSx} align="right">
Стоимость
</th>
</tr>
</thead>
<TableSkeleton
rows={4}
columns={[
{ width: '30%' },
{ width: '50%' },
{ width: '20%' },
{ width: '25%' },
{ width: '25%' },
]}
/>
</table>
</div>
</Box>
</Box>
</Box>
<Box component="tbody">
{[1, 2, 3, 4].map((row) => (
<Box component="tr" key={row}>
<Box component="td" sx={tdSxLeft}>
<Skeleton height={12} width="30%" shape="text" />
</Box>
<Box component="td" sx={tdSxLeft}>
<Skeleton height={12} width="50%" shape="text" />
</Box>
<Box component="td" sx={tdSx}>
<Skeleton height={12} width="20%" shape="text" />
</Box>
<Box component="td" sx={tdSx}>
<Skeleton height={12} width="25%" shape="text" />
</Box>
<Box component="td" sx={tdSx}>
<Skeleton height={12} width="25%" shape="text" />
</Box>
</Box>
))}
</Box>
</Box>
</Box>
) : positions.length === 0 && !isFetching ? (
<p style={{ color: 'var(--color-text-secondary)' }}>{emptyMessage}</p>
<Text component="p" tone="secondary">
{emptyMessage}
</Text>
) : (
<div className="table-container">
<div style={{ overflowX: 'auto', background: 'var(--color-surface)' }}>
<table aria-label={`Брокерские позиции: ${title}`} style={tableStyle}>
<thead>
<tr>
<th align="left" style={thStyle}>
<Box sx={{ position: 'relative' }}>
<Box sx={{ overflowX: 'auto', bgcolor: 'surface.default' }}>
<Box component="table" sx={tableSx} aria-label={`Брокерские позиции: ${title}`}>
<Box component="thead">
<Box component="tr">
<Box component="th" sx={thSx} align="left">
Тикер
</th>
<th align="left" style={thStyle}>
</Box>
<Box component="th" sx={thSx} align="left">
Название
</th>
<th align="right" style={thStyle}>
</Box>
<Box component="th" sx={thSx} align="right">
Количество
</th>
<th align="right" style={thStyle}>
</Box>
<Box component="th" sx={thSx} align="right">
Цена
</th>
<th align="right" style={thStyle}>
</Box>
<Box component="th" sx={thSx} align="right">
Стоимость
</th>
</tr>
</thead>
<tbody>
</Box>
</Box>
</Box>
<Box component="tbody">
{positions.map((position) => (
<tr
<Box
component="tr"
key={
position.positionUid ||
position.instrumentUid ||
@ -197,37 +189,45 @@ export function BrokerPositionTable({
position.figi
}
>
<td style={tdStyle}>
<Box component="td" sx={tdSxLeft}>
<PositionTicker position={position} />
</td>
<td style={tdStyle}>
<span style={{ color: 'var(--color-text-secondary)' }}>
{position.name || '-'}
</span>
</td>
<td align="right" style={tdStyle}>
</Box>
<Box component="td" sx={tdSxLeft}>
<Text tone="secondary">{position.name || '-'}</Text>
</Box>
<Box component="td" sx={tdSx}>
{formatQuantity(position.quantity)}
</td>
<td align="right" style={tdStyle}>
</Box>
<Box component="td" sx={tdSx}>
{formatMoney(position.currentPrice)}
</td>
<td align="right" style={tdStyle}>
</Box>
<Box component="td" sx={tdSx}>
{formatMoney(position.currentValue)}
</td>
</tr>
</Box>
</Box>
))}
</tbody>
</table>
</div>
</Box>
</Box>
</Box>
{isFetching && (
<div className="table-loading-overlay">
<div className="loading-spinner" />
<span style={{ fontSize: 13, color: 'var(--color-text-secondary)' }}>
<Box
sx={{
position: 'absolute',
inset: 0,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: 1,
bgcolor: 'rgba(255,255,255,0.7)',
}}
>
<Box className="loading-spinner" />
<Text variant="caption" tone="secondary">
Загрузка страницы {pageNumber}
</span>
</div>
</Text>
</Box>
)}
</div>
</Box>
)}
</section>
);

View File

@ -1,4 +1,5 @@
import { Link } from 'react-router-dom';
import { Box } from '@mui/material';
import type { BrokerPosition } from '@/shared/api/responses';
import { getBrokerInstrumentPath } from '@/entities/broker-position';
@ -11,12 +12,18 @@ export function PositionTicker({ position }: { position: BrokerPosition }) {
});
if (!path || label === '-') {
return <strong>{label}</strong>;
return (
<Box component="span" sx={{ fontWeight: 700 }}>
{label}
</Box>
);
}
return (
<Link to={path} style={{ fontWeight: 700 }}>
{label}
<Link to={path}>
<Box component="span" sx={{ fontWeight: 700 }}>
{label}
</Box>
</Link>
);
}

View File

@ -1,7 +1,7 @@
# Дизайн-системный рефакторинг страниц брокерского счёта
Дата: 2026-06-21
Статус: Draft
Статус: реализовано
## Контекст
@ -55,15 +55,31 @@ Epic `Брокерский портфель` уже покрыт функцио
## Acceptance Criteria
- [ ] `BrokerAccountLayout` не содержит CSS-классов из `styles.css`; используется `<Heading>`, `<Text>`, `<Box>`.
- [ ] `BrokerAccountOverviewPage` и содержащиеся в нём `BrokerSummary`, `BrokerAssetCards` переведены на DS-компоненты.
- [ ] `BrokerOverviewSkeleton` использует DS `<Skeleton>`.
- [ ] `BrokerAllocationChart` обёртки (`<figure>`, `<figcaption>`) переведены на `<Box>`; текст легенды — на `<Text>`.
- [ ] `BrokerPositionTable` и `BrokerOperationsTable` используют `<Box>` для layout, `<Heading>` для заголовков, `<Button>` или `<Box>` для пагинации, пустые и loading-состояния — через DS.
- [ ] `TableSkeleton` переведён на DS `<Skeleton>`.
- [ ] `SkeletonBlock` удалён после замены всех потребителей.
- [ ] `BrokerPositionsPage` и `BrokerOperationsPage` переведены на `<Box>`, `<Heading>`, `<Text>`.
- [ ] `PositionTicker``<Link>` с `<Text>` (или оставляет `fontWeight: 700` если без `sx`).
- [ ] ESLint allowlist не нарушен (`no-restricted-imports` разрешает `Box`, `Stack`, `Grid` из `@mui/material` barrel).
- [ ] `npm run test:frontend && npm run lint -w apps/frontend && npm run build:frontend` проходят.
- [ ] CSS-классы, оставшиеся без потребителей, удалены из `styles.css` (но сохраняются градиенты hero-секций).
- [x] `BrokerAccountLayout` не содержит CSS-классов из `styles.css`; используется `<Heading>`, `<Text>`, `<Box>`.
- [x] `BrokerAccountOverviewPage` и содержащиеся в нём `BrokerSummary`, `BrokerAssetCards` переведены на DS-компоненты.
- [x] `BrokerOverviewSkeleton` использует DS `<Skeleton>`.
- [x] `BrokerAllocationChart` обёртки (`<figure>`, `<figcaption>`) переведены на `<Box>`; текст легенды — на `<Text>`.
- [x] `BrokerPositionTable` и `BrokerOperationsTable` используют `<Box>` для layout, `<Heading>` для заголовков, `<Button>` или `<Box>` для пагинации, пустые и loading-состояния — через DS.
- [x] `TableSkeleton` переведён на DS `<Skeleton>`.
- [x] `SkeletonBlock` удалён после замены всех потребителей.
- [x] `BrokerPositionsPage` и `BrokerOperationsPage` переведены на `<Box>`, `<Heading>`, `<Text>`.
- [x] `PositionTicker``<Link>` с `<Box component="span" sx={{ fontWeight: 700 }}>`.
- [x] ESLint allowlist не нарушен (`no-restricted-imports` разрешает `Box`, `Stack`, `Grid` из `@mui/material` barrel).
- [x] `npm run test:frontend && npm run lint -w apps/frontend && npm run build:frontend` проходят.
- [x] CSS-классы, оставшиеся без потребителей, удалены из `styles.css` (но сохраняются градиенты hero-секций).
## Результаты реализации
Все 12 задач плана выполнены и закоммичены в ветку `codex/broker-accounts-page` (13 коммитов). Ключевые изменения:
- **Полностью мигрированы на DS:** `BrokerAccountLayout`, `BrokerAccountOverviewPage`, `BrokerSummary`, `BrokerAssetCards`, `BrokerOverviewSkeleton`, `BrokerAllocationChart`, `BrokerPositionTable`, `BrokerOperationsTable`, `BrokerPositionsPage`, `BrokerOperationsPage`, `PositionTicker`.
- **Удалён legacy:** `SkeletonBlock` удалён из `shared/ui/SkeletonBlock.tsx` и `shared/ui/index.ts`.
- **Очистка CSS:** все `broker-account__*`, `broker-overview__*`, `broker-allocation__*`, `broker-operations__toolbar*` классы и переменные удалены из `styles.css`. CSS уменьшился с 274 до 99 строк.
- Верификация: 111 тестов PASS, lint чистый, build проходит без ошибок.
### Отклонения от плана
- `PositionTicker`: использован `<Box component="span">` вместо DS `<Text>` с `sx`, так как DS `Text` не поддерживает кастомный `sx`.
- `TableSkeleton`: сохранён как shared компонент (вместо удаления), так как используется `BrokerOperationsTable`.
- `loading-spinner`: оставлен как глобальный CSS-класс (генерируется через `<Box className="loading-spinner">`). DS `Skeleton shape="circular"` использован для inline-спиннеров в пагинации.
- `TableSkeleton` type signature остался без изменений (все уже импортируют `Skeleton` из DS, не `SkeletonBlock`).

View File

@ -8,93 +8,94 @@
## Task 1: BrokerAccountLayout
- [ ] Заменить `div.broker-account` на `<Box component="div">`
- [ ] Перевести `header` + `h1` на `<Box>` + `<Heading level={1}>`
- [ ] Перевести `nav` на `<Box component="nav">` + `<NavLink>` (оставить className callback)
- [ ] Перевести `div.broker-account__workspace` на grid `<Box>`
- [ ] Перевести `div.broker-account__content` на `<Box>`
- [ ] Удалить соответствующие CSS-selectors из `styles.css`
- [x] Заменить `div.broker-account` на `<Box component="div">`
- [x] Перевести `header` + `h1` на `<Box>` + `<Heading level={1}>`
- [x] Перевести `nav` на `<Box component="nav">` + `<NavLink>` (Box component={NavLink} с `aria-current="page"`)
- [x] Перевести `div.broker-account__workspace` на grid `<Box>`
- [x] Перевести `div.broker-account__content` на `<Box>`
- [x] Удалить соответствующие CSS-selectors из `styles.css`
## Task 2: BrokerAccountOverviewPage + BrokerSummary + BrokerAssetCards
- [ ] Перевести `BrokerSummary` на `<Box>` + `<Text>`
- [ ] Перевести eyebrow/label на `<Text variant="label" tone="secondary">`
- [ ] Перевести `<strong>` значений на `<Text sx={{ fontWeight: 700 }}>`
- [ ] Перевести `<ul>` cash на `<Box component="ul">`
- [ ] Перевести `BrokerAssetCards` на `<Box>` + `<Link>` + `<Text>`
- [ ] Перевести `BrokerAccountOverviewPage` container на `<Box component="div">`
- [ ] Оставить hero-gradient без изменений (Out of scope)
- [x] Перевести `BrokerSummary` на `<Box>` + `<Text>`
- [x] Перевести eyebrow/label на `<Text variant="label" tone="secondary">`
- [x] Перевести `<strong>` значений на `<Box component="span" sx={{ fontWeight: 700 }}>`
- [x] Перевести `<ul>` cash на `<Box component="ul">`
- [x] Перевести `BrokerAssetCards` на `<Box>` + `<Link>` + `<Text>`
- [x] Перевести `BrokerAccountOverviewPage` container на `<Box component="div">`
- [x] Перевести `<p role="alert">` на `<Text component="p" tone="negative">`
- [x] Оставить hero-gradient без изменений (Out of scope)
## Task 3: BrokerOverviewSkeleton
- [ ] Заменить импорт `SkeletonBlock` на DS `<Skeleton>`
- [ ] Перевести контейнеры на `<Box>`
- [ ] Сделать circular skeleton для портфельной карточки
- [ ] Сделать text skeleton для текстовых placeholder'ей
- [x] Заменить импорт `SkeletonBlock` на DS `<Skeleton>`
- [x] Перевести контейнеры на `<Box>`
- [x] Сделать circular skeleton для портфельной карточки
- [x] Сделать text skeleton для текстовых placeholder'ей
## Task 4: BrokerAllocationChart (wrap only)
- [ ] Перевести `<figure>` на `<Box component="figure">`
- [ ] Перевести `<figcaption>` на `<Box component="figcaption">`
- [ ] Перевести `<p>` пустого состояния на `<Text tone="muted">`
- [ ] Перевести `<ul>` / `<li>` легенды на `<Box component="ul">` + `<Box component="li">`
- [ ] Перевести swatch на `<Box>` с inline-цветом в `sx`
- [ ] Перевести тексты легенды на `<Text>` / `<Box component="span">`
- [ ] Перевести negative-список на `<Box component="ul">`
- [ ] Удалить CSS для `.broker-allocation*` (кроме inline SVG) в `styles.css`
- [x] Перевести `<figure>` на `<Box component="figure">`
- [x] Перевести `<figcaption>` на `<Box component="figcaption">`
- [x] Перевести `<p>` пустого состояния на `<Text tone="muted">`
- [x] Перевести `<ul>` / `<li>` легенды на `<Box component="ul">` + `<Box component="li">`
- [x] Перевести swatch на `<Box>` с inline-цветом в `sx`
- [x] Перевести тексты легенды на `<Box component="span">`
- [x] Перевести negative-список на `<Box component="ul">`
- [x] Удалить CSS для `.broker-allocation*` в `styles.css`
## Task 5: BrokerPositionTable + PositionTicker
- [ ] Перевести вспомогательные стили на `<Box sx={{...}}>`
- [ ] Перевести `<h2>` на `<Heading level={2}>` с кастомной `sx`
- [ ] Перевести alert-тексты на `<Text tone="negative">`
- [ ] Перевести пагинационные `<button>` на `<Button variant="secondary">`
- [ ] Перевести `loading-overlay` на `<Box>`
- [ ] Перевести `PositionTicker` ссылки на `<Link>` + `<Text sx={{ fontWeight: 700 }}>`
- [ ] Сохранить `loading-spinner` (глобальный класс, пока без замены)
- [x] Перевести вспомогательные стили на `<Box sx={{...}}>`
- [x] Перевести `<h2>` на `<Heading level={2}>`
- [x] Перевести alert-тексты на `<Text tone="negative">`
- [x] Перевести пагинационные `<button>` на `<Button variant="secondary">`
- [x] Перевести `loading-overlay` на `<Box>`
- [x] Перевести `PositionTicker` ссылки на `<Box component="span" sx={{ fontWeight: 700 }}>`
- [x] Сохранить `loading-spinner` (глобальный класс, пока без замены)
## Task 6: TableSkeleton (DS Skeleton)
- [ ] Убрать импорт `SkeletonBlock`
- [ ] Заменить на `<Skeleton height={12} width={col.width} shape="text" />`
- [ ] Сделать прогон тестов, убедиться что нет предупреждений
- [x] Убрать импорт `SkeletonBlock`
- [x] Заменить на `<Skeleton height={12} width={col.width} shape="text" />`
## Task 7: BrokerOperationsTable
- [ ] Перевести вспомогательные стили на `<Box sx={{...}}>`
- [ ] Перевести `<h2>` на `<Heading level={2}>`
- [ ] Перевести `headerAction` container на `<Box>`
- [ ] Перевести пагинационные `<button>` на `<Button variant="secondary">`
- [ ] Перевести alert-тексты на `<Text tone="negative">`
- [ ] Перевести empty-тексты на `<Text tone="muted">`
- [ ] Перевести `<label>` + `<select>` на `<Box component="label">` + `<select>`
- [ ] Оставить `loading-spinner` для overlay (глобальный класс)
- [x] Перевести вспомогательные стили на `<Box sx={{...}}>`
- [x] Перевести `<h2>` на `<Heading level={2}>`
- [x] Перевести `headerAction` container на `<Box>`
- [x] Перевести пагинационные `<button>` на `<Button variant="secondary">`
- [x] Перевести alert-тексты на `<Text tone="negative">`
- [x] Перевести empty-тексты на `<Text tone="muted">`
- [x] Перевести `<label>` + `<select>` на `<Box component="label">` + `<select>`
- [x] Оставить `loading-spinner` для overlay (глобальный класс)
## Task 8: BrokerPositionsPage + BrokerOperationsPage
- [ ] Перевести `BrokerPositionsPage` на `<Box component="section">` + `<Heading>` + `<Text>`
- [ ] Перевести `BrokerOperationsPage` на `<Box>` + `<Heading>` + `<Box component="label">` + `<select>`
- [ ] Убедиться, что `role="alert"` сохраняется через `<Text tone="negative">`
- [x] Перевести `BrokerPositionsPage` на `<Box component="section">` + `<Heading>` + `<Text>`
- [x] Перевести `BrokerOperationsPage` на `<Box>` + `<Heading>` + `<Box component="label">` + `<select>`
- [x] Убедиться, что `role="alert"` сохраняется через `<Text tone="negative">`
## Task 9: SkeletonBlock удаление
- [ ] Удалить `apps/frontend/src/shared/ui/SkeletonBlock.tsx`
- [ ] Удалить экспорт из `apps/frontend/src/shared/ui/index.ts`
- [ ] Проверить grep по `SkeletonBlock` — 0 совпадений
- [x] Удалить `apps/frontend/src/shared/ui/SkeletonBlock.tsx`
- [x] Удалить экспорт из `apps/frontend/src/shared/ui/index.ts`
- [x] Проверить grep по `SkeletonBlock` — 0 совпадений
## Task 10: Очистка `styles.css`
- [ ] Удалить блоки `.broker-account__*`
- [ ] Удалить блоки `.broker-overview__*` (кроме SVG-связанных)
- [ ] Удалить блоки `.broker-allocation__*` (кроме SVG-внутренних, если остались)
- [ ] Удалить блоки `.broker-operations__toolbar*`
- [ ] Оставить `.loading-spinner` и `:root` переменные
- [x] Удалить блоки `.broker-account__*`
- [x] Удалить блоки `.broker-overview__*`
- [x] Удалить блоки `.broker-allocation__*`
- [x] Удалить блоки `.broker-operations__toolbar*`
- [x] Удалить CSS-переменные `--broker-overview-*`
- [x] Оставить `.loading-spinner`, `.skeleton`, `:root` общие переменные
## Task 11: Финальная проверка
- [ ] `npm run test:frontend`
- [ ] `npm run lint -w apps/frontend`
- [ ] `npm run build:frontend`
- [ ] grep по `broker-(account|overview|allocation)` в TSX — 0 совпадений
- [ ] grep по `SkeletonBlock` в TSX — 0 совпадений
- [ ] `npm run format` для форматирования
- [x] `npm run test:frontend` — 111 tests PASS
- [x] `npm run lint -w apps/frontend` — без ошибок
- [x] `npm run build:frontend` — без TypeScript/Vite ошибок
- [x] grep по `broker-(account|overview|allocation)` в TSX — 0 совпадений
- [x] grep по `SkeletonBlock` в TSX — 0 совпадений
- [x] CSS: 274 → 99 строк

View File

@ -2,7 +2,7 @@
## Status
Draft
Implemented — 2026-06-21.
## Goal

View File

@ -2,7 +2,7 @@
## Status
Approved — утверждена пользователем 2026-06-21.
Implemented — 2026-06-21.
## Goal