From d858bd4e0fc7aaba15509a17b35138e843667bc1 Mon Sep 17 00:00:00 2001 From: Pawel Zelawski Date: Thu, 10 Apr 2025 14:35:56 +0200 Subject: refactor: improve layout and spacing across all views - Remove extra space at the top of the page by adjusting body and root styles - Add consistent 20px top padding to all views through app-container - Simplify layout structure by removing unnecessary flex containers - Adjust spacing between elements for better visual hierarchy: - Reduce gaps between elements from 1.5rem to 1rem - Reduce bottom margin of h1 from 1.5rem to 1rem - Remove negative margins and extra padding - Maintain consistent box dimensions (390px width, 560px height) for all views - Ensure proper spacing for QR code and other content within views --- src/client/App.tsx | 101 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 44 deletions(-) (limited to 'src/client/App.tsx') diff --git a/src/client/App.tsx b/src/client/App.tsx index 00280cd..b3f0308 100644 --- a/src/client/App.tsx +++ b/src/client/App.tsx @@ -99,7 +99,7 @@ function App() { setQrCodeDataUrl(null); // Clear previous QR code if any setSessionId(null); setResultData(null); - console.log('Requesting new DigiID session...'); + console.log('Requesting new Digi-ID session...'); try { const response = await fetch('/api/digiid/start'); @@ -113,9 +113,9 @@ function App() { setQrCodeDataUrl(data.qrCodeDataUrl); setUiState('waiting'); // Move to waiting state } catch (err) { - console.error('Error starting DigiID session:', err); + console.error('Error starting Digi-ID session:', err); const message = err instanceof Error ? err.message : 'An unknown error occurred'; - setError(`Failed to initiate DigiID: ${message}`); + setError(`Failed to initiate Digi-ID: ${message}`); setUiState('initial'); // Stay in initial state on error } finally { setIsLoading(false); @@ -135,57 +135,70 @@ function App() { return (
-

DigiID-TS Demo

+

Digi-ID TypeScript Integration Demo

- {/* --- Initial State --- */} + {/* --- Views based on uiState --- */} {uiState === 'initial' && (
-

Welcome

-

Click the button below to generate a DigiID login QR code.

- {/* TODO: Add Icon here */} - {/* DigiID Icon */} -
)} - {/* --- Waiting State --- */} - {uiState === 'waiting' && qrCodeDataUrl && ( -
-

Scan the QR Code

-

Scan the QR code below using your DigiID compatible mobile wallet.

- DigiID QR Code -

Waiting for authentication...

- {/* Optional: Add a cancel button here */} - + {uiState !== 'initial' && ( +
+ {uiState === 'waiting' && qrCodeDataUrl && ( +
+

Scan the QR Code

+

Scan the QR code below using your Digi-ID compatible mobile wallet.

+ Digi-ID QR Code +

Waiting for authentication...

+ +
+ )} + + {uiState === 'success' && resultData?.address && ( +
+ + + + +

Authentication Successful!

+

Verified Address:

+

{resultData.address}

+

Address Format: {getDigiByteAddressType(resultData.address)}

+ +
+ )} + + {uiState === 'failed' && ( +
+

Authentication Failed

+

+ Reason: {resultData?.error || error || 'An unknown error occurred.'} +

+ +
+ )}
)} - {/* --- Success State --- */} - {uiState === 'success' && resultData?.address && ( -
-

Authentication Successful!

-

Verified Address:

-

{resultData.address}

-

Address Type: {getDigiByteAddressType(resultData.address)}

- -
- )} - - {/* --- Failed State --- */} - {uiState === 'failed' && ( -
-

Authentication Failed

-

- Reason: {resultData?.error || error || 'An unknown error occurred.'} -

- -
- )} - - {/* General error display (e.g., for initial start error) */} - {error && uiState === 'initial' &&

Error: {error}

} + {/* --- Description section (Always visible below the view container) --- */} +
+

+ This application demonstrates integrating Digi-ID authentication using the digiid-ts library. +

+

+ Upon successful verification, the system can identify the following DigiByte address formats: +

+
    +
  • Legacy Addresses (P2PKH) - starting with 'D'
  • +
  • Pay-to-Script-Hash Addresses (P2SH) - commonly starting with 'S'
  • +
  • Segregated Witness (SegWit) Addresses - starting with 'dgb1'
  • +
+
); } -- cgit v1.2.3