Skip to content

Commit 41112f2

Browse files
committed
tiny improvements
1 parent 7d36266 commit 41112f2

File tree

5 files changed

+41
-13
lines changed

5 files changed

+41
-13
lines changed

app/profile/[login]/components/overview-page.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const OverviewPage: FC<OverviewPageProps> = ({ user, isGlobalContext }) =
3838
const tiers = isGlobalContext ? user.tiersGlobal : user.tiersCountry;
3939

4040
return (
41-
<LayoutLeftColumn user={user} className="gap-6">
41+
<LayoutLeftColumn user={user} className="gap-10">
4242
<JsonLd payloads={buildProfileTabSEO('overview', user).jsonLd} />
4343

4444
<div className="flex flex-col gap-3">
@@ -58,10 +58,7 @@ export const OverviewPage: FC<OverviewPageProps> = ({ user, isGlobalContext }) =
5858
<h3 className="text-xl font-semibold">{repositoriesCount > 5 ? 'Top 5 Repositories' : 'Repositories'}</h3>
5959
<UserRepositoriesList repositories={repositories} login={login} loadMore={false} />
6060
{repositoriesCount > 5 && (
61-
<Link
62-
className="self-end"
63-
href={`/profile/${login}/repositories`}
64-
>{`View all ${repositoriesCount} repositories`}</Link>
61+
<Link href={`/profile/${login}/repositories`}>{`View all ${repositoriesCount} repositories`}</Link>
6562
)}
6663
</div>
6764
)}
@@ -70,9 +67,7 @@ export const OverviewPage: FC<OverviewPageProps> = ({ user, isGlobalContext }) =
7067
<div className="flex flex-col gap-3">
7168
<h3 className="text-xl font-semibold">Last Contributions</h3>
7269
<UserContributionsList contributions={contributions} login={login} contributionCount={false} />
73-
<Link className="self-end" href={`/profile/${login}/repositories`}>
74-
View all contributions
75-
</Link>
70+
<Link href={`/profile/${login}/repositories`}>View all contributions</Link>
7671
</div>
7772
)}
7873

app/profile/[login]/repositories/components/repository-card.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Repository } from '@/types/generated/graphql';
1010

1111
import { RepositoryDetail } from './repository-detail';
1212
import { RepositoryLanguages } from './repository-languages';
13+
import { RepositoryTopLanguage } from './repository-top-language';
1314
import { ProfileCard, ProfileCardContent, ProfileCardHeader } from '../../components/profile-card';
1415

1516
type RepositoryCardProps = {
@@ -64,6 +65,7 @@ export const RepositoryCard: FC<RepositoryCardProps> = ({
6465
<ProfileCardContent>
6566
<div className="flex gap-x-4 gap-y-2 flex-wrap">
6667
<div className="flex gap-4">
68+
{type === 'contribution' && <RepositoryTopLanguage languages={repository.languages} />}
6769
<RepositoryDetail Icon={Star} value={stargazerCount} />
6870
<RepositoryDetail Icon={Split} value={forkCount} />
6971
{!!releasesCount && <RepositoryDetail Icon={Package} value={releasesCount} />}
@@ -80,7 +82,7 @@ export const RepositoryCard: FC<RepositoryCardProps> = ({
8082
</div>
8183
</ProfileCardContent>
8284
</div>
83-
<RepositoryLanguages languages={repository.languages} />
85+
{type === 'repository' && <RepositoryLanguages languages={repository.languages} />}
8486
</ProfileCard>
8587
);
8688
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { FC, useMemo } from 'react';
2+
3+
import { LanguageEntity } from '@/types/generated/graphql';
4+
5+
type RepositoryTopLanguageProps = {
6+
languages?: LanguageEntity[] | null;
7+
};
8+
9+
export const RepositoryTopLanguage: FC<RepositoryTopLanguageProps> = ({ languages }) => {
10+
const topLanguage = useMemo(() => {
11+
if (!languages?.length) {
12+
return null;
13+
}
14+
15+
return languages.reduce((prev, curr) => ((curr.size ?? 0) > (prev.size ?? 0) ? curr : prev));
16+
}, [languages]);
17+
18+
if (!topLanguage) {
19+
return null;
20+
}
21+
22+
return (
23+
<div className="flex items-center gap-1.5">
24+
<span
25+
className="inline-block h-2.5 w-2.5 rounded-full ring-1 ring-black/10 dark:ring-white/20 shrink-0"
26+
style={{ backgroundColor: topLanguage.color! }}
27+
aria-hidden
28+
/>
29+
<span className="text-sm">{topLanguage.name}</span>
30+
</div>
31+
);
32+
};

components/timeline/timeline.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const Timeline = ({ children }: { children: ReactNode }) => {
88

99
export const TimelineItem = ({ children }: { children: ReactNode }) => {
1010
return (
11-
<li className="mb-10 ms-4 last:mb-0">
11+
<li className="mb-6 ms-4 last:mb-0">
1212
<div className="absolute w-3 h-3 bg-border rounded-full mt-1.5 -start-1.5 border"></div>
1313
{children}
1414
</li>

utils/get-percentile-rank.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ type Bin = {
66
};
77

88
const bins: Bin[] = [
9-
{ upper: 0.0001, round: () => 0.0001 },
109
{ upper: 0.001, round: () => 0.001 },
1110
{ upper: 0.01, round: () => 0.01 },
1211
{ upper: 0.1, round: () => 0.1 },
1312
{ upper: 0.5, round: () => 0.5 },
1413
{ upper: 10, round: (n) => Math.ceil(n) },
15-
{ upper: 50, round: (n) => Math.ceil(n / 5) * 5 },
14+
{ upper: 50, round: (n) => Math.ceil(n / 10) * 10 },
1615
];
1716

1817
export function normalizeValue(value: number): number | null {
@@ -27,7 +26,7 @@ export function normalizeValue(value: number): number | null {
2726
}
2827

2928
// Fallback for values <= 0 or any unexpected case
30-
return 0.0001;
29+
return 0.001;
3130
}
3231

3332
export const getPercentileRank = (rank?: number | null, amountOfUsers?: number): number | null => {

0 commit comments

Comments
 (0)