Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions resources/js/components/bio-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mentionPattern } from '@/lib/mentions';
import { show } from '@/routes/user';

const mentionClassName =
'inline-flex h-[1.55em] items-center gap-[0.3em] rounded-md border bg-muted pr-[0.55em] pl-[calc(0.2em-1px)] align-[-0.3em] text-[0.93em] font-medium whitespace-nowrap text-foreground transition-colors hover:border-primary/45 hover:bg-primary-soft hover:text-primary-hover';
'inline-flex h-[1.55em] max-w-full items-center gap-[0.3em] rounded-md border bg-muted pr-[0.55em] pl-[calc(0.2em-1px)] align-[-0.3em] text-[0.93em] font-medium whitespace-nowrap text-foreground transition-colors hover:border-primary/45 hover:bg-primary-soft hover:text-primary-hover';

// Like a shortened URL, the "@" stays in the text, so copying the bio keeps the mention.
function MentionContent({ handle }: { handle: string }) {
Expand All @@ -21,7 +21,8 @@ function MentionContent({ handle }: { handle: string }) {
className="size-full"
/>
</span>
<span>
{/* A handle wider than its column, as GitHub allows 39 characters, ends in an ellipsis instead of overflowing. */}
<span className="min-w-0 truncate">
<span className="text-[0px]">@</span>
{handle}
</span>
Expand Down
8 changes: 5 additions & 3 deletions resources/js/pages/organization/show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ export default function Show({

<ul className="mt-3 flex flex-wrap gap-x-4 gap-y-1.5 text-sm text-muted-foreground">
{organization.location && (
<li className="flex items-center gap-1.5">
<MapPin className="size-4" />
{organization.location}
<li className="flex min-w-0 items-center gap-1.5">
<MapPin className="size-4 shrink-0" />
<span className="min-w-0 wrap-anywhere">
{organization.location}
</span>
</li>
)}
{organization.website && (
Expand Down
14 changes: 8 additions & 6 deletions resources/js/pages/user/show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ export default function Show({

<ul className="mt-3 flex flex-wrap gap-x-4 gap-y-1.5 text-sm text-muted-foreground">
{user.company && (
<li className="flex items-center gap-1.5">
<Building2 className="size-4" />
<span>
<li className="flex min-w-0 items-center gap-1.5">
<Building2 className="size-4 shrink-0" />
<span className="min-w-0 wrap-anywhere">
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
<BioText
bio={user.company}
profiles={bioProfiles}
Expand All @@ -410,9 +410,11 @@ export default function Show({
</li>
)}
{user.location && (
<li className="flex items-center gap-1.5">
<MapPin className="size-4" />
{user.location}
<li className="flex min-w-0 items-center gap-1.5">
<MapPin className="size-4 shrink-0" />
<span className="min-w-0 wrap-anywhere">
{user.location}
</span>
</li>
)}
{user.show_local_time && user.timezone && (
Expand Down
16 changes: 16 additions & 0 deletions tests/Unit/BioText.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ test('keeps the whole bio as copyable text', () => {
assert.equal(textOf(renderToStaticMarkup(<BioText bio={bio} />)), bio);
});

test('shrinks a long handle with its badge instead of overflowing a narrow column', () => {
const handle = 'W'.repeat(39);
const html = renderToStaticMarkup(<BioText bio={`@${handle}`} />);
const badge = html.match(/<a [^>]*data-test="bio-mention"[^>]*>/)?.[0];

assert.ok(badge?.match(/class="[^"]*\bmax-w-full\b/));
assert.ok(
html.match(
new RegExp(
`<span class="[^"]*\\bmin-w-0\\b[^"]*\\btruncate\\b[^"]*"><span class="text-\\[0px\\]">@</span>${handle}</span>`,
),
),
);
assert.equal(textOf(html), `@${handle}`);
});

test('leaves emails, package names and domains as plain text', () => {
const bio = 'Mail me@example.com, I use @inertiajs/react and @vue.js';
const html = renderToStaticMarkup(<BioText bio={bio} />);
Expand Down