Enhance UI components and styles for better performance and accessibility

- Added a fixed minimum height to the AdSlot component to reduce Cumulative Layout Shift (CLS) and adjusted styles for better layout consistency.
- Specified width and height attributes for the Barcode and QR Code images to improve rendering performance and maintain aspect ratios.
- Introduced font-face declarations in global CSS for 'Inter' and 'Tajawal' fonts with 'swap' display to optimize font loading and reduce CLS.
This commit is contained in:
Your Name
2026-03-25 03:08:19 +02:00
parent d87f7dba8d
commit a6877c6dd7
5 changed files with 272 additions and 249 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -92,11 +92,18 @@ export default function AdSlot({
// Pro users see no ads
if (user?.plan === 'pro') return null;
// حجز مساحة ثابتة لتقليل CLS
// يمكن تخصيص الارتفاع حسب نوع الإعلان
const minHeight = format === 'horizontal' ? 90 : format === 'rectangle' ? 250 : 120;
return (
<div ref={containerRef} className={`ad-slot ${className}`}>
<div
ref={containerRef}
className={`ad-slot ${className}`}
style={{ minHeight, position: 'relative' }}
>
<ins
className="adsbygoogle"
style={{ display: 'block' }}
style={{ display: 'block', width: '100%', minHeight }}
data-ad-client={clientId}
data-ad-slot={resolvedSlot}
data-ad-format={format}

View File

@@ -98,7 +98,7 @@ export default function BarcodeGenerator() {
{phase === 'done' && downloadUrl && (
<div className="space-y-4 text-center">
<div className="rounded-2xl bg-white p-6 ring-1 ring-slate-200 dark:bg-slate-800 dark:ring-slate-700">
<img src={downloadUrl} alt="Barcode" loading="lazy" decoding="async" className="mx-auto max-w-full" />
<img src={downloadUrl} alt="Barcode" loading="lazy" decoding="async" className="mx-auto max-w-full" width="300" height="100" style={{aspectRatio:'3/1'}} />
</div>
<div className="flex gap-3">
<a href={downloadUrl} download className="btn-primary flex-1">{t('common.download')}</a>

View File

@@ -113,7 +113,7 @@ export default function QrCodeGenerator() {
{phase === 'done' && result && result.status === 'completed' && downloadUrl && (
<div className="space-y-6 text-center">
<div className="rounded-2xl bg-white p-8 ring-1 ring-slate-200 dark:bg-slate-800 dark:ring-slate-700">
<img src={downloadUrl} alt="QR Code" loading="lazy" decoding="async" className="mx-auto max-w-[300px] rounded-lg" />
<img src={downloadUrl} alt="QR Code" loading="lazy" decoding="async" className="mx-auto max-w-[300px] rounded-lg" width={size} height={size} style={{aspectRatio:'1/1'}} />
</div>
<div className="flex gap-3">
<a href={downloadUrl} download={result.filename || 'qrcode.png'}

View File

@@ -29,6 +29,22 @@
text-rendering: optimizeLegibility;
}
/* تحسين تحميل الخطوط لتقليل CLS */
@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 400;
src: local('Inter'), url('/fonts/Inter.woff2') format('woff2');
font-display: swap;
}
@font-face {
font-family: 'Tajawal';
font-style: normal;
font-weight: 400;
src: local('Tajawal'), url('/fonts/Tajawal.woff2') format('woff2');
font-display: swap;
}
/* RTL Support */
[dir="rtl"] body {
font-family: 'Tajawal', 'Inter', system-ui, sans-serif;