<?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>DEV Community: alexpaper</title>
    <description>The latest articles on DEV Community by alexpaper (@alexpaper).</description>
    <link>https://dev.to/alexpaper</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%2F168590%2F423422b8-6458-4f5e-89a7-dc59ff5a3f19.jpeg</url>
      <title>DEV Community: alexpaper</title>
      <link>https://dev.to/alexpaper</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alexpaper"/>
    <language>en</language>
    <item>
      <title>My struggles with TypeScript</title>
      <dc:creator>alexpaper</dc:creator>
      <pubDate>Fri, 29 Jul 2022 14:34:53 +0000</pubDate>
      <link>https://dev.to/alexpaper/my-struggles-with-typescript-13g6</link>
      <guid>https://dev.to/alexpaper/my-struggles-with-typescript-13g6</guid>
      <description>&lt;h2&gt;
  
  
  Premise
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;TypeScript&lt;/strong&gt; has changed the schemes, the first time I heard about it, I thought 🤔: &lt;/p&gt;

&lt;p&gt;"Simple, just declare the data type and that's it"! &lt;/p&gt;

&lt;p&gt;I soon realized it's not that simple! 😞&lt;/p&gt;

&lt;p&gt;Things are not exactly like this and in any case, this logic applies to everything, variables, objects, functions, classes, etc., in short, it is another way of programming, it is another way of thinking, you have to completely change your approach!&lt;/p&gt;

&lt;h2&gt;
  
  
  Realization
&lt;/h2&gt;

&lt;p&gt;The best ones can do amazing things with TypeScript, I think &lt;em&gt;it has now become an essential tool&lt;/em&gt; for those who regularly use JavaScript! &lt;/p&gt;

&lt;p&gt;I have developed some little projects in React, some simple applications, a blog, and I must admit that the idea of redoing everything with TypeScript scares me deeply! 😱&lt;/p&gt;

&lt;p&gt;The secret to learning is to practice constantly! So, since I am constantly looking for work, I made this little application using JavaScript and TypeScript to see the newest job offers on the market!&lt;/p&gt;

&lt;h2&gt;
  
  
  Some examples.
&lt;/h2&gt;

&lt;p&gt;For example, if you use &lt;em&gt;axios&lt;/em&gt; package, in normal project, you simple need to import the package, in TypeScript you need also to import &lt;em&gt;AxiosResponse&lt;/em&gt; to specify the type of the axios response, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Import axios
import axios, { AxiosResponse } from 'axios';

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

&lt;/div&gt;



&lt;p&gt;If you have an object, you need to describe the shape of it using ‘Interfaces’;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Job {
title: string;
description: string;
company: {
display_name: string;
};
location: {
display_name: string;
};
category: {
label: string;
};
contract_type: string;
created: string;
latitude: number;
longitude: number;
redirect_url: string;
salary_min: number;
salary_max: number;
}

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

&lt;/div&gt;



&lt;p&gt;Sure, the code becomes more robust, but it is easy to understand that in this way the code extends beyond measure, to be clear, it is not a criticism, but an simple observation!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusions.
&lt;/h2&gt;

&lt;p&gt;Slowly using TypeScript I have to admit that I start to like it and as I said before, I think it has become an essential tool, in fact I see it in job requests, before employers only asked for JavaScript, now they also ask for TypeScript!&lt;/p&gt;

&lt;p&gt;In this video you can see my struggles with TypeScript. &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/DUM4iZKStA8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Have a Good day! 👋&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>job</category>
      <category>search</category>
    </item>
    <item>
      <title>🗾️ TypeScript Customers Info With MapBox</title>
      <dc:creator>alexpaper</dc:creator>
      <pubDate>Fri, 15 Jul 2022 13:22:57 +0000</pubDate>
      <link>https://dev.to/alexpaper/typescript-customers-info-with-mapbox-376f</link>
      <guid>https://dev.to/alexpaper/typescript-customers-info-with-mapbox-376f</guid>
      <description>&lt;p&gt;Working with &lt;em&gt;typescript&lt;/em&gt; especially in the beginning (I am a beginner 🤔️),&lt;br&gt;
declaring the type of each variable, the syntax not always intuitive, can be very frustrating! 😤️&lt;/p&gt;

&lt;p&gt;The code stretches a lot but the advantages in the long run are undeniable! 🤓️&lt;/p&gt;

&lt;p&gt;In this video guide i created a litle customer page to get familiar with typescript sintax, for example, when you fetch some customer info you need to declare in advance the object type using ** interface **&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// User Interface
interface User {
    name: string;
    username: string;
    email: string;
    address:{
        street: string;
        suite: string;
        city: string;
        zipcode: string;
        geo:{
            lat: string;
            lng: string;
        }
    };
    phone: string;
    website: string;
    company: {
        name:string;
        catchPhrase: string;
        bs:string;
    };
};

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

&lt;/div&gt;



&lt;p&gt;In this way typescript knows what kind of data to expect, and if there is something wrong, report it in advance!&lt;/p&gt;

&lt;p&gt;To view the customer coordinates I used &lt;a href="https://www.mapbox.com/"&gt;MapBox&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Hope this little exercise helps you better understand the importance of typescript in your code!&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/VWMB_3h8RSg"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/VWMB_3h8RSg"&gt;Video Guide&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have a nice day!&lt;br&gt;
🖐️&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>map</category>
      <category>mapbox</category>
      <category>axios</category>
    </item>
    <item>
      <title>📏 Resize Observer API</title>
      <dc:creator>alexpaper</dc:creator>
      <pubDate>Tue, 07 Jun 2022 21:12:39 +0000</pubDate>
      <link>https://dev.to/alexpaper/resize-observer-api-fme</link>
      <guid>https://dev.to/alexpaper/resize-observer-api-fme</guid>
      <description>&lt;p&gt;Resize Observer interface reports changes to the dimensions of an HTML &lt;em&gt;elements&lt;/em&gt; .&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use
&lt;/h3&gt;

&lt;p&gt;It is very simple to use and in some special cases, can be used as an &lt;em&gt;javascript&lt;/em&gt; alternative to &lt;em&gt;CSS @media query.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You need to create a new ResizeObserver instance&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const observer = new ResizeObserver(entries =&amp;gt;{
    // console.log(entries[0]);
    ...
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;then you need to *&lt;em&gt;observe *&lt;/em&gt; the HTML element, in this case the main &lt;em&gt;container&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;observer.observe(container);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now whenever the container size changes, the observer returns an object with the new &lt;em&gt;width&lt;/em&gt; and &lt;em&gt;hight&lt;/em&gt; values, &lt;br&gt;
values that can be used to manipulate elements within the page.&lt;/p&gt;

&lt;p&gt;In this video you can see a simple example&lt;/p&gt;

&lt;p&gt;have a good day 👋&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/hDPR8VNn6vU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>resize</category>
      <category>observer</category>
      <category>api</category>
      <category>resizeobserver</category>
    </item>
    <item>
      <title>🐦 JavaScript Twitter Share Url Button</title>
      <dc:creator>alexpaper</dc:creator>
      <pubDate>Sun, 22 May 2022 08:56:24 +0000</pubDate>
      <link>https://dev.to/alexpaper/javascript-twitter-share-url-button-1g9h</link>
      <guid>https://dev.to/alexpaper/javascript-twitter-share-url-button-1g9h</guid>
      <description>&lt;p&gt;The Tweet button allows you to quickly share the webpage you're viewing with all your followers,&lt;br&gt;
clicking the Tweet button provides you with a prepopulated Tweet containing a link to that webpage.&lt;/p&gt;

&lt;p&gt;Amazing, but how to add the Tweet button to your website, to share a blog post url for example?&lt;/p&gt;

&lt;p&gt;In React you can use &lt;a href="https://www.npmjs.com/package/react-share"&gt;React-Share&lt;/a&gt;, but if you don't want to use an external package you can achieve the same result in a few lines of code7&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use the Tweet button
&lt;/h3&gt;

&lt;p&gt;Very simple&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When you see the Tweet button on a webpage that you feel like sharing, click it.&lt;/li&gt;
&lt;li&gt;If you're not already logged in to Twitter, you will be prompted by a pop-up box to log in.&lt;/li&gt;
&lt;li&gt;A Tweet box will appear for you to post a Tweet linking to the webpage you visited. &lt;/li&gt;
&lt;li&gt;When ready, click “Tweet.”&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Implementation
&lt;/h3&gt;

&lt;p&gt;After creating the button all you have to do is associate it a click event that calls this function:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function sharePage() {
    const url = window.location.href;
    window.open('https://twitter.com/intent/tweet?text=' + encodeURIComponent(document.title) + '&amp;amp;url=' + encodeURIComponent(url), '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=350,width=600');
    return false;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Done!&lt;/p&gt;

&lt;p&gt;In this video you can see a simple implementation&lt;br&gt;
&lt;a href="https://youtu.be/LefZJ56CcSM"&gt;video&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;have a good day!&lt;br&gt;
👋&lt;/p&gt;

</description>
    </item>
    <item>
      <title>🗳️ NodeJs WebSocket Real Time Voting App</title>
      <dc:creator>alexpaper</dc:creator>
      <pubDate>Sun, 08 May 2022 21:15:55 +0000</pubDate>
      <link>https://dev.to/alexpaper/nodejs-websocket-real-time-voting-app-3g28</link>
      <guid>https://dev.to/alexpaper/nodejs-websocket-real-time-voting-app-3g28</guid>
      <description>&lt;p&gt;This is the original question: how to create a voting app so that everyone is updated in real time, &lt;br&gt;
at the very moment you vote?&lt;br&gt;
This is the answer: via WebSocket!&lt;/p&gt;
&lt;h3&gt;
  
  
  BackEnd
&lt;/h3&gt;

&lt;p&gt;In Nodejs you can install &lt;a href="https://www.npmjs.com/package/ws"&gt;WS&lt;/a&gt;,&lt;br&gt;
The WebSocket API tecnology allows you to create a communication client/server, and therefore to send&lt;br&gt;
and receive data in real-time.&lt;/p&gt;

&lt;p&gt;First of all you need to create a new WebSocketServer instance, you must indicate a Port number&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import WebSocket, {WebSocketServer} from 'ws';

const wss = new WebSocketServer({port:8080});

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

&lt;/div&gt;



&lt;p&gt;now it is very simple, when a user votes you have to make a broadcast of the updated data,&lt;br&gt;
in this case an object with string values and an array of numbers&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wss.clients.forEach(c=&amp;gt;{
    if(c.readyState === WebSocket.OPEN){
        c.send(JSON.stringify({time:datetime, message:`Updated data`, data:jsonData.data}))
    }
});

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  FrontEnd
&lt;/h3&gt;

&lt;p&gt;In the client side you need to do the same, first create a WebSocket instance pointing to the server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const ws = new WebSocket('ws://localhost:8080');

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

&lt;/div&gt;



&lt;p&gt;now when the user gives the preference sends the data to the server that sends it back to all connected &lt;br&gt;
clients and then updates the UI&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ws.send(JSON.stringify({data:chartData.datasets[0].data}));

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

&lt;/div&gt;



&lt;p&gt;very straight forward!&lt;/p&gt;

&lt;p&gt;In this video guide you can see a super simple implementation of this, Have a nice day!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/5VEbSbM5m3Q"&gt;Video Guide&lt;/a&gt;&lt;br&gt;
🆗 👋&lt;/p&gt;

</description>
      <category>voting</category>
      <category>node</category>
      <category>websocket</category>
      <category>chartjs</category>
    </item>
    <item>
      <title>💬NodeJs WebSocketS Chat App</title>
      <dc:creator>alexpaper</dc:creator>
      <pubDate>Thu, 05 May 2022 12:43:32 +0000</pubDate>
      <link>https://dev.to/alexpaper/nodejs-websockets-chat-app-4d51</link>
      <guid>https://dev.to/alexpaper/nodejs-websockets-chat-app-4d51</guid>
      <description>&lt;p&gt;If you want create a super simple chat application, of course you must use socket.io, which is the absolute number one, &lt;br&gt;
you can also use WebSocket API on frontend and in the backend.&lt;/p&gt;
&lt;h3&gt;
  
  
  WebSocket Client
&lt;/h3&gt;

&lt;p&gt;The WebSocket object provides the API for creating and managing a WebSocket connection to a server, &lt;br&gt;
as well as for sending and receiving data on the connection.&lt;/p&gt;

&lt;p&gt;In the client side first of all you need to create a WebSocket connection&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const socket = new WebSocket('ws://localhost:8080');

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Events
&lt;/h3&gt;

&lt;p&gt;You need to create three event listeners using addEventListener(),&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;the first one for the 'open' event,&lt;br&gt;
fired when a connection with a WebSocket is opened,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the second one for the 'close' event&lt;br&gt;
fired when a connection with a WebSocket is closed,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;and the last one for the 'message' event,&lt;br&gt;
fired when data is received through a WebSocket.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;socket.addEventListener('open', function (event) {
    socket.send('Hello Server!');
});

socket.addEventListener('message', function (event) {
    console.log('Message from server ', event.data);
});

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  WebSocket on the Server Side
&lt;/h3&gt;

&lt;p&gt;In the backend you can also use WebSocket tecnology, in NodeJs you can install &lt;br&gt;
&lt;a href="https://www.npmjs.com/package/ws"&gt;ws library&lt;/a&gt;&lt;br&gt;
it is very easy to implement, to install it perform this command&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;npm i ws&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;import and crete the WebSocket Server 'wss'&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import WebSocket, {WebSocketServer} from 'ws';

const wss = new WebSocketServer({port:8080});

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

&lt;/div&gt;



&lt;p&gt;listen for connection and send a string or an object welcome message&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wss.on('connection', (ws, req)=&amp;gt;{

 ws.send(JSON.stringify({time: datetime, message:`💬 Welcome from the Server 🎉.`}));
});

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

&lt;/div&gt;



&lt;p&gt;In this video guide you can see a super simple implementation, have a nice day!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/qJ2SfFcYUrM"&gt;Video Guide&lt;/a&gt;&lt;br&gt;
🆗 👋&lt;/p&gt;

</description>
    </item>
    <item>
      <title>⚛️ React Intersection Observer 👀 Hook 🪝.</title>
      <dc:creator>alexpaper</dc:creator>
      <pubDate>Mon, 02 May 2022 09:25:37 +0000</pubDate>
      <link>https://dev.to/alexpaper/react-intersection-observer-hook--4c6o</link>
      <guid>https://dev.to/alexpaper/react-intersection-observer-hook--4c6o</guid>
      <description>&lt;p&gt;As &lt;strong&gt;MDN&lt;/strong&gt; says the &lt;strong&gt;Intersection Observer API&lt;/strong&gt; provides a way to asynchronously observe &lt;br&gt;
changes in the intersection of a target element with an ancestor element or with a top-level document's.&lt;/p&gt;

&lt;p&gt;It seems complicated but in React you can achieve intersection using a simple hook&lt;br&gt;
the only thing to keep in mind is that you need to pass a &lt;em&gt;'target element'&lt;/em&gt; to the observer &lt;br&gt;
using useRef()&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const targetMiddle = React.useRef();
const targetTop = React.useRef();

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

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h3 ref={targetTop}&amp;gt;TOP&amp;lt;/h3&amp;gt;
&amp;lt;h3 ref={targetMiddle}&amp;gt;Middle&amp;lt;/h3&amp;gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Hook
&lt;/h3&gt;

&lt;p&gt;The hook is very simple &lt;br&gt;
you need to export a function that accept the target element as argument&lt;br&gt;
By default the &lt;em&gt;threshold&lt;/em&gt; is set to 0 but you can play around with the options based on your needs&lt;br&gt;
set the state using _isIntersecting _entry property&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export function useObserver(ref) {

    const [isIntersecting, setIsIntersecting] = React.useState(false);

     // OPTIONS
     const options = {
        // root: target.current,
        rootMargin: '0px',
        threshold: 0.5, // A threshold of 1.0 means that when 100% of the target is visible within the element specified by the root option, the callback is invoked.
    };
    // Observer
    const observer = new IntersectionObserver(([entry]) =&amp;gt; setIsIntersecting(entry.isIntersecting),options);

    // Use Effect
    React.useEffect(() =&amp;gt; {

        observer.observe(ref.current)
        // DISCONNECT 
        return () =&amp;gt; observer.disconnect()

    }, []);
    // Return
    return isIntersecting
  };

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

&lt;/div&gt;



&lt;p&gt;inside useEffect you can call the _disconnect _ method to stop it from observing the target element&lt;br&gt;
and finally return the state that can be true or false,&lt;br&gt;
and based on this value you can change the vDom, for example by showing or hiding a video &lt;br&gt;
when the target element is visible, the limit is your imagination!&lt;/p&gt;

&lt;p&gt;In this video guide you can see a super simple implementation, good observation 👀 ...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/5Z3jzMWhGHQ"&gt;Video Guide&lt;/a&gt;&lt;br&gt;
🆗 👋&lt;/p&gt;

</description>
      <category>hook</category>
      <category>react</category>
      <category>intersection</category>
      <category>observer</category>
    </item>
    <item>
      <title>⌛ Html Css Js SVG Clock 🕐</title>
      <dc:creator>alexpaper</dc:creator>
      <pubDate>Wed, 20 Apr 2022 14:21:56 +0000</pubDate>
      <link>https://dev.to/alexpaper/html-css-js-svg-clock-43mg</link>
      <guid>https://dev.to/alexpaper/html-css-js-svg-clock-43mg</guid>
      <description>&lt;p&gt;How to create a super simple clock using html, css, svg images and javascript?&lt;/p&gt;

&lt;p&gt;Well it is not so complicated if you keep in mind some essential points,&lt;br&gt;
you need to place the svg circle image directly inside the &lt;strong&gt;Html&lt;/strong&gt; page in this way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="clock-container flex"&amp;gt;
  &amp;lt;svg class="svg-seconds" width="24px" height="24px" viewBox="0 0 24 24"  xmlns="http://www.w3.org/2000/svg"&amp;gt;&amp;lt;path d="M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486  10-10S17.514 2 12 2z"/&amp;gt;&amp;lt;/svg&amp;gt;
  &amp;lt;svg class="svg-minutes" width="24px" height="24px" viewBox="0 0 24 24"  xmlns="http://www.w3.org/2000/svg"&amp;gt;&amp;lt;path d="M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486  10-10S17.514 2 12 2z"/&amp;gt;&amp;lt;/svg&amp;gt;
  &amp;lt;svg class="svg-hours" width="24px" height="24px" viewBox="0 0 24 24"    xmlns="http://www.w3.org/2000/svg"&amp;gt;&amp;lt;path d="M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486  10-10S17.514 2 12 2z"/&amp;gt;&amp;lt;/svg&amp;gt;
    
   &amp;lt;div class="time-box"&amp;gt;
            &amp;lt;div class="time"&amp;gt;00:00:00&amp;lt;/div&amp;gt;
   &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;and this is all the &lt;strong&gt;Html&lt;/strong&gt; code you really need,&lt;/p&gt;

&lt;p&gt;for the &lt;strong&gt;Css&lt;/strong&gt; part it is necessary to give a position relative to the &lt;em&gt;time-box&lt;/em&gt; div, so you can position the &lt;em&gt;Svg&lt;/em&gt; circles absolutely within it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.time-box{
    position: relative;
...
}

/* SVGS  */
svg.svg-seconds{  
    position: absolute;
    width: 360px;
    height: 360px;
    fill: var(--second);
    stroke: var(--third);
    stroke-width: 0.5;
    stroke-dasharray: 63;
}

svg.svg-minutes{  
    position: absolute;
    width: 330px;
    height: 330px;
    fill: transparent;
    stroke: var(--fourth);
    stroke-width: 0.6;
    stroke-dasharray: 63;
}

svg.svg-hours{  
    position: absolute;
    width: 270px;
    height: 270px;
    fill: transparent;
    stroke: var(--seventh);
    stroke-width: 3;
    stroke-dasharray: 63;
}

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

&lt;/div&gt;



&lt;p&gt;for the &lt;strong&gt;javascript&lt;/strong&gt; part instead, you need to create a simple function that change the stroke of the Svg circles and return a time string&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// TIME FN
function timeFn (){
    let time = new Date();
    let hours = addZero(time.getHours());
    let minutes = addZero(time.getMinutes());
    let seconds = time.getSeconds().toString().padStart(2,0);
    // 4 SVG OFFSET
    secCircle.style.strokeDashoffset = -(63 - (64 * seconds) / 60);
    minCircle.style.strokeDashoffset = -(63 - (64 * minutes) / 60);
    hoursCircle.style.strokeDashoffset = -(63 - (64 * hours) / 24)
    // FULL TIME
    let fullTime = `${hours}:${minutes}:${seconds}`;
    // console.log(fullTime)
    return fullTime;
}

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

&lt;/div&gt;



&lt;p&gt;to add a zero you can use a function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function addZero (timeValue) {
    return Number(timeValue) &amp;gt;= 10 ? timeValue : '0'+ timeValue;
};

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

&lt;/div&gt;



&lt;p&gt;or use padStart() methods&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.toString().padStart(2,0);

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

&lt;/div&gt;



&lt;p&gt;now all that you need to do is set the interval to 1 second (default) and every time change the inner Html of the time div&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;setInterval(()=&amp;gt; time.innerHTML = timeFn());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you can find the code here &lt;a href="https://github.com/sitowebveloce/js-css-svg-clock.git"&gt;github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;this is a simple  &lt;a href="https://youtu.be/pxDydQk47FM"&gt;video guide&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👋&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Css Shake Animation</title>
      <dc:creator>alexpaper</dc:creator>
      <pubDate>Thu, 14 Apr 2022 05:15:10 +0000</pubDate>
      <link>https://dev.to/alexpaper/css-shake-animation-5gn2</link>
      <guid>https://dev.to/alexpaper/css-shake-animation-5gn2</guid>
      <description>&lt;p&gt;I've always liked the shaking effect on the login screen on Linux &lt;br&gt;
or Mac systems, yes, but how to make a similar effect through CSS?&lt;br&gt;
In a few lines of code!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.card {
    ...
    animation: shake 1s ease-in-out forwards;
}
@keyframes shake {
    0%,100% {
        transform: translate(0, 0);
    }
    10%,30%,50%,70%,90% {
        transform: translate(30px);
    }
    20%,40%,60%,80% {
        transform: translate(-30px);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this video guide you can see how to create a super ultra simple shaking effect&lt;br&gt;
via CSS ...&lt;br&gt;
&lt;a href="https://youtu.be/xFUUP7Kd41U"&gt;Video Guide&lt;/a&gt;&lt;br&gt;
🆗 👋&lt;/p&gt;

</description>
      <category>card</category>
      <category>shake</category>
      <category>animation</category>
      <category>css</category>
    </item>
    <item>
      <title>🦜 JS Text To Voice</title>
      <dc:creator>alexpaper</dc:creator>
      <pubDate>Fri, 08 Apr 2022 10:16:30 +0000</pubDate>
      <link>https://dev.to/alexpaper/js-text-to-voice-5863</link>
      <guid>https://dev.to/alexpaper/js-text-to-voice-5863</guid>
      <description>&lt;p&gt;As you know  Web Speech API enables you to incorporate voice data into web apps. The Web Speech API has two parts: &lt;br&gt;
SpeechSynthesis (Text-to-Speech), and &lt;br&gt;
SpeechRecognition (Asynchronous Speech Recognition).&lt;/p&gt;

&lt;p&gt;Using &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance"&gt;Speech Synthesis Utterance&lt;/a&gt; you can create a super simple Html Css and Javascript 'Text To Voice' Web App,&lt;/p&gt;

&lt;p&gt;For the HTML part, you just need an input field and a button, like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="container"&amp;gt;
        &amp;lt;div class="box"&amp;gt;
            &amp;lt;h1&amp;gt;🦜 Text To Voice&amp;lt;/h1&amp;gt;
            &amp;lt;input class="text" type="text" placeholder="Text To Voice"&amp;gt;
            &amp;lt;button class="play"&amp;gt;Play&amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the javascrit part you just need to instantiate a new &lt;em&gt;&lt;strong&gt;SpeechSynthesisUtterance&lt;/strong&gt;&lt;/em&gt; interface of the Web Speech API that represents a speech request, then you need to add the content the speech service should read and information about how to read it (e.g. language, pitch, text and volume, like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let utter = new SpeechSynthesisUtterance();
utter.text = 'Hello World';
utter.volume = 0.5; // From 0 to 1
// utter.lang = 'us-EN';
utter.voice = voices[33]; // 33 english voice, 53 it
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now to transform the text into voice 🎤, you can use &lt;em&gt;speechSynthesis speak&lt;/em&gt; method, like this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.speechSynthesis.speak(utter);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, through the use of &lt;em&gt;events&lt;/em&gt;, you can create a nice user experience!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; // START EVENT LISTENER
       utter.addEventListener('start',()=&amp;gt;{
        if(window.speechSynthesis.speaking){
            play.classList.add('active');
        }
        });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a super fast &lt;a href="https://youtu.be/F2FNZOa2znk"&gt;video guide&lt;/a&gt;.&lt;br&gt;
👋&lt;/p&gt;

</description>
      <category>text</category>
      <category>voice</category>
      <category>speech</category>
      <category>api</category>
    </item>
    <item>
      <title>JavaScript Navigator Media Devices 📷 🎙️</title>
      <dc:creator>alexpaper</dc:creator>
      <pubDate>Tue, 05 Apr 2022 20:47:08 +0000</pubDate>
      <link>https://dev.to/alexpaper/javascript-navigator-media-devices-3jmm</link>
      <guid>https://dev.to/alexpaper/javascript-navigator-media-devices-3jmm</guid>
      <description>&lt;p&gt;As you know, with &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/mediaDevices"&gt;&lt;u&gt;Navigator.mediaDevices&lt;/u&gt;&lt;/a&gt; you can access to connected media input devices in your machine like cameras and microphones.&lt;/p&gt;

&lt;p&gt;Taking advantage of the potential of this amazing API you can create pretty awesome web app in a few code lines.&lt;/p&gt;

&lt;p&gt;For example you can create a simple app to &lt;br&gt;
&lt;em&gt;take a picture&lt;/em&gt; using the computer onboard camera.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;MediaDevices.getUserMedia()&lt;/em&gt; method prompts the user for permission to use a media input which produces a MediaStream with tracks containing the requested types of media.&lt;/p&gt;

&lt;p&gt;It returns a &lt;em&gt;&lt;strong&gt;Promise&lt;/strong&gt;&lt;/em&gt; that resolves to a MediaStream object, using this async function you can attach the camera stream as source in your video web page&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const video = document.querySelector('video');
// Navigator video stream
async function videoStream (){
    try{
        const stream = await navigator.mediaDevices.getUserMedia({
            video:true,
            audio:false
        });
        // Set video source
        video.srcObject = stream;
  }catch(err){
        console.log(err);
    }
}

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Some Privacy and security considerations
&lt;/h2&gt;

&lt;p&gt;As an API that may involve significant privacy concerns, getUserMedia()'s specification lays out a wide array of privacy and security requirements that browsers are obligated to meet.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;getUserMedia()&lt;/em&gt; is a powerful feature which can only be used in &lt;strong&gt;secure contexts&lt;/strong&gt;; in insecure contexts, navigator.mediaDevices is &lt;em&gt;undefined&lt;/em&gt;, preventing access to getUserMedia(). &lt;br&gt;
A secure context is, in short, a page loaded using &lt;em&gt;HTTPS&lt;/em&gt; or the file:/// URL scheme, or a page loaded from &lt;em&gt;localhost&lt;/em&gt;.&lt;br&gt;
In addition to that, user permission is always required to access the user's audio and video inputs.&lt;/p&gt;

&lt;p&gt;This is a little &lt;a href="https://youtu.be/Vbj4PtmL0ko"&gt;youtube guide&lt;/a&gt; that show how simple it is implementig navigator API 📸.&lt;/p&gt;

</description>
      <category>navigator</category>
      <category>mediadevices</category>
      <category>getusermedia</category>
      <category>picture</category>
    </item>
    <item>
      <title>CSS NeuBrutalism Card</title>
      <dc:creator>alexpaper</dc:creator>
      <pubDate>Thu, 31 Mar 2022 07:01:36 +0000</pubDate>
      <link>https://dev.to/alexpaper/css-neubrutalism-card-4n45</link>
      <guid>https://dev.to/alexpaper/css-neubrutalism-card-4n45</guid>
      <description>&lt;p&gt;Maybe you already know, the new UI super cool trend is &lt;em&gt;&lt;strong&gt;neubrutalism&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;this is M. Malewicz definition:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Neo brutalism ditches most of that and merges traditional layout concepts with super-high contrast, solid, often purposefully clashing colors and simpler, yet quirky typography.&lt;/p&gt;

&lt;p&gt;People think: I can do this myself! &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But it's not that simple!&lt;/p&gt;

&lt;p&gt;This is a super &lt;em&gt;brutal&lt;/em&gt;, first attempt...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/BRybWulMaZ8"&gt;Video&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can read the full M. Malewicz article here&lt;/p&gt;

&lt;p&gt;&lt;a href="https://hype4.academy/articles/design/neubrutalism-is-taking-over-web"&gt;https://hype4.academy/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>neubrutalism</category>
      <category>css</category>
      <category>neobrutalism</category>
      <category>malewicz</category>
    </item>
  </channel>
</rss>
