Skip to content

Commit 7a23c8f

Browse files
committed
feat: add visual previews for credit card mask real-world scenarios
1 parent d681cb4 commit 7a23c8f

File tree

1 file changed

+77
-3
lines changed

1 file changed

+77
-3
lines changed

apps/docs/src/app/pages/pipes/credit-card-mask.ts

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,21 @@ import { Breadcrumb } from '../../reusables/breadcrumb/breadcrumb';
162162
Payment Method Selection
163163
</h3>
164164
<app-code-preview [code]="paymentMethodExample" [language]="'typescript'">
165-
<div></div>
165+
<div class="space-y-3 p-6 bg-muted/30 rounded-lg">
166+
<h4 class="font-medium text-sm mb-4">Preview:</h4>
167+
@for (card of sampleCards; track card.id) {
168+
<div class="flex items-center gap-4 p-4 rounded-lg border border-border bg-background hover:border-primary transition-colors cursor-pointer">
169+
<div class="w-12 h-8 rounded bg-gradient-to-br from-blue-600 to-blue-800 flex items-center justify-center text-white text-xs font-bold">
170+
{{ card.brand }}
171+
</div>
172+
<div class="flex-1">
173+
<div class="font-mono text-sm font-medium">{{ card.number | creditCardMask }}</div>
174+
<div class="text-xs text-muted-foreground">Expires {{ card.expiry }}</div>
175+
</div>
176+
<div class="text-xs text-primary">Select</div>
177+
</div>
178+
}
179+
</div>
166180
</app-code-preview>
167181
</div>
168182
@@ -172,7 +186,29 @@ import { Breadcrumb } from '../../reusables/breadcrumb/breadcrumb';
172186
Transaction History
173187
</h3>
174188
<app-code-preview [code]="transactionExample" [language]="'typescript'">
175-
<div></div>
189+
<div class="p-6 bg-muted/30 rounded-lg overflow-x-auto">
190+
<h4 class="font-medium text-sm mb-4">Preview:</h4>
191+
<table class="w-full text-sm">
192+
<thead class="border-b border-border">
193+
<tr class="text-left">
194+
<th class="pb-2 font-medium">Date</th>
195+
<th class="pb-2 font-medium">Description</th>
196+
<th class="pb-2 font-medium">Card</th>
197+
<th class="pb-2 font-medium text-right">Amount</th>
198+
</tr>
199+
</thead>
200+
<tbody>
201+
@for (tx of sampleTransactions; track tx.id) {
202+
<tr class="border-b border-border/50 last:border-0">
203+
<td class="py-3 text-muted-foreground">{{ tx.date }}</td>
204+
<td class="py-3">{{ tx.description }}</td>
205+
<td class="py-3 font-mono text-xs">{{ tx.cardNumber | creditCardMask }}</td>
206+
<td class="py-3 text-right font-medium">{{ tx.amount }}</td>
207+
</tr>
208+
}
209+
</tbody>
210+
</table>
211+
</div>
176212
</app-code-preview>
177213
</div>
178214
@@ -182,7 +218,31 @@ import { Breadcrumb } from '../../reusables/breadcrumb/breadcrumb';
182218
Conditional Display (Admin View)
183219
</h3>
184220
<app-code-preview [code]="adminExample" [language]="'typescript'">
185-
<div></div>
221+
<div class="space-y-4 p-6 bg-muted/30 rounded-lg">
222+
<h4 class="font-medium text-sm mb-4">Preview:</h4>
223+
<div class="space-y-4">
224+
<div class="p-4 rounded-lg border border-border bg-background">
225+
<div class="flex items-center justify-between mb-3">
226+
<h5 class="font-semibold">Order #12345</h5>
227+
<span class="text-xs px-2 py-1 rounded-full bg-orange-500/10 text-orange-600">Admin View</span>
228+
</div>
229+
<div class="flex items-center gap-2">
230+
<span class="text-sm text-muted-foreground">Payment Card:</span>
231+
<span class="font-mono text-sm font-medium">{{ adminCardMasked }}</span>
232+
</div>
233+
</div>
234+
<div class="p-4 rounded-lg border border-border bg-background">
235+
<div class="flex items-center justify-between mb-3">
236+
<h5 class="font-semibold">Order #12345</h5>
237+
<span class="text-xs px-2 py-1 rounded-full bg-green-500/10 text-green-600">Customer Service (Full Access)</span>
238+
</div>
239+
<div class="flex items-center gap-2">
240+
<span class="text-sm text-muted-foreground">Payment Card:</span>
241+
<span class="font-mono text-sm font-medium">{{ adminCardFull }}</span>
242+
</div>
243+
</div>
244+
</div>
245+
</div>
186246
</app-code-preview>
187247
</div>
188248
</div>
@@ -232,6 +292,20 @@ import { Breadcrumb } from '../../reusables/breadcrumb/breadcrumb';
232292
`,
233293
})
234294
export class CreditCardMask {
295+
sampleCards = [
296+
{ id: 1, number: '4532015112830366', brand: 'VISA', expiry: '12/25' },
297+
{ id: 2, number: '5425233430109903', brand: 'MC', expiry: '09/26' }
298+
];
299+
300+
sampleTransactions = [
301+
{ id: 1, date: 'Jan 10, 2026', description: 'Amazon Purchase', cardNumber: '4532015112830366', amount: '$49.99' },
302+
{ id: 2, date: 'Jan 12, 2026', description: 'Netflix Subscription', cardNumber: '5425233430109903', amount: '$15.99' },
303+
{ id: 3, date: 'Jan 13, 2026', description: 'Grocery Store', cardNumber: '4532015112830366', amount: '$127.45' }
304+
];
305+
306+
adminCardMasked = '**** **** **** 0366';
307+
adminCardFull = '4532 0151 1283 0366';
308+
235309
code = `
236310
import { Component } from '@angular/core';
237311
import { CreditCardMaskPipe } from '@ngx-transforms';

0 commit comments

Comments
 (0)