Refactor QR code implementation in ConfigCard, SubscriptionCard, TelegramLinkCard, and TelegramLoginButton components
- Replaced `QRCodeSVG` with a new `QrCode` component from the shared UI library across multiple files, enhancing consistency in QR code rendering. - Adjusted sizes of QR codes in `ConfigCard` and `SubscriptionCard` for improved visual presentation.
This commit is contained in:
1 parent
9925968e22
commit
a8358b930d
5 files changed
+41
-8
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { QRCodeSVG } from 'qrcode.react'
|
||||
import { cn } from '@/shared/lib/cn'
|
||||
|
||||
export type QrCodeProps = {
|
||||
value: string
|
||||
size?: number
|
||||
className?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* QR всегда рисуем тёмным по белому, с quiet zone и уровнем коррекции M: дефолты qrcode.react
|
||||
* (marginSize=0, level="L") дают код впритык к тёмному фону диалога — камеры и встроенные
|
||||
* сканеры VPN-клиентов такой код не находят. Белая подложка + color-scheme:light дополнительно
|
||||
* гасит force-dark мобильных браузеров, который инвертирует SVG и делает QR нечитаемым.
|
||||
*/
|
||||
export function QrCode({ value, size = 224, className }: QrCodeProps) {
|
||||
return (
|
||||
<div
|
||||
className={cn('shrink-0 rounded-md bg-white p-3 [color-scheme:light]', className)}
|
||||
style={{ width: size + 24, maxWidth: '100%' }}
|
||||
>
|
||||
<QRCodeSVG
|
||||
value={value}
|
||||
size={size}
|
||||
level="M"
|
||||
marginSize={2}
|
||||
bgColor="#FFFFFF"
|
||||
fgColor="#000000"
|
||||
className="h-auto w-full"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user