<?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: DarkArtistry</title>
    <description>The latest articles on DEV Community by DarkArtistry (@darkartistry).</description>
    <link>https://dev.to/darkartistry</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%2F96421%2Fb17ba358-6c2a-40cf-860c-009594c90087.png</url>
      <title>DEV Community: DarkArtistry</title>
      <link>https://dev.to/darkartistry</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/darkartistry"/>
    <language>en</language>
    <item>
      <title>React Material UI Visual Editor</title>
      <dc:creator>DarkArtistry</dc:creator>
      <pubDate>Mon, 02 May 2022 13:41:59 +0000</pubDate>
      <link>https://dev.to/darkartistry/react-material-ui-visual-editor-3if8</link>
      <guid>https://dev.to/darkartistry/react-material-ui-visual-editor-3if8</guid>
      <description>&lt;h2&gt;
  
  
  React Material UI Visual Editor
&lt;/h2&gt;

&lt;p&gt;In recent days, no code platforms has seen a rise in demand. Thus, begun my exploration into creating a visual editor.&lt;/p&gt;

&lt;h3&gt;
  
  
  Objectives
&lt;/h3&gt;

&lt;p&gt;Users will be able to drag and drop material components on the left drawer to the dropzone (middle/user layout), and use the toolbox on the right drawer to edit the CSS of individual components in the dropzone. Export a json data structure for various device purposes. Also, possibly becoming a library for people who want to build no code platforms.&lt;/p&gt;

&lt;h3&gt;
  
  
  Milestones
&lt;/h3&gt;

&lt;p&gt;To achieve visual editing with components: Buttons, Grid container, Grid item and Typography. Paper, Icon buttons, Material icons, Accordion, Divider and ImageList components will be an over achievement.&lt;/p&gt;

&lt;h3&gt;
  
  
  To see this Project Grow:
&lt;/h3&gt;

&lt;p&gt;&lt;b&gt;Join us&lt;/b&gt; and &lt;b&gt;collaborate&lt;/b&gt;&lt;br&gt;
OR&lt;br&gt;
&lt;b&gt;Donate&lt;/b&gt; to us at:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Coin&lt;/th&gt;
&lt;th&gt;NetWork&lt;/th&gt;
&lt;th&gt;Address&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fs2.coinmarketcap.com%2Fstatic%2Fimg%2Fcoins%2F200x200%2F825.png"&gt;&lt;/td&gt;
&lt;td&gt;USDT&lt;/td&gt;
&lt;td&gt;BSC Network&lt;/td&gt;
&lt;td&gt;0x81C2A19Ab37A48EB435CFe75c1ba42E3070517B1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Ff%2Ffc%2FBinance-coin-bnb-logo.png"&gt;&lt;/td&gt;
&lt;td&gt;BNB&lt;/td&gt;
&lt;td&gt;BSC Network&lt;/td&gt;
&lt;td&gt;0x81C2A19Ab37A48EB435CFe75c1ba42E3070517B1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fd33wubrfki0l68.cloudfront.net%2Ffcd4ecd90386aeb50a235ddc4f0063cfbb8a7b66%2F4295e%2Fstatic%2Fbfc04ac72981166c740b189463e1f74c%2F40129%2Feth-diamond-black-white.jpg"&gt;&lt;/td&gt;
&lt;td&gt;ETH&lt;/td&gt;
&lt;td&gt;ETH Network&lt;/td&gt;
&lt;td&gt;0x81C2A19Ab37A48EB435CFe75c1ba42E3070517B1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h3&gt;
  
  
  Phase 1: Required Core Concepts
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FBOT2fg6.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FBOT2fg6.gif" title="Phase 1" alt="Phase 1"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Drag and Drop for Document:
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// code to handle drag start:
// ev is the event parameter

ev.dataTransfer.setData("text/plain", ev.target.id);
ev.dataTransfer.effectAllowed = 'copy';
ev.dataTransfer.setData('text/html', ev.currentTarget.innerHTML);

// code to handle drop:

ev.preventDefault();
ev.stopPropagation(); // this prevents propagating events up to the target's parents something critical
let html = ev.dataTransfer.getData("text/html");
ev.currentTarget.style.border = "none";
let text = ev.dataTransfer.getData("text/plain");
let element = document.getElementById(text)
let element_prime = element.cloneNode(true)
ev.currentTarget.append(element_prime)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;However the above is &lt;b&gt;NOT&lt;/b&gt; the React Way of doing things. And we would have to use xml conversions which is "losy" and complex.&lt;/p&gt;
&lt;h3&gt;
  
  
  Phase 2: Introducing .. Redux + React-DnD
&lt;/h3&gt;

&lt;p&gt;React-Dnd also makes use of the Flux Flow, same as Redux. What we want to do now is to make use of React-DnD, and Redux Global Store to save our JSON tree of component hierarchies. Subsequently we can simply make use of the this data structure to render the components.&lt;/p&gt;

&lt;p&gt;NOTE: We will have to separate the components that are used to drag and drop from the list of components and those that are &lt;b&gt;already rendered&lt;/b&gt; as they have different behaviours.&lt;/p&gt;

&lt;p&gt;I will not repeat the React-DnD documents here are the list of features that are used in the project: useDrag, canDrag, isOver, isDragging, useDrop, canDrop.&lt;/p&gt;

&lt;p&gt;Something worth mentioning will be the shallow parameter for isOver, that allowed me to highlight the targetted component instead of every parent related to the component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;monitor.isOver({ shallow: true })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Results of Phase 2:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://open-react-material-ui.web.app/" rel="noopener noreferrer"&gt;Live Demo&lt;/a&gt;&lt;br&gt;
&lt;a href="https://youtu.be/N7Qpv-3ojGM" rel="noopener noreferrer"&gt;Introductory Video&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FWFbmy6u.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FWFbmy6u.gif" title="Phase 2" alt="Phase 2"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>material</category>
      <category>design</category>
    </item>
  </channel>
</rss>
