<?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 Amir Nazari on Medium]]></title>
        <description><![CDATA[Stories by Amir Nazari on Medium]]></description>
        <link>https://medium.com/@a.nazari?source=rss-c124a2727564------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DNrkPZZXXa49mVHVH0ZnYA@2x.jpeg</url>
            <title>Stories by Amir Nazari on Medium</title>
            <link>https://medium.com/@a.nazari?source=rss-c124a2727564------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 04:22:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@a.nazari/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[Creating a Knockout UX Design Portfolio: A Comprehensive Guide]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/fibomarket/creating-a-knockout-ux-design-portfolio-a-comprehensive-guide-2e8a97c70532?source=rss-c124a2727564------2"><img src="https://cdn-images-1.medium.com/max/2600/1*0tLWlwrJcfNlUpQa28aU-g.jpeg" width="3098"></a></p><p class="medium-feed-snippet">Creating a strong and effective UX design portfolio is a critical component of your career as a UX designer. Whether you&#x2019;re looking to&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/fibomarket/creating-a-knockout-ux-design-portfolio-a-comprehensive-guide-2e8a97c70532?source=rss-c124a2727564------2">Continue reading on FiboMarket »</a></p></div>]]></description>
            <link>https://medium.com/fibomarket/creating-a-knockout-ux-design-portfolio-a-comprehensive-guide-2e8a97c70532?source=rss-c124a2727564------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e8a97c70532</guid>
            <category><![CDATA[ux-design]]></category>
            <category><![CDATA[design-thinking]]></category>
            <category><![CDATA[prototyping]]></category>
            <category><![CDATA[design-process]]></category>
            <category><![CDATA[ux-portfolio]]></category>
            <dc:creator><![CDATA[Amir Nazari]]></dc:creator>
            <pubDate>Mon, 06 Feb 2023 14:34:42 GMT</pubDate>
            <atom:updated>2023-02-06T14:34:42.411Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Creating a Seamless Experience:]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/fibomarket/creating-a-seamless-experience-54271d71db9b?source=rss-c124a2727564------2"><img src="https://cdn-images-1.medium.com/max/2600/1*bncPJKVJ4YtdruEeWD7Ctw.jpeg" width="3000"></a></p><p class="medium-feed-snippet">The 5 Key Elements of User-Centered Design</p><p class="medium-feed-link"><a href="https://medium.com/fibomarket/creating-a-seamless-experience-54271d71db9b?source=rss-c124a2727564------2">Continue reading on FiboMarket »</a></p></div>]]></description>
            <link>https://medium.com/fibomarket/creating-a-seamless-experience-54271d71db9b?source=rss-c124a2727564------2</link>
            <guid isPermaLink="false">https://medium.com/p/54271d71db9b</guid>
            <category><![CDATA[ux-strategy]]></category>
            <category><![CDATA[uxdesing]]></category>
            <category><![CDATA[usability]]></category>
            <category><![CDATA[user-experience-design]]></category>
            <category><![CDATA[user-centered-design]]></category>
            <dc:creator><![CDATA[Amir Nazari]]></dc:creator>
            <pubDate>Mon, 30 Jan 2023 14:05:41 GMT</pubDate>
            <atom:updated>2023-01-30T14:05:41.992Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Experience the unmatched benefits of a decentralized digital marketplace]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/fibomarket/experience-the-unmatched-benefits-of-a-decentralized-digital-marketplace-ab903c4c015b?source=rss-c124a2727564------2"><img src="https://cdn-images-1.medium.com/max/2600/1*QLgkbjppBu2t91o_FRmYEQ.jpeg" width="4168"></a></p><p class="medium-feed-snippet">Embrace the future of commerce</p><p class="medium-feed-link"><a href="https://medium.com/fibomarket/experience-the-unmatched-benefits-of-a-decentralized-digital-marketplace-ab903c4c015b?source=rss-c124a2727564------2">Continue reading on FiboMarket »</a></p></div>]]></description>
            <link>https://medium.com/fibomarket/experience-the-unmatched-benefits-of-a-decentralized-digital-marketplace-ab903c4c015b?source=rss-c124a2727564------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab903c4c015b</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[digital-asset]]></category>
            <category><![CDATA[marketplaces]]></category>
            <category><![CDATA[decentralization]]></category>
            <dc:creator><![CDATA[Amir Nazari]]></dc:creator>
            <pubDate>Mon, 23 Jan 2023 14:13:40 GMT</pubDate>
            <atom:updated>2023-01-23T14:17:39.473Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[HOW TO CREATE AN ERC20 TOKEN FROM ZERO TO HERO?]]></title>
            <link>https://medium.com/@a.nazari/how-to-create-an-erc20-token-from-zero-to-hero-ffa92c075d5d?source=rss-c124a2727564------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffa92c075d5d</guid>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[erc20]]></category>
            <dc:creator><![CDATA[Amir Nazari]]></dc:creator>
            <pubDate>Mon, 31 Jan 2022 22:04:57 GMT</pubDate>
            <atom:updated>2022-01-31T22:05:21.570Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="ERC-20 Token" src="https://cdn-images-1.medium.com/max/1024/1*gx8Be2uDak9wfh8gymDMwg.jpeg" /><figcaption>Hands psd created by freepik — <a href="http://www.freepik.com/">www.freepik.com</a></figcaption></figure><h3>What is a smart contract?</h3><p>A smart contract is like a regular contract with rules and conditions between buyer and seller. Still, the difference is in a smart contract, these terms of the agreement are written with executable code on the machines, and then they are running on a distributed system.</p><p>One of the most popular smart contract networks is Ethereum, and its programming language is Solidity. You can write your smart contract with this powerful language and publish it on the Ethereum blockchain network as a Token.</p><p><a href="https://soliditylang.org/">https://soliditylang.org/</a></p><h3>What is Token?</h3><p>A token is an interchangeable item with many different properties and behavior. Tokens are used in many different ways, like:</p><ul><li>reputation points in an online platform</li><li>an online piece of art</li><li>skills of a character in a game</li><li>lottery tickets</li><li>voting</li><li>financial assets like a share in a company</li><li>a fiat currency like USD</li><li>an ounce of gold</li><li>and so more …</li></ul><p>This powerful feature of Ethereum should have standard cause these tokens wanted to speak to each other with an API; this is where ERC-20 plays its role.</p><h3>What is ERC-20?</h3><p>As we found here, ERC-20 is a standard for writing tokens with smart contract programming language. Now the question is, what is this standard?<br>In this standard, we need to implement some predetermined events and methods.</p><p>COPY</p><pre>function name() public view returns (string)<br>function symbol() public view returns (string)<br>function decimals() public view returns (uint8)<br>function totalSupply() public view returns (uint256)<br>function balanceOf(address _owner) public view returns (uint256 balance)<br>function transfer(address _to, uint256 _value) public returns (bool success)<br>function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)<br>function approve(address _spender, uint256 _value) public returns (bool success)<br>function allowance(address _owner, address _spender) public view returns (uint256 remaining)</pre><pre>event Transfer(address indexed _from, address indexed _to, uint256 _value)<br>event Approval(address indexed _owner, address indexed _spender, uint256 _value)</pre><ul><li>Function name: Will return the token’s name defined in the project.</li><li>Function symbol: Will return the sign of the token.</li><li>Function decimals: This is defined to show how many decimals this token can have.</li><li>Function totlaSupply: The total supply of the token in the network.</li><li>Function balanceOf: Return the balance of the given wallet address.</li><li>Function transfer: Transfer the given value to the provided wallet address.</li><li>Function transferFrom: Transfer given value from the given sender wallet address to the receiver wallet address.</li><li>Function approve: which will check if the total supply has the amount of token which needs to be allocated to a user.</li><li>Function allowance: which will check if the sender has enough supply to send to the receiver.</li><li>Event Transfer: This event is published when the token is transferred from the sender to the receiver.</li><li>Event Approval: This event is published when the spender approves that can send the given value to the receiver.</li></ul><h3>The Wallet (MetaMask)</h3><p>To work with the ETH network and develop on top of that, you need a wallet address. The simplest way to set up our wallet and use it in our journey is to use <a href="https://metamask.io/">MetaMask</a>.</p><p><a href="https://metamask.io/">A crypto wallet &amp; gateway to blockchain apps | MetaMaskA crypto wallet &amp; gateway to blockchain appsmetamask.io</a></p><p>Owing a MetaMask wallet is very easy, and you can do it in a couple of minutes. First, you need to download the MetaMask browser extension and then follow it to finish the process.</p><p><em>Be careful; if this account of MetaMask is your one, you should save the credentials somewhere safe and don’t forget it!</em></p><h3>The Test Environments (Ropsten Test Network)</h3><p>For beginning the development of the token, you need a place for the test environment.</p><p><a href="https://www.anyblockanalytics.com/networks/ethereum/ropsten/">Ropsten | Anyblock AnalyticsRopsten Ethereum is an Ethereum test network that allows for blockchain development testing before deployment on the main Ethereum network. It is supp…www.anyblockanalytics.com</a></p><p>In the MetaMask browser extension, you can find a dropdown at the top of it and should be written “Ethereum Mainnet.” Click on that and change it to the Ropsten Test Network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/0*Qk0ig6d_Mww-lAcc" /></figure><p><em>MetaMask wallet</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/0*cg41-VdzgBhlfrse" /></figure><p><em>MetaMask change network</em></p><p>Using the <a href="https://faucet.ropsten.be/">Ropsten faucet</a> you can earn some test ETH for testing purposes. You need to change the network on your MetaMask wallet to Ropsten Test Network and copy-paste your wallet address that starts with “0x…” into the mentioned website text field, then click “Send me test Ether”.</p><h3>Development IDE (Remix IDE)</h3><blockquote>An integrated development environment is a software application that provides comprehensive facilities to computer programmers for software development. An IDE usually consists of a source code editor, build automation tools, and a debugger.</blockquote><blockquote><a href="https://en.wikipedia.org/wiki/Integrated_development_environment">Wikipedia</a></blockquote><p><a href="https://remix.ethereum.org/">Remix IDE</a> has all the necessary tools that we need to create, debug, compile and deploy an ERC-20 token.</p><h3>How to create an ERC-20 token</h3><p>Go to the Remix IDE and make a new solidity file, for example — mytoken.sol</p><p>Paste the following code into your new Solidity script:</p><p>COPY</p><pre>pragma solidity ^0.4.24;</pre><pre>//Safe Math Interface</pre><pre>contract SafeMath {</pre><pre>    function safeAdd(uint a, uint b) public pure returns (uint c) {<br>        c = a + b;<br>        require(c &gt;= a);<br>    }</pre><pre>    function safeSub(uint a, uint b) public pure returns (uint c) {<br>        require(b &lt;= a);<br>        c = a - b;<br>    }</pre><pre>    function safeMul(uint a, uint b) public pure returns (uint c) {<br>        c = a * b;<br>        require(a == 0 || c / a == b);<br>    }</pre><pre>    function safeDiv(uint a, uint b) public pure returns (uint c) {<br>        require(b &gt; 0);<br>        c = a / b;<br>    }<br>}<br></pre><pre>//ERC Token Standard #20 Interface</pre><pre>contract ERC20Interface {<br>    function totalSupply() public constant returns (uint);<br>    function balanceOf(address tokenOwner) public constant returns (uint balance);<br>    function allowance(address tokenOwner, address spender) public constant returns (uint remaining);<br>    function transfer(address to, uint tokens) public returns (bool success);<br>    function approve(address spender, uint tokens) public returns (bool success);<br>    function transferFrom(address from, address to, uint tokens) public returns (bool success);</pre><pre>    event Transfer(address indexed from, address indexed to, uint tokens);<br>    event Approval(address indexed tokenOwner, address indexed spender, uint tokens);<br>}<br></pre><pre>//Contract function to receive approval and execute the function in one call</pre><pre>contract ApproveAndCallFallBack {<br>    function receiveApproval(address from, uint256 tokens, address token, bytes data) public;<br>}</pre><pre>//Actual token contract</pre><pre>contract SampleToken is ERC20Interface, SafeMath {<br>    string public symbol;<br>    string public name;<br>    uint8 public decimals;<br>    uint public _totalSupply;</pre><pre>    mapping(address =&gt; uint) balances;<br>    mapping(address =&gt; mapping(address =&gt; uint)) allowed;</pre><pre>    constructor() public {<br>        symbol = &quot;ST&quot;;<br>        name = &quot;Sample Token Coin&quot;;<br>        decimals = 2;<br>        _totalSupply = 100000;<br>        balances[YOUR_METAMASK_WALLET_ADDRESS] = _totalSupply;<br>        emit Transfer(address(0), YOUR_METAMASK_WALLET_ADDRESS, _totalSupply);<br>    }</pre><pre>    function totalSupply() public constant returns (uint) {<br>        return _totalSupply - balances[address(0)];<br>    }</pre><pre>    function balanceOf(address tokenOwner) public constant returns (uint balance) {<br>        return balances[tokenOwner];<br>    }</pre><pre>    function transfer(address to, uint tokens) public returns (bool success) {<br>        balances[msg.sender] = safeSub(balances[msg.sender], tokens);<br>        balances[to] = safeAdd(balances[to], tokens);<br>        emit Transfer(msg.sender, to, tokens);<br>        return true;<br>    }</pre><pre>    function approve(address spender, uint tokens) public returns (bool success) {<br>        allowed[msg.sender][spender] = tokens;<br>        emit Approval(msg.sender, spender, tokens);<br>        return true;<br>    }</pre><pre>    function transferFrom(address from, address to, uint tokens) public returns (bool success) {<br>        balances[from] = safeSub(balances[from], tokens);<br>        allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);<br>        balances[to] = safeAdd(balances[to], tokens);<br>        emit Transfer(from, to, tokens);<br>        return true;<br>    }</pre><pre>    function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {<br>        return allowed[tokenOwner][spender];<br>    }</pre><pre>    function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {<br>        allowed[msg.sender][spender] = tokens;<br>        emit Approval(msg.sender, spender, tokens);<br>        ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);<br>        return true;<br>    }</pre><pre>    function () public payable {<br>        revert();<br>    }<br>}</pre><p>You can change the token name and symbol by changing the lines 62 and 63.<br>You can change the decimal and totalsupply of your token by changing lines 64 and 65.</p><p>It would help if you changed YOUR_METAMASK_WALLET_ADDRESS with your wallet address (the same wallet address that you put in the Ropsten faucet).</p><blockquote>Note : The total supply value must have additional trailing zeros as specified by the decimals field. For example, the decimal value in this contract is two, and we need a total supply of 1000 tokens, so we’ll have to set the real supply variable to 100000 (simply because it won’t allow a decimal point).</blockquote><p>Let’s explain each part of this code:</p><p>contract SafeMath : This contract is used to safely implement the four primary math operations and use its methods instead of the usual operations to avoid possible problems.</p><p>safeAdd : This is a method for adding only two positive numbers and returning the result;</p><p>safeSub : This is a method for subtracting only two positive numbers that the second one has to be less than the first one and return the results;</p><p>safeMul : This is a method for multiplying only two positive numbers and producing the results;</p><p>safeDiv : This is a method for dividing only two positive numbers also the second one is not zero and yielding the results;</p><p>contract ERC20Interface : This is an interface of the ERC20 standard token that we will use to implement our token.</p><p>function totalSupply : This function is used to return the token’s total amount.</p><p>function balanceOf : This function gets an address and returns its balance in the network.</p><p>function allowance : This checks the remaining amounts of the token that the spender can use.</p><p>function transfer : This will transfer the desired quantity token to the given address.</p><p>function approve : The will permit the spender to use the user token on their behalf.</p><p>function transferFrom : This will send tokens from the sender to the receiver.</p><p>function approveAndCall : Executing the transactions of buying and selling the tokens.</p><p>event Transfer : This will propagate when some tokens are transferred.</p><p>event Approval : When approval is submitted, this will publish to the network.</p><p>function () public payable: Fallback function prevents sending tokens directly to the contract address.</p><p>contract ApproveAndCallFallBack : A contract function to receive authorization and execute a function in one call.</p><h3>How to Compile and Deploy an ERC-20 token</h3><p>You can click on the compile icon and submit the compile button on the left pane. Your token is ready to deploy now!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SmumqylWO7NGJh4b" /></figure><p><em>Compile ERC-20 Token</em></p><p>For deploying your token on the Ropsten Test Network, click on the deploy icon on the left pane and select the environment option “Injected Web3.”. Make sure to choose your primary contract name from the contract selector. Now you can submit the “Deploy” button and confirm the transaction on your MetaMask. Currently, you can see your token contract at the bottom of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j-qKNPeMevtE9W0p" /></figure><p><em>Deploy ERC-20 Token</em></p><p>Great! Your first token is published on the test network.</p><h3>Add custom token to MetaMask</h3><p>The last step is adding your custom token to your MetaMask wallet and seeing your balance.<br>At the deployed contracts tab where you deployed in the IDE, copy the contract address from there, and on your MetaMask, click on the “Import tokens” button, and paste the contract address in the “Token Contract Address” field. MetaMask will retrieve other details from the network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/0*535oS-YTqIcFO9ZI" /></figure><p><em>Import token in MetaMask</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/0*ndcNHuK5JY5HXDD7" /></figure><p><em>Add custom token in MetaMask</em></p><h3>Conclusion</h3><p>Congratulations! You have created an ERC-20 token on the Ethereum network successfully.</p><p>If you want to know when the new article will be published, subscribe to my Newsletter on my website! <a href="https://fibocolon.com/newsletter/">Subscribe to Newsletter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffa92c075d5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SINGLE APP FOR WEB, IOS, AND ANDROID USING REACT-NATIVE ( Components ) — PART 2]]></title>
            <link>https://medium.com/@a.nazari/single-app-for-web-ios-and-android-using-react-native-components-part-2-58b46185fb57?source=rss-c124a2727564------2</link>
            <guid isPermaLink="false">https://medium.com/p/58b46185fb57</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Amir Nazari]]></dc:creator>
            <pubDate>Mon, 10 Jan 2022 13:00:00 GMT</pubDate>
            <atom:updated>2022-01-12T20:18:11.978Z</atom:updated>
            <content:encoded><![CDATA[<h3>SINGLE APP FOR WEB, IOS, AND ANDROID USING REACT-NATIVE ( Components ) — PART 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nm7qr_SGBqmwrcdMorrEWQ.png" /></figure><p>This is the second part of the article. In the <a href="https://fibocolon.com/web-development/single-app-for-web-mobile/">previous part</a>, we have examined how to configure a project and run it on all environments (iOS, Android, and Web). In this part, we want to explain how to create different containers and components to develop the logic and UI part of our project on various platforms.</p><p><a href="https://fibocolon.com/web-development/single-app-for-web-mobile/">Single App for web, iOS, and Android using React-Native ( NEW APPROACH ) - PART 1 - FiboColon Smart Solutions</a></p><h3>Concept</h3><p>As we know, Web projects are working with DOM, and native projects have their native components. So we need to separate the UI parts of the different platforms to solve the issue.</p><p>For this purpose, we should keep the logic codes apart from the UI and put them in the different components called containers. For separating the UI parts at platforms, we can use the following two extensions: .native.tsx , .web.tsx</p><p>At the rest of the article, I explained the listed majors:</p><ol><li>How to create a mock server for getting data</li><li>How to create container for the logic</li><li>How to create components for the UI of the application</li></ol><h3>Prerequisite</h3><p>For calling AJAX request axios the library is needed, so let&#39;s execute the following command at the terminal:</p><pre>$ npm install axios</pre><h3>Mock Server</h3><p>There are many libraries and tools to make a mock server for your project; I chose the mocks-server to create the mock server. For installing this lib execute the following command in the terminal of the project:</p><pre>$ npm i @mocks-server/main --save-dev</pre><p>Then add the following code to the <em>scripts</em> part of your package.json file:</p><pre>&quot;mocks&quot;: &quot;mocks-server&quot;</pre><p>After putting the above code, you can execute the mocks from your terminal with this command:</p><pre>$ npm run mocks</pre><p>After running the command, you’ll see that some files and directories will be created on the project. The mocks-server will generate a sample API for getting users inside the <em>/mocks/routes/users.js</em> route.</p><h3>Container</h3><p>This is a place for putting the logical codes there. Everythings that are the same between different platforms and related to the data should be in containers.</p><p>The containers can be named like XConatiner.jsx, and the “X” will be the name of the related feature or component.</p><p>For now, we need UsersContainer.jsx to get the user&#39;s data and pass it to the corresponding component. <br><em>There are many ways to structure the React and React-Native projects, and this article doesn&#39;t focus on them.</em></p><p>First of all, we need a folder inside the src directory called Users. So let’s execute the following command at the terminal:</p><pre>$ cd ./src &amp;&amp; mkdir Users &amp;&amp; cd ./Users</pre><p>Then run the below command to create the mentioned file:</p><pre>$ touch UsersContainer.jsx</pre><p>As mentioned, we need to retrieve the users and pass them to the related UI component in this container, so let’s put the below code inside the UsersContainer.jsx:</p><pre>import React, {useState, useEffect} from &#39;react&#39;;<br>import axios from &#39;axios&#39;;<br>import UsersComponent from &#39;./UsersComponent&#39;;<br><br>export const UsersContainer = () =&gt; {<br>  const [users, setUsers] = useState([]);<br><br>  useEffect(() =&gt; {<br>    axios<br>      .get(&#39;http://localhost:3100/api/users&#39;)<br>      .then(response =&gt; {<br>        setUsers(response.data);<br>      })<br>      .catch(err =&gt; {<br>        console.log(&#39;error&#39;, err);<br>      });<br>  }, []);<br><br>  return users.length &gt; 0 ? &lt;UsersComponent users={users} /&gt; : null;<br>};</pre><h3>Components</h3><p>Here we have the distinction for the different platforms for the UI part. All the visual things and other specific libraries for one platform should be in these components.</p><p>We need two components for web and mobile, UsersComponent.web.jsx and UsersComponent.native.jsx. Create these files inside the Users directory with the following command:</p><pre>$ cd ./src/Users &amp;&amp; touch UsersComponent.web.jsx UsersComponent.native.jsx</pre><p>These components should get users from their parent container and render it. Let’s put the following code for each file:</p><pre>UsersComponnent.web.jsx</pre><pre>import React from &#39;react&#39;;</pre><pre>const UsersComponent = ({users}) =&gt; {<br>  return (<br>    &lt;ul&gt;<br>      {users.map(user =&gt; (<br>        &lt;li key={user.id}&gt;{user.name}&lt;/li&gt;<br>      ))}<br>    &lt;/ul&gt;<br>  );<br>};</pre><pre>export default UsersComponent;</pre><pre>UsersComponent.native.jsx</pre><pre>import React from &#39;react&#39;;<br>import {View, Text} from &#39;react-native&#39;;</pre><pre>const UsersComponent = ({users}) =&gt; {<br>  return (<br>    &lt;View&gt;<br>      {users.map(user =&gt; (<br>        &lt;Text key={user.id}&gt;{user.name}&lt;/Text&gt;<br>      ))}<br>    &lt;/View&gt;<br>  );<br>};</pre><pre>export default UsersComponent;</pre><p>According to the container, you noticed that you didn’t mention importing the component .native or .web. Yes! This is the power of the Webpack and Metro, they can understand which one should be compiled, and you don’t need to worry!</p><p><em>Originally published at </em><a href="https://fibocolon.com/web-development/single-app-for-web-mobile-part-2/"><em>https://fibocolon.com</em></a><em> on January 10, 2022.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58b46185fb57" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SINGLE APP FOR WEB, IOS, AND ANDROID USING REACT-NATIVE ( NEW APPROACH ) — PART 1]]></title>
            <link>https://medium.com/@a.nazari/single-app-for-web-ios-and-android-using-react-native-new-approach-part-1-80d62ff53f50?source=rss-c124a2727564------2</link>
            <guid isPermaLink="false">https://medium.com/p/80d62ff53f50</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Amir Nazari]]></dc:creator>
            <pubDate>Sat, 08 Jan 2022 17:07:06 GMT</pubDate>
            <atom:updated>2022-01-08T17:07:06.431Z</atom:updated>
            <content:encoded><![CDATA[<h3>SINGLE APP FOR WEB, IOS, AND ANDROID USING REACT-NATIVE ( NEW APPROACH ) — PART 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UBJ6Lvnsmdp5m_cnRAGpAA.png" /><figcaption>Single App in all environment</figcaption></figure><h3>Introduction</h3><p>Many projects need to implement both web and mobile applications, but there is always hard to decide how they should be developed. Some of them implemented web applications initially, and after that, mobile application development started. Also, some libraries are out there to implement both web and mobile applications together, like React-Native-Web. But the negative point with these libraries is they are not compatible with all other libraries and they make the apps lower. There is a different approach that we can use to satisfy these needs, and that’s creating separate UI component for web and mobile, but all of them has a single logical part.</p><h3>Concept</h3><p>Before starting to write code, and creating the file structures let me explain the concept of this approach. In React and React-Native one of the best structures is that separating the logic and data parts of every component from the UI part. So we have “Container” and “Screen” for every component in our project. Also as we need to create a project that works in iOS, Android, and Web, we need to separate every UI component into at least 2 parts; “native” and “web”. Our UI components will be like “Component.native.ts” and “Component.web.ts”.</p><p>Maybe it looks like weird these extensions but with this separation, we can use different bundlers for each platform and our purpose will reach out.</p><p>In this tutorial, I didn’t integrate Redux or any state management to reduce the complexity of the tutorial but as I like Typescript and I’d like to spread the use of this wonderful language, I’ll use it in my codes.</p><p>This project will be in 2 parts because it’s a quite long.</p><ol><li><strong>First Part:</strong> Create and Configure the project</li><li><strong>Second Part:</strong> Create some components for different envrionements</li></ol><h3>Phase 1 (Create a Project):</h3><p>I prefer to use VSCode as an editor but you can choose any other editor or IDE you want.</p><p><a href="https://code.visualstudio.com/Download">Download Visual Studio Code - Free AI Code Editor for Mac, Linux, Windows</a></p><h3>Download Visual Studio Code — Mac, Linux, Windows</h3><p>Visual Studio Code is free and available on your favorite platform — Linux, macOS, and Windows. Download Visual Studio Code to experience a redefined code editor, optimized for building and debugging modern web and cloud applications.</p><p>First of all, need to create a project, To do so, the React-Native Typescript template should execute in the terminal: <em>(You can change the name of the project by changing the “PROJECT_NAME” in the command below)</em></p><pre>$ npx react-native init PROJECT_NAME --template react-native-template-typescript</pre><p>If you are using Macbook with any M1 chips you will face with CocoaPods error and there are some possibilities to fix the issue:</p><pre>$ sudo arch -x86_64 gem install ffi</pre><pre>$ arch -x86_64 pod install</pre><p>You can follow this thread for any other ways that you like to follow for solving this issue:</p><p><a href="https://stackoverflow.com/questions/64901180/running-cocoapods-on-apple-silicon-m1">How to running CocoaPods on Apple Silicon (M1)</a></p><h3>How to run CocoaPods on Apple Silicon (M1)</h3><p>I have a Flutter project that I’m trying to run on iOS. It runs normally on my Intel-based Mac, but on my new Apple Silicon-based M1 Mac it fails to install pods. LoadError — dlsym(0x7f8926035eb0,</p><h3>Phase 2 (Adding Web files):</h3><p>In this step, we need to add some files to our project for adding the web functionality to it. For this purpose, we are using React library because React is already part of the project and we don’t need to do a lot for compatibility. <br>First of all, we should create a public directory at the root of the project:</p><pre>$ mkdir public &amp;&amp; cd ./public</pre><p>Public folder stands for keeping the web files like index.html, favicon.ico, manifest.json, and robots.txt. So we need to create these files in the public directory:</p><pre>$ touch index.html manifest.json robots.txt</pre><h3>index.html</h3><p>Is the page template. We need to put the following content inside it:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>  &lt;head&gt;<br>    &lt;meta charset=&quot;utf-8&quot; /&gt;<br>    &lt;link rel=&quot;icon&quot; href=&quot;%PUBLIC_URL%/favicon.ico&quot; /&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot; /&gt;<br>    &lt;meta name=&quot;theme-color&quot; content=&quot;#000000&quot; /&gt;<br>    &lt;meta<br>      name=&quot;description&quot;<br>      content=&quot;Web site created using create-react-app&quot;<br>    /&gt;<br>    &lt;link rel=&quot;apple-touch-icon&quot; href=&quot;%PUBLIC_URL%/logo192.png&quot; /&gt;<br>    &lt;!--<br>      manifest.json provides metadata used when your web app is installed on a<br>      user&#39;s mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/<br>    --&gt;<br>    &lt;link rel=&quot;manifest&quot; href=&quot;%PUBLIC_URL%/manifest.json&quot; /&gt;<br>    &lt;!--<br>      Notice the use of %PUBLIC_URL% in the tags above.<br>      It will be replaced with the URL of the `public` folder during the build.<br>      Only files inside the `public` folder can be referenced from the HTML.</pre><pre>      Unlike &quot;/favicon.ico&quot; or &quot;favicon.ico&quot;, &quot;%PUBLIC_URL%/favicon.ico&quot; will<br>      work correctly both with client-side routing and a non-root public URL.<br>      Learn how to configure a non-root public URL by running `npm run build`.<br>    --&gt;<br>    &lt;title&gt;React App&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;noscript&gt;You need to enable JavaScript to run this app.&lt;/noscript&gt;<br>    &lt;div id=&quot;root&quot;&gt;&lt;/div&gt;<br>    &lt;!--<br>      This HTML file is a template.<br>      If you open it directly in the browser, you will see an empty page.</pre><pre>      You can add webfonts, meta tags, or analytics to this file.<br>      The build step will place the bundled scripts into the &lt;body&gt; tag.</pre><pre>      To begin the development, run `npm start` or `yarn start`.<br>      To create a production bundle, use `npm run build` or `yarn build`.<br>    --&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><h3>manifest.json</h3><p><a href="https://hackthestuff.com/article/what-is-manifest-json-file-and-how-it-is-useful">The manifest.json is a simple JSON file in your website that tells the browser about your website on the user’s mobile device or desktop. Having a manifest is required by Chrome to show the Add to Home Screen prompt.</a> <br>We should fill in this file with the below content:</p><pre>{<br>  &quot;short_name&quot;: &quot;PROJECT_NAME&quot;,<br>  &quot;name&quot;: &quot;PROJECT_NAME&quot;,<br>  &quot;icons&quot;: [<br>    {<br>      &quot;src&quot;: &quot;favicon.ico&quot;,<br>      &quot;sizes&quot;: &quot;64x64 32x32 24x24 16x16&quot;,<br>      &quot;type&quot;: &quot;image/x-icon&quot;<br>    },<br>    {<br>      &quot;src&quot;: &quot;logo192.png&quot;,<br>      &quot;type&quot;: &quot;image/png&quot;,<br>      &quot;sizes&quot;: &quot;192x192&quot;<br>    },<br>    {<br>      &quot;src&quot;: &quot;logo512.png&quot;,<br>      &quot;type&quot;: &quot;image/png&quot;,<br>      &quot;sizes&quot;: &quot;512x512&quot;<br>    }<br>  ],<br>  &quot;start_url&quot;: &quot;.&quot;,<br>  &quot;display&quot;: &quot;standalone&quot;,<br>  &quot;theme_color&quot;: &quot;#000000&quot;,<br>  &quot;background_color&quot;: &quot;#ffffff&quot;<br>}</pre><p><em>You should change the PROJECT_NAME with your project </em>name.</p><p>As you can see in the contents of the manifest.json we need 3 files; favicon.ico, logo192.png, and logo512.png. You should put your own logo file with these three formats and sizes in the public directory that was created.</p><h3>robots.txt</h3><p><a href="https://developers.google.com/search/docs/advanced/robots/intro">A <strong>robots.txt</strong> file tells search engine crawlers which URLs the crawler can access on your site.</a><br>Add this file with the following content:</p><pre># https://www.robotstxt.org/robotstxt.html<br>User-agent: *<br>Disallow:</pre><p><em>You can put any pages that the robots should read in front of the Disallow.</em></p><h3>index.web.tsx</h3><p>After that, we need to create a start point for the web project. This file will be the place the compiler starts to create the hierarchy. The place of this file should be inside the src directory.</p><pre>$ cd ./src &amp;&amp; touch index.web.tsx</pre><p>Then we need to put some code inside it for rendering our code:</p><pre>import React from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;</pre><pre>ReactDOM.render(<br>  &lt;React.StrictMode&gt;<br>    {/* Here will be our codes and components */}<br>  &lt;/React.StrictMode&gt;,<br>  document.getElementById(&#39;root&#39;)<br>);</pre><p>After creating these files we need to change some configurations from the project. You can open your editor and open the .eslintrc.js file, then add &#39;react-app&#39;, &#39;react-app/jest&#39; to the extends key and it should be like:</p><pre>module.exports = {<br>  root: true,<br>  extends: [&#39;@react-native-community&#39;, &#39;react-app&#39;, &#39;react-app/jest&#39;],<br>  parser: &#39;@typescript-eslint/parser&#39;,<br>  plugins: [&#39;@typescript-eslint&#39;],<br>  rules: {<br>    &#39;no-shadow&#39;: &#39;off&#39;,<br>    &#39;@typescript-eslint/no-shadow&#39;: [&#39;error&#39;],<br>  },<br>};</pre><p>Then we need to change 2 properties in the tsconfig.json file; change the &quot;lib&quot; property to &quot;dom&quot;, &quot;dom.iterable&quot;, &quot;esnext&quot; and change the &quot;jsx&quot; property to &quot;preserve&quot;. <br>The file will be like this:</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    /* Basic Options */<br>    &quot;target&quot;: &quot;esnext&quot;,                       /* Specify ECMAScript target version: &#39;ES3&#39; (default), &#39;ES5&#39;, &#39;ES2015&#39;, &#39;ES2016&#39;, &#39;ES2017&#39;,&#39;ES2018&#39; or &#39;ESNEXT&#39;. */<br>    &quot;module&quot;: &quot;commonjs&quot;,                     /* Specify module code generation: &#39;none&#39;, &#39;commonjs&#39;, &#39;amd&#39;, &#39;system&#39;, &#39;umd&#39;, &#39;es2015&#39;, or &#39;ESNext&#39;. */<br>    &quot;lib&quot;: [&quot;dom&quot;, &quot;dom.iterable&quot;, &quot;esnext&quot;],                        /* Specify library files to be included in the compilation. */<br>    &quot;allowJs&quot;: true,                          /* Allow javascript files to be compiled. */<br>    // &quot;checkJs&quot;: true,                       /* Report errors in .js files. */<br>    &quot;jsx&quot;: &quot;preserve&quot;,                    /* Specify JSX code generation: &#39;preserve&#39;, &#39;react-native&#39;, or &#39;react&#39;. */<br>    // &quot;declaration&quot;: true,                   /* Generates corresponding &#39;.d.ts&#39; file. */<br>    // &quot;sourceMap&quot;: true,                     /* Generates corresponding &#39;.map&#39; file. */<br>    // &quot;outFile&quot;: &quot;./&quot;,                       /* Concatenate and emit output to single file. */<br>    // &quot;outDir&quot;: &quot;./&quot;,                        /* Redirect output structure to the directory. */<br>    // &quot;rootDir&quot;: &quot;./&quot;,                       /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */<br>    // &quot;removeComments&quot;: true,                /* Do not emit comments to output. */<br>    &quot;noEmit&quot;: true,                           /* Do not emit outputs. */<br>    // &quot;incremental&quot;: true,                   /* Enable incremental compilation */<br>    // &quot;importHelpers&quot;: true,                 /* Import emit helpers from &#39;tslib&#39;. */<br>    // &quot;downlevelIteration&quot;: true,            /* Provide full support for iterables in &#39;for-of&#39;, spread, and destructuring when targeting &#39;ES5&#39; or &#39;ES3&#39;. */<br>    &quot;isolatedModules&quot;: true,                  /* Transpile each file as a separate module (similar to &#39;ts.transpileModule&#39;). */</pre><pre>    /* Strict Type-Checking Options */<br>    &quot;strict&quot;: true,                           /* Enable all strict type-checking options. */<br>    // &quot;noImplicitAny&quot;: true,                 /* Raise error on expressions and declarations with an implied &#39;any&#39; type. */<br>    // &quot;strictNullChecks&quot;: true,              /* Enable strict null checks. */<br>    // &quot;strictFunctionTypes&quot;: true,           /* Enable strict checking of function types. */<br>    // &quot;strictPropertyInitialization&quot;: true,  /* Enable strict checking of property initialization in classes. */<br>    // &quot;noImplicitThis&quot;: true,                /* Raise error on &#39;this&#39; expressions with an implied &#39;any&#39; type. */<br>    // &quot;alwaysStrict&quot;: true,                  /* Parse in strict mode and emit &quot;use strict&quot; for each source file. */</pre><pre>    /* Additional Checks */<br>    // &quot;noUnusedLocals&quot;: true,                /* Report errors on unused locals. */<br>    // &quot;noUnusedParameters&quot;: true,            /* Report errors on unused parameters. */<br>    // &quot;noImplicitReturns&quot;: true,             /* Report error when not all code paths in function return a value. */<br>    // &quot;noFallthroughCasesInSwitch&quot;: true,    /* Report errors for fallthrough cases in switch statement. */</pre><pre>    /* Module Resolution Options */<br>    &quot;moduleResolution&quot;: &quot;node&quot;,               /* Specify module resolution strategy: &#39;node&#39; (Node.js) or &#39;classic&#39; (TypeScript pre-1.6). */<br>    // &quot;baseUrl&quot;: &quot;./&quot;,                       /* Base directory to resolve non-absolute module names. */<br>    // &quot;paths&quot;: {},                           /* A series of entries which re-map imports to lookup locations relative to the &#39;baseUrl&#39;. */<br>    // &quot;rootDirs&quot;: [],                        /* List of root folders whose combined content represents the structure of the project at runtime. */<br>    // &quot;typeRoots&quot;: [],                       /* List of folders to include type definitions from. */<br>    // &quot;types&quot;: [],                           /* Type declaration files to be included in compilation. */<br>    &quot;allowSyntheticDefaultImports&quot;: true,     /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */<br>    &quot;esModuleInterop&quot;: true,                  /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies &#39;allowSyntheticDefaultImports&#39;. */<br>    // &quot;preserveSymlinks&quot;: true,              /* Do not resolve the real path of symlinks. */<br>    &quot;skipLibCheck&quot;: false,                    /* Skip type checking of declaration files. */<br>    &quot;resolveJsonModule&quot;: true                 /* Allows importing modules with a ‘.json’ extension, which is a common practice in node projects. */</pre><pre>    /* Source Map Options */<br>    // &quot;sourceRoot&quot;: &quot;./&quot;,                    /* Specify the location where debugger should locate TypeScript files instead of source locations. */<br>    // &quot;mapRoot&quot;: &quot;./&quot;,                       /* Specify the location where debugger should locate map files instead of generated locations. */<br>    // &quot;inlineSourceMap&quot;: true,               /* Emit a single file with source maps instead of having a separate file. */<br>    // &quot;inlineSources&quot;: true,                 /* Emit the source alongside the sourcemaps within a single file; requires &#39;--inlineSourceMap&#39; or &#39;--sourceMap&#39; to be set. */</pre><pre>    /* Experimental Options */<br>    // &quot;experimentalDecorators&quot;: true,        /* Enables experimental support for ES7 decorators. */<br>    // &quot;emitDecoratorMetadata&quot;: true,         /* Enables experimental support for emitting type metadata for decorators. */<br>  },<br>  &quot;exclude&quot;: [<br>    &quot;node_modules&quot;, &quot;babel.config.js&quot;, &quot;metro.config.js&quot;, &quot;jest.config.js&quot;<br>  ]<br>}</pre><p>Then last but not least, we need to add some packages to the package.json and add scripts to it.</p><p>For supporting the DOM and React scripts we should add the following package to the project.</p><p>&quot;react-dom&quot;: &quot;^17.0.2&quot;,<br>&quot;react-scripts&quot;: &quot;^5.0.0&quot;</p><pre>$ npm install react-dom react-scripts</pre><p>For the development purpose, we need some other packages that should be added to the <em>devDependencies</em> inside the package.json. For adding to the dev part we should pass the --save-dev at the end of the command. These are the packages that should be added:</p><ul><li>&quot;@types/react-dom&quot;: &quot;^17.0.11&quot;,</li><li>&quot;@testing-library/jest-dom&quot;: &quot;^5.16.1&quot;,</li><li>&quot;@testing-library/react&quot;: &quot;^12.1.2&quot;,</li><li>&quot;@testing-library/user-event&quot;: &quot;^13.5.0&quot;,</li><li>&quot;@types/node&quot;: &quot;^16.11.17&quot;,</li><li>&quot;@types/react&quot;: &quot;^17.0.38&quot;,</li></ul><p>For adding these packages to your devDependencies execute the following command inside the terminal at the project root folder:</p><pre>$ npm install @types/react-dom @testing-library/jest-dom @testing-library/react @testing-library/user-event @types/node @types/react --save-dev</pre><p>After adding the dependencies that we need for the project, it’s time to add some additional scripts and change the previous ones for the readability of the project. Let’s change the scripts part in the package.json file with the following:</p><pre>&quot;scripts&quot;: {<br>    &quot;build-android&quot;: &quot;react-native run-android&quot;,<br>    &quot;build-ios&quot;: &quot;react-native run-ios&quot;,<br>    &quot;start-native&quot;: &quot;react-native start&quot;,<br>    &quot;test&quot;: &quot;jest&quot;,<br>    &quot;lint&quot;: &quot;eslint . --ext .js,.jsx,.ts,.tsx&quot;,<br>    &quot;start-web&quot;: &quot;react-scripts start&quot;,<br>    &quot;build-web&quot;: &quot;react-scripts build&quot;<br>  },</pre><p>Congratulations! You’ve finished the configurations of the project. Now you can start the project for the different environments.</p><h4>For starting on the web:</h4><pre>$ npm start start-web</pre><h4>For starting on the iOS:</h4><pre>$ npm start build-ios</pre><h4>For starting on the Android:</h4><pre>$ npm start build-android</pre><p><strong>The rest of the article will be in the next article that comes in a few days. If you want to know when the new article will be published, subscribe to my Newsletter at my own website!</strong></p><p><a href="https://fibocolon.com/newsletter/">Newsletter - FiboColon Smart Solutions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80d62ff53f50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a JavaScript project from SCRATCH]]></title>
            <link>https://medium.com/swlh/create-a-pure-html-project-from-scratch-c27a134dc672?source=rss-c124a2727564------2</link>
            <guid isPermaLink="false">https://medium.com/p/c27a134dc672</guid>
            <category><![CDATA[sass]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[how-to-compile-sass]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Amir Nazari]]></dc:creator>
            <pubDate>Fri, 31 Dec 2021 19:03:20 GMT</pubDate>
            <atom:updated>2022-01-05T03:40:59.866Z</atom:updated>
            <content:encoded><![CDATA[<p>How to compile sass and js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EC3Vu9VMXY2HbUCp" /><figcaption>Photo by <a href="https://unsplash.com/@startdig?utm_source=medium&amp;utm_medium=referral">Start Digital</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It was so long that I didn’t create an HTML project from scratch, and I forgot how to start it? How should I compile the SCSS file to CSS? How should I minimize the JS? How was to start watching the changes? <br>So I decided to summarize my investigation and put them all here for reference!</p><h3>Pre-requisites</h3><p>You need Node.js installed on your computer.</p><p>If you’re on a Mac, I recommend installing Homebrew, a package manager for mac.</p><p>After installing this, you can install Node.js by doing:</p><pre>$ brew install node</pre><p>If you want more details on installing Node.js, check out <a href="http://blog.teamtreehouse.com/install-node-js-npm-mac">this article from Treehouse</a>.</p><h3><strong>Let’s begin</strong></h3><p>First, we need to create our folder structure, open the terminal and, create a new folder for our project.</p><pre>$ mkdir PROJECT &amp;&amp; cd PROJECT</pre><p>We need three folders inside our project:<br><em>- public<br> — css<br> — js<br> — images<br>- scss</em></p><pre>$ mkdir public scss &amp;&amp; mkdir public/css public/js public/images</pre><ul><li><strong>public</strong> folder is where I keep all my static assets, inside I have css, js and images folders.</li><li><strong>scss</strong> folder is where I like to keep all of my scss files directories.</li></ul><p>Next, we need to start the npm for compiling the JS and SCSS files:</p><pre>npm init</pre><p>After running this command, it will ask you some questions about your project like name, version, author, etc.</p><p>now let’s create some files:</p><pre>$ touch scss/main.scss .gitignore public/index.html</pre><ul><li><strong>main.scss</strong> is where we will write all styles code.</li><li><em>(optional)</em> <strong>.gitignore</strong> is a hidden file we use to tell GitHub what files and folders to exclude from our repo. I like to ask GitHub to ignore my <strong>node_modules</strong> folder. If I or anyone else needs to clone my repo, I usually ask them to npm install based on the packages in <strong>package.json</strong>.</li><li><strong>index.html</strong> is where we will write all markup codes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*JiYUp7OZG7w7rPocZQLkGQ.png" /><figcaption>Folder structure and files (VSCode with theme Aura Soft Dark)</figcaption></figure><h3>Sass compiler and watcher</h3><p>There are many ways to do this, and I found some of the easiest ones from a great article.</p><p><a href="https://medium.com/@brianhan/watch-compile-your-sass-with-npm-9ba2b878415b">Watch &amp; Compile your Sass with npm.</a></p><p>Let’s install the dev dependencies:</p><pre>$ npm install -D node-sass nodemon css-minify</pre><ul><li>-D flag is another way of saying, “write these node_modules into my package.json under devDependencies” (go look at your package.json)</li><li><strong>node-sass </strong>is that thing gulp-sass uses to compile your scss files to css files. node-sass wraps Libsass.</li><li><strong>nodemon</strong> is a thing we’ll use to watch for changes on our scss files. Normally, it’s used to watch for changes on your server-side Node.js code.</li><li><strong>css-minify</strong> is a lib for css-compression command-line tool</li></ul><p>Now it’s time to write some Sass codes to be able to compile it. 😬<br>Add the following codes to your <em>main.scss</em> file:</p><pre>$grey: #ccc</pre><pre>body {<br>  background-body: $grey;<br>  padding: 0;<br>  margin: 0;<br>}</pre><p>Great! We can create our scripts to compile this sass file to a css one. Put the following script inside your <em>package.json </em>file at the script section:</p><pre>&quot;scripts&quot;: {<br>   &quot;build-css&quot;: &quot;node-sass --include-path scss scss/main.scss   public/css/main.css&quot;,<br>   &quot;minify-css&quot;: &quot;css-minify -d public/css -o public/css&quot;,<br>},</pre><p>For executing this command, you need to do this in your terminal:</p><pre>$ npm run build-css &amp;&amp; npm run minify-css</pre><p>Now you can see the compiled code at <em>main.css </em>and<em> main.min.css</em> files inside the <em>public/css</em> folder. Awesome!</p><p>There is a problem with this script: you should run this command every time you change your sass codes to compile it again, and it doesn’t have a good experience. So we should update our scripts and add the following watch command to the <em>package.json</em> file:</p><pre>&quot;watch-css&quot;: &quot;nodemon -e scss -x \&quot;npm run build-css &amp;&amp; npm run minify-css\&quot;&quot;</pre><p>Now let’s try this command in the terminal</p><pre>$ npm run watch-css</pre><p>Now you can edit your <em>main.scss </em>file and watch the <em>main.css </em>and<em> main.min.css </em>that will change whenever any changes are submitted. Whoaaa!</p><h3>Add CSS to HTML</h3><p>Our css files are ready to be added to the HTML header part. Before adding CSS, we need to create our HTML body structure.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76ad07da055181c1d23a09c935b9d7e5/href">https://medium.com/media/76ad07da055181c1d23a09c935b9d7e5/href</a></iframe><p>Let’s make your index.html file like the above file and change the “PAGE TITLE” with your desired title for your page.</p><p>Now let’s link the CSS file to the <em>index.html</em> file.</p><pre>&lt;link href=&quot;./css/main.min.css&quot; rel=&quot;stylesheet&quot; /&gt;</pre><p>Add the above line inside the &lt;head&gt; tag in the index.html file below the &lt;title&gt; tag.</p><h3>Serve project</h3><p>To serve the local project to work in the web browser, we can use a serve library. Run the following command in the terminal to install the serve</p><pre>$ npm install -g serve</pre><p>Now for running the project with serve you can run this command in the terminal:</p><pre>$ serve -s public</pre><p>Then it will show you the port that the project is running on, then you can open it in your favorite browser! 🤩</p><h3>Uglify JS</h3><p>It sounds weird, yes!</p><blockquote>UglifyJS is a JavaScript parser, minifier, compressor and beautifier toolkit.</blockquote><p>We need this tool for minimizing the JavaScript codes size to reduce the loading time of the webpage. Let’s add it to our project:</p><pre>$ npm install -D uglify-js </pre><p>For using this powerful tool following command should be added to the scripts in <em>package.json</em> file:</p><pre>&quot;compress-js&quot;: &quot;uglifyjs public/js/index.js -c -o public/js/index.min.js&quot;</pre><ul><li>The first argument is the input and if you have multiple JS files you can put all of them together there.</li><li>-c is standing as compress</li><li>-o is used for the output file and the following file name is the file name of the output.</li></ul><h3>Wire the JS to the HTML</h3><p>Now it’s time to add the compressed JS file to the HTML file. For this purpose it needs to add the following tag at the end of the &lt;body&gt; tag inside the index.html file:</p><pre>&lt;script src=&quot;./js/index.min.js&quot;&gt;&lt;/script&gt;</pre><p>There is a lot of things that can be added to this tutorial but I think it should be simple to be useful!</p><p>Anyway, thanks for reading.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MRiglpB03a_8Hs1G" /><figcaption>Photo by <a href="https://unsplash.com/@howier?utm_source=medium&amp;utm_medium=referral">Howie R</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c27a134dc672" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/create-a-pure-html-project-from-scratch-c27a134dc672">Create a JavaScript project from SCRATCH</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to build a React-Native app with React website and Webview]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/swlh/how-to-build-a-react-native-app-with-react-website-and-webview-2ae53594dc07?source=rss-c124a2727564------2"><img src="https://cdn-images-1.medium.com/max/970/1*AsCW8Thkw6_lhdUO8mv7hw.jpeg" width="970"></a></p><p class="medium-feed-snippet">Why should you build an react native app with webview ?</p><p class="medium-feed-link"><a href="https://medium.com/swlh/how-to-build-a-react-native-app-with-react-website-and-webview-2ae53594dc07?source=rss-c124a2727564------2">Continue reading on The Startup »</a></p></div>]]></description>
            <link>https://medium.com/swlh/how-to-build-a-react-native-app-with-react-website-and-webview-2ae53594dc07?source=rss-c124a2727564------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ae53594dc07</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[webview]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[react-native-navigation]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Amir Nazari]]></dc:creator>
            <pubDate>Sat, 04 Apr 2020 05:02:51 GMT</pubDate>
            <atom:updated>2020-06-27T08:12:41.676Z</atom:updated>
        </item>
    </channel>
</rss>