Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OSS101] Task 3: Display OpenDigger labels in the right of the repository header #807 #847

Merged
merged 4 commits into from
Jul 29, 2024
Merged
Changes from 1 commit
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
24 changes: 24 additions & 0 deletions src/pages/ContentScripts/features/repo-header-labels/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ const View = ({ activity, openrank, participant, contributor, meta }: Props): JS
const participantData = generateDataByMonth(participant, meta.updatedAt);
const contributorData = generateDataByMonth(contributor, meta.updatedAt);

type Label = {
id: string;
name: string;
type: string;
};

const labels: Label[] = meta.labels as Label[];
wangyantong2000 marked this conversation as resolved.
Show resolved Hide resolved

const spans = labels.map((label, index) => (
wangyantong2000 marked this conversation as resolved.
Show resolved Hide resolved
wangyantong2000 marked this conversation as resolved.
Show resolved Hide resolved
<span
key={label.id} // 使用label的id作为key
wangyantong2000 marked this conversation as resolved.
Show resolved Hide resolved
id={label.id}
className="Label Label--secondary v-align-middle mr-1 unselectable"
style={{
color: githubTheme === 'light' ? '#24292f' : '#c9d1d9'
}}
>
{label.name}
</span>
));

return (
<div className="d-flex">
<span
Expand Down Expand Up @@ -125,6 +146,9 @@ const View = ({ activity, openrank, participant, contributor, meta }: Props): JS
{numberWithCommas(contributorData[contributorData.length - 1][1])}/
{numberWithCommas(participantData[participantData.length - 1][1])}
</span>

{spans}

</div>
);
};
Expand Down
Loading