<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ My Hacktoberfest Journey]]></title><description><![CDATA[ My Hacktoberfest Journey]]></description><link>https://rakshithapatel08.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 17:30:43 GMT</lastBuildDate><atom:link href="https://rakshithapatel08.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA["A Month of Pull Requests: My Hacktoberfest Story"]]></title><description><![CDATA[Hacktoberfest is a joyful event for coders to contribute to open-source projects and be a part of the global coding community. It happens during the month of October. In this journey, I worked on "dom-manipulation library" called DOM Wizard, a javasc...]]></description><link>https://rakshithapatel08.hashnode.dev/a-month-of-pull-requests-my-hacktoberfest-story</link><guid isPermaLink="true">https://rakshithapatel08.hashnode.dev/a-month-of-pull-requests-my-hacktoberfest-story</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[DOM manipulation]]></category><dc:creator><![CDATA[Rakshitha Patel]]></dc:creator><pubDate>Mon, 13 Nov 2023 09:33:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/044AnorPjAU/upload/bc2d05d6cb2c8d14608d4a696f9f0361.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hacktoberfest is a joyful event for coders to contribute to open-source projects and be a part of the global coding community. It happens during the month of October. In this journey, I worked on <strong>"dom-manipulation library"</strong> called <strong>DOM Wizard</strong>, a javascript predominant library which mainly focuses on making the dom-manipulation functions easier.</p>
<p>My contributions was to <a target="_blank" href="https://github.com/lindelwa122/dom-wizard">https://github.com/lindelwa122/dom-wizard</a>. I gained lot of experiences while working on this package.</p>
<p>This package is now available on NPMJS Registry - <a target="_blank" href="https://www.npmjs.com/package/dom-wizard">https://www.npmjs.com/package/dom-wizard</a></p>
<h2 id="heading-contribution-01-dom-delete-feature">Contribution 01 : DOM delete Feature</h2>
<h3 id="heading-dommanager">domManager</h3>
<p>The <strong>domManager</strong> module is responsible for creating, updating, reading, and deleting DOM elements.</p>
<h3 id="heading-delete">delete()</h3>
<p>The <code>delete()</code> function is responsible for removing an element or elements from the DOM.</p>
<p><strong>Parameters/Inputs:</strong></p>
<ul>
<li><p><code>selector</code>: string</p>
</li>
<li><p><code>all</code>: boolean (optional)</p>
</li>
</ul>
<p>The function accepts two parameters: <code>selector</code> (string) and <code>all</code> (boolean), with a default value of <code>false</code>.</p>
<p><code>delete()</code> function will remove the specified element from the DOM, or if <code>all</code> is set to <code>true</code>, it will remove all elements that match the selector.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> deleteContent = <span class="hljs-function">() =&gt;</span> {

  <span class="hljs-keyword">const</span> deleteElement = <span class="hljs-function">(<span class="hljs-params">selector, all = <span class="hljs-literal">false</span></span>)=&gt;</span>{

    <span class="hljs-keyword">const</span> el = (!all ? <span class="hljs-built_in">document</span>.querySelector(selector): <span class="hljs-built_in">document</span>.querySelectorAll(selector))

    <span class="hljs-keyword">if</span>(!el || el.length === <span class="hljs-number">0</span>){
      <span class="hljs-built_in">console</span>.error(<span class="hljs-string">"invalid selector"</span>)
      <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"invalid selector"</span>);
    }     

    <span class="hljs-keyword">if</span> (!all) {
      el.remove();
    }

    <span class="hljs-keyword">if</span> (all) {
      el.forEach(<span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
          e.remove();
        })
      }
    };

    <span class="hljs-keyword">return</span> { deleteElement };
};

<span class="hljs-keyword">export</span> { deleteContent }
</code></pre>
<pre><code class="lang-markdown"><span class="hljs-section">## DOM-delete() feature usage</span>

To delete the specific HTML element from the DOM, use the <span class="hljs-code">`deleteElement()`</span> function. For example, to delete a HTML element with id as <span class="hljs-code">`heading`</span> you would use the following code:

<span class="hljs-code">```javascript
import { deleteContent } from "./index.js";

const dom = deleteContent();

dom.deleteElement("#heading");
```</span>

To delete all the elements matching the selector (here class <span class="hljs-code">`para`</span>), pass the second parameter <span class="hljs-code">`all`</span> as <span class="hljs-code">`true`</span> (has default value false), use the following code:

<span class="hljs-code">```javascript
import { deleteContent } from "./index.js";

const dom = deleteContent();

dom.deleteElement(".para", true);
```</span>

NOTE: Always valid selector must be passed.
</code></pre>
<h2 id="heading-contribution-02-storegetstate-feature">Contribution 02 : store.getState() Feature</h2>
<h3 id="heading-store">store</h3>
<p>The <code>store</code> will hold variables that are intended to be accessible throughout the app. Users will be able to retrieve and modify these variables from anywhere within the app.</p>
<h3 id="heading-getstate">getState()</h3>
<p><code>getState()</code> takes a property name as input and returns the value of that property.</p>
<p><strong>Parameter/Input:</strong></p>
<ul>
<li><code>key</code>: string</li>
</ul>
<p>The function returns the value of the <code>key</code> if it exists, and <code>undefined</code> if it doesn't.</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getState</span>(<span class="hljs-params">key</span>)</span>{

    <span class="hljs-keyword">if</span> (key === <span class="hljs-string">""</span> || <span class="hljs-keyword">typeof</span>(key) !== <span class="hljs-string">"string"</span> ) {
        <span class="hljs-built_in">console</span>.error(<span class="hljs-string">"Invalid key"</span>);
        <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Invalid key"</span>);
    }

    <span class="hljs-comment">// if the value of the key is undefined , gives an error and returns undefined</span>
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">this</span>[key] === <span class="hljs-literal">undefined</span>) {
        <span class="hljs-built_in">console</span>.error(<span class="hljs-string">"The value of the key is undefined "</span>);
        <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Value is undefined"</span>);
    }

    <span class="hljs-keyword">return</span> <span class="hljs-built_in">this</span>[key];

}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> getState;
</code></pre>
<pre><code class="lang-markdown"><span class="hljs-section">## getState Usage</span>

To get the state of the store, use the <span class="hljs-code">`getState()`</span> function. For example, to get the state of the <span class="hljs-code">`key`</span>, you would use the following code:

<span class="hljs-code">```javascript
const value = store.getState(key);

// prints value of the key
console.log(value);
```</span>

Note: the function throws an error if the value doesn't exist.
</code></pre>
<h2 id="heading-contribution-03-routeractivate-feature">Contribution 03 : router.activate() Feature</h2>
<h3 id="heading-router">router</h3>
<p>The <code>router</code> module is responsible for registering routes, linking pages, and configuring URLs.</p>
<h3 id="heading-activate">activate()</h3>
<p><code>activate()</code> is a private function responsible for adding the <code>active</code> "className" to a specific element.</p>
<p><strong>Parameters/Inputs:</strong></p>
<ul>
<li><code>element</code>: HTMLElement</li>
</ul>
<p>The function takes an element as input and adds the <code>active</code> class to its <code>classList</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> _activate = <span class="hljs-function">(<span class="hljs-params">ele</span>) =&gt;</span> {
    ele.classList.add(<span class="hljs-string">'active'</span>);
  };

_activate(info.element);
</code></pre>
<h2 id="heading-contribution-04-addevent-feature">Contribution 04 : addEvent() Feature</h2>
<p>This feature is <strong>"hacktoberfest accepted"</strong>, but you can see this in the second version of the library which will be published soon in the <strong>npm registry</strong>.</p>
<p>This function <code>addEvent()</code> is implemented to add events . By using this function, user can easily add the events for the required html elements by just passing them as parameters.</p>
<ul>
<li><p>It increases code readability .</p>
</li>
<li><p>The user can import the callback functions and re-use them.</p>
</li>
<li><p>The user can just focus on writing the <code>eventHandlers</code> rather than getting the HTML element each time and adding event listeners.</p>
</li>
</ul>
<p>The code will look something like this.<br /><code>addEvent(selector,event,eventHandler,all);</code> , this will add the <code>event</code> for the HTML element matching the selector. <code>all</code> will be default <code>false</code> , when set to <code>true</code> the function will add the event for all the elements matching the selector.</p>
<p>And the function will validate all the parameters.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> event = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> addEvent = <span class="hljs-function">(<span class="hljs-params">selector, event, eventHandler, all = <span class="hljs-literal">false</span></span>)=&gt;</span>{
    <span class="hljs-keyword">const</span> el = !all
      ? <span class="hljs-built_in">document</span>.querySelector(selector)
      : <span class="hljs-built_in">document</span>.querySelectorAll(selector);

      <span class="hljs-keyword">if</span>(<span class="hljs-keyword">typeof</span>(selector) !== <span class="hljs-string">'string'</span> || <span class="hljs-keyword">typeof</span>(event) !== <span class="hljs-string">'string'</span> || <span class="hljs-keyword">typeof</span>(all) !== <span class="hljs-string">'boolean'</span>){
        <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Parameter type is invalid"</span>);
      }

      <span class="hljs-keyword">if</span> (!el || el.length === <span class="hljs-number">0</span>) {
        <span class="hljs-built_in">console</span>.error(<span class="hljs-string">'invalid selector'</span>);
        <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">'invalid selector'</span>);
      }

      <span class="hljs-keyword">if</span>(<span class="hljs-keyword">typeof</span>(eventHandler) !== <span class="hljs-string">"function"</span>){
        <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Event handler must be a callback function"</span>);
      }

      <span class="hljs-keyword">if</span>(!all){
        el.addEventListener(event, eventHandler);
      }

      <span class="hljs-keyword">if</span>(all){
        el.forEach(<span class="hljs-function">(<span class="hljs-params">element</span>)=&gt;</span>{
           element.addEventListener(event, eventHandler);
        });
      }

  };
  <span class="hljs-keyword">return</span> { addEvent };
};

<span class="hljs-keyword">export</span> { event };
</code></pre>
<pre><code class="lang-markdown"><span class="hljs-section">## addEvent() usage</span>

This function is used to <span class="hljs-code">`add events`</span> to specific HTML element. It takes four parameters like <span class="hljs-code">`selector`</span> (can be id, class), <span class="hljs-code">`event`</span> (can be any events like click, onchange,mouseover), <span class="hljs-code">`eventHandler`</span> (must be a callback function) and <span class="hljs-code">`all`</span>(default is false).

<span class="hljs-code">```javascript
import { event } from './index.js';

const { addEvent } = event();

// adds "click" event to button with id "button".
addEvent("#button","click",()=&gt;{console.log("clicked")},false);
```</span>

The <span class="hljs-code">`selector`</span> and <span class="hljs-code">`event`</span> must be in string, <span class="hljs-code">`all`</span> must be in boolean. 

If <span class="hljs-code">`all`</span> is set to true , the function adds the event to all HTML elements matching the selector.

<span class="hljs-code">```javascript
import { event } from './index.js';

const { addEvent } = event();

const clickHandler = ()=&gt;{console.log("clicked")};

// adds "click" event to ALL the buttons with class "button".
addEvent(".button", "click", clickHandler, true);
```</span>

The callback function can be imported from any other <span class="hljs-code">`.js`</span>file also.
</code></pre>
<h2 id="heading-contribution-05-ui-enhancements">Contribution 05 : UI Enhancements</h2>
<p>I found the <a target="_blank" href="https://github.com/justEhmadSaeed/landing-page-template">https://github.com/justEhmadSaeed/landing-page-template</a> quite interesting and thought of improving some features to make it look more aesthetic using <strong>ReactJS</strong> and <strong>NextJS.</strong></p>
<p><a target="_blank" href="https://landing-page-template-nine.vercel.app/">https://landing-page-template-nine.vercel.app/</a> This website needed some enhancements with regard to the logo color, updating the twitter logo, button features upon hover.</p>
<ul>
<li><p>The <code>vercel app logo</code> has been changed to colour white when in dark mode for better visibility.</p>
</li>
<li><p>The button containing the <code>github logo</code> did not match in terms of color with the wordings <code>Get it on github</code>.</p>
</li>
<li><p>During hover of this button the logo must change to black and remain white not hovered. This feature is coded.</p>
</li>
<li><p>In the footer, the logos has been changed to white for better visibility.</p>
</li>
<li><p>The outdated <code>twitter logo</code> was updated.</p>
</li>
</ul>
<p>After adding my feature the website looked like..</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698850631193/eab33295-9d51-4cb5-a61e-3519bb17ef75.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698850656803/d464c7f9-9018-441e-aca0-413da666fb94.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item></channel></rss>