From 6a27cd259b67bdad85e8d82a31543cc11c309fc6 Mon Sep 17 00:00:00 2001 From: eti Date: Fri, 24 Apr 2026 20:15:11 +0200 Subject: [PATCH] ogre/footer: use char-length thresholds to hide stats on long handles Signed-off-by: eti --- ogre/src/__tests__/fixtures.ts | 2 + ogre/src/__tests__/render.test.ts | 8 +- ogre/src/components/cards/issue.tsx | 4 +- ogre/src/components/shared/footer-stats.tsx | 98 +++++++++------------ 4 files changed, 51 insertions(+), 61 deletions(-) diff --git a/ogre/src/__tests__/fixtures.ts b/ogre/src/__tests__/fixtures.ts index eae8a2b4..440aa1fd 100644 --- a/ogre/src/__tests__/fixtures.ts +++ b/ogre/src/__tests__/fixtures.ts @@ -89,3 +89,5 @@ export const createLongTitlePullRequestData = ( title: LONG_TITLE, ...overrides, }); + + diff --git a/ogre/src/__tests__/render.test.ts b/ogre/src/__tests__/render.test.ts index 19bfa699..90609945 100644 --- a/ogre/src/__tests__/render.test.ts +++ b/ogre/src/__tests__/render.test.ts @@ -87,9 +87,9 @@ describe("issue cards", () => { await renderAndSave(h(IssueCard, validated), "issue-card-long-title.png"); }); - test("renders issue with long author handle (reactions hidden)", async () => { + test("renders issue with long author handle", async () => { const data = createIssueData(avatarDataUri, { - authorHandle: "extremely-long-handle.example.com", + authorHandle: "very.very.long.tangled.org", }); const validated = issueCardSchema.parse(data); await renderAndSave( @@ -146,9 +146,9 @@ describe("pull request cards", () => { ); }); - test("renders pull request with long author handle (reactions hidden)", async () => { + test("renders pull request with long author handle", async () => { const data = createPullRequestData(avatarDataUri, { - authorHandle: "extremely-long-handle.example.com", + authorHandle: "very.very.long.tangled.org", }); const validated = pullRequestCardSchema.parse(data); await renderAndSave( diff --git a/ogre/src/components/cards/issue.tsx b/ogre/src/components/cards/issue.tsx index e6d160f1..4710f59b 100644 --- a/ogre/src/components/cards/issue.tsx +++ b/ogre/src/components/cards/issue.tsx @@ -37,8 +37,8 @@ export function IssueCard(data: IssueCardData) { LONG_HANDLE_THRESHOLD; - const isVeryLongHandle = handleLength > VERY_LONG_HANDLE_THRESHOLD; - const gap = isLongHandle ? 40 : 64; - const hideReactions = isLongHandle; - const hideComments = isVeryLongHandle; + const handleLength = authorHandle?.length ?? 0; + const showReactions = handleLength <= 16; + const showComments = handleLength <= 11; - return ( - - {authorHandle && authorAvatarUrl ? ( - - - - {authorHandle} - + return ( + + {authorHandle && authorAvatarUrl ? ( + + + + {authorHandle} + + + ) : null} + + {showReactions && reactionCount ? ( + + ) : null} + {showComments && commentCount ? ( + + ) : null} - ) : null} - - {reactionCount && !hideReactions ? ( - - ) : null} - {commentCount && !hideComments ? ( - - ) : null} - - ); + ); } -- 2.51.2