<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Yazed Jamal on Medium]]></title>
        <description><![CDATA[Stories by Yazed Jamal on Medium]]></description>
        <link>https://medium.com/@yazed.jamal?source=rss-f83a92b7ef8f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UYZPXoe_0g3eZhS8j3RIWQ.jpeg</url>
            <title>Stories by Yazed Jamal on Medium</title>
            <link>https://medium.com/@yazed.jamal?source=rss-f83a92b7ef8f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 06:47:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yazed.jamal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building Retro UIs with React: Introducing pixelartui-react]]></title>
            <link>https://medium.com/@yazed.jamal/building-retro-uis-with-react-introducing-pixelartui-react-9c89aec4a6e0?source=rss-f83a92b7ef8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c89aec4a6e0</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[webdev]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Yazed Jamal]]></dc:creator>
            <pubDate>Wed, 06 May 2026 08:11:01 GMT</pubDate>
            <atom:updated>2026-05-06T08:11:01.290Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8pe3nhVsfMZfCep3nlcpkw.png" /></figure><h3>Why Pixel Art in Modern Web Design?</h3><p>In an era of ultra-minimalist designs and Material UI clones, there’s something refreshingly unique about pixel art aesthetics. Whether you’re building a retro-styled game, a nostalgic portfolio, or just want to stand out from the crowd, pixel art UI brings character and personality to your React applications.</p><p>Enter <strong>pixelartui-react</strong> — an open-source React component library that makes building pixel-perfect retro interfaces as easy as importing a component.</p><h3>What is pixelartui-react?</h3><p>pixelartui-react is a comprehensive React component library built entirely around pixel art design principles. It provides ready-to-use, customizable components that bring that authentic 8-bit and 16-bit era aesthetic to modern web applications.</p><p><strong>Key Features:</strong></p><ul><li>🎮 <strong>11+ Pixel Art Components</strong> — Button, Modal, Select, TextInput, TextArea, Pagination, Switch, and more</li><li>⚡ <strong>Built for React 19</strong> — Modern, performant, and fully typed with TypeScript</li><li>🎨 <strong>Customizable Theming</strong> — Adapt the pixel art style to match your brand</li><li>📦 <strong>Zero Config</strong> — Install and start building immediately</li><li>🌐 <strong>Open Source</strong> — MIT licensed, community-driven development</li></ul><h3>Getting Started in 60 Seconds</h3><h3>Installation</h3><pre>npm  install  pixelartui-react</pre><h3>Peer Dependencies</h3><p>Make sure you have React 19 installed:</p><pre>npm  install  react@^19.1.0  react-dom@^19.1.0</pre><h3>Default Font (Optional but Recommended)</h3><p>pixelartui-react uses the Pixelify Sans font for that authentic pixel art look:</p><pre>npm  install  @fontsource/pixelify-sans</pre><p>Then import it in your app:</p><pre>import  &#39;@fontsource/pixelify-sans&#39;;</pre><h3>Your First Component</h3><pre>import { Button } from  &#39;pixelartui-react&#39;;</pre><pre>function  App() {</pre><pre>return (</pre><pre>&lt;Button  onClick={() =&gt;  alert(&#39;Retro!&#39;)}&gt;</pre><pre>Click Me!</pre><pre>&lt;/Button&gt;</pre><pre>);</pre><pre>}</pre><p>That’s it! You now have a beautiful pixel art button in your app.</p><h3>Component Showcase</h3><h3>Buttons with Character</h3><pre>import { Button } from  &#39;pixelartui-react&#39;;</pre><pre>&lt;Button  variant=&quot;primary&quot;&gt;Primary Action&lt;/Button&gt;</pre><pre>&lt;Button  variant=&quot;secondary&quot;&gt;Secondary&lt;/Button&gt;</pre><pre>&lt;Button  disabled&gt;Disabled&lt;/Button&gt;</pre><h3>Modal Dialogs</h3><pre>import { Modal, Button } from  &#39;pixelartui-react&#39;;</pre><pre>import { useState } from  &#39;react&#39;;</pre><pre>function  GameOverModal() {</pre><pre>const [isOpen, setIsOpen] = useState(false);</pre><pre>return (</pre><pre>&lt;&gt;</pre><pre>&lt;Button  onClick={() =&gt;  setIsOpen(true)}&gt;</pre><pre>Open Modal</pre><pre>&lt;/Button&gt;</pre><pre>&lt;Modal</pre><pre>isOpen={isOpen}</pre><pre>onClose={() =&gt;  setIsOpen(false)}</pre><pre>title=&quot;Game Over&quot;</pre><pre>&gt;</pre><pre>&lt;p&gt;Your score: 9999&lt;/p&gt;</pre><pre>&lt;Button  onClick={() =&gt;  setIsOpen(false)}&gt;</pre><pre>Try Again</pre><pre>&lt;/Button&gt;</pre><pre>&lt;/Modal&gt;</pre><pre>&lt;/&gt;</pre><pre>);</pre><pre>}</pre><h3>Form Inputs</h3><pre>import { TextInput, TextArea, Select, Switch } from  &#39;pixelartui-react&#39;;</pre><pre>&lt;TextInput</pre><pre>placeholder=&quot;Enter player name&quot;</pre><pre>value={playerName}</pre><pre>onChange={(e) =&gt;  setPlayerName(e.target.value)}</pre><pre>/&gt;</pre><pre>&lt;Select</pre><pre>options={[</pre><pre>{ value:  &#39;easy&#39;, label:  &#39;Easy Mode&#39; },</pre><pre>{ value:  &#39;hard&#39;, label:  &#39;Hard Mode&#39; }</pre><pre>]}</pre><pre>value={difficulty}</pre><pre>onChange={(value) =&gt;  setDifficulty(value)}</pre><pre>/&gt;</pre><pre>&lt;Switch</pre><pre>checked={soundEnabled}</pre><pre>onChange={setSoundEnabled}</pre><pre>label=&quot;Sound Effects&quot;</pre><pre>/&gt;</pre><h3>Pagination</h3><pre>import { Pagination } from  &#39;pixelartui-react&#39;;</pre><pre>&lt;Pagination</pre><pre>currentPage={currentPage}</pre><pre>totalPages={10}</pre><pre>onPageChange={(page) =&gt;  setCurrentPage(page)}</pre><pre>/&gt;</pre><h3>Perfect Use Cases</h3><p>pixelartui-react shines in these scenarios:</p><h3>🎮 Web-Based Games</h3><p>Build game UIs, menus, and HUDs with authentic retro styling that matches your pixel art graphics.</p><h3>🌟 Portfolio Sites</h3><p>Stand out from the crowd with a unique, memorable design that shows your creative personality.</p><h3>🎨 Creative Projects</h3><p>Perfect for art projects, interactive experiences, or any project where you want a distinctive visual identity.</p><h3>🏆 Hackathons</h3><p>Rapidly prototype retro-styled applications with ready-made components that look great out of the box.</p><h3>📚 Educational Projects</h3><p>Teach React concepts with components that are fun and engaging for students.</p><h3>🎭 Themed Applications</h3><p>NFT galleries, retro marketplaces, gaming communities — anywhere a pixel art aesthetic makes sense.</p><h3>Why Choose pixelartui-react?</h3><h3>1. Save Development Time</h3><p>Don’t spend hours crafting pixel-perfect borders and shadows. We’ve done the hard work so you can focus on building your app.</p><h3>2. Consistent Aesthetic</h3><p>All components follow the same design language, ensuring a cohesive look across your entire application.</p><h3>3. Modern React Practices</h3><p>Built with hooks, TypeScript, and modern React patterns. No class components, no legacy code.</p><h3>4. Lightweight &amp; Fast</h3><p>Tree-shakeable exports mean you only bundle what you use. No bloat, no performance penalties.</p><h3>5. Active Development</h3><p>Regular updates, bug fixes, and new components based on community feedback.</p><h3>6. Community-Driven</h3><p>Open-source and welcoming to contributors. Your ideas and PRs are encouraged!</p><h3>What’s Next for pixelartui-react?</h3><p>The roadmap includes exciting additions:</p><ul><li><strong>More Components</strong>: Tabs, Tooltips, Dropdown menus, Progress bars</li><li><strong>Animation Library</strong>: Pixel art transitions and effects</li><li><strong>Theme Builder</strong>: Visual tool for creating custom pixel art themes</li><li><strong>Storybook Playground</strong>: Interactive component explorer</li><li><strong>Additional Variants</strong>: 8-bit, 16-bit, and 32-bit style options</li></ul><h3>Get Involved</h3><p>pixelartui-react is open source and thrives on community contributions!</p><ul><li>⭐ <strong>Star the repo</strong>: <a href="https://github.com/Pixelartui/pixelartui-react">github.com/Pixelartui/pixelartui-react</a></li><li>📦 <strong>Try it out</strong>: npm install pixelartui-react</li><li>🐛 <strong>Report bugs</strong>: Open an issue on GitHub</li><li>💡 <strong>Request features</strong>: We love hearing your ideas</li><li>🤝 <strong>Contribute</strong>: PRs are welcome! Check out <a href="http://contributing.md/">CONTRIBUTING.md</a></li><li>💬 <strong>Join the discussion</strong>: GitHub Discussions</li></ul><h3>Resources</h3><ul><li><strong>NPM Package</strong>: <a href="https://www.npmjs.com/package/pixelartui-react">npmjs.com/package/pixelartui-react</a></li><li><strong>GitHub Repository</strong>: <a href="https://github.com/Pixelartui/pixelartui-react">github.com/Pixelartui/pixelartui-react</a></li><li><strong>Documentation</strong>: <a href="https://pixelartui.github.io/storybook">https://pixelartui.github.io</a></li><li><strong>License</strong>: MIT</li></ul><h3>Conclusion</h3><p>If you’re looking to add character, nostalgia, and uniqueness to your React applications, pixelartui-react offers a polished solution that saves you time while delivering that authentic retro aesthetic.</p><p>Whether you’re a game developer, creative coder, or just someone who appreciates good design, pixelartui-react makes it easy to bring pixel art charm to the modern web.</p><p>Give it a try, star the repo, and join us in bringing retro computing aesthetics back to the web!</p><p><strong>Author</strong>: Yazed Jamal</p><p><strong>Current Version</strong>: 0.4.45</p><p><strong>License</strong>: MIT</p><p><strong>Contributions</strong>: Welcome and encouraged!</p><p><em>Have you built something cool with pixelartui-react? Share it in the GitHub Discussions — we’d love to see what you create!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c89aec4a6e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web Component Library with Lit]]></title>
            <link>https://medium.com/@yazed.jamal/web-component-library-with-lit-6b7153eb3e96?source=rss-f83a92b7ef8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b7153eb3e96</guid>
            <dc:creator><![CDATA[Yazed Jamal]]></dc:creator>
            <pubDate>Thu, 04 Dec 2025 23:32:55 GMT</pubDate>
            <atom:updated>2025-12-04T23:32:55.604Z</atom:updated>
            <content:encoded><![CDATA[<p>A few days ago, I set out to find the best way to adapt my current <a href="https://github.com/Pixelartui"><strong>PixelArtUI</strong></a> library so it could be used more easily across popular <a href="https://github.com/collections/javascript-game-engines">JavaScript game frameworks</a>. During my research, I noticed that most game libraries provide a DOM container capable of wrapping HTML elements and rendering them above the canvas.</p><p>This led me to realize that <strong>Web Components</strong> are an ideal format for the next evolution of PixelArtUI, allowing its components to integrate seamlessly with a wide range of game engines. As I dug deeper, I also discovered that the <a href="https://lit.dev/"><strong>Lit</strong></a> framework from Google offers an elegant way to build these components.</p><p>In this blog post, I’ll walk you through how to create a Web Component library using Lit and publish it to NPM. I will also include steps on how to setup test, Storybook and Github flow in the process.</p><p>If you only care onhow to build a Web component using Lit and nothing else, then I would recommend their step by step tutorial which is very easy to follow. But if you would like to know how I do it myself for my PixelArt component, plese follow through</p><h3>Step 1 — Create New project</h3><p>Lit provides a <a href="https://lit.dev/docs/tools/starter-kits/">starter kit</a> that makes it easy to kick off your development. You can choose to work in either JavaScript or TypeScript, I’ll be using TypeScript for this tutorial.</p><p>You can download the entire repository directly, but I prefer using the GitHub template feature to generate a clean project of my own. Simply visit the TypeScript starter kit repository, click the <strong>“Use this template”</strong> button in the top-right corner, and select <strong>“Create new repository.”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S6cOTl3AAjOuD5T7nhqFig.png" /></figure><p>Then, you can setup your new repo with your own details and create the repo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cw3hiejJZijQWav1TdZrhw.png" /></figure><p>Next, I’ll clone the newly created repository to my local environment. From there, I’ll clean up the project by removing files I don’t need. The starter kit includes <strong>Eleventy (11ty)</strong>, a static site generator, but since my component library already has its own documentation site and I’ll be using <strong>Storybook</strong> as well, so I’ll delete everything related to <strong>11ty</strong> and <strong>rollup</strong> which is used to compiled the documentation. If you like to use rollup for compiling the component library itself you definitely can do that, but for this tutorial I will use typescript compiler.</p><p>By default, the starter kit serves an HTML file that lets you preview any components you’ve built. The index.html file sits in the project root, and there’s also a dev folder containing individual component demo pages. Since we’ll be using <strong>Storybook</strong> for development and previews, we can delete the index.html file, the dev folder, and the web-dev-server.config file that powers the built-in server.</p><p>We are also going to delete the test folder and my-element.ts file in the src folder. We will get back to this later in the tutorial. Finally you could install the dependencies</p><pre>npm i</pre><p>I would like also to setup tsconfig.json properly so there will be no errors or anything later on. Here is how I setup the config</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;target&quot;: &quot;es2018&quot;,<br>    &quot;module&quot;: &quot;esnext&quot;,<br>    &quot;moduleResolution&quot;: &quot;node&quot;,<br>    &quot;noEmitOnError&quot;: true,<br>    &quot;lib&quot;: [&quot;es2017&quot;, &quot;dom&quot;],<br>    &quot;strict&quot;: true,<br>    &quot;esModuleInterop&quot;: false,<br>    &quot;allowSyntheticDefaultImports&quot;: true,<br>    &quot;experimentalDecorators&quot;: true,<br>    &quot;importHelpers&quot;: true,<br>    &quot;outDir&quot;: &quot;dist&quot;,<br>    &quot;sourceMap&quot;: true,<br>    &quot;inlineSources&quot;: true,<br>    &quot;rootDir&quot;: &quot;./src&quot;,<br>    &quot;declaration&quot;: true,<br>    &quot;skipLibCheck&quot;: true<br>  },<br>  &quot;include&quot;: [&quot;**/*.ts&quot;],<br>  &quot;exclude&quot;: [&quot;dist&quot;, &quot;**/*.stories.ts&quot;]<br>}</pre><h3>Step 2 — Integrate Storybook</h3><p>First install the Storybook itself</p><pre>npm create storybook@latest</pre><p>When prompt for the right builder, choose Vite, Then choose minimal installation as we would like to keep thins simple. Next it will install all necessary dependencies related to web component and automatically start the server. If somehow this do not happen, you need to install the dependencies and update the storybook config manually like below.</p><pre>npm install --save-dev @storybook/web-components-vite</pre><pre>// main.ts<br><br>import type {StorybookConfig} from &#39;@storybook/web-components-vite&#39;;<br><br>const config: StorybookConfig = {<br>  stories: [&#39;../src/**/*.stories.@(js|jsx|mjs|ts|tsx)&#39;],<br>  addons: [],<br>  framework: &#39;@storybook/web-components-vite&#39;,<br>};<br>export default config;</pre><p>During the installation, Storybook also will automatically create a stories folder where it store all the component story files. We would not need this folder and it can be deleted, and everything inside it.</p><h3>Step 3 — Create our first component</h3><p>For simplicity lets create a component which comprises a div with a border and a text inside it. We will call it Boxt. First create a folder of the same name in the src folder and an index.ts inside it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*BhOH8jmQM-xHiCoQ5XuurA.png" /></figure><p>Below is the minimum code on how to create a web component using Lit.</p><pre>// index.ts<br>import {LitElement, html} from &#39;lit&#39;;<br>import {customElement} from &#39;lit/decorators.js&#39;;<br><br>@customElement(&#39;my-boxt&#39;)<br>export class Boxt extends LitElement {<br>  override render() {<br>    return html`<br>      &lt;div&gt;<br>        &lt;slot&gt;&lt;/slot&gt;<br>      &lt;/div&gt;<br>    `;<br>  }<br>}</pre><p>Lets actually understand what it is all about. First we import the necessary items from lit. LitElement is the class we need to inherits all the web components properties. html tag returns a description of the DOM to render as a value. In other words we need to use this to render our web component.</p><p>Lit also support decorators in their framework. customElement is one of them which allow us to declare my-boxt as a custom element in the DOM. Please refer <a href="https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/define#valid_custom_element_names">here</a> for a guide how to choose a valid name for your component</p><p>So as I said earlier, when we create our new component class we should extend LitElement to it. If you notice, in the returned html literal, I’ve used a slot tag inside the div. We need to use slot in order to render any child inside the custom element. In our case we need to render a text so we will need slot for that. More information about slot and the shadow DOM you can have a read <a href="https://lit.dev/docs/components/shadow-dom/#slots">here</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/slot">here</a>.</p><p>Next we will create the story for Boxt component. In the same Boxt folder create a file called Boxt.stories.ts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*dObVsSDKAANURCl0ZxeuYQ.png" /></figure><p>Below is the basic code to create your story for web component</p><pre>// Box.stories.ts<br>import type {Meta, StoryObj} from &#39;@storybook/web-components-vite&#39;;<br><br>const meta: Meta = {<br>  title: &#39;Components/Boxt&#39;,<br>  component: &#39;my-boxt&#39;,<br>};<br><br>export default meta;<br><br>type Story = StoryObj;<br><br>export const Default: Story = {<br>  args: {<br>    innerText: &#39;This is a Boxt&#39;,<br>  },<br>};</pre><p>since web component is just another DOM element we assign the child using innerText . Run you Storybook server and this is how it looks</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*JRjorA_nzqm2gS_Zikzu4w.png" /></figure><p>Yeaaah, the component is alive!!! However we need to touch it up with some CSS next. Create another file called styles.ts inside the Boxt folder. Here we will defined our styling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*raCsj5S4j1DFf90IPPsG6Q.png" /></figure><p>Before we start styling, we need to actually understand how shadow DOM works. In simple words, when you render a LitElement, it will render the template inside a <strong>shadow DOM</strong> in a form called <strong>shadow tree</strong>. This shadow tree is hosted or owns by another parent element called <strong>host element.</strong></p><p>Any styling applied to a shadow tree is scoped to itself and will not effect any other element or shadow tree. Document- level styling will also no effect the content of the shadow tree.</p><p>However, the host element can be affacted by other element outside the shadow tree. In other words, it can be overridden by higher level styling. In our case we will not going to style the host element but only the rendered template. Below is how we style our component.</p><pre>// styles.ts<br>import {css} from &#39;lit&#39;;<br><br>export const StyledContainer = css`<br>  .boxt-container {<br>    border: 2px solid black;<br>    width: 200px;<br>    height: 80px;<br>  }<br>`;</pre><p>Lit provide a tagged template literal css to materialised the styles. As you can se we defined a css class called .boxt-container . We need to reflect this on the div in the template as well. Below is the updated index.ts on how to inject and apply the styling</p><pre>// index.ts<br>import {LitElement, html} from &#39;lit&#39;;<br>import {customElement} from &#39;lit/decorators.js&#39;;<br>import {StyledContainer} from &#39;./styles&#39;; // import styling<br><br>@customElement(&#39;my-boxt&#39;)<br>export class Boxt extends LitElement {<br>  static override styles = [StyledContainer]; // define as static styles<br><br>  override render() {<br>    // include the class<br>    return html`<br>      &lt;div class=&quot;boxt-container&quot;&gt; <br>        &lt;slot&gt;&lt;/slot&gt;<br>      &lt;/div&gt;<br>    `;<br>  }<br>}</pre><p>Now back to storybook and see what happen to the component. Well nothing much. This is because we forgot to do one thing. Import the component itself in the story.</p><pre>// Boxt.stories.ts<br>import type {Meta, StoryObj} from &#39;@storybook/web-components-vite&#39;;<br>import &#39;.&#39;; // import our component<br><br>const meta: Meta = {<br>  title: &#39;Components/Boxt&#39;,<br>  component: &#39;my-boxt&#39;,<br>};<br><br>export default meta;<br><br>type Story = StoryObj;<br><br>export const Default: Story = {<br>  args: {<br>    innerText: &#39;This is a Boxt&#39;,<br>  },<br>};</pre><p>Finally, the component appear as what we intended</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*_cWUc97qMuu6Nue5Dx6fSQ.png" /></figure><p>Now lets create a prop customColor so we can customised our border color. List have a decorator in order to include a porperty for the component. Import the decorator property from lit/decorators.js and define the ne property as below</p><pre><br>// index.ts<br>import {LitElement, html} from &#39;lit&#39;;<br>import {customElement, property} from &#39;lit/decorators.js&#39;; // import here<br>import {StyledContainer} from &#39;./styles&#39;;<br><br>@customElement(&#39;my-boxt&#39;)<br>export class Boxt extends LitElement {<br>  static override styles = [StyledContainer];<br><br>  /**<br>   * Custom border color.<br>   */<br>  @property({type: String}) //define here<br>  customColor = &#39;&#39;;<br><br>  override render() {<br>    return html`<br>      &lt;div style=&quot;border-color: ${this.customColor}&quot; class=&quot;boxt-container&quot;&gt;<br>        &lt;slot&gt;&lt;/slot&gt;<br>      &lt;/div&gt;<br>    `;<br>  }<br>}</pre><p>We also need to make the new property to overwrite the border color to the style property. By default the string will be empty. Now we need to add a new story for the custom color.</p><pre>import type {Meta, StoryObj} from &#39;@storybook/web-components-vite&#39;;<br>import &#39;.&#39;;<br>import {html} from &#39;lit&#39;;<br><br>const meta: Meta = {<br>  title: &#39;Components/Boxt&#39;,<br>  tags: [&#39;autodocs&#39;],<br>  component: &#39;my-boxt&#39;,<br>};<br><br>export default meta;<br><br>type Story = StoryObj;<br><br>export const Default: Story = {<br>  args: {<br>    innerText: &#39;This is a Boxt&#39;,<br>  },<br>};<br><br>export const BoxtCustomColor: Story = {<br>  args: {<br>    ...Default.args,<br>    customColor: &#39;#1C8139&#39;,<br>  },<br>  render: (args) =&gt;<br>    html`&lt;my-boxt customColor=&quot;${args.customColor}&quot;<br>      &gt;${args.innerText}&lt;/my-boxt<br>    &gt;`,<br>};</pre><p>When you save it you will see a new component sub item appear in Story book</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*va_kuKf7Nu0h-nwZhuryyw.png" /></figure><p>For a better visual in Storybook I would normally add the doc addon</p><pre>npm i --save-dev @storybook/addon-docs</pre><p>Then you will need to add the property in the Meta</p><pre>// Boxt.stories.ts<br>const meta: Meta = {<br>  title: &#39;Components/Boxt&#39;,<br>  tags: [&#39;autodocs&#39;], // add here<br>  component: &#39;my-boxt&#39;,<br>};</pre><p>and add the addon in the main.ts file</p><pre>import type { StorybookConfig } from &#39;@storybook/web-components-vite&#39;;<br><br>const config: StorybookConfig = {<br>  &quot;stories&quot;: [<br>    &quot;../src/**/*.stories.@(js|jsx|mjs|ts|tsx)&quot;<br>  ],<br>  &quot;addons&quot;: [&#39;@storybook/addon-docs&#39;], // add here<br>  &quot;framework&quot;: &quot;@storybook/web-components-vite&quot;<br>};<br>export default config;</pre><p>Finally, you will get a doc page for the component. If it doesn’t look like this you might want to kill the server and restart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kO4vav-gqNwXaxJozdR7g.png" /></figure><h3>Step 4 — Create a test</h3><p>The process will not complete without a test. Lets first setup the test environment for our components. By default, the starter kit came with <a href="https://open-wc.org/docs/testing/testing-package/">Open Web Components</a> testing library. You can always use any testing library you like which will support web components.</p><p>First renamed the config file web-test-runner.config.js to web-test-runner.mjs. You also need to install another library to support typescript</p><pre>npm i --save-dev @web/dev-server-esbuild</pre><p>Then amend the content like below</p><pre>// web-test-runner.mjs<br>/**<br> * @license<br> * Copyright 2021 Google LLC<br> * SPDX-License-Identifier: BSD-3-Clause<br> */<br><br>import {esbuildPlugin} from &#39;@web/dev-server-esbuild&#39;;<br>import {fileURLToPath} from &#39;url&#39;;<br>export default {<br>  files: [&#39;src/**/*.test.ts&#39;],<br>  nodeResolve: true,<br>  plugins: [<br>    esbuildPlugin({<br>      ts: true,<br>      tsconfig: fileURLToPath(new URL(&#39;./tsconfig.json&#39;, import.meta.url)),<br>    }),<br>  ],<br>};</pre><p>Now we can create the test file. In the same Boxt folder lets create a file called Boxt.test.ts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*FnyABBsJWITaSTkjmZCsiA.png" /></figure><p>and write some test like below</p><pre>import {html, fixture, expect} from &#39;@open-wc/testing&#39;;<br><br>import {Boxt} from &#39;.&#39;;<br>import &#39;.&#39;;<br><br>describe(&#39;Component&#39;, () =&gt; {<br>  it(&#39;should renders child correctly&#39;, async () =&gt; {<br>    const child = &#39;This is a child&#39;;<br>    const el: Boxt = await fixture(html` &lt;my-boxt&gt;${child}&lt;/my-boxt&gt; `);<br>    expect(<br>      el.shadowRoot?.querySelector(&#39;slot&#39;)?.assignedNodes()[0].textContent<br>    ).to.contain(child);<br>  });<br>});</pre><p>In the first assertion we are checking the correct child to be rendered. Run below commad to run the test</p><pre>npm run tes:dev</pre><p>Hopefully the test will pass.</p><h3>Step 5- Production Build</h3><p>So everyhting now in place, we would like to setup we want the component library to be bundled and publish as a package. I think there nothing more to add other run the script to build the package. We just need add one more thing in tsconfig.json before we could build the package. We need to exclude the tests file form being transpiled.</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;target&quot;: &quot;es2018&quot;,<br>    &quot;module&quot;: &quot;esnext&quot;,<br>    &quot;moduleResolution&quot;: &quot;node&quot;,<br>    &quot;noEmitOnError&quot;: true,<br>    &quot;lib&quot;: [&quot;es2017&quot;, &quot;dom&quot;],<br>    &quot;strict&quot;: true,<br>    &quot;esModuleInterop&quot;: false,<br>    &quot;allowSyntheticDefaultImports&quot;: true,<br>    &quot;experimentalDecorators&quot;: true,<br>    &quot;importHelpers&quot;: true,<br>    &quot;outDir&quot;: &quot;dist&quot;,<br>    &quot;sourceMap&quot;: true,<br>    &quot;inlineSources&quot;: true,<br>    &quot;rootDir&quot;: &quot;./src&quot;,<br>    &quot;declaration&quot;: true,<br>    &quot;skipLibCheck&quot;: true<br>  },<br>  &quot;include&quot;: [&quot;**/*.ts&quot;],<br>  &quot;exclude&quot;: [&quot;dist&quot;, &quot;**/*.stories.ts&quot;, &quot;**/*.test.ts&quot;] //add here<br>}</pre><p>Next, we just need to run</p><pre>npm run build</pre><p>We also need include the new generated dist folder to the gitignore list since we just need to build the package when releasing it through github action</p><pre>// .gitignore<br><br>/node_modules/<br>/lib/<br>/test/<br>custom-elements.json<br># top level source<br>my-element.js<br>my-element.js.map<br>my-element.d.ts<br>my-element.d.ts.map<br># only generated for size check<br>my-element.bundled.js<br>*storybook.log<br>storybook-static<br>/dist/</pre><p>below is the generated folder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*jFo_1OT_d-kkwdBs2-rouQ.png" /></figure><h3>Step 6 — Cretae Github actions for Pull request and Release</h3><p>First we will create a Github workflow for development push, pull request and merge. In the root location create .github/workflows folder. Then create a yml file called main.yml inside it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*kO4YvJWVXVntMhudDKDZWg.png" /></figure><p>Place the code like below</p><pre>name: Main CI<br>on:<br>  push:<br>    branches: [main]<br>  pull_request:<br>    branches: [main]<br>  merge_group:<br>    types:<br>      - checks_requested<br><br>concurrency:<br>  group: ${{ github.workflow }}-${{ github.ref }}<br>  cancel-in-progress: true<br><br>jobs:<br>  lint:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - name: Checkout<br>        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0<br><br>      - name: Setup<br>        uses: actions/setup-node@v4<br>        with:<br>          node-version: ${{ matrix.node_version }}<br>          cache: npm<br>      - name: Install dep<br>        run: npm install<br>      - name: Lint files<br>        run: npm run lint<br><br>  test:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - name: Checkout<br>        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0<br><br>      - name: Setup<br>        uses: actions/setup-node@v4<br>        with:<br>          node-version: ${{ matrix.node_version }}<br>          cache: npm<br>      - name: Install dep<br>        run: npm install<br>      - name: Run unit tests<br>        run: npm test</pre><p>In the first section it define when to trigger the jobs. In this case it will trigger push and pull request to a branch. The job listed here to run the linting check and run the unit test. Let save it, commit and try to push the changes to github. In github, on the action tab you could see the workflow in progress. In my case you can see both of the jobs successfully completed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vnTm9-24K4vXroo8EeC5nw.png" /></figure><p>Next, we need to create a workflow for the NPM package publish. In order to do that we need to create another file named publish.yml inside the workflows folder with the workflow below</p><pre>name: Publish<br><br>on:<br>  push:<br>    tags:<br>      - &#39;v*.*.*&#39;<br><br>jobs:<br>  build:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - uses: actions/checkout@v4<br>      - uses: actions/setup-node@v4<br>        with:<br>          node-version: 20<br>      - run: npm ci<br>      - run: npm test<br>      - run: npm run build<br><br>  publish-npm:<br>    needs: build<br>    runs-on: ubuntu-latest<br>    steps:<br>      - uses: actions/checkout@v4<br>      - uses: actions/setup-node@v4<br>        with:<br>          node-version: 20<br>          registry-url: https://registry.npmjs.org/<br>      - run: npm ci<br>      - run: npm run build<br>      - run: npm publish<br>        env:<br>          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}</pre><p>Now there are a few things that we need to do in prder for this workflow to work. First we need to update out package.json according to make sure the package will be publish with no problem.</p><p>We need to change the name, add the files property to tell npm that we only want to publish the listed file in the array and we also add a new script to bump up our version and create a tag.</p><p>In order for the script to work, We need to install a package we are using to manage the version which is called standard-version .</p><pre>npm i --save-dev standard-version</pre><p>Below is the final version of package.json file</p><pre>{<br>  &quot;name&quot;: &quot;boxt-component&quot;,<br>  &quot;version&quot;: &quot;0.0.1&quot;,<br>  &quot;description&quot;: &quot;A simple web component&quot;,<br>  &quot;main&quot;: &quot;dist&quot;,<br>  &quot;module&quot;: &quot;dist&quot;,<br>  &quot;files&quot;: [<br>    &quot;dist&quot;,<br>    &quot;README.md&quot;<br>  ],<br>  &quot;scripts&quot;: {<br>    &quot;build&quot;: &quot;tsc&quot;,<br>    &quot;build:watch&quot;: &quot;tsc --watch&quot;,<br>    &quot;clean&quot;: &quot;rimraf my-element.{d.ts,d.ts.map,js,js.map} test/my-element.{d.ts,d.ts.map,js,js.map} test/my-element_test.{d.ts,d.ts.map,js,js.map}&quot;,<br>    &quot;lint&quot;: &quot;npm run lint:lit-analyzer &amp;&amp; npm run lint:eslint&quot;,<br>    &quot;lint:eslint&quot;: &quot;eslint &#39;src/**/*.ts&#39;&quot;,<br>    &quot;lint:lit-analyzer&quot;: &quot;lit-analyzer&quot;,<br>    &quot;format&quot;: &quot;prettier \&quot;**/*.{cjs,html,js,json,md,ts}\&quot; --ignore-path ./.eslintignore --write&quot;,<br>    &quot;analyze&quot;: &quot;cem analyze --litelement --globs \&quot;src/**/*.ts\&quot;&quot;,<br>    &quot;analyze:watch&quot;: &quot;cem analyze --litelement --globs \&quot;src/**/*.ts\&quot; --watch&quot;,<br>    &quot;serve&quot;: &quot;wds --watch&quot;,<br>    &quot;serve:prod&quot;: &quot;MODE=prod npm run serve&quot;,<br>    &quot;test&quot;: &quot;npm run test:dev &amp;&amp; npm run test:prod&quot;,<br>    &quot;test:dev&quot;: &quot;wtr&quot;,<br>    &quot;test:watch&quot;: &quot;wtr --watch&quot;,<br>    &quot;test:prod&quot;: &quot;MODE=prod wtr&quot;,<br>    &quot;test:prod:watch&quot;: &quot;MODE=prod wtr --watch&quot;,<br>    &quot;checksize&quot;: &quot;rollup -c ; cat my-element.bundled.js | gzip -9 | wc -c ; rm my-element.bundled.js&quot;,<br>    &quot;storybook&quot;: &quot;storybook dev -p 6006&quot;,<br>    &quot;build-storybook&quot;: &quot;storybook build&quot;,<br>    &quot;release&quot;: &quot;standard-version &amp;&amp; git push --follow-tags origin main&quot;<br>  },<br>  &quot;keywords&quot;: [<br>    &quot;web-components&quot;,<br>    &quot;lit-element&quot;,<br>    &quot;typescript&quot;,<br>    &quot;lit&quot;<br>  ],<br>  &quot;author&quot;: &quot;Google LLC&quot;,<br>  &quot;license&quot;: &quot;BSD-3-Clause&quot;,<br>  &quot;dependencies&quot;: {<br>    &quot;lit&quot;: &quot;^3.2.0&quot;<br>  },<br>  &quot;devDependencies&quot;: {<br>    &quot;@custom-elements-manifest/analyzer&quot;: &quot;^0.6.3&quot;,<br>    &quot;@open-wc/testing&quot;: &quot;^4.0.0&quot;,<br>    &quot;@storybook/addon-docs&quot;: &quot;^10.1.4&quot;,<br>    &quot;@storybook/web-components-vite&quot;: &quot;^10.1.4&quot;,<br>    &quot;@typescript-eslint/eslint-plugin&quot;: &quot;^5.25.0&quot;,<br>    &quot;@typescript-eslint/parser&quot;: &quot;^5.25.0&quot;,<br>    &quot;@web/dev-server-esbuild&quot;: &quot;^1.0.4&quot;,<br>    &quot;@web/test-runner&quot;: &quot;^0.15.0&quot;,<br>    &quot;@web/test-runner-playwright&quot;: &quot;^0.9.0&quot;,<br>    &quot;@webcomponents/webcomponentsjs&quot;: &quot;^2.8.0&quot;,<br>    &quot;eslint&quot;: &quot;^8.15.0&quot;,<br>    &quot;eslint-plugin-storybook&quot;: &quot;^10.1.4&quot;,<br>    &quot;lit-analyzer&quot;: &quot;^1.2.1&quot;,<br>    &quot;prettier&quot;: &quot;^2.6.2&quot;,<br>    &quot;rimraf&quot;: &quot;^3.0.2&quot;,<br>    &quot;standard-version&quot;: &quot;^9.5.0&quot;,<br>    &quot;storybook&quot;: &quot;^10.1.4&quot;,<br>    &quot;typescript&quot;: &quot;~5.9.0&quot;<br>  },<br>  &quot;customElements&quot;: &quot;custom-elements.json&quot;<br>}</pre><p>Next we also need to create an Access Token from NPM registry assuming you already have an account with them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eX3m-Uruisewje_-eMTT7Q.png" /></figure><p>Later this token we need to set in the Github repository secrets like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*LiRhHvL560IuxeHXPswN8A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-NZU3zEfDwzCBQ9LmTKRQ.png" /></figure><p>The secret name should reflect the same name we defined in the publish.yml file.</p><pre>.<br>.<br>.<br>- run: npm publish<br>        env:<br>          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}</pre><p>After evrything is done, commit and push the latest changes. When the normal CI flow has finished you publish you package to to NPM by running</p><pre>npm run release</pre><p>A new tag will be pushed, Github will now run publish.yml workflow and publish your your package.</p><p>Thank you for reading this tutorial until the end. Feel free to use my own starter kit based on this tutorial as your starting template to build your own web component library</p><p><a href="https://github.com/muyaszed/web-component-lit-stroybook">web-component-lit-stroybook</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b7153eb3e96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Pixel art Using PixelArtUI]]></title>
            <link>https://medium.com/@yazed.jamal/create-pixel-art-using-pixelartui-f429a72af451?source=rss-f83a92b7ef8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f429a72af451</guid>
            <dc:creator><![CDATA[Yazed Jamal]]></dc:creator>
            <pubDate>Mon, 24 Nov 2025 10:58:47 GMT</pubDate>
            <atom:updated>2025-11-24T12:10:07.479Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iuED35YeimlBAQ27-xTt2Q.png" /></figure><p>After being made redundant, I decided it was finally time to finish my long-planned component-library project: <strong>PixelArtUI</strong>.</p><p>PixelArtUI is an open-source component library inspired by pixel-art aesthetics. The goal is to support all major JavaScript UI frameworks such as React and Vue, as well as popular JavaScript game libraries.</p><p>Along with common UI components like buttons, switches, and modals, PixelArtUI includes a special component that lets you <strong>render custom pixel art directly on your website</strong>.</p><p>You might wonder: <em>Why create pixel art using divs when CSS alone can do it?</em><br>The quick answer: <strong>because it’s fun</strong> and sometimes it’s useful to have pixel art as a component instead of pure CSS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*7gEX3IvY5BCuKYVJ30xkKQ.png" /><figcaption>picture credit to <a href="https://pixelartcss.com/">https://pixelartcss.com/</a></figcaption></figure><p>In this tutorial, I’ll show you how to build pixel art(like above)step-by-step using PixelArtUI and a simple React application.</p><h3>Step 1 — Create a new react app</h3><p>Create a fresh React project using your preferred setup tool (Vite, CRA, Next.js — anything works for this tutorial).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lgLMe7wJMM7pCKTMnZHAVQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ynaX_VMc0aEctrlbuemwVQ.png" /></figure><h3>Step 2 — Install the necessary library</h3><p>For now, the only dependency you need is the React version of the library:</p><pre>    npm install pixelartui-react</pre><p>(Complete installation instructions are available in the PixelArtUI <a href="https://pixelartui.github.io/doc/frameworks/react/setup">documentation</a>.)</p><h3>Step 3 — Design Your Pixel Art</h3><p>Before creating your art, it helps to understand how the <strong>Pixelator</strong> component renders pixels.</p><p>Imagine a 16×16 grid. Pixelator fills this grid <strong>from top to bottom, left to right</strong>, one pixel box at a time. This ordering helps you determine which index corresponds to which pixel. You can design your pixel art manually, but using an online tool is much easier. For this tutorial, I’ll use the editor from <a href="https://pixelartcss.com/"><strong>pixelartcss.com</strong></a>. Despite being under development, the current version works well and provides the CSS box-shadow output needed later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*7gEX3IvY5BCuKYVJ30xkKQ.png" /><figcaption>picture credit to <a href="https://pixelartcss.com/">https://pixelartcss.com/</a></figcaption></figure><p>For the example below, I’ll use:</p><ul><li>Canvas size: <strong>16 × 16</strong></li><li>Pixel size: <strong>10px</strong></li></ul><h3>Step 4 — Render Your Art With the Pixelator Component</h3><p>By the time you are reading this, the PixelArtUi documentation should spell out all the <a href="https://pixelartui.github.io/doc/components/pixelator">instruction</a> how to do this(hopefully).</p><p>According to the PixelArtUI docs, the Pixelator component requires several props, especially the pixels data:</p><pre>&lt;Pixelator<br>    pixelPerRow={10}<br>    pixelPerCol={10}<br>    pixelSize={20}<br>    showgrid={false}<br>    pixels={pixels}<br>/&gt;</pre><h4>Pixel Data Structure</h4><p>Each pixel is represented by an entry in a PixelData map:</p><pre>interface PixelData {<br>    [key: string]: {<br>        color: string;<br>        x?: string;<br>        y?: string;<br>    };<br>}</pre><p>The <strong>key</strong> represents the index of the pixel position in the grid, counting from top-left to bottom-right.</p><p>For example, a 3×3 grid contains 9 keys:</p><pre>{<br>  &quot;0&quot;: { color: &quot;#303f46&quot; },<br>  &quot;1&quot;: { color: &quot;#303f46&quot; },<br>  &quot;2&quot;: { color: &quot;#303f46&quot; },<br>  &quot;3&quot;: { color: &quot;#303f46&quot; },<br>  &quot;4&quot;: { color: &quot;#303f46&quot; },<br>  &quot;5&quot;: { color: &quot;#303f46&quot; },<br>  &quot;6&quot;: { color: &quot;#303f46&quot; },<br>  &quot;7&quot;: { color: &quot;#303f46&quot; },<br>  &quot;8&quot;: { color: &quot;#303f46&quot; },<br> }</pre><p>A 16×16 artwork contains <strong>256 entries</strong>.</p><p>Typing all of that manually would be painful, but don’t worry.</p><p>PixelArtUI provides a helper utility called <strong>cssToPixelator</strong> that generates this data automatically using the CSS box-shadow version of your design.</p><pre>import { cssToPixelator ] from &#39;pixelartui-react&#39;</pre><p>Here is how you do it.</p><p>If you read this <a href="https://css-tricks.com/fun-times-css-pixel-art/">article</a>, there are a lot of ways you can render a pixel art on your website and one of them is using css box shadows.</p><h4>The Utility Input Format</h4><p>cssToPixelator accepts this structure:</p><pre>interface CssData {<br>    css: string;<br>    canvasWidth: number;<br>    canvasHeight: number;<br>    pixelSize: number;<br>}</pre><p>The css field must contain the box-shadow output for your pixel art.<br>Here’s an example of what such CSS looks like:</p><pre>.pixelart {<br>  box-shadow: 70px 60px 0 0 #000000, 80px 60px 0 0 #000000, 60px 70px 0 0 #000000, 80px 70px 0 0 #000000, 90px 70px 0 0 #000000, 50px 80px 0 0 #000000, 60px 80px 0 0 #000000, 70px 80px 0 0 #000000, 80px 80px 0 0 #000000, 90px 80px 0 0 #000000, 50px 90px 0 0 #000000, 70px 90px 0 0 #000000, 80px 100px 0 0 #000000, 90px 100px 0 0 #000000, 80px 110px 0 0 #000000, 90px 110px 0 0 #000000, 80px 120px 0 0 #000000, 90px 120px 0 0 #000000;<br>  height: 10px;<br>  width: 10px;<br>}</pre><p>But then you might ask how am I going to come out with the box shadow css code by myself? Not to worry, again, the tool I recommended you earlier -&gt; <a href="https://pixelartcss.com/">pixelartcss.com</a>, could generate those code for you based on your pixel art design.</p><h3>Final Step — Add the Pixel Art to Your React App</h3><p>Below is a simplified example of how to integrate everything into your React code:</p><pre>//App.tsx<br><br>import { Pixelator, cssToPixelator } from &quot;pixelartui-react&quot;;<br>import &quot;./App.css&quot;;<br><br>function App() {<br>    const pixels = cssToPixelator({<br>        canvasHeight: 16,<br>        canvasWidth: 16,<br>        pixelSize: 10,<br>        css: `box-shadow: 10px 10px 0 0 #303f46, 20px 10px 0 0 #303f46, 30px 10px 0 0 #303f46, 40px 10px 0 0 #303f46, 50px 10px 0 0 #303f46, 60px 10px 0 0 #303f46, 70px 10px 0 0 #ffffff, 80px 10px 0 0 #303f46, 90px 10px 0 0 #303f46, 100px 10px 0 0 #303f46, 110px 10px 0 0 #303f46, 120px 10px 0 0 #ffffff, 130px 10px 0 0 #303f46, 140px 10px 0 0 #303f46, 150px 10px 0 0 #303f46, 160px 10px 0 0 #303f46, 10px 20px 0 0 #303f46, 20px 20px 0 0 #303f46, 30px 20px 0 0 #303f46, 40px 20px 0 0 #303f46, 50px 20px 0 0 #303f46, 60px 20px 0 0 #ffffff, 70px 20px 0 0 #ffcdd2, 80px 20px 0 0 #ffffff, 90px 20px 0 0 #303f46, 100px 20px 0 0 #303f46, 110px 20px 0 0 #ffffff, 120px 20px 0 0 #ffcdd2, 130px 20px 0 0 #ffffff, 140px 20px 0 0 #303f46, 150px 20px 0 0 #303f46, 160px 20px 0 0 #303f46, 10px 30px 0 0 #303f46, 20px 30px 0 0 #303f46, 30px 30px 0 0 #303f46, 40px 30px 0 0 #303f46, 50px 30px 0 0 #303f46, 60px 30px 0 0 #ffffff, 70px 30px 0 0 #ffcdd2, 80px 30px 0 0 #ffcdd2, 90px 30px 0 0 #ffffff, 100px 30px 0 0 #ffffff, 110px 30px 0 0 #ffcdd2, 120px 30px 0 0 #ffcdd2, 130px 30px 0 0 #ffffff, 140px 30px 0 0 #303f46, 150px 30px 0 0 #303f46, 160px 30px 0 0 #303f46, 10px 40px 0 0 #303f46, 20px 40px 0 0 #303f46, 30px 40px 0 0 #303f46, 40px 40px 0 0 #303f46, 50px 40px 0 0 #303f46, 60px 40px 0 0 #ffffff, 70px 40px 0 0 #ffcdd2, 80px 40px 0 0 #ffffff, 90px 40px 0 0 #ffffff, 100px 40px 0 0 #ffffff, 110px 40px 0 0 #ffffff, 120px 40px 0 0 #ffcdd2, 130px 40px 0 0 #ffffff, 140px 40px 0 0 #303f46, 150px 40px 0 0 #303f46, 160px 40px 0 0 #303f46, 10px 50px 0 0 #303f46, 20px 50px 0 0 #303f46, 30px 50px 0 0 #303f46, 40px 50px 0 0 #303f46, 50px 50px 0 0 #303f46, 60px 50px 0 0 #ffffff, 70px 50px 0 0 #ffffff, 80px 50px 0 0 #ffffff, 90px 50px 0 0 #ffffff, 100px 50px 0 0 #ffffff, 110px 50px 0 0 #ffffff, 120px 50px 0 0 #ffffff, 130px 50px 0 0 #ffffff, 140px 50px 0 0 #303f46, 150px 50px 0 0 #303f46, 160px 50px 0 0 #303f46, 10px 60px 0 0 #303f46, 20px 60px 0 0 #303f46, 30px 60px 0 0 #303f46, 40px 60px 0 0 #303f46, 50px 60px 0 0 #303f46, 60px 60px 0 0 #ffffff, 70px 60px 0 0 #000000, 80px 60px 0 0 #ffffff, 90px 60px 0 0 #ffffff, 100px 60px 0 0 #000000, 110px 60px 0 0 #ffffff, 120px 60px 0 0 #ffffff, 130px 60px 0 0 #ffffff, 140px 60px 0 0 #303f46, 150px 60px 0 0 #303f46, 160px 60px 0 0 #303f46, 10px 70px 0 0 #303f46, 20px 70px 0 0 #303f46, 30px 70px 0 0 #303f46, 40px 70px 0 0 #303f46, 50px 70px 0 0 #303f46, 60px 70px 0 0 #ffffff, 70px 70px 0 0 #ffffff, 80px 70px 0 0 #000000, 90px 70px 0 0 #ffffff, 100px 70px 0 0 #ffffff, 110px 70px 0 0 #ffffff, 120px 70px 0 0 #ffffff, 130px 70px 0 0 #ffffff, 140px 70px 0 0 #303f46, 150px 70px 0 0 #303f46, 160px 70px 0 0 #303f46, 10px 80px 0 0 #303f46, 20px 80px 0 0 #303f46, 30px 80px 0 0 #303f46, 40px 80px 0 0 #303f46, 50px 80px 0 0 #303f46, 60px 80px 0 0 #ffffff, 70px 80px 0 0 #ffffff, 80px 80px 0 0 #ffffff, 90px 80px 0 0 #ffffff, 100px 80px 0 0 #ffffff, 110px 80px 0 0 #ffffff, 120px 80px 0 0 #ffffff, 130px 80px 0 0 #ffffff, 140px 80px 0 0 #303f46, 150px 80px 0 0 #303f46, 160px 80px 0 0 #303f46, 10px 90px 0 0 #303f46, 20px 90px 0 0 #303f46, 30px 90px 0 0 #303f46, 40px 90px 0 0 #303f46, 50px 90px 0 0 #303f46, 60px 90px 0 0 #303f46, 70px 90px 0 0 #ffffff, 80px 90px 0 0 #ffffff, 90px 90px 0 0 #ffffff, 100px 90px 0 0 #ffffff, 110px 90px 0 0 #ffffff, 120px 90px 0 0 #ffffff, 130px 90px 0 0 #303f46, 140px 90px 0 0 #303f46, 150px 90px 0 0 #303f46, 160px 90px 0 0 #303f46, 10px 100px 0 0 #303f46, 20px 100px 0 0 #303f46, 30px 100px 0 0 #303f46, 40px 100px 0 0 #303f46, 50px 100px 0 0 #303f46, 60px 100px 0 0 #303f46, 70px 100px 0 0 #303f46, 80px 100px 0 0 #ffffff, 90px 100px 0 0 #ffffff, 100px 100px 0 0 #ffffff, 110px 100px 0 0 #ffffff, 120px 100px 0 0 #303f46, 130px 100px 0 0 #303f46, 140px 100px 0 0 #ffffff, 150px 100px 0 0 #303f46, 160px 100px 0 0 #303f46, 10px 110px 0 0 #303f46, 20px 110px 0 0 #303f46, 30px 110px 0 0 #303f46, 40px 110px 0 0 #303f46, 50px 110px 0 0 #303f46, 60px 110px 0 0 #303f46, 70px 110px 0 0 #303f46, 80px 110px 0 0 #ffffff, 90px 110px 0 0 #ffffff, 100px 110px 0 0 #ffffff, 110px 110px 0 0 #ffffff, 120px 110px 0 0 #303f46, 130px 110px 0 0 #303f46, 140px 110px 0 0 #303f46, 150px 110px 0 0 #ffffff, 160px 110px 0 0 #303f46, 10px 120px 0 0 #303f46, 20px 120px 0 0 #303f46, 30px 120px 0 0 #303f46, 40px 120px 0 0 #303f46, 50px 120px 0 0 #303f46, 60px 120px 0 0 #303f46, 70px 120px 0 0 #ffffff, 80px 120px 0 0 #ffffff, 90px 120px 0 0 #ffffff, 100px 120px 0 0 #ffffff, 110px 120px 0 0 #ffffff, 120px 120px 0 0 #ffffff, 130px 120px 0 0 #303f46, 140px 120px 0 0 #303f46, 150px 120px 0 0 #ffffff, 160px 120px 0 0 #303f46, 10px 130px 0 0 #303f46, 20px 130px 0 0 #303f46, 30px 130px 0 0 #303f46, 40px 130px 0 0 #303f46, 50px 130px 0 0 #ffffff, 60px 130px 0 0 #ffffff, 70px 130px 0 0 #ffffff, 80px 130px 0 0 #ffffff, 90px 130px 0 0 #ffffff, 100px 130px 0 0 #ffffff, 110px 130px 0 0 #ffffff, 120px 130px 0 0 #ffffff, 130px 130px 0 0 #303f46, 140px 130px 0 0 #303f46, 150px 130px 0 0 #ffffff, 160px 130px 0 0 #303f46, 10px 140px 0 0 #303f46, 20px 140px 0 0 #303f46, 30px 140px 0 0 #303f46, 40px 140px 0 0 #303f46, 50px 140px 0 0 #ffffff, 60px 140px 0 0 #ffffff, 70px 140px 0 0 #ffffff, 80px 140px 0 0 #ffffff, 90px 140px 0 0 #ffffff, 100px 140px 0 0 #ffffff, 110px 140px 0 0 #ffffff, 120px 140px 0 0 #ffffff, 130px 140px 0 0 #303f46, 140px 140px 0 0 #ffffff, 150px 140px 0 0 #ffffff, 160px 140px 0 0 #303f46, 10px 150px 0 0 #303f46, 20px 150px 0 0 #303f46, 30px 150px 0 0 #303f46, 40px 150px 0 0 #ffffff, 50px 150px 0 0 #ffffff, 60px 150px 0 0 #ffffff, 70px 150px 0 0 #ffffff, 80px 150px 0 0 #ffffff, 90px 150px 0 0 #ffffff, 100px 150px 0 0 #ffffff, 110px 150px 0 0 #ffffff, 120px 150px 0 0 #ffffff, 130px 150px 0 0 #ffffff, 140px 150px 0 0 #ffffff, 150px 150px 0 0 #303f46, 160px 150px 0 0 #303f46, 10px 160px 0 0 #607d8b, 20px 160px 0 0 #607d8b, 30px 160px 0 0 #607d8b, 40px 160px 0 0 #607d8b, 50px 160px 0 0 #607d8b, 60px 160px 0 0 #ffffff, 70px 160px 0 0 #ffffff, 80px 160px 0 0 #607d8b, 90px 160px 0 0 #607d8b, 100px 160px 0 0 #607d8b, 110px 160px 0 0 #ffffff, 120px 160px 0 0 #ffffff, 130px 160px 0 0 #607d8b, 140px 160px 0 0 #607d8b, 150px 160px 0 0 #607d8b, 160px 160px 0 0 #607d8b;`,<br>    });<br>    return (<br>        &lt;div<br>            style={{<br>                display: &quot;flex&quot;,<br>                justifyContent: &quot;center&quot;,<br>                alignItems: &quot;center&quot;,<br>                height: &quot;100vh&quot;,<br>            }}<br>        &gt;<br>            &lt;Pixelator<br>                pixelPerRow={pixels.canvasWidth}<br>                pixelPerCol={pixels.canvasHeight}<br>                pixelSize={pixels.pixelSize}<br>                showgrid={false}<br>                pixels={pixels.data}<br>            /&gt;<br>        &lt;/div&gt;<br>    );<br>}<br><br>export default App;</pre><p>Once everything is set up, run:</p><pre>npm run dev</pre><p>You should now see your pixel art rendered on the screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*By4f49HWK8w5CRVX2DY-XA.png" /></figure><p>The simplest way to resize the output is by adjusting the pixelSize prop:</p><pre><br>    &lt;Pixelator<br>          pixelPerRow={pixels.canvasWidth}<br>          pixelPerCol={pixels.canvasHeight}<br>          pixelSize={20}<br>          showgrid={false}<br>          pixels={pixels.data}<br>      /&gt;<br>.<br>.<br>.</pre><p>This makes it easy to generate multiple sizes of the same artwork.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E7049lyNSQ7YncGIbpc2Ww.png" /></figure><h3>Final Words</h3><p>Thank you for following this tutorial!<br><a href="https://github.com/Pixelartui">PixelArtUI</a> is still growing, and we welcome contributors of all experience levels. If you’re interested, feel free to visit the <a href="https://github.com/Pixelartui/pixelartui-react">GitHub</a> repository and leave a star.</p><p>The full <a href="https://github.com/Pixelartui/pixelator-tutorial">source code</a> for this tutorial is available on GitHub as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f429a72af451" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JS mini series: Function]]></title>
            <link>https://medium.com/@yazed.jamal/js-mini-series-function-63c80250f61d?source=rss-f83a92b7ef8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/63c80250f61d</guid>
            <category><![CDATA[js]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[beginner]]></category>
            <dc:creator><![CDATA[Yazed Jamal]]></dc:creator>
            <pubDate>Sat, 18 Dec 2021 10:15:10 GMT</pubDate>
            <atom:updated>2021-12-18T10:15:10.913Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iMgWcEM66ZAkvsei" /></figure><p>What is function exactly?</p><p>By <a href="https://www.google.com/search?q=function+meaning&amp;oq=function+meaning&amp;aqs=chrome..69i57j0i512l9.4522j0j9&amp;sourceid=chrome&amp;ie=UTF-8">definition</a> , function is a purpose of something or in Mathematics it can be defined as an expression which consist of one or more variables.</p><p>Personally, in programming I would say function is everything mention above. Specifically in JS, because function is an object(value type), it is defined as a series of action that can be invoked, assign to a variable or pass around as an argument. By default a function will return undefined if no return statement is provided.</p><pre>//This is a function<br>function doSomething() {<br>  //do something<br>}</pre><pre>//function with no name<br>function() {<br>  //do something<br>}</pre><pre>//assigned to a variable<br>const nameSomething = function doSomething() {<br>  //do something<br>}</pre><pre>//can also be in the form of arrow function<br>const arrowFunction = () =&gt; { <br>  //do something<br>}</pre><pre>//passed as an argument<br>function beforeDoSomething(nameSomething) {<br>  //use the passed function<br>  nameSomething();<br>}</pre><pre>//assigned to an object property<br>const myObject = {<br>    functionOne: function functionOne() {<br>      console.log(&#39;Function One&#39;);<br>  },<br>  functionTwo: function functionTwo() {<br>      console.log(&#39;Function Two&#39;)<br>  }<br>}</pre><p>There are two main method to define a function in JS</p><ol><li>Function declaration</li><li>Function expression</li></ol><h3>Function declaration</h3><p>The main important aspect about function declaration is the name. The compiler will throw an error if a function statement is declared without a name.</p><p>When it is declared, all of its identifier, properties, value etc is defined during the compilation stage. Having said that, how do you invoke the function later doesn’t really matter as it is available anywhere during the runtime.</p><pre>//named function<br>function doSomething() {<br>  //do something<br>}</pre><h3>Function expression</h3><pre>//anonymous function<br>const myFunction = function() {<br>  //do something<br>}</pre><pre>//named function<br>const newFunction = function doSomething() {<br>  //do something<br>}</pre><p>So contrary to a function declaration, a function expression can be defined without a name. It also need to be properly defined before it can be called.</p><pre>//throw error when compiled<br>function() {<br>  //do something<br>}</pre><p><em>Originally published at </em><a href="https://lifelongnoob.hashnode.dev/js-mini-series-function"><em>https://lifelongnoob.hashnode.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63c80250f61d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JS mini series: Variables]]></title>
            <link>https://medium.com/@yazed.jamal/js-mini-series-variables-9c2a17c51ca2?source=rss-f83a92b7ef8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c2a17c51ca2</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[javascript-basics]]></category>
            <dc:creator><![CDATA[Yazed Jamal]]></dc:creator>
            <pubDate>Tue, 07 Dec 2021 18:13:39 GMT</pubDate>
            <atom:updated>2021-12-07T18:13:39.210Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xuOP5w906UVTZcBp" /></figure><h3>Variables</h3><p>Variables is a address in memory that contains a certain value. Only one type of value is allowed in each variable and it can be change. Think of variable as a small box which contains only one item. The item can be swap and the box could be empty.</p><p>In JS values can be assign to variables. Before we can assign a value, a variable need to be declared. There are 3 ways how you create a variable</p><h3>var</h3><p>Looking at the code above, we are creating the variable box with a string ‘item’(primitive value). It can also be used to declare a variable without a value and assign them later. This is called variable initialisation.</p><p>According to MDN var will create either a function scope or a global scope.</p><pre>//global scope<br>var box = &#39;toy&#39;; </pre><pre>function main { <br>// function scope<br>  var box1 = &#39;flower&#39;; <br>  console.log(box) //toy<br>  console.log(box1) //flower<br>}</pre><pre>function second { <br>  console.log(box) //toy<br>  console.log(box1) //reference error<br>} </pre><pre>console.log(box) //toy<br>console.log(box1) //reference error</pre><pre>main() <br>second()</pre><p>Block scoping will not apply to var. This is another topic that we could discuss later on.</p><pre>if(showBox) { var flower = &#39;flower&#39;; console.log(flower) } console.log(flower)</pre><h3>let</h3><p>Similar to var, let is another way to declare a variable with a little bit more of scope limitation.</p><p>variable initialisation</p><p>block scoping</p><pre>if(showBox) { <br>  let flower = &#39;flower&#39;; <br>  console.log(flower) //flower<br>} </pre><pre>console.log(flower) //reference error</pre><h3>const</h3><p>The final way to declare a variable is by using const. Having the same level of scope as let, the only difference about const is, the value assign to it should be immutable or constant as you might already guess from its name.</p><pre>const box = &#39;box&#39;;<br>const box = &#39;flower&#39;; //syntax error<br>box = &#39;small&#39;; //type error</pre><p>However, if you assign a non-primitive value such as an object or an array. The content of the object is still mutable.</p><pre>const names = [&#39;yaz&#39;, &#39;joe&#39;]<br>names[0] = &#39;vico&#39;; // no error<br>console.log(names[0]) //vico</pre><p>This might create some confusion against how const was defined, so developer should be careful on its usage.</p><p><em>Originally published at </em><a href="https://lifelongnoob.hashnode.dev/js-mini-series-variables"><em>https://lifelongnoob.hashnode.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c2a17c51ca2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JS mini series: Values]]></title>
            <link>https://medium.com/@yazed.jamal/js-mini-series-values-f7d9591fcd4d?source=rss-f83a92b7ef8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7d9591fcd4d</guid>
            <category><![CDATA[js]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-basics]]></category>
            <dc:creator><![CDATA[Yazed Jamal]]></dc:creator>
            <pubDate>Tue, 07 Dec 2021 16:58:03 GMT</pubDate>
            <atom:updated>2021-12-07T18:26:44.406Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UhQMYdrc50KuL7Gx" /></figure><p>What is Value?</p><p>By the definition, according to <a href="https://www.merriam-webster.com/dictionary/value">Merriam Webster Dictionary</a> , Value has many meanings. The one that I am interested with is as stated below.</p><blockquote><em>a numerical quantity that is assigned or is determined by calculation or measurement</em></blockquote><p>In other words, value is something definite that can be measured or manipulated. According to <a href="https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/get-started/ch2.md#values">Kyle Simpson</a> , value is data.</p><p>In JS, there are two main types of value, <strong>Primitive</strong> and <strong>Object</strong>. This article will mainly talk about Primitive values.</p><h3>Primitive</h3><p>There are seven primitive values is JS. They are:</p><p>Feeling a bit surprised? Yes array in JS is not a primitive value. We will talk more about this later</p><h3>String</h3><p>String is a group of characters presented in an ordered manner. In JS a string can be defined by &quot;&quot;, &#39;&#39; or `` surrounding them. Each of them have should be used accordingly which I will not talk about it here.</p><pre>&quot;This is a string&quot; <br>&#39;This is also a string&#39; <br>`This can also be a string`</pre><h3>Number</h3><p>A number is a literal mathematical value that you can use to count, add, subtract etc. Technically it is a <a href="https://en.wikipedia.org/wiki/Double_precision_floating-point_format">double-precision 64-bit binary format IEEE 754 value</a> according to MDN. In JS it can be a whole number or even fractions. It also have limits on what value can be used.</p><pre>12<br>12.56 //decimal<br>0e+5 //exponential<br>0b10000000000000000000000000000000 //binary<br>0O755 //octal<br>0XA //hexadecimal</pre><h3>BigInt</h3><p>BigInt represent a very large whole number which can’t be used with Number. Basically, Bigint is very similar to Number on how we use the value, however it cannot be mixed with Number when performing an operation hence using it with built in Math methods is also not permissible.</p><pre>123456789123456789n</pre><h3>Boolean</h3><p>A Boolean is a value which have one of two possible outcome. To be more specific it should be either true or false. It is mostly used for a logic implementation in a code.</p><pre>const thisIsTrue = true;<br>if(thisIsTrue) {<br>   //do something<br>}</pre><p>In JS, where it is a dynamic type of language, some value will be changed into Boolean through <a href="https://developer.mozilla.org/en-US/docs/Glossary/Type_Conversion">Type Conversion</a>. One good example is the <a href="https://developer.mozilla.org/en-US/docs/Glossary/Falsy">Falsy Value</a></p><h3>Symbol</h3><p>Symbol is value normally use a unique identifiers. Each symbol created is unique. This is useful for creating keys that will not conflicting with each other. It also used for creating hidden key for an object.</p><p>When creating a Symbol, we could pass on a string argument and this argument is only for debugging purpose only.</p><pre>const thisIsASymbol = Symbol(&#39;First symbol&#39;);<br>const thisIsAnotherSymbol = Symbol(&#39;Second symbol&#39;);</pre><pre>thisIsASymbol === thisIsAnotherSymbol //false</pre><h3>Null</h3><p>Null as we can understand from the word itself, it represents the absence of a value. In JS, null value is when a variable having no reference point. It will also act as a falsy value for boolean operation.</p><pre>const something = null;</pre><h3>Undefined</h3><p>Similar to Null Undefined is a falsey value but unlike Null, Undefined is where something does not exist. One example, in JS when we try to get something that does not exist it will return undefined</p><pre>const human = {<br>  name: &#39;My Name&#39;,<br>};</pre><pre>console.log(human.age)//undefined</pre><p><em>Originally published at </em><a href="https://lifelongnoob.hashnode.dev/js-mini-series-values"><em>https://lifelongnoob.hashnode.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7d9591fcd4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Analytic V4 API with Rails 5]]></title>
            <link>https://medium.com/isian-blog/google-analytic-v4-api-with-rails-5-18d14b1c5893?source=rss-f83a92b7ef8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/18d14b1c5893</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[google-analytics]]></category>
            <category><![CDATA[rails-5]]></category>
            <dc:creator><![CDATA[Yazed Jamal]]></dc:creator>
            <pubDate>Tue, 27 Feb 2018 16:33:00 GMT</pubDate>
            <atom:updated>2018-02-27T16:33:00.321Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fJ31bsZeX_HC4cU43PSPfQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*PQWGKHcWtcOJTaxPblHpxA.png" /></figure><p>Pulling data from an API is something that I have not done in a while. In a recent app I was making for a client requires the app to pull data from Google Analytic, populate it and finally display it on a leaderboard. Google have not provide a very detail guide yet, but they have some infos for anyone to get started.</p><p>Base on their documentations, I need to use Oauth 2 for my authentication to get an access token in order to fetch any data from Google Analytic API. Because I am using Rails I will not create the flow to request the token manualy, instead I will use devise for this purpose.</p><p>Next I will require a gem which is maintain by google specifically to handle APIs request, <a href="https://github.com/google/google-api-ruby-client">google-api-client</a> gem. Basically, what I will do is.</p><ol><li>Request token and refresh token from google</li><li>Use these tokens to get new token later</li><li>Make a request to google analytic</li></ol><p>So today I will walkthrough the process to setup these items only. I will not talk about how I populate the data for the leaderboard and I also I will not show how to setup devise because I believed there are enough example and tutorial how to do that out there.</p><p>According to google, I need to make a request to the OAuth server to get an authorization code before exchanging it with an access token. Thanks to devise I do not need to worry for any of this. I just need to configure devise to utilize Omniauth Google for user login and make sure to save the refresh and access token in the database. Before writing any code, I need to do these 3 important steps beforehand.</p><ol><li><a href="https://developers.google.com/api-client-library/ruby/auth/web-app#enable-apis">Enable Google Analytic V4 API</a></li><li><a href="https://developers.google.com/api-client-library/ruby/auth/web-app#creatingcred">Obtain google credentials, Client id and Client secret</a></li><li><a href="https://developers.google.com/api-client-library/ruby/auth/web-app#identify-access-scopes">Identify the scope I would like to use when requesting the API.</a></li></ol><p><strong>Request token and refresh token from google</strong></p><p>Since, I am going to use devise to obtain the tokens, I also need to configure devise to include scope for Google Analytic, so whenever a user proceed with an authentication, google will ask permission to access their google analytic data base on the scope provided. I also believe that step 2 above about geeting credential is covered since the same credential needed when I setup devise with Omniauth for the first time.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6fc59c1509f58059ea3134ae316c2589/href">https://medium.com/media/6fc59c1509f58059ea3134ae316c2589/href</a></iframe><p>On line 3, I would want google to ask for consent each time a user perform an authentication. I would like to do just to make sure the refresh token is provided each time a user authenticate.</p><p>On line 4, google recommend to include this in order for me to have incremental authorisation. Head to this link in order to learn more about it</p><p><a href="https://developers.google.com/identity/protocols/OAuth2WebServer#incrementalAuth">Using OAuth 2.0 for Web Server Applications | Google Identity Platform | Google Developers</a></p><p>On line 6, this is where I define the scope for accessing Google Analytic. For this case, I will set it on readonly access.</p><p>And on the final line is just to make sure rails could use a local certificate for SSL if it can’t find one on the system.</p><p>Finally don’t forget to save the tokens for use later</p><p><strong>Use these tokens to get new token later</strong></p><p>The tokens’ validity that google provide after the authentication will not last long. After it is expired, the token need to be replace by a new one using the refresh token. So imagine if the application need to call the api long after the user make the authentication, I need to create a method which will refresh the token each time I need to call the API.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ba7ab565fde4d4cf7ac19e31cca0eb9/href">https://medium.com/media/7ba7ab565fde4d4cf7ac19e31cca0eb9/href</a></iframe><p>From line 3 to 14, I prepared the body and headers to make a request for a token replacement. On line 16, I amusing HTTParty gem to make a request and finally from line 18 to 21 I will update the token if the request is a success.(<em>The code should also handle other response for best practice</em>).</p><p><strong>Make a request to google analytic</strong></p><p>Now , I am ready to make an API call</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/feae27c69d49422af44cca4337df5f91/href">https://medium.com/media/feae27c69d49422af44cca4337df5f91/href</a></iframe><p>On line 3, I create an instance of the Google Analytic request service from the <a href="https://github.com/google/google-api-ruby-client">google-api-client</a> gem.</p><p>From line 5, I refresh the token to make sure the token is still valid.</p><p>From line 7 to 11, I make an authorisation for the api connection by creating a client object using the updated token.</p><p>From line 13 to 22, I prepare all the details required for the API call. This items may vary depends on what information I am trying to get from the API call.</p><p>Lastly on line 24, I make the API call.</p><p>If the request is 200, I can now use the information from the response for whatever I want, in my case, I can save it to the database and update my leaderboard with the latest information.</p><p>That’s all Folk. Cheers</p><p><strong>Notes</strong>: There are probably many ways to implement this feature, but this is what I have come out with. Anybody is free to comment on any mistakes or improvements that I can apply. This guide is initially for me to learn and remember what I have done. Nonetheless anybody is welcome to follow this guide if you find it is helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18d14b1c5893" width="1" height="1" alt=""><hr><p><a href="https://medium.com/isian-blog/google-analytic-v4-api-with-rails-5-18d14b1c5893">Google Analytic V4 API with Rails 5</a> was originally published in <a href="https://medium.com/isian-blog">Isian</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Service Worker API]]></title>
            <link>https://medium.com/@yazed.jamal/service-worker-api-e6b4ada19ff5?source=rss-f83a92b7ef8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6b4ada19ff5</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[browsers]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[service-worker]]></category>
            <category><![CDATA[offline-first]]></category>
            <dc:creator><![CDATA[Yazed Jamal]]></dc:creator>
            <pubDate>Tue, 06 Feb 2018 10:07:35 GMT</pubDate>
            <atom:updated>2018-02-06T10:07:35.318Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*hyoKzgJivMbijHKrX29l7Q.jpeg" /></figure><p>Recently I was surprised with an email saying that I was accepted to a Scholarship challenge program organised by Udacity and Google. This is a 3 month program which will lead me to one of Udacity Nanodegree program if selected.</p><p>One of the topic that I need to learn during this 3 month is Service Worker. In this post I will write about Service worker, what is the function, how it works and what is it used for.</p><p><strong>What is a service worker?</strong></p><p>From the name itself, it already suggest that it is some sort of a worker that will provide you a service. But what and where is the worker? And what kind of service we are talking about here? First of all, service worker is just a small but powerful javascript code or file that can control the behaviour of your application online or particularly offline.</p><p>Service worker is basically a working layer that works between your app, the browser and the network. It is a worker which could control the behaviour of an application accordingly by intercepting its communication and response. With the intercepted data, service worker is capable of doing anything that it requires to do including custom routing and saving data.</p><p><strong>How does it works?</strong></p><p>To get a better understanding, I always imagine service worker is like a kitchen expeditor working in a restaurant. A kitchen expeditor is a person who is in charge as the middle man between the front-end or the servers, the kitchen and the management of the restaurant. As the middle man, the expeditor will handle all the orders from the server. There could be many orders coming at the same time and the expeditor should manage the order and provide the kitchen staff with the right information. When the food is ready, the expeditor then will again manage the food properly and provide the server with the right dish according to the orders. On top of these function, the expeditor also will make sure the quality and speed of the food is in order base on the management KPIs. The most wonderful thing about this middle-man, the expeditor has no access or authority on neither the front area nor the kitchen but powerful enough to control the input and output between the kitchen and the customers.</p><p><strong>What it is used for?</strong></p><p>Connectivity is very crucial nowadays. People are almost connected 24 hours a day to the internet. Developer are trying to make their apps always available no matter of what condition the network is. In the sense of business, a second network is down, a company could lost a billion dollars in term of potential income and worst lost of customer. This is why now there is a new way of developing an application and that is the offline first approach. To achieve this goal Service Worker is created used for this purpose. Service Worker give developer a full control of what the behaviour and response of an application during any state of network condition.</p><p>This means that you will never get a network error message again if you are trying to use your favourite app inside a tunnel or in a very remote area, thanks to Service Worker.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6b4ada19ff5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s build the Dig Dug game using MelonJS]]></title>
            <link>https://medium.com/free-code-camp/lets-build-the-dig-dug-game-using-melonjs-5fc0c9fd7132?source=rss-f83a92b7ef8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fc0c9fd7132</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Yazed Jamal]]></dc:creator>
            <pubDate>Thu, 11 Jan 2018 18:52:13 GMT</pubDate>
            <atom:updated>2025-10-24T08:41:03.772Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*BSr2KU-TRKONo4AkGOK1Rw.png" /></figure><p>Recently I had the chance to watch Stranger Things Season 2. After watching it, I was very excited to see one of my favorite game during my childhood, “Dig Dug”, featured in the series. At the same time, I was searching for a game that I could build to practice my game development skills. So today I have decided that Dig Dug is the game.</p><p>This Dig Dug version is not a complete version. It is only the basic mechanism of the game, which can be expand to a full working Dig Dug version later on.</p><p>MelonJS is the chosen framework, not because of any particular reason. I just picked it randomly from the many frameworks out there.</p><p>Below are the steps that I will go through for this game development:</p><ol><li>Setting up the framework</li><li>Creating the ground</li><li>Creating the digger</li><li>Creating the Monster</li><li>Creating the collision logic</li><li>Adding Head Unit Display</li><li>Adding sound effects and background music</li><li>Adding the Intro screen</li><li>Final adjustment</li><li>What’s next</li></ol><h4><strong>Step 1 — Setting up the framework</strong></h4><p>MelonJS recommends using the boilerplate provided by them, to start a game development. First, I need to download the boilerplate from <a href="https://github.com/melonjs/boilerplate">GitHub</a>.</p><p>I am going to clone the boilerplate to my local directory of choice:</p><pre>#terminal<br>git clone <a href="https://github.com/melonjs/boilerplate.git">https://github.com/melonjs/boilerplate.git</a> mylocalfolder</pre><p>Then I will need to setup my own remote repository for the game by using this <a href="https://help.github.com/articles/duplicating-a-repository/">guide</a>. It is also advisable to go through their tutorial to familiarize yourself with the usage of the framework.</p><p>Next, I will need to download the game assets provided by MelonJS on their tutorial pages. This may be useful if you need some images or tiles and have no time to design and create them. These assets can be downloaded on either of the MelonJS tutorial pages <a href="http://melonjs.github.io/tutorial-space-invaders/">here</a> and <a href="http://melonjs.github.io/tutorial-platformer/">here</a>.</p><p>Now I would like to discuss a bit about some important skeleton files provided in the boilerplate. MelonJS is using the <a href="https://github.com/parasyte/jay-extend">Jay Extend</a> inheritance library. So I need also to familiarize myself with the files.</p><p><strong>js/game.js</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/409447fd59b4abb1d27e67352eca233d/href">https://medium.com/media/409447fd59b4abb1d27e67352eca233d/href</a></iframe><p>Here is the global namespace of my game which happens to be defined as game (which can be anything I like).</p><p>From lines 1 to 8, I can define any information I require as an object.</p><p>Then from lines 12 to 25 is where I can setup the resolution of the game, how the screen behaves, and load all the game resources like image and sounds.</p><p>I need to change some details, like the screen resolution and scale method for the game performance on line 14.</p><p>Lastly, lines 28 to 37 is when the game will run everything.</p><p><strong>js/screen/play.js</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/690a88ac03404d5cb574d2adfb345337/href">https://medium.com/media/690a88ac03404d5cb574d2adfb345337/href</a></iframe><p>This file will be loaded by <strong>game.js</strong> which handles the play screen.</p><p>From lines 5 to 13, all the execution happens when the game starts. This is where I will specify to render all the game entities later on.</p><p>But, lines 18 to 21 is where all the entities will be removed. I will be going to edit these two files a lot along the way.</p><p>So before creating any other object, I need to install all the npm libraries required by running the command below:</p><pre>#terminal<br>npm install</pre><p>and I need to install <strong>grunt-cli</strong> which is required:</p><pre>npm install -g grunt-cli</pre><p>Finally, to run the game, I can execute the command below and get to the local server to see the game running:</p><pre>grunt serve</pre><p>For now I can only see a black blank screen when the game is running.</p><h4><strong>Step 2 — Creating the ground</strong></h4><p>After knowing a bit about the boilerplate provided, now is the time to create my first entity, the ground. There are several types of objects that I could build from this framework.</p><p>So because this ground will collide with the digger and the monster in the game, I need to create an Entity object for the ground. The ground is the object where the game takes place and which the digger needs to dig out for the digger to pass through.</p><p>Originally, the ground is a small 15 x 15 pixel square drawing which can then be repeatedly rendered on the screen to make a larger area. I could use a software called <a href="http://www.mapeditor.org/">Tile Map Editor</a> for this purpose, but for this game I will be doing it manually.</p><p>So this is how I do it. First create a file in the <strong>js</strong> folder called <strong>ground.js</strong>. Then I will create a new object entity as below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0a6454a9323efd391698be801f7db80/href">https://medium.com/media/d0a6454a9323efd391698be801f7db80/href</a></iframe><p>On line 2, I will crate a new object called game.Ground which extends from the Entity object provided by MelonJS.</p><p>On the next line, I will initialize the object through the parent object with all required arguments. This object will need x and y values as the location of the object.</p><p>The width and height is defined on lines 37 and 38.</p><p>To render something, I can use an image sprite for this purpose. But in this case, I will make use of the draw function from the HTML5 Canvas. This was done in lines 9 to 28. Here I will program to draw a rectangle with polka dots in it. The color of the square and dots will be defined by the variables declared on lines 5 and 6, respectively.</p><p>On lines 30 to 35 is where the object’s update function is. Here I need to set the entity to update itself on line 32 each time the update function is called. And finally return a true value to make sure the entity is redrawn each time the game is updated.</p><p>In the next step, I will need to make a reference to this file on the <strong>index.html</strong> file on line 40 and:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01740d7c095fd3042c16dc15cafe4399/href">https://medium.com/media/01740d7c095fd3042c16dc15cafe4399/href</a></iframe><p>register the entity to the pool in <strong>game.js</strong> on line 33. I will not need the code previously in <strong>game.js</strong> which registered the game.PlayerEntity because I will create the player entity manually later.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a635d7b6a31a4aee00390d07ae7f2b5d/href">https://medium.com/media/a635d7b6a31a4aee00390d07ae7f2b5d/href</a></iframe><p>Since the ground needs to be drawn quite a few times, it is good for me to create a container for all the ground which will handle all the work. To create a container, I will need to create a new object and extend the container object provided by MelonJS.</p><p>I will name this container game.LevelManager.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/02e0875d68e1947c6d919a0aa9603626/href">https://medium.com/media/02e0875d68e1947c6d919a0aa9603626/href</a></iframe><p>As before, I will need to initialize the arguments. Define the name of this object, and define the data that will be used to place all the squares on the screen at lines 2 to 21.</p><p>Then I will create a custom function that executes the rendering work based on the data on lines 24 to 37. On line 30 is how I add the square to this container, and after all squares are rendered I need to update the container boundary area in line 36.</p><p>Finally, I will need to render the container on the play screen, so everything under this container will be rendered as well.</p><p>Before doing that, I will need to create an instance of the levelManager object at lines 9 to 11 below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eef2904b612f2b4f6bb959779e370bee/href">https://medium.com/media/eef2904b612f2b4f6bb959779e370bee/href</a></iframe><p>I also need to remember to always make a reference to the new object created in the <strong>index.html</strong> file.</p><p>Now if i run the server, I should get a view like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ZbZbtDKdAnBqXTbjIA9aA.png" /></figure><h4><strong>Step 3 — Creating the digger</strong></h4><p>First I will need an image sprite for my digger. At first I was going to use the game assets provided by MelonJS, but luckily my son created a pixel image for me to use for the digger:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/144/1*_iy9MtYX5DdGxAWegVr2Ag.png" /></figure><p>I then need to place this image in the <strong>data/img</strong> folder of the boilerplate directory. When I run the server now, Grunt will automatically build and append the resource file in build/js folder with the image data above.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/652344d97960df90045aa6380905835b/href">https://medium.com/media/652344d97960df90045aa6380905835b/href</a></iframe><p>To create the Digger object, I will again need to extend the Entity object.</p><p>I will create a new file called <strong>digger.js </strong>in the <strong>js </strong>folder and make the reference in <strong>index.html.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7718efadb25771bbc727a9f1db53660b/href">https://medium.com/media/7718efadb25771bbc727a9f1db53660b/href</a></iframe><p>In line 3, I load the image from the resource file I made earlier and assign it to a variable. On line 5, I initialize the object with the required arguments and settings. For the digger, I will assign the image with the image defined earlier.</p><p>Next, on line 12, I flip the sprite when it is rendered the first time.</p><p>I will also need to make the gravity to 0 in line 13 because this is not a platform game which requires gravity for the character to act properly. In this case, the digger will be floating.</p><p>In line 14, the velocity of the digger is initialized so it can be moved later. I define the collision type for this entity for the use of the collision logic later on.</p><p>From lines 17 to 22, I define and manage the sprite animation. The numbers in the array of the addAnimation function are to determine which particular frame in the image is to be used for the animation. The number next to it is to define the speed. Finally, I set up the initial animation to be used when the play screen starts.</p><p>Now I will need to define the digger movement. I notice in the original Dig Dug game that each time the digger turns up or down, it will always rotate its character appropriately base on the ground. I need to take note of this to implement it properly in my digger. This will be quite a long section of code.</p><p>I discover that in order for the digger to act properly each time I rotate the sprite, I will need to adjust the boundary of the entity and also the shape of the collision box.</p><p>Initially the digger sprite is 48 x 24 in size. This is because of the picture of the digger firing its weapon. However, during normal movement, I will only need the digger to be 24 x 24 in size.</p><p>This is handled by changing the collision shape initially to be 24 x 24 and having it transform to 48 x 24 when the digger fires its weapon, at lines 17 to 19 below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c125591455d875120b10202b557f89b/href">https://medium.com/media/9c125591455d875120b10202b557f89b/href</a></iframe><p>From lines 28 to 33, I define several boolean flags that I will use in the movement function.</p><p>Starting on line 36 is the digger update function which also contains the digger movement logic based on the keyboard input from lines 40 to 134.</p><p>In this logic, I need to consider a lot of things like what happens when the movement key is pressed or released, the last position of the digger before a direction or fire button is pressed and released, and the different state of animation required. It is not a complex function, but the logic is a bit lengthy (although basically straightforward).</p><p>From lines 143 to 283 is the movement function for up, down, left and right.</p><p>To render the digger to the screen and make the movement possible, I need to add the digger object to game.world container at line 12 and register the keyboard key from lines 19 to 23 for the movement in <strong>play.js</strong> below. I will also need to unbind when the game leaves the play screen for other uses if required at lines 30 to 34.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b97fe5ae1b0f6a0c64873b764546189/href">https://medium.com/media/4b97fe5ae1b0f6a0c64873b764546189/href</a></iframe><p>If I run the server now, I can see the digger in action and move him up, down, left and right.</p><p>However, I can see a trailing image when the digger is moving, as well as the line of the MelonJS startup image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RssUgB7SFW-cX0hLGWGNMA.png" /></figure><p>The trailing image is because of the drawing executed each time the game loop updates. This can be solved by adding a layer of drawing before each time the digger is redrawn at line 12 below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/57b54f3aaa82859e65d577be4ed9cbc6/href">https://medium.com/media/57b54f3aaa82859e65d577be4ed9cbc6/href</a></iframe><h4><strong>Step 4 — Creating the Monster</strong></h4><p>Done with the digger for now, I will create the monsters next. It will be basically the same process for the monsters. I will need to create an object Entity for the monsters, add the monsters to the levelManager container, and finally render it to the screen.</p><p>Below is the object Entity for the monster:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b156ad6b9f6f8b4fcadf3c14dc48e871/href">https://medium.com/media/b156ad6b9f6f8b4fcadf3c14dc48e871/href</a></iframe><p>I will first initialize the object on lines 5 to 9. This time, I will just use a sprite provided by MelonJS from it’s platform game tutorial which I modified to add more frames below.</p><p>This sprite needs to be in the same folder as the digger sprite:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/72/1*aU3m-AZl2JSKPnN6GE-ycw.png" /></figure><p>Then I name the object on line 11, define the collision type on line 12, reset the collision square and make it smaller at lines 14 to 15, and set velocity and gravity of the monster at lines 17 to 18. I also define the animation group to be used before setting up the initial animation to be used on lines 20 to 22.</p><p>Next, I define a function for the monster’s movement. It is a very basic movement algorithm manipulating the object’s velocity value X for horizontal movement and Y for vertical movement on lines 26 to 43. Finally, I create the object’s update function which will contain only the body update for now on lines 45 to 52.</p><p>Before proceeding any further, again I need to always remind myself to make a reference in <strong>index.html </strong>and a registration in <strong>game.js</strong> for any new entity object created.</p><p>After creating the object, I will need to update the LevelManager container to include the monster’s data and also the creation function.</p><p>Below is the updated code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0aec13e05ba672f5ece0c17a0d84af2c/href">https://medium.com/media/0aec13e05ba672f5ece0c17a0d84af2c/href</a></iframe><p>From lines 21 to 28 is the data for the monster’s location. The function for the monster creation or adding to this container is added on lines 48 to 56. Lastly, to make it appear on the screen, some lines need to be added in <strong>play.js</strong>.</p><p>Below is the addition on line 11 which calls the function to create all the monsters:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a2ad56331b4987324f2d5bfce7abfed1/href">https://medium.com/media/a2ad56331b4987324f2d5bfce7abfed1/href</a></iframe><p>Now if I run the server, I can see two little cute monsters appear on the the specific location on the screen. At the moment they will not move.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dH4wDQDkzszq52nEag0D9w.png" /></figure><h4><strong>Part 5 — Creating the collision logic</strong></h4><p>I will start with the digger collision logic with the ground and the monster. In order for the framework to check for any collision on the entity object, I need to include the<strong> collision check</strong> method in the update function. After that, now I can include the onCollision function which provides the information about the specific objects that are colliding together.</p><p>Below is the updated digger object codes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/41d1a1b4fd4f637c630d5ddddbc60777/href">https://medium.com/media/41d1a1b4fd4f637c630d5ddddbc60777/href</a></iframe><p>In line 138, the code check for any collision occurs for this object.</p><p>In lines 144 to 166, a function provides a response when the objects collide. When the digger collides with the ground at lines 147 to 150, the specific ground entity will be removed from the levelManager container.</p><p>However, I don’t want the ground to disappear when the digger is firing its weapon, so I put an exception on line 148.</p><p>Next is the logic for collision with the monsters. If the digger collides with a monster while firing its weapon, the monster will flicker and be removed. Other than that the digger will flicker, be removed, and the game will reset from lines 151 to 163. Returning true in the collision function will make other objects that collide with the digger solid. In other words, the digger will not pass through another object during collision. For this case, I want it to return false.</p><p>To finish this up, I will then create the logic for the boundaries. Currently, the digger is allowed to travel off the screen. To do this I will define the maximum distance the digger is allowed to travel on the x and y axis in the object init function at lines 16 to 17 below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c5a32ca014f3caf44953954cf167c26/href">https://medium.com/media/2c5a32ca014f3caf44953954cf167c26/href</a></iframe><p>Then in the update function, I will set the boundaries by using the built-in clamp method at lines 105–106.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cdd0a5359d6ea60921e7cbab4e07fa75/href">https://medium.com/media/cdd0a5359d6ea60921e7cbab4e07fa75/href</a></iframe><p>Now for the monsters. After making the collision check on monster, I need to define the collision logic with the ground and also the boundary. This logic must also include some sort of Artificial Intelligence (AI) for the monster to chase the digger.</p><p>The monster will not able to dig the ground, so it will bounce to the direction where the digger is when it hits the ground or boundary. In order for the boundary collision to work, I need to define the maximum distance movement for the monster and set it up. I do not have to define the collision logic with the digger because it is already being handled by the Digger object. I also made the monster move to the right when the game starts.</p><p>Below is the latest Monster object:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0a9f8855eb29679ae1862592cda49d3/href">https://medium.com/media/c0a9f8855eb29679ae1862592cda49d3/href</a></iframe><p>From lines 138 to 159 is a function I defined that will be executed when the monster collides with the ground in the onCollision function. The logic is to make the monster move toward the digger when it hits the ground.</p><p>From lines 76 to 136 I defined a function that represents the monster collision logic with the boundary, which is called in the update function on line 57.</p><p>Whenever the monster is not hitting the boundary, it will always check the digger’s location and move towards it. Then if the monster hits the boundary, it will turn toward the digger and continue chasing it. I did not come up with the AI algorithm myself — it is a combination from scripts I found on the internet with my own. Also in this function, I am required to access the digger’s object properties like the X and Y position. To gain this access, I need to make some changes on how the digger is rendered to the play screen.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a66d2e7f607e1afb2ab851cdf31d484/href">https://medium.com/media/4a66d2e7f607e1afb2ab851cdf31d484/href</a></iframe><p>On line 13 I declare a game property that represents the registered digger from the pool before adding it to the play screen. This property will be used to access the digger properties inside the monster object.</p><p>Finally, I will include the code that will reset the game if all the monsters collided with the digger in firing mode. In other words, if the digger manages to killed all the monsters. This checking will be done in the levelManager container.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0c59ec5e86e69477946c568c97c595b/href">https://medium.com/media/d0c59ec5e86e69477946c568c97c595b/href</a></iframe><p>I will check the array containing all the monsters from lines 60 to 62. If the array is empty, I will reset the game.</p><p>But before that, I must also create a boolean flag at line 56 which will confirm that the monster is already created when I start the game. If not, the game will keep on resetting before the monsters can be created.</p><h4><strong>Step 6 — Adding Head Unit Display</strong></h4><p>First I need to create a font folder in the data directory:</p><pre>data/fnt</pre><p>then use the font provided by MelonJS in the game assets downloaded earlier:</p><pre>PressStart2P.png<br>PressStart2P.fnt</pre><p>and put them in the new folder.</p><p>Then, I need to add some script in the <strong>gruntfile</strong> in order for it to generate the resource data for the font below on lines 22 to 28:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe79178b0a602c0d32a9a4609a9012a9/href">https://medium.com/media/fe79178b0a602c0d32a9a4609a9012a9/href</a></iframe><p>When I run the server, the font will be in the resource data:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd054aa8eb159ed8be2b13cf07cb2444/href">https://medium.com/media/cd054aa8eb159ed8be2b13cf07cb2444/href</a></iframe><p>By default, the Head Unit Display (HUD) object is already created in the boilerplate. I can access the file in <strong>js/entities/HUD.js</strong>. I just need to define the font added earlier and create a draw function for it.</p><p>Below is the updated code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a92a756e5e656f4e66e32a12c3bb1332/href">https://medium.com/media/a92a756e5e656f4e66e32a12c3bb1332/href</a></iframe><p>I define and initialize the font on lines 42 to 48, then I create the draw function which will render the game score on the specific location as defined on line 71.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XogFTGiBXcjroHyuUNksdQ.png" /></figure><p>Lastly, I will add a high score display and its logic. The logic is just saving and adding up the current score to the highScore property each time game resets. Either the digger kills all the monsters or the digger is killed.</p><p>First I created the highScore property on line 9:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2990e9f88ce23c2b2886c26f26e0076c/href">https://medium.com/media/2990e9f88ce23c2b2886c26f26e0076c/href</a></iframe><p>Then, in the onCollision function of the <strong>digger</strong> I will increase the point each time a monster is killed at line 14 and add up the current points to the high score if the digger is killed at line 26.</p><p>I will also make a bit of an adjustment to what will happen when the monster hits the fire. I will make the monster stop moving, right after it hits the fire, to avoid any unnecessary collisions afterwards at line 11.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84dc2cfc1d274a87c93c6509cc938a02/href">https://medium.com/media/84dc2cfc1d274a87c93c6509cc938a02/href</a></iframe><h4><strong>Step 7 — Adding sound effects and background music</strong></h4><p>Setting this up is a breeze. All the required code is already there in the boilerplate. What I’ll need to do is put the required music or sound file to the relevant folder and do something with the music.</p><p>Based on the original game when the digger moves, the background music will be played. A simple logic needs to be implemented so the background music will not try to start repeatedly when a direction key is pressed.</p><p>Below is the digger updated object:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/488c0a010c98831f36c87cc8b6df9df7/href">https://medium.com/media/488c0a010c98831f36c87cc8b6df9df7/href</a></iframe><p>On line 37 I create a boolean flag to be used in the movement and background music logic.</p><p>On lines 45 to 47 is the logic so that the background music doesn’t repeatedly start if a direction key is pressed continuously.</p><p>Respectively on lines 114, 200, 224, 249 and 288, the flag is set in order for the logic to work properly.</p><p>The background music was made to stop when the digger stops at line 115.</p><p>As for the other sounds, I also add a sound for the digger in firing mode and a pop sound when the monster dies. In line 69 I activate the sound when fire key is pressed, and stop it when the the fire key is released in line 140. The pop sound will be activated when the monster collides with the digger during firing mode just after it is removed from the screen in line 174.</p><h4><strong>Step 8 — Adding the Intro screen</strong></h4><p>First, I will open <strong>game.js</strong> and modify one piece of code. Instead of changing the game state to PLAY, I will change the state to MENU in line 40.</p><p>This will load the <strong>title.js</strong> file when the game is loaded:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/495819fc24e95dca054c2887e5b921c7/href">https://medium.com/media/495819fc24e95dca054c2887e5b921c7/href</a></iframe><p>Next I will edit the file <strong>title.js</strong> in <strong>js/screens</strong> folder:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/917f281de1f2c8a1abee558f11a3b6cd/href">https://medium.com/media/917f281de1f2c8a1abee558f11a3b6cd/href</a></iframe><p>Here, in the onResetEvent I play the background music when the screen appears in line 8.</p><p>Next, I cover the viewport with brown colored layer at line 10.</p><p>Then, I create a Renderable object which contains the title and some wordings from line 13 to 43.</p><p>This Renderable object will be scrolled upwards from outside to the middle of the screen using Tween at lines 22 to 23.</p><p>Finally I will need to bind the ENTER key to trigger an event which will start the game at lines 47 to 57.</p><h4><strong>Step 9 — Final adjustment</strong></h4><p>I will not do much for the final adjustment. I will just add another background sound to the monster and I will position the digger similarly to the original game. First I will add another Tween for the digger to move to the center of the screen when the game starts.</p><p>I will include the new sound file to the right folder then I will update the <strong>digger</strong> file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bfb001ede56a4fb3197be94c0780dcb/href">https://medium.com/media/6bfb001ede56a4fb3197be94c0780dcb/href</a></iframe><p>I will declare a few more boolean flags to be used in lines 38 to 40, play the background music at the beginning of the game in line 30, and execute the initial digger movement by calling the defined function in line 29.</p><p>Below is the new function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cfb4fd15d54b1a348b56ade53d8d557/href">https://medium.com/media/9cfb4fd15d54b1a348b56ade53d8d557/href</a></iframe><p>From line 4, I will define the Tween animation with a callback function which stops the background music, sets some flags for the logic, and moves the binding key registration here from the <strong>play.js</strong> to avoid any additional movement by any key press during the tweening.</p><p>Finally, below is the function to create the monster sound every 5 seconds. This function will be called in the update function of the <strong>digger</strong> object.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb5034ce0a862e4949246cabce048e84/href">https://medium.com/media/eb5034ce0a862e4949246cabce048e84/href</a></iframe><h4><strong>Step 10 — What’s next</strong></h4><p>Below are the items I could continue to develop for this game:</p><ol><li>Create the ghost version of the monster that goes through ground.</li><li>Create a second and next level for the game.</li><li>Create additional items where digger could gain more points.</li><li>Create a local database with cookies where the game will remember the player’s high score.</li><li>Refactor, refactor and refactor.</li><li>Improve the game performance.</li></ol><p>Thank you for reading until this end. If you have any more suggestion on the above list, feel free to comment on this post below.</p><p>The full code can be pulled from <a href="https://github.com/muyaszed/dig-dug-clone">GitHub</a>.</p><p>Feel free to try the <a href="https://muyaszed.github.io/myDigDug/">demo</a> of the game.</p><p><strong>Notes</strong>: There are probably many ways to implement this feature, but this was easiest for me. Anybody is free to comment on any mistakes or improvements that I can apply. This guide is initially for me to learn and remember what I have done. Nonetheless anybody is welcome to follow this guide if you find it is helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fc0c9fd7132" width="1" height="1" alt=""><hr><p><a href="https://medium.com/free-code-camp/lets-build-the-dig-dug-game-using-melonjs-5fc0c9fd7132">Let’s build the Dig Dug game using MelonJS</a> was originally published in <a href="https://medium.com/free-code-camp">We’ve moved to freeCodeCamp.org/news</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Form handling on React.js — Self note series]]></title>
            <link>https://medium.com/@yazed.jamal/form-handling-on-react-js-self-note-series-ae798215f243?source=rss-f83a92b7ef8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae798215f243</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[forms]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Yazed Jamal]]></dc:creator>
            <pubDate>Sun, 10 Dec 2017 11:15:25 GMT</pubDate>
            <atom:updated>2017-12-10T11:15:25.135Z</atom:updated>
            <content:encoded><![CDATA[<p>After playing with <a href="https://medium.com/front-end-hacking/react-router-setup-self-notes-series-93646f28cc78">router in the last series</a>, today I will play around with react state and props. I will go through the process on how to setup user sign in process in React which will involve states and props. This series will also touch on how can I handle forms interaction and submissions.</p><p><strong>Step 1</strong></p><p>In the previous series I created a sign in page which only contains a title text, so now I will replace this text with a simple form</p><pre>#client/components/Signin.js<br>import SigninForm from &#39;./signinform/SigninForm&#39;;</pre><pre>class SignIn extends Component {</pre><pre>constructor(props) {<br>  super(props);<br>  <br>  this.state = {<br>   username: &quot; &quot;<br>  }</pre><pre>this.handleUserInput = this.handleUserInput.bind(this);<br> }</pre><pre>handleUserInput(obj) {<br>  this.setState(obj);<br> }<br> render() {<br>  return(<br>   &lt;div id=&quot;signin-container&quot;&gt;</pre><pre>&lt;SigninForm inputUserName={this.state.username} onUserInput={this.handleUserInput}/&gt;<br>    <br>   &lt;/div&gt;<br>   <br>  );<br> }</pre><pre>#client/components/signinform/SigninForm.js<br>import React, {Component} from &#39;react&#39;;</pre><pre>class SigninForm extends Component {</pre><pre>constructor(props) {<br>  super(props);</pre><pre>this.handleOnChange = this.handleOnChange.bind(this);<br> }</pre><pre>handleOnChange(e) {<br>  let name = e.target.name;<br>  let obj = {};<br>  obj[name] = e.target.value;</pre><pre>return this.props.onUserInput(obj);<br> }</pre><pre>render() {<br>  return(<br>   &lt;form&gt;<br>   &lt;div className=&quot;grid-x&quot;&gt;<br>       &lt;div className=&quot;small-12 cell&quot;&gt;<br>       &lt;label&gt;<br>        Your Username<br>        &lt;input <br>         type=&quot;text&quot; <br>         name=&quot;username&quot;<br>         value={this.props.inputUserName}<br>         onChange = {this.handleOnChange} /&gt;<br>       &lt;/label&gt;<br>       &lt;/div&gt;<br>       &lt;div className=&quot;small-12 cell&quot;&gt;<br>       <br>        &lt;input type=&quot;submit&quot; className=&quot;button&quot;/&gt;<br>       <br>       &lt;/div&gt;<br>       <br>    &lt;/div&gt;<br>    &lt;/form&gt;</pre><pre>  );<br> }<br>}</pre><pre>export default SigninForm;</pre><p>In order for the form to behave properly, it must have a function to handle all the behaviour. In this case, every time there is a change on the input text, it will trigger the function handleOnChange. This function then will return an object containing the latest change of the input to the prop called onUserInput which later will trigger a function named handleUserInput on the parent component.</p><p>Finally, this function will update the state which is defined relatively to the form’s inputs.</p><p><strong>Step 2</strong></p><p>Next, I will make sure the data is handle properly when I hit the submit button. At the moment I will just log the data in the console if I hit the submit button.</p><pre>#client/components/Signin.js<br>import SigninForm from &#39;./signinform/SigninForm&#39;;</pre><pre>class SignIn extends Component {</pre><pre>constructor(props) {<br>  super(props);<br>  <br>  this.state = {<br>   username: &quot; &quot;<br>  }</pre><pre>this.handleUserInput = this.handleUserInput.bind(this);<br>this.handleUserSubmit = this.handleUserSubmit.bind(this);<br> }</pre><pre>handleUserInput(obj) {<br>  this.setState(obj);<br> }</pre><pre>handleUserSubmit() {<br>  <br>  console.log(this.state);<br> }</pre><pre> render() {<br>  return(<br>   &lt;div id=&quot;signin-container&quot;&gt;</pre><pre>&lt;SigninForm inputUserName={this.state.username} onUserInput={this.handleUserInput} onSubmit={this.handleUserSubmit}/&gt;<br>    <br>   &lt;/div&gt;<br>   <br>  );<br> }</pre><pre>#client/components/signinform/SigninForm.js<br>import React, {Component} from &#39;react&#39;;</pre><pre>class SigninForm extends Component {</pre><pre>constructor(props) {<br>  super(props);</pre><pre>this.handleOnChange = this.handleOnChange.bind(this);<br>this.handleOnSubmit = this.handleOnSubmit.bind(this);<br> }</pre><pre>handleOnChange(e) {<br>  let name = e.target.name;<br>  let obj = {};<br>  obj[name] = e.target.value;</pre><pre>return this.props.onUserInput(obj);<br> }</pre><pre>handleOnSubmit(e) {<br>  e.preventDefault();<br>  this.props.onSubmit();<br> }</pre><pre>render() {<br>  return(<br>   &lt;form onSubmit = {this.handleOnSubmit}&gt;<br>   &lt;div className=&quot;grid-x&quot;&gt;<br>       &lt;div className=&quot;small-12 cell&quot;&gt;<br>       &lt;label&gt;<br>        Your Username<br>        &lt;input <br>         type=&quot;text&quot; <br>         name=&quot;username&quot;<br>         value={this.props.inputUserName}<br>         onChange = {this.handleOnChange} /&gt;<br>       &lt;/label&gt;<br>       &lt;/div&gt;<br>       &lt;div className=&quot;small-12 cell&quot;&gt;<br>       <br>        &lt;input type=&quot;submit&quot; className=&quot;button&quot;/&gt;<br>       <br>       &lt;/div&gt;<br>       <br>    &lt;/div&gt;<br>    &lt;/form&gt;</pre><pre>);<br> }<br>}</pre><pre>export default SigninForm;</pre><p>I created a function called handleOnSubmit which is link to the onChange event listener. This function will call another function from the parent component through its prop and hence the function will log the current state in the console.</p><p><strong>Step 3</strong></p><p>I will complete the form with the other required inputs. First I will add more state so I can store more data from the form. Then, I need to change the way how the current state is sent to the child component and finally add more html forms in the SigninForm component.</p><pre>#client/components/Signin.js<br>import React,  {Component} from &#39;react&#39;;<br>import SigninForm from &#39;./signinform/SigninForm&#39;;</pre><pre>class SignIn extends Component {<br> constructor(props) {<br>  super(props);<br>  <br>  this.state = {<br>   username: &quot;&quot;,<br>   email: &quot;&quot;,<br>   password: &quot;&quot;,<br>   passwordConfirmation: &quot;&quot;<br>  }</pre><pre>this.handleUserInput = this.handleUserInput.bind(this);<br>  this.handleUserSubmit = this.handleUserSubmit.bind(this);<br> }</pre><pre>handleUserInput(obj) {<br>  this.setState(obj);<br> }</pre><pre>handleUserSubmit() {</pre><pre>console.log(this.state);<br> }</pre><pre>render() {<br>  return(<br>   &lt;div id=&quot;signin-container&quot;&gt;</pre><pre>&lt;SigninForm userData={this.state} onUserInput={this.handleUserInput} onSubmit={this.handleUserSubmit}/&gt;<br>    <br>   &lt;/div&gt;<br>   <br>  );<br> }<br>}</pre><pre>export default SignIn;</pre><pre>#client/components/signinform/SigninForm.js<br>import React, {Component} from &#39;react&#39;;</pre><pre>class SigninForm extends Component {<br> constructor(props) {<br>  super(props);</pre><pre>this.handleOnChange = this.handleOnChange.bind(this);<br>  this.handleOnSubmit = this.handleOnSubmit.bind(this);<br> }</pre><pre>handleOnChange(e) {<br>  let name = e.target.name;<br>  let obj = {};<br>  obj[name] = e.target.value;</pre><pre>return this.props.onUserInput(obj);<br> }</pre><pre>handleOnSubmit(e) {<br>  e.preventDefault();<br>  this.props.onSubmit();<br> }</pre><pre>render() {<br>  return(<br>   &lt;form onSubmit = {this.handleOnSubmit}&gt;<br>   &lt;div className=&quot;grid-x&quot;&gt;<br>       &lt;div className=&quot;small-12 cell&quot;&gt;<br>        &lt;label&gt;<br>         Your Username<br>         &lt;input <br>          type=&quot;text&quot; <br>          name=&quot;username&quot;<br>          value={this.props.userData.username}<br>          onChange = {this.handleOnChange} /&gt;<br>        &lt;/label&gt;<br>       &lt;/div&gt;<br>       &lt;div className=&quot;small-12 cell&quot;&gt;<br>        &lt;label&gt;<br>         Your email<br>         &lt;input <br>          type=&quot;email&quot; <br>          name=&quot;email&quot;<br>          value={this.props.userData.email}<br>          onChange = {this.handleOnChange} /&gt;<br>        &lt;/label&gt;<br>       &lt;/div&gt;<br>       &lt;div className=&quot;small-12 cell&quot;&gt;<br>        &lt;label&gt;<br>         Your password<br>         &lt;input <br>          type=&quot;password&quot; <br>          name=&quot;password&quot;<br>          value={this.props.userData.password}<br>          onChange = {this.handleOnChange} /&gt;<br>        &lt;/label&gt;<br>       &lt;/div&gt;</pre><pre>&lt;div className=&quot;small-12 cell&quot;&gt;<br>        &lt;label&gt;<br>         Your password confirmation<br>         &lt;input <br>          type=&quot;password&quot; <br>          name=&quot;passwordConfirmation&quot;<br>          value={this.props.userData.passwordConfirmation}<br>          onChange = {this.handleOnChange} /&gt;<br>        &lt;/label&gt;<br>       &lt;/div&gt;</pre><pre>&lt;div className=&quot;small-12 cell&quot;&gt;<br>       <br>        &lt;input type=&quot;submit&quot; className=&quot;button&quot;/&gt;<br>       <br>       &lt;/div&gt;<br>       <br>   &lt;/div&gt;<br>   &lt;/form&gt;<br>  );<br> }<br>}</pre><pre>export default SigninForm;</pre><p>I will let the data as it is right now and will handle it later in other episode.</p><p>Cheers, see you in the next post.</p><p><a href="https://github.com/muyaszed/React-with-Redux-complete-app/tree/14d9ab5a0329b0b8f3243795f7753417a3bccaf6">Github resource</a></p><p><strong>notes</strong>: There are probably many ways to implement this feature and and this is how I find the easiest way for me to implement this. Anybody is free to give a comment for any mistakes or improvement that I can apply. This guide is initially for my own self to learn and remember about what I have done, nonetheless anybody is welcome to follow this guide if you find it is very helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae798215f243" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>