Skip to content

Commit

Permalink
Merge pull request #317 from Subhajit-2023-44/1
Browse files Browse the repository at this point in the history
Create a responsive Total Contributions section done ! #312
  • Loading branch information
multiverseweb authored Nov 9, 2024
2 parents 37a0080 + bb116d6 commit 48b3345
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions resources/contributorsSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ async function fetchData() {
}

// Render stats
function renderStats(repoStats, contributorsCount) {
function renderStats(repoStats, contributors) {

const statsGrid = document.getElementById('statsGrid');


// Calculate total contributions from the fetched contributors data
const totalContributions = contributors.reduce((sum, contributor) => sum + contributor.contributions, 0);

const stats = [
{ label: 'Contributors', value: contributorsCount, icon: 'users' },
{ label: 'Total Contributions', value: repoStats.contributors?.reduce((sum, contributor) => sum + contributor.contributions, 0) || 0, icon: 'git-commit' },
{ label: 'Contributors', value: contributors.length, icon: 'users' },
{ label: 'Total Contributions', value: totalContributions, icon: 'git-commit' },
{ label: 'GitHub Stars', value: repoStats.stargazers_count || 0, icon: 'star' },
{ label: 'Forks', value: repoStats.forks_count || 0, icon: 'git-branch' }
];
Expand Down Expand Up @@ -77,6 +83,7 @@ function getIcon(name) {

// Initialize the page
async function init() {

const loading = document.getElementById('loading');
const contributorsGrid = document.getElementById('contributorsGrid');

Expand All @@ -85,13 +92,16 @@ async function init() {

const { contributors, repoStats } = await fetchData();

renderStats(repoStats, contributors.length);
// Pass both the repoStats and contributors array to renderStats
renderStats(repoStats, contributors);
renderContributors(contributors);

loading.style.display = 'none';
contributorsGrid.style.display = 'grid';

}


// Handle form submission
document.getElementById('subscribeForm').addEventListener('submit', function(e) {
e.preventDefault();
Expand Down

0 comments on commit 48b3345

Please sign in to comment.