Skip to content

Commit e8bd90c

Browse files
committed
Polish feed result presentation
1 parent c5dd861 commit e8bd90c

3 files changed

Lines changed: 28 additions & 17 deletions

File tree

frontend/src/__tests__/ResultDisplay.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ describe('ResultDisplay', () => {
2121
json: async () => ({
2222
items: [
2323
{ title: 'Item One' },
24+
{ content_text: '56 points by canpan 1 hour ago | hide | 18 comments' },
2425
{ content_text: '2. Item Two ( example.com )' },
25-
{ title: 'Item Three' },
2626
],
2727
}),
2828
} as Response);
@@ -36,7 +36,8 @@ describe('ResultDisplay', () => {
3636
expect(screen.getByRole('link', { name: 'Open feed' })).toBeInTheDocument();
3737
await waitFor(() => {
3838
expect(screen.getByText('Item One')).toBeInTheDocument();
39-
expect(screen.getByText('Item Three')).toBeInTheDocument();
39+
expect(screen.getByText(/points by canpan/i)).toBeInTheDocument();
40+
expect(screen.getByText('Item Two')).toBeInTheDocument();
4041
});
4142
expect(window.fetch).toHaveBeenCalledWith('https://example.com/feed.xml', {
4243
headers: { Accept: 'application/feed+json' },

frontend/src/components/ResultDisplay.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function ResultDisplay({ result, onCreateAnother }: ResultDisplayProps) {
9999

100100
{previewItems.length > 0 && (
101101
<section class="result-preview" aria-label="Feed preview">
102-
<p class="result-preview__label">Latest items</p>
102+
<p class="result-preview__label">Feed preview</p>
103103
<ul class="result-preview__list">
104104
{previewItems.map((item) => (
105105
<li key={item}>{item}</li>
@@ -120,11 +120,19 @@ export function ResultDisplay({ result, onCreateAnother }: ResultDisplayProps) {
120120
function normalizePreviewText(value?: string): string | null {
121121
if (!value) return null;
122122

123-
const normalized = value
123+
const normalized = decodeHtmlEntities(value)
124124
.replace(/\s+/g, ' ')
125125
.replace(/^\d+\.\s+/, '')
126126
.replace(/\s+\([^)]*\)\s*$/, '')
127127
.trim();
128128

129129
return normalized || null;
130130
}
131+
132+
function decodeHtmlEntities(value: string): string {
133+
if (typeof document === 'undefined') return value;
134+
135+
const textarea = document.createElement('textarea');
136+
textarea.innerHTML = value;
137+
return textarea.value;
138+
}

frontend/src/styles/main.css

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -582,24 +582,25 @@ a:focus-visible {
582582
}
583583

584584
.result-meta {
585-
max-width: 36rem;
586-
font-size: clamp(1.15rem, 2vw, 1.45rem);
587-
line-height: 1.2;
588-
color: var(--text-body);
585+
max-width: 32rem;
586+
font-size: clamp(0.98rem, 1.5vw, 1.16rem);
587+
line-height: 1.18;
588+
color: var(--text-strong);
589589
}
590590

591591
.result-preview {
592592
width: min(100%, 40rem);
593593
margin: 0 auto;
594594
display: grid;
595-
gap: var(--space-2);
595+
gap: var(--space-3);
596596
justify-items: start;
597-
padding-top: var(--space-1);
597+
padding-top: var(--space-3);
598+
border-top: var(--border-width) solid rgba(255, 255, 255, 0.08);
598599
}
599600

600601
.result-preview__label {
601602
margin: 0;
602-
color: var(--text-muted);
603+
color: rgba(255, 255, 255, 0.72);
603604
font-size: var(--font-size-00);
604605
letter-spacing: 0.08em;
605606
text-transform: uppercase;
@@ -616,10 +617,10 @@ a:focus-visible {
616617

617618
.result-preview__list li {
618619
color: var(--text-body);
619-
max-width: 32rem;
620+
max-width: 34rem;
620621
font-family: var(--font-family-display);
621-
font-size: clamp(1.08rem, 1.8vw, 1.42rem);
622-
line-height: 1.24;
622+
font-size: clamp(1rem, 1.65vw, 1.28rem);
623+
line-height: 1.2;
623624
text-align: left;
624625
}
625626

@@ -628,12 +629,13 @@ a:focus-visible {
628629
margin: 0 auto;
629630
justify-items: start;
630631
justify-content: start;
631-
gap: var(--space-5);
632+
gap: var(--space-4);
633+
margin-top: calc(var(--space-2) * -1);
632634
}
633635

634636
.btn--linkish {
635-
color: var(--text-body);
636-
font-weight: 600;
637+
color: rgba(255, 255, 255, 0.78);
638+
font-weight: 560;
637639
}
638640

639641
.status-card {

0 commit comments

Comments
 (0)