<?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>Forem: Gino Llerena</title>
    <description>The latest articles on Forem by Gino Llerena (@ginollerena).</description>
    <link>https://forem.com/ginollerena</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%2F79375%2F652b64fb-f118-4b2b-89f8-1c5894a954eb.png</url>
      <title>Forem: Gino Llerena</title>
      <link>https://forem.com/ginollerena</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ginollerena"/>
    <language>en</language>
    <item>
      <title>A Form Builder for a dynamic form render in SolidJS</title>
      <dc:creator>Gino Llerena</dc:creator>
      <pubDate>Thu, 09 Mar 2023 04:03:23 +0000</pubDate>
      <link>https://forem.com/ginollerena/a-form-builder-for-a-dynamic-form-render-in-solidjs-41f2</link>
      <guid>https://forem.com/ginollerena/a-form-builder-for-a-dynamic-form-render-in-solidjs-41f2</guid>
      <description>&lt;p&gt;This article is the second part of  &lt;a href="https://dev.to/ginollerena/porting-my-old-dynamic-form-render-from-react-to-solidjs-101a"&gt;Porting my old dynamic form render from React to SolidJS&lt;/a&gt;. Having defined a structure in JSON (a template) to implement dynamic forms, now the next step is to build a tool to dynamically create this JSON template and continue learning SolidJS.&lt;/p&gt;

&lt;p&gt;This tool will reuse some components from the previous implementation, and it will support the following elements:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GTz9a7TQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8zbkcw2h4zfkzdcbsa3f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GTz9a7TQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8zbkcw2h4zfkzdcbsa3f.png" alt="Elements supported" width="631" height="274"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each one of these elements will be included in a toolbar:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uDc3Komr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ubcpa3y2uy4k9guvr3t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uDc3Komr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ubcpa3y2uy4k9guvr3t.png" alt="Toolbar" width="613" height="86"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After adding an element to the form, it will support two modes: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The read-only mode.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eS_FnpRy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v4xnaoy62t7es9r3y7wx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eS_FnpRy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v4xnaoy62t7es9r3y7wx.png" alt="Read only mode" width="753" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The edit mode&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U2Q3zKjQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9gz98g0x79tku0bdw8be.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U2Q3zKjQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9gz98g0x79tku0bdw8be.png" alt="Edit mode" width="732" height="394"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Both modes support re-ordering through drag and drop, and &lt;a href="(https://solid-dnd.com/)"&gt;Solid DnD&lt;/a&gt; is the library used to accomplish this feature.&lt;/p&gt;

&lt;p&gt;It’s Worth a mention that Radio and Simple Select have the following edit design:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aLISZRVu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bdqrz7cey23bn6ikm6gj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aLISZRVu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bdqrz7cey23bn6ikm6gj.png" alt="Radio &amp;amp; Simple select" width="733" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each option also can be reordered and removed at any time.&lt;/p&gt;

&lt;p&gt;The complete code can be found &lt;a href="https://github.com/GinoLlerena/mysolidform/tree/builder"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>solidjs</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Porting my old dynamic form render from React to SolidJS</title>
      <dc:creator>Gino Llerena</dc:creator>
      <pubDate>Thu, 16 Feb 2023 02:35:27 +0000</pubDate>
      <link>https://forem.com/ginollerena/porting-my-old-dynamic-form-render-from-react-to-solidjs-101a</link>
      <guid>https://forem.com/ginollerena/porting-my-old-dynamic-form-render-from-react-to-solidjs-101a</guid>
      <description>&lt;p&gt;A few years ago I posted an implementation of a &lt;a href="https://github.com/GinoLlerena/dynamicform" rel="noopener noreferrer"&gt;Dynamic Form Render&lt;/a&gt; working in ReactJS. Now with the advent of SolidJS I have ported that app to it with the intention of learning a little bit about this awesome library.&lt;/p&gt;

&lt;p&gt;The idea behind a dynamic form implies designing a structure of components where each one of them represents an element inside of the form. A JSON object fits well with this kind of structure and each object inside of a list represents a text, textarea, radio and so on, as can be seen in this &lt;a href="https://github.com/GinoLlerena/mysolidform/blob/main/src/data/data.js" rel="noopener noreferrer"&gt;template&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;As a starting point, our goal is to support the following element types:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6lsq1q65cb0mlhx3lrw7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6lsq1q65cb0mlhx3lrw7.png" alt="TABLE 1 - LIST OF TYPES " width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The basic structure of the template follows the next pattern:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   formId: "",
   name: "",
   formElements:  ""
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TABLE 2 - BASIC FORM STRUCTURE&lt;/p&gt;

&lt;p&gt;The first two properties represent an Id and Name, just for future extension, with the idea of having multiple forms as templates to be used in specific situations. The formElements property is intended to be a collection of ordered objects, and each object stores the particular configuration of one type of element inside the form. &lt;/p&gt;

&lt;p&gt;Next there is an example of one object using Radio buttons with a collection of options.  The &lt;strong&gt;elementId&lt;/strong&gt; property works as an identifier, the &lt;strong&gt;type&lt;/strong&gt; stores the kind of element (radio in this example) and &lt;strong&gt;formElementValues&lt;/strong&gt; is the list of options available for this collection of radio buttons.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
 "displayName": "Status", 
 "displayOrder": 9, 
 "elementId": "status", 
 "type": "radio", 
 "isHidden": ()=&amp;gt;(false),  
 "formElementValues": [{ 
   "displayName": "Approved", 
   "displayOrder": 1, 
   "elementvalueId": "approved" 
 }, {
   "displayName": "Declined",
   "displayOrder": 2,
   "elementvalueId": "declined"
 }, {
   "displayName": "Pending",
   "displayOrder": 3,
   "elementvalueId": "pending"
 }]
}

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

&lt;/div&gt;



&lt;p&gt;TABLE 3 - JSON OBJECT REPRESENTING A COLLECTION OF RADIO BUTTONS &lt;/p&gt;

&lt;p&gt;The object above allows us to display the following component in a form:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw3qglobmza8jm9gneikg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw3qglobmza8jm9gneikg.png" alt="A RADIO BUTTON IN A FORM RENDER" width="622" height="99"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each value collected by the form has to be stored and used later, and to achieve that purpose another JSON object works well.  In this implementation a JSON object called valueMap is used and each property matches the &lt;strong&gt;elementId&lt;/strong&gt; inside of the form element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Example of a valueMap with the data collected.
{
  "firstname": "John",
  "lastname": "Smith",
  "standardCompanyname": "SolidJS",
  "jobtitle": "Software Engineer",
  "gender": "male",
  "status": "approved"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TABLE 4 - A VALUE MAP SAMPLE&lt;/p&gt;

&lt;p&gt;It is important to note that the &lt;strong&gt;elementId&lt;/strong&gt; in TABLE 3, &lt;strong&gt;“status”&lt;/strong&gt; matches with the analog property in TABLE 4 with the &lt;strong&gt;“approved”&lt;/strong&gt; value. &lt;/p&gt;

&lt;p&gt;Brief technical details about this implementation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/GinoLlerena/mysolidform/blob/main/src/store/store.js" rel="noopener noreferrer"&gt;The data store&lt;/a&gt; for this purpose ,&lt;a href="https://www.solidjs.com/tutorial/stores_createstore" rel="noopener noreferrer"&gt;createStore&lt;/a&gt;, is used because it gives some benefits to working with nested objects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { createStore } from 'solid-js/store'
import { data } from '../data/data';


export const [store, setStore] = createStore(data)


export const [valueMap, setValueMap] = createStore({
   firstname: '',
   relatives: [{id: '1', firstName: 'Juan', lastName: 'Lopez'}]
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The dynamic form render makes use of the component FormRender:&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;FormRender 
          formElements={store.formElements}
          setValueMap={setValueMap}
          valueMap={valueMap}
          setStore={setStore}
 /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It requires the configuration of the following properties:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk91masltigtsn70wzqr5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk91masltigtsn70wzqr5.png" alt="TABLE 7 - THE FORM RENDER PROPERTIES" width="800" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we have the dynamic form rendered, in action:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqfocnvfhk5samih0j9r9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqfocnvfhk5samih0j9r9.png" alt="TABLE 8 - THE FORM RENDER IN ACTION" width="800" height="987"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Final Notes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The resulting code is cleaner than the original version, and the pattern used by SolidJS enforces that.&lt;/li&gt;
&lt;li&gt;The similarity of both libraries allows us a smooth transition.&lt;/li&gt;
&lt;li&gt;This is my first implementation using SolidJS and maybe some patterns have been broken, sorry for that.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The complete code can be found &lt;a href="https://github.com/GinoLlerena/mysolidform" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recommended pages:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.solidjs.com/" rel="noopener noreferrer"&gt;https://www.solidjs.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://solid-dnd.com/" rel="noopener noreferrer"&gt;https://solid-dnd.com/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>frontend</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
