<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Edet John</title>
    <description>The latest articles on Forem by Edet John (@cyberohn).</description>
    <link>https://forem.com/cyberohn</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1269297%2F54eb313b-d1cd-4ded-9ba6-0e48560ef880.jpeg</url>
      <title>Forem: Edet John</title>
      <link>https://forem.com/cyberohn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/cyberohn"/>
    <language>en</language>
    <item>
      <title>Prototypal Inheritance in JavaScript</title>
      <dc:creator>Edet John</dc:creator>
      <pubDate>Fri, 02 Feb 2024 10:59:35 +0000</pubDate>
      <link>https://forem.com/cyberohn/prototypal-inheritance-in-javascript-58kd</link>
      <guid>https://forem.com/cyberohn/prototypal-inheritance-in-javascript-58kd</guid>
      <description>&lt;p&gt;JavaScript is a prototype-based language, which means objects can serve as prototypes for other objects. Each object in JavaScript has a prototype, and it inherits properties and methods from that prototype.&lt;/p&gt;

&lt;h2&gt;
  
  
  Object Prototype
&lt;/h2&gt;

&lt;p&gt;Every object in JavaScript is linked to a prototype object. When you create an object, JavaScript automatically attaches a special property called &lt;strong&gt;proto&lt;/strong&gt; to it, pointing to its prototype.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myObject = {};
console.log(myObject.__proto__); // Outputs the prototype of myObject

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Prototype Chain
&lt;/h2&gt;

&lt;p&gt;Objects in JavaScript form a chain, known as the prototype chain. If a property or method is not found on an object, JavaScript looks up the prototype chain until it finds the property or reaches the end of the chain (usually the Object prototype).&lt;br&gt;
Creating objects with prototypes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Creating a prototype object
const animalPrototype = {
  speak: function() {
    console.log("Some generic sound");
  }
};

// Creating an object using the prototype
const dog = Object.create(animalPrototype);
dog.speak(); // Outputs "Some generic sound"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, dog is created with animalPrototype as its prototype. It inherits the speak method from animalPrototype.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constructor Functions:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Constructor function
function Animal() {}

// Adding a method to the prototype of the constructor
Animal.prototype.speak = function() {
  console.log("Some generic sound");
};

// Creating an instance
const cat = new Animal();
cat.speak(); // Outputs "Some generic sound"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, Animal is a constructor function, and instances created with new Animal() inherit from Animal.prototype.&lt;/p&gt;

&lt;p&gt;Prototypal inheritance is a fundamental concept in JavaScript that allows objects to inherit properties and methods from other objects. Here's a breakdown :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prototype: Think of a prototype as a blueprint for creating objects. Every object has a prototype, and it serves as a template for the object's properties and methods.&lt;/li&gt;
&lt;li&gt;Prototype Chain: Objects are linked together in a chain, forming the prototype chain. If a property or method is not found on an object, JavaScript looks up the chain until it finds the property or reaches the end.&lt;/li&gt;
&lt;li&gt;Creating Objects with Prototypes: You can create objects directly using Object.create(prototype) or use constructor functions. Objects created with the same prototype share common functionality.&lt;/li&gt;
&lt;li&gt;Constructor Functions: Constructor functions are a way to create objects with a shared prototype. They serve as a template for creating multiple instances with similar properties and methods.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>typescript</category>
      <category>frontend</category>
    </item>
    <item>
      <title>React Tilt With React JS and Tailwind CSS</title>
      <dc:creator>Edet John</dc:creator>
      <pubDate>Tue, 30 Jan 2024 14:47:17 +0000</pubDate>
      <link>https://forem.com/cyberohn/react-tilt-with-react-js-and-tailwind-css-3ppd</link>
      <guid>https://forem.com/cyberohn/react-tilt-with-react-js-and-tailwind-css-3ppd</guid>
      <description>&lt;p&gt;React Tilt is a cool tool that adds movement and animation to elements on your website. It makes things look more interesting by giving them a floating and tilting effect. It’s easy to use and brings a touch of magic to your apps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Create new react app using vite and add tailwind css. As the next step add react tilt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i react-tilt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  React Tilt Options
&lt;/h2&gt;

&lt;p&gt;Here are configuration options for React tilt package:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reverse: Determines whether the tilt direction is
reversed or not.&lt;/li&gt;
&lt;li&gt;Max: Sets the maximum tilt rotation in degrees. • perspective: Adjusts the transform perspective, influencing the intensity of the tilt effect.&lt;/li&gt;
&lt;li&gt;Scale: Specifies the scale of the elements, allowing them to appear larger or smaller.&lt;/li&gt;
&lt;li&gt;Speed: Controls the speed of the enter/exit transition, determining how quickly the tilt effect occurs.&lt;/li&gt;
&lt;li&gt;Transition: Enables or disables smooth transitions on enter/exit.&lt;/li&gt;
&lt;li&gt;Axis: Defines which axis (X or Y) should be disabled for tilting.&lt;/li&gt;
&lt;li&gt;Reset: Determines whether the tilt effect should be reset on exit or persist.&lt;/li&gt;
&lt;li&gt;Easing: Specifies the easing function for enter/exit transitions, influencing the smoothness of the animation.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Tilt options
&lt;/h2&gt;

&lt;p&gt;In card.jsx file, define some options for the card component to work with react tilt. For this tutorial we will be using the default options but feel free to checkout the custom ones or to create new ones on your own.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Tilt } from 'react-tilt'

  const defaultOptions = {
    reverse: false,
    max: 35,
    perspective: 1000,
    scale: 1.1,
    speed: 1000,
    transition: true,
    axis: null,
    reset: true,
    easing: "cubic-bezier (.03,.98,.52,.99)",
  }

  const customOptions = {
    reverse: true,
    max: 45,
    perspective: 1500,
    scale: 1.2,
    speed: 2000,
    transition: true,
    axis: "X",
    reset: false,
    easing: "cubic-bezier(.2, .8, .3, 1)"
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Card JSX
&lt;/h2&gt;

&lt;p&gt;Now let's take a look a the card component itself. It uses Tilt component as a wrapper from react tilt and receives props: image, title, description from the App component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Card = {{image, title, description}) =&amp;gt; { return (
  &amp;lt;Tilt options={defaultOptions)&amp;gt;
    &amp;lt;div className="relative w-64 h-80 bg-white bg-opacity-20 backdrop-filter backdrop-blur-lg shadow-md rounded-xl overflow-hidden"&amp;gt; &amp;lt;img src=(image) alt={title}
    className="w-full h-48 object-cover" /&amp;gt; 
      &amp;lt;div className="absolute bottom-0 left-0 right-0 p-4
      text-white"&amp;gt;
        &amp;lt;h2 className="text-xl font-bold mb-2"&amp;gt;
        {title}&amp;lt;/h2&amp;gt;
        &amp;lt;p className="text-gray-200"&amp;gt;
        {description}&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/Tilt&amp;gt;
}
export default Card;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  App JSX
&lt;/h2&gt;

&lt;p&gt;Finally let's have a look at the App component&lt;br&gt;
code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import bg from './assets/bg.png' import Card from './components/card'

function App() {
  return (
    &amp;lt;div className="w-full h-screen flex justify-center items-center bg-gradient-to-r Ofrom-slate-950 Oto-slate-900"&amp;gt;
      &amp;lt;Card image=(bg) title="hello world" description="some description" /&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}
export default App
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope you learned something new from this. If you've used React Tilt before, i want to see your lovely tilt card, share them with me in the description below. Check out &lt;a href="https://www.buymeacoffee.com/cyberohn/e/186510"&gt;these awesome coding materials&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>reactjsdevelopment</category>
    </item>
  </channel>
</rss>
