{"id":72,"date":"2019-09-25T05:47:04","date_gmt":"2019-09-25T05:47:04","guid":{"rendered":"https:\/\/docs.theironnetwork.org\/reactify\/?page_id=72"},"modified":"2019-10-10T08:21:16","modified_gmt":"2019-10-10T08:21:16","slug":"adding-widgets","status":"publish","type":"page","link":"https:\/\/docs.theironnetwork.org\/reactify\/adding-widgets\/","title":{"rendered":"Adding Widgets"},"content":{"rendered":"\n<h5 id=\"adding-a-new-widget\">Adding a new widget<a href=\"#adding-a-new-widget\"><\/a><\/h5>\n\n\n\n<p>Please follow the given steps to add a new widget in the template. We are taking an example of adding a &#8220;New Widget&#8221; on the &#8220;Ecommerce Dashboard&#8221; but you can add any widget on any of the dashboard in the template:<\/p>\n\n\n\n<p><strong>Step 1:<\/strong> Please create a new widget file(of extension .js) in the folder <code>src-&gt;components-&gt;Widgets<\/code>. Like We have created a file named <code>NewWidget.js<\/code> in the same folder.<\/p>\n\n\n\n<p><strong>Step 2: <\/strong>Now add the code in the widget file as per your requirements. For Example we have added the simple text block in the widget file as given in the code snippet below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/**<br> * new widget<br> *\/<br>import React, { Component } from 'react';<br> <br>export default class NewWidget extends Component {<br>   render() {<br>      return (<br>         &lt;div className=\"new-widget\"><br>            &lt;div className=\"bg-primary p-50 mb-30\"><br>               &lt;h2 className=\"text-light\">{'This is a new widget'}&lt;\/h2><br>            &lt;\/div><br>        &lt;\/div><br>      )<br>   }<br>};<\/pre>\n\n\n\n<p><strong>Step 3:<\/strong> Open the <code>index.js<\/code> file from the <code>src->components->Widgets<\/code> and import and then export the widget in the <code>export<\/code> array like given in the code snippet below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ Imported New Widget<br> const NewWidget = Loadable({<br>    loader: () =&gt; import(\".\/NewWidget\"),<br>    loading: MyLoadingComponent<br> })<br> export {<br>    \u2026<br>    TwitterFeedsV2,<br>    \/\/ Exported New Widget<br>    NewWidget<br> }<\/pre>\n\n\n\n<p><strong>Step 4:<\/strong> Open<code>src->routes->dashboard->ecommerce->index.js<\/code> file and add the <code>NewWidget<\/code> in the <code>div<\/code> section <code>&lt;div className=\"ecom-dashboard-wrapper\"><\/code> as given in the code and also import the <code>NewWidget<\/code> at the top like other import statements already imported.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import React, { Component } from 'react'<br> <br>\/\/ intl messages<br>import IntlMessages from 'Util\/IntlMessages';<br> <br>\/\/ page title bar<br>import PageTitleBar from 'Components\/PageTitleBar\/PageTitleBar';<br> <br>\/\/ Newly added widget import statement<br>import { NewWidget } from 'Components\/Widgets';<br> <br>export default class EcommerceDashboard extends Component {<br>   render() {<br>      const { match } = this.props;<br>      return (<br>         &lt;div className=\"ecom-dashboard-wrapper\"><br>            &lt;PageTitleBar title={&lt;IntlMessages id=\"sidebar.ecommerce\" \/>} match={match} \/><br> <br>            \/\/ Newly added widget div section<br>            &lt;NewWidget \/><br>         &lt;\/div><br>      )<br>   }<br>}<br><\/pre>\n\n\n\n<p>Now save the file and open the browser, you will see your newly added widget on your dashboard like below screenshot:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/docs.theironnetwork.org\/reactify\/wp-content\/uploads\/sites\/4\/2019\/09\/addwidget.png\"><img loading=\"lazy\" width=\"1024\" height=\"423\" src=\"https:\/\/docs.theironnetwork.org\/reactify\/wp-content\/uploads\/sites\/4\/2019\/09\/addwidget-1024x423.png\" alt=\"\" class=\"wp-image-73\" srcset=\"https:\/\/docs.theironnetwork.org\/reactify\/wp-content\/uploads\/sites\/4\/2019\/09\/addwidget-1024x423.png 1024w, https:\/\/docs.theironnetwork.org\/reactify\/wp-content\/uploads\/sites\/4\/2019\/09\/addwidget-300x124.png 300w, https:\/\/docs.theironnetwork.org\/reactify\/wp-content\/uploads\/sites\/4\/2019\/09\/addwidget-768x318.png 768w, https:\/\/docs.theironnetwork.org\/reactify\/wp-content\/uploads\/sites\/4\/2019\/09\/addwidget.png 1306w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n\n<h5 id=\"adding-an-existing-widget\">Adding an existing widget<a href=\"#adding-an-existing-widget\"><\/a><\/h5>\n\n\n\n<p>Please follow the given steps to add an existing widget in the template. We are taking an example of adding a &#8220;ToDo List&#8221; on the &#8220;Ecommerce Dashboard&#8221; but you can add any widget on any of the dashboard in the template:<\/p>\n\n\n\n<p><strong>Step 1: <\/strong>Open<code>src->routes->dashboard->ecommerce->index.js<\/code> file and add the <code>TodoListWidget<\/code> in the <code>div<\/code> section <code>&lt;div className=\"ecom-dashboard-wrapper\"><\/code> as given in the code and also import the <code>TodoListWidget<\/code> at the top like other import statements already imported.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/**<br> * Ecommerce Dashboard<br> *\/<br> <br>import React, { Component } from 'react'<br>import IntlMessages from 'Util\/IntlMessages';<br>import PageTitleBar from 'Components\/PageTitleBar\/PageTitleBar';<br> <br>\/\/ Newly added widget import statement<br>import TodoListWidget from 'Components\/Widgets';<br> <br>export default class EcommerceDashboard extends Component {<br>   render() {<br>      const { match } = this.props;<br>      return (<br>         &lt;div className=\"ecom-dashboard-wrapper\"><br>            &lt;PageTitleBar title={&lt;IntlMessages id=\"sidebar.ecommerce\" \/>} match={match} \/><br>            <br>            \/\/ Newly added widget div section<br>            &lt;TodoListWidget \/><br>            <br>         &lt;\/div><br>      )<br>   }<br>}<\/pre>\n\n\n\n<p>Now save the file and open the browser, you will see your newly added widget on your dashboard like below screenshot:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/docs.theironnetwork.org\/reactify\/wp-content\/uploads\/sites\/4\/2019\/09\/addtodo.png\"><img loading=\"lazy\" width=\"1024\" height=\"494\" src=\"https:\/\/docs.theironnetwork.org\/reactify\/wp-content\/uploads\/sites\/4\/2019\/09\/addtodo-1024x494.png\" alt=\"\" class=\"wp-image-74\" srcset=\"https:\/\/docs.theironnetwork.org\/reactify\/wp-content\/uploads\/sites\/4\/2019\/09\/addtodo-1024x494.png 1024w, https:\/\/docs.theironnetwork.org\/reactify\/wp-content\/uploads\/sites\/4\/2019\/09\/addtodo-300x145.png 300w, https:\/\/docs.theironnetwork.org\/reactify\/wp-content\/uploads\/sites\/4\/2019\/09\/addtodo-768x370.png 768w, https:\/\/docs.theironnetwork.org\/reactify\/wp-content\/uploads\/sites\/4\/2019\/09\/addtodo.png 1307w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption> Added Todo List on Ecommerce Dashboard<\/figcaption><\/figure><\/div>\n\n\n\n<blockquote class=\"wp-block-quote\"><p> It does not matters whether you are using the seed project or the complete template, the steps remains the same for both. <\/p><\/blockquote>\n<div class=\"pld-like-dislike-wrap pld-template-1\">\n    <div class=\"pld-like-wrap  pld-common-wrap\">\n    <a href=\"javascript:void(0);\" class=\"pld-like-trigger pld-like-dislike-trigger \" title=\"\" data-post-id=\"72\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-ip-check=\"0\" data-user-check=\"1\">\n                        <i class=\"fas fa-thumbs-up\"><\/i>\n                    <\/a>\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\n<\/div><div class=\"pld-dislike-wrap  pld-common-wrap\">\n    <a href=\"javascript:void(0);\" class=\"pld-dislike-trigger pld-like-dislike-trigger \" title=\"\" data-post-id=\"72\" data-trigger-type=\"dislike\" data-ip-check=\"0\" data-restriction=\"cookie\" data-user-check=\"1\">\n                        <i class=\"fas fa-thumbs-down\"><\/i>\n                    <\/a>\n    <span class=\"pld-dislike-count-wrap pld-count-wrap\"><\/span>\n<\/div><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Adding a new widget Please follow the given steps to add a new widget in the template. We are taking an example of adding a &#8220;New Widget&#8221; on the &#8220;Ecommerce Dashboard&#8221; but you can add any widget on any of the dashboard in the template: Step 1: Please create a new widget file(of extension .js) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":7,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/docs.theironnetwork.org\/reactify\/wp-json\/wp\/v2\/pages\/72"}],"collection":[{"href":"https:\/\/docs.theironnetwork.org\/reactify\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/docs.theironnetwork.org\/reactify\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/docs.theironnetwork.org\/reactify\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.theironnetwork.org\/reactify\/wp-json\/wp\/v2\/comments?post=72"}],"version-history":[{"count":9,"href":"https:\/\/docs.theironnetwork.org\/reactify\/wp-json\/wp\/v2\/pages\/72\/revisions"}],"predecessor-version":[{"id":398,"href":"https:\/\/docs.theironnetwork.org\/reactify\/wp-json\/wp\/v2\/pages\/72\/revisions\/398"}],"wp:attachment":[{"href":"https:\/\/docs.theironnetwork.org\/reactify\/wp-json\/wp\/v2\/media?parent=72"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}