Skip to content

Commit e58e41f

Browse files
committed
fix: wrap GitHub repository paths on narrow screens
1 parent e9f230b commit e58e41f

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

‎website/src/components/GitHubSocialProof/index.module.css‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@
7474
vertical-align: baseline;
7575
}
7676

77+
/* Long repo paths must wrap inside the item instead of overflowing it: the flex
78+
item has min-width:auto by default, which pins it to its content width. No
79+
overflow-wrap: that would split the URL mid-word — break only at the path's
80+
own separators. */
81+
.projectSourceLink {
82+
min-width: 0;
83+
}
84+
7785
.starCount {
7886
transform: translateY(var(--space-px));
7987
}

‎website/src/components/GitHubSocialProof/index.tsx‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useState, type ReactNode } from 'react';
1+
import { Fragment, useEffect, useState, type ReactNode } from 'react';
22

33
import styles from './index.module.css';
44

@@ -83,6 +83,22 @@ function StarCount({
8383
);
8484
}
8585

86+
// Break opportunities after each `/` so long repo paths wrap at segment
87+
// boundaries on narrow screens instead of overflowing their list item.
88+
function RepoPath({ repo }: { repo: string }): ReactNode {
89+
const segments = `github.com/${repo}`.split('/');
90+
return segments.map((segment, index) => (
91+
<Fragment key={segment}>
92+
{segment}
93+
{index < segments.length - 1 ? (
94+
<>
95+
/<wbr />
96+
</>
97+
) : null}
98+
</Fragment>
99+
));
100+
}
101+
86102
export function GitHubProjectSource({
87103
name,
88104
repo,
@@ -98,7 +114,7 @@ export function GitHubProjectSource({
98114
target="_blank"
99115
rel="noopener noreferrer"
100116
>
101-
github.com/{repo}
117+
<RepoPath repo={repo} />
102118
</a>{' '}
103119
<span className={styles.projectSourceStars}>
104120
<GitHubSocialProof

0 commit comments

Comments
 (0)