refactor(converter): shared page layout + reusable conversion logic/UI
Pages: - add WalletLayout route (WalletHeader + main + Footer via <Outlet/>), wrap converter/swap/bridge/transactions; thin pages, drop duplicated shell CSS - extract SwapBridgeTabs shared between swap/bridge pages Converter reuse (FSD layers, no widget->widget imports): - move commission tiers to entities/commission (+ CommissionTable ui) - shared calc hook features/payment/model/useCurrencyConversion; useConverterSection becomes thin wrapper; HomePage Converter reuses it - move ConvertField/DirectionSwapButton to shared/ui; delete dead useConverter Tooling: - add eslint.config.js (ESLint 9 flat config); fix no-explicit-any in WalletPage Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
82
src/shared/ui/ConvertField/ConvertField.module.css
Normal file
82
src/shared/ui/ConvertField/ConvertField.module.css
Normal file
@@ -0,0 +1,82 @@
|
||||
.field {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.compact {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.fieldError {
|
||||
margin-top: 8px;
|
||||
font-size: 13px;
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
.fieldLabel {
|
||||
font-size: 12px;
|
||||
letter-spacing: 2px;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.fieldInput {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: 12px;
|
||||
padding: 0 16px;
|
||||
transition: border-color 0.3s;
|
||||
}
|
||||
|
||||
.fieldInput:focus-within {
|
||||
border-color: var(--interactive);
|
||||
}
|
||||
|
||||
.fieldInput input {
|
||||
flex: 1;
|
||||
background: none;
|
||||
border: none;
|
||||
outline: none;
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 18px;
|
||||
padding: 16px 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.currency {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--text-secondary);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.currencyIcon {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.currencyRub {
|
||||
background: var(--interactive);
|
||||
}
|
||||
|
||||
.currencyUsdt {
|
||||
background: var(--success);
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.field {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
}
|
||||
44
src/shared/ui/ConvertField/ConvertField.tsx
Normal file
44
src/shared/ui/ConvertField/ConvertField.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
import styles from './ConvertField.module.css'
|
||||
|
||||
export type Currency = 'USDT' | 'RUB'
|
||||
|
||||
export interface ConvertFieldData {
|
||||
value: string
|
||||
currency: Currency
|
||||
onChange?: (raw: string) => void
|
||||
error?: string
|
||||
}
|
||||
|
||||
interface Props extends ConvertFieldData {
|
||||
label?: string
|
||||
compact?: boolean
|
||||
}
|
||||
|
||||
export function ConvertField({ label, value, currency, onChange, error, compact }: Props) {
|
||||
const readOnly = !onChange
|
||||
|
||||
return (
|
||||
<div className={compact ? `${styles.field} ${styles.compact}` : styles.field}>
|
||||
{label && <div className={styles.fieldLabel}>{label}</div>}
|
||||
<div className={styles.fieldInput}>
|
||||
<input
|
||||
type="text"
|
||||
value={value}
|
||||
onChange={onChange ? (e) => onChange(e.target.value) : undefined}
|
||||
readOnly={readOnly}
|
||||
placeholder="0"
|
||||
inputMode={readOnly ? undefined : 'decimal'}
|
||||
/>
|
||||
<div className={styles.currency}>
|
||||
<span
|
||||
className={`${styles.currencyIcon} ${currency === 'USDT' ? styles.currencyUsdt : styles.currencyRub}`}
|
||||
>
|
||||
{currency === 'USDT' ? '₮' : '₽'}
|
||||
</span>
|
||||
{currency}
|
||||
</div>
|
||||
</div>
|
||||
{error && <div className={styles.fieldError}>{error}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
2
src/shared/ui/ConvertField/index.ts
Normal file
2
src/shared/ui/ConvertField/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { ConvertField } from './ConvertField'
|
||||
export type { ConvertFieldData, Currency } from './ConvertField'
|
||||
Reference in New Issue
Block a user