The View My Work button at the top should point to my GitHub. When hovering over the Tech Stack & Expertise cards, it should reference the GitHub projects I have that utilize these technologies, and the icons towards the bottom aren't currently successfully loading the icons.
81c9a7c verified Download script.js from iHadTimeOnce/pixelwizard-portfolio-playground: direct link, hf CLI and curl.
- Browser
- Download file 6.61 kB
-
https://huggingface.co/spaces/iHadTimeOnce/pixelwizard-portfolio-playground/resolve/main/script.js
- Command line
-
hf download hf://spaces/iHadTimeOnce/pixelwizard-portfolio-playground/script.js
-
curl -L -o script.js https://huggingface.co/spaces/iHadTimeOnce/pixelwizard-portfolio-playground/resolve/main/script.js
6.61 kB
| // Main application script | |
| // GitHub API configuration | |
| const GITHUB_USERNAME = 'JoelA510'; | |
| const GITHUB_API_URL = `https://api.github.com/users/${GITHUB_USERNAME}/repos`; | |
| const PROJECTS_TO_SHOW = 4; | |
| // DOM Elements | |
| const projectsContainer = document.getElementById('projects-container'); | |
| // Fetch and display GitHub projects | |
| async function loadGitHubProjects() { | |
| try { | |
| // Show loading state | |
| projectsContainer.innerHTML = ` | |
| <div class="col-span-2 flex justify-center items-center py-12"> | |
| <div class="loading-spinner"></div> | |
| <span class="ml-3 text-gray-600">Loading projects...</span> | |
| </div> | |
| `; | |
| const response = await fetch(GITHUB_API_URL); | |
| if (!response.ok) { | |
| throw new Error(`GitHub API error: ${response.status}`); | |
| } | |
| const repos = await response.json(); | |
| // Sort by last updated and take the most recent ones | |
| const recentRepos = repos | |
| .sort((a, b) => new Date(b.updated_at) - new Date(a.updated_at)) | |
| .slice(0, PROJECTS_TO_SHOW); | |
| // Clear loading state | |
| projectsContainer.innerHTML = ''; | |
| // Create project cards | |
| recentRepos.forEach((repo, index) => { | |
| const projectCard = document.createElement('project-card'); | |
| projectCard.setAttribute('title', repo.name); | |
| projectCard.setAttribute('description', repo.description || 'No description available'); | |
| projectCard.setAttribute('language', repo.language || 'Various'); | |
| projectCard.setAttribute('stars', repo.stargazers_count); | |
| projectCard.setAttribute('forks', repo.forks_count); | |
| projectCard.setAttribute('url', repo.html_url); | |
| projectCard.setAttribute('updated', new Date(repo.updated_at).toLocaleDateString()); | |
| projectCard.setAttribute('delay', index * 100); | |
| // Add progress visualization (simulated based on repo metrics) | |
| const progress = calculateProgress(repo); | |
| projectCard.setAttribute('progress', progress); | |
| projectsContainer.appendChild(projectCard); | |
| }); | |
| } catch (error) { | |
| console.error('Error loading GitHub projects:', error); | |
| projectsContainer.innerHTML = ` | |
| <div class="col-span-2 text-center py-12"> | |
| <i data-feather="alert-circle" class="w-16 h-16 text-red-500 mx-auto mb-4"></i> | |
| <h3 class="text-xl font-semibold text-gray-700 mb-2">Unable to load projects</h3> | |
| <p class="text-gray-600">Please check your connection or try again later.</p> | |
| <button onclick="loadGitHubProjects()" class="mt-4 px-6 py-2 bg-primary-500 text-white rounded-lg hover:bg-primary-600 transition-colors"> | |
| <i data-feather="refresh-cw" class="w-4 h-4 inline mr-2"></i> | |
| Retry | |
| </button> | |
| </div> | |
| `; | |
| feather.replace(); | |
| } | |
| } | |
| // Calculate progress based on repository metrics | |
| function calculateProgress(repo) { | |
| // Simulate progress based on various factors | |
| let progress = 50; // Base progress | |
| // Adjust based on repository activity | |
| if (repo.has_pages) progress += 10; | |
| if (repo.has_issues) progress += 5; | |
| if (repo.has_projects) progress += 5; | |
| if (repo.has_wiki) progress += 5; | |
| // Adjust based on size (more files = more complete) | |
| if (repo.size > 1000) progress += 10; | |
| // Adjust based on age (newer = less complete) | |
| const daysSinceUpdate = (new Date() - new Date(repo.updated_at)) / (1000 * 60 * 60 * 24); | |
| if (daysSinceUpdate > 30) progress += 15; // Older projects might be more complete | |
| if (daysSinceUpdate > 90) progress += 10; | |
| // Cap at 100 | |
| return Math.min(progress, 100); | |
| } | |
| // Smooth scroll for anchor links | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Smooth scroll for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| const targetId = this.getAttribute('href'); | |
| if (targetId === '#') return; | |
| const targetElement = document.querySelector(targetId); | |
| if (targetElement) { | |
| window.scrollTo({ | |
| top: targetElement.offsetTop - 100, | |
| behavior: 'smooth' | |
| }); | |
| } | |
| }); | |
| }); | |
| // Add animation classes on scroll | |
| const observerOptions = { | |
| threshold: 0.1, | |
| rootMargin: '0px 0px -50px 0px' | |
| }; | |
| const observer = new IntersectionObserver((entries) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| entry.target.classList.add('animate-fadeInUp'); | |
| } | |
| }); | |
| }, observerOptions); | |
| // Observe elements to animate | |
| document.querySelectorAll('section > div').forEach(section => { | |
| observer.observe(section); | |
| }); | |
| // Initialize tooltips | |
| document.querySelectorAll('[data-tooltip]').forEach(element => { | |
| element.addEventListener('mouseenter', function() { | |
| const tooltip = document.createElement('div'); | |
| tooltip.className = 'absolute z-50 px-3 py-2 text-sm text-white bg-gray-900 rounded-lg shadow-lg'; | |
| tooltip.textContent = this.getAttribute('data-tooltip'); | |
| tooltip.style.top = `${this.offsetTop - 40}px`; | |
| tooltip.style.left = `${this.offsetLeft + this.offsetWidth / 2 - tooltip.offsetWidth / 2}px`; | |
| document.body.appendChild(tooltip); | |
| this.dataset.tooltipElement = tooltip; | |
| }); | |
| element.addEventListener('mouseleave', function() { | |
| if (this.dataset.tooltipElement) { | |
| document.body.removeChild(this.dataset.tooltipElement); | |
| delete this.dataset.tooltipElement; | |
| } | |
| }); | |
| }); | |
| // Initialize theme (light mode by default) | |
| document.documentElement.classList.remove('dark'); | |
| document.documentElement.classList.add('light'); | |
| // Load GitHub projects | |
| loadGitHubProjects(); | |
| }); | |
| // Utility function to format numbers | |
| function formatNumber(num) { | |
| if (num >= 1000000) { | |
| return (num / 1000000).toFixed(1) + 'M'; | |
| } | |
| if (num >= 1000) { | |
| return (num / 1000).toFixed(1) + 'K'; | |
| } | |
| return num.toString(); | |
| } | |
| // Export functions for use in components | |
| window.PortfolioUtils = { | |
| formatNumber, | |
| loadGitHubProjects | |
| }; |