Home > Web Front-end > JS Tutorial > body text

Hacktoberfest Week Diving Deeper into Code Contributions

Patricia Arquette
Release: 2024-10-12 08:38:01
Original
704 people have browsed it

Hacktoberfest Week Diving Deeper into Code Contributions

Greetings, everyone! How’s Hacktoberfest going for you this year? Personally, I’m really enjoying it so far. We’ve now entered the second week of October, which means it’s time for my second pull request (PR) out of the four needed to complete the challenge. This week, I decided to push myself a bit further by contributing to a project’s codebase rather than focusing solely on documentation, as I did in Week 1.

Recap of Week 1

In my first PR of Hacktoberfest, I worked on improving project documentation. As a beginner, I wanted to ease into the process with smaller, manageable tasks. However, for this second week, I decided to take on something more technical: contributing to the GitExplorer project.

Project Overview: GitExplorer

GitExplorer is a web application that simplifies the discovery and exploration of top GitHub repositories. It allows users to filter repositories based on programming languages, topics, and other sorting criteria. While the UI is still under development, the project offers a valuable learning opportunity for contributors, especially beginners. Many of the issues in the repository are tagged as "good first issue," making it a great place to start.

For my contribution, I chose to implement a navigation feature that enhances user experience when browsing repositories.

Identifying the Problem

The project initially had a button for navigating to the next page of repositories, but it lacked a full pagination system. Users couldn't easily navigate back and forth between pages or jump to a specific page, which posed usability issues. I noticed this limitation and requested the project maintainer to assign the issue to me.

During my time working on the project, one aspect that stood out (and not in a good way) was the way the codebase was structured. The project had all the logic written into a single script.js file, which could become difficult to maintain as the project grows. While I didn't want to make major changes in this PR—since it focused only on the pagination buttons—I plan to suggest refactoring the code structure in a future issue.

Actually, before that there is another developer who created a button that navigate to the next page, but it's not good for User experience when they want to navigate back and forth, as well as specific page. Due to this reason, I commented to ask maintainer assign this issue for me.
As the time when I was working on this project, there is one thing that I didn't like about it. It is the way the maintainer structure his code base as he was writing every logic into only 1 script.js file. However, I don't want to have a lot of fix in this issue because it only ask for pagination buttons. I will create a new issue requesting to re-structure the code base later.

New Feature: Enhanced Pagination

The existing functionality had only one button to navigate between pages, with 10 repositories displayed per page. My goal was to implement a more user-friendly pagination system with "Previous," "Next," and numbered page buttons. This would allow users to jump directly to the page they're interested in, making the navigation experience smoother.

Implementation

GitHub API Constraints:

While implementing the pagination, I encountered a limitation with GitHub's API, which restricts results to 1,000 items. If a search yields more than 1,000 repositories, attempting to navigate beyond this limit results in an error, returning undefined data. Given the design displays 10 repositories per page, I capped the number of pages at 100 to avoid hitting this issue.

Code Changes:

  • I introduced a new

    section in script.js for pagination. This allowed me to add some CSS styles to improve the button aesthetics and user experience.

  • The core logic for pagination was encapsulated in two new functions:

    • createButton()
    • renderPagination() These functions dynamically generated the pagination buttons based on the available pages and applied styles to disable the current page button, preventing users from accidentally re-clicking it. I also added hover effects to the buttons for a more polished look.

CSS Improvements:

For the pagination design, I made sure that the current page button is disabled and styled differently to indicate its state. Other page buttons received hover effects to enhance interactivity and improve user experience.

結論

我對 Hacktoberfest 第二週的貢獻就到此結束了。我現在正在尋找下周可以貢獻的另一個存儲庫。理想情況下,我希望找到一個更具挑戰性的項目,這樣我就可以繼續鞭策自己並逐步提高我的技能。

感謝您的閱讀,我期待分享更多有關我的 Hacktoberfest 之旅的資訊!

The above is the detailed content of Hacktoberfest Week Diving Deeper into Code Contributions. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template