<?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 Roshan Sachan on Medium]]></title>
        <description><![CDATA[Stories by Roshan Sachan on Medium]]></description>
        <link>https://medium.com/@roshansachan?source=rss-9ee3d897e73c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ufy2NNDXEozC993jJQKieQ.jpeg</url>
            <title>Stories by Roshan Sachan on Medium</title>
            <link>https://medium.com/@roshansachan?source=rss-9ee3d897e73c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 23:23:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@roshansachan/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[Power your ReactJs application with themes]]></title>
            <link>https://medium.com/the101times/power-your-reactjs-application-with-themes-92bb7de15959?source=rss-9ee3d897e73c------2</link>
            <guid isPermaLink="false">https://medium.com/p/92bb7de15959</guid>
            <category><![CDATA[101shop]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[themes]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Roshan Sachan]]></dc:creator>
            <pubDate>Thu, 27 May 2021 06:37:05 GMT</pubDate>
            <atom:updated>2021-05-27T06:37:05.686Z</atom:updated>
            <content:encoded><![CDATA[<p>While creating the e-commerce storefront web application for sellers on our platform we wanted to provide:</p><ol><li>Themes with variation in color and other CSS properties — This enables the sellers to customize their storefront as per their brand guidelines.</li><li>Themes with variation in structure — This enables the sellers to choose from a variety of themes that are best suited for their industry.</li></ol><h3><strong>1. Themes with variation in colour and other css properties:</strong></h3><figure><img alt="Themes with different colour." src="https://cdn-images-1.medium.com/max/621/0*fXPywtotixQeqezN" /><figcaption>Themes with variation in colour and other css properties</figcaption></figure><p>When it’s only about changing the color and other properties like font style, font, weight, etc. all you need to do is create functions that will return values for the CSS property based on the selected theme.</p><p>We chose a very simple approach. Any CSS property, for example, color, is written as color: getThemed(‘colors.primary’).</p><p>getThemed function here returns the colors.primary from a theme object. This theme object can be fetched from an API call. We use Server-side rendering so the object is available readily.</p><figure><img alt="Theme object" src="https://cdn-images-1.medium.com/max/305/0*sC-HfxS3PZurQFHe" /><figcaption>The theme object</figcaption></figure><h3><strong>2. Themes with variation in structure.</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/0*QiO48WUeCkz6YFAc" /><figcaption>Homepage of three themes that have different structure</figcaption></figure><p>This can be achieved by</p><p>A. Decoupling the<strong> logic</strong> and <strong>view</strong></p><p>B. Organising the folders and files in a way that the application returns the file for currently selected theme.</p><h4><strong>A. Decoupling the logic and view</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/0*oV59nGYldHqld1n2" /><figcaption>Container folder structure</figcaption></figure><p>When it’s about changing the structure it involves decoupling the<strong> logic</strong> and <strong>view</strong> part of the application because you do not want to write the same logic of adding an item to a cart for every theme you create.</p><p>You would want to move all the functions up in the state hierarchy. In our case, it was very easy with the use of sagas, actions, reducers, and selectors. The theme files that have JSX<strong>(view)</strong> only dispatch actions and get the updated data using selectors. APIs calls and app <strong>logic</strong> is in sagas.</p><p>If you are not using sagas, you can move all your API calls and action listeners in a separate JS file and your view file will only dispatch actions.</p><p><strong>B. Organising the folders and files in a way that the application returns the file for currently selected theme</strong></p><p>Let’s say you want to have a different view for Product Tile for each theme. The Product tile component folder can have the following structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*KJZRBduVrDq6oCwZCZZG2A.png" /><figcaption>Component folder</figcaption></figure><p><strong>Theme Selection Logic in ProductTile/index.js</strong></p><p>While we create different views for the product tile we wanted to ensure that consuming the components remains as easy as import ProductTile from ‘components/ProductTile’ irrespective of the theme. To achieve this, all you need to do is return the file for the currently selected theme from components/ProductTile/index.js.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/0*kPa4T6d_78MC1Hx5" /><figcaption>Theme selection logic</figcaption></figure><p><strong>The View File in ProductTile/DefaultTheme/index.js</strong></p><p>Let say that the currently selected theme is DefaultTheme. Then the ProductTile/DefaultTheme/index.js<strong> </strong>will receive all the props that are passed to it from anywhere it is used in the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*mVrVeKcs_A29RrvzlhSiYg.png" /><figcaption><strong>DefaultTheme/index.js </strong>props</figcaption></figure><p>Here is an example of how you would use the ProductTile anywhere in the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*NMc9sCmWjsGqwmVd9VhNvg.png" /><figcaption>ProductTile component in use</figcaption></figure><p>In the theme selection file we see {…this.props}, which passes all the props shown in the above image to <strong>DefaultTheme/index.js</strong>.</p><p>The best part about this approach is that you can start applying it to your existing project, one component at a time without affecting the rest of your application.</p><p><strong>Bonus</strong>: You can use the same approach to make your application adaptive (render different views for mobile and desktop) by placing the device selection logic in <strong>DefaultTheme/index.js </strong>and<strong> </strong>creating a<strong> Mobile and Desktop </strong>folder in the DefaultTheme folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*De5cUp6ioGF59MgBWg068A.jpeg" /><figcaption>Device selection for making adaptive application</figcaption></figure><p>I hope you got an insight into how we created the eCommerce storefront web application on our platform for our sellers.</p><p>While you are new at this, we are consistently looking for solutions to better the app. Your feedback and suggestions will help us put our best ‘code’ forward!</p><p>If you are interested in knowing more about the team, please visit the ‘About Us’ page on <a href="https://www.shop101.com/about-us">Shop101</a> and <a href="https://dash101.com/about-us/">Dash101</a>.</p><p>Stay tuned for more such blogs and informative content from the team.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92bb7de15959" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the101times/power-your-reactjs-application-with-themes-92bb7de15959">Power your ReactJs application with themes</a> was originally published in <a href="https://medium.com/the101times">The 101 Times</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>