How & Why i designed ReactorJS
Tags: webdesign, javascript, reactorjs, jquery
Published: 2019-12-24 20:14:24

<h1>The two main reasons why i designed reactor js:</h1>
<ul>
<li> A creative javascript solution to writing less code</li>
<li> Solutions like this often require dependencies or heavy frameworks like angular or react, etc, this doesn't.</li>
</ul>

App Website: https://reactor-js.com

<h4>Introduction</h4>
<p>So what exactly is reactor js and why is it of any use?</p>
<p>The short and commercial description is: "Reactor JS is a highly modular and powerful framework designed to help you create custom web designs with much less code.".
You're probably not itnerested in that definition, so let's get real. Reactorjs does actually help web designers with little or no javascript or other framework knowledge to design websites with using as little code as possible. This does not mean it isn't useful for advanced web developers (on the contrary).

Reactorjs also allows the developer to work in a modular fashion similar to angular. Each individual page can be broken down into components, (e.g. a header page, footer, sidebar, etc.) and are all loaded using an html element. 

Since reactor js is designed for simplicity, it allows the designer to use only html throught the reactor app.

<h4>Idea</h4>
<p>Say we wish to design an e-commerce website with a listing of numerous products. An example image is shown below (<small>image taken from https://www.designyourway.net</small>).
<img src="https://thepracticaldev.s3.amazonaws.com/i/otd86nbqrow4ezdegtsd.jpg"/>

To create each product, along with its product image, title, price, description, etc, we can take one of two methods, either use a framework like react, which is not ideal for commercial websites, we can use angular but the same problem arises, or simply the web designer does not have sufficient angular knowledge. The second method is to just write x number of product divs in the markup. This isn't ideal at all and of course not efficient. This is the problem which reactorjs elegantly solves.

<h4>Demo</h4>
<p>To demonstrate its functionality we will simulate a small demo of reactorjs so you can understand its power and why it allows you to design websites with less code.
The first thing we do to design this website with numerous products is create a new html document and link reactorjs script inside the script tag in the head section. 

```html
<script src="https://reactor-js/reactor/reactorjs_2.3.5.js"></script>
```

In your body tag we add a div element with class "app". Everything inside this app div will be processed by reactor, everything outside it won't be.

Inside our "app" div we create another div with class name "reactorapp", this div will contain our template design. So we can now add our product container div as we would in common web markup. Let's give it the class "reactor". Inside this div container we add an image, a title, a price and perhaps a description, an add to cart button and whatever else we want in the product container. 
Now instead of hardcoding the images, title, prices etc. we will inject variables inside them as so: 
<ul>
<li>Title: "&lt;h2&gt;{winetitle}&lt;/h2&gt;"</li>
<li>Price: "&lt;h4&gt;{wineprice}&lt;/h4&gt;"</li>
<li>Image "&lt;img src='{wineimg}'/&gt; "</li>
</ul>

We can then style the product container by applying css styles to the &lt;my-product&gt;&lt;/my-product&gt; containers.
Now we have a product container template which is ready to be instantiated as many times as we need. 
How can we achieve this? Firstly, we need to declare our variables which we used on the product template.

Variable declaration in reactor utilizes custom html elements as so (these elements must be outside the "reactor" div):

<img src="https://thepracticaldev.s3.amazonaws.com/i/loshida9jjyr2x4ibm8e.JPG"/>
The first line will be explained later
The second is all the plain text variable declarations (grouped together)
The third are all images variables declarations (grouped together)
(image variables cannot be declared in the reactor-vars tag, and vice-cersa, text variables cannot be declared in the reactor-imsg tag).

Lastly, we can generate any number of product containers that we need by using our variable my-product in a html tag: 
&lt;my-product&gt;&lt;/my-product&gt; 

Then our variables are instantiated sing data-ids. For example a "wintitle" variable for one product container can be instantiated like so: 
data-winetitle="Cabernet Sauvigon 1924"

Price of a wine product: 
data-winetitle="$234.99"

Our wine image: 
data-wineimg="cabernet001.jpg"

We can do repeat this for 100 bottles of wine if we wish:
<img src="https://thepracticaldev.s3.amazonaws.com/i/p413vimz2cn2n0ckf61v.JPG"/>
Each product contains its appropriate image, title and price this way. We achieved this writing the template of all the product containers only with a few lines of code.

Your html document should look like this if you did everything correctly.

<img src="https://thepracticaldev.s3.amazonaws.com/i/b7v15es5bx9hfj30fej6.JPG"/>

Note: ReactorJS uses jquery library so make sure you import the jquery library BEFORE the reactorjs library in the head tag of your html.
Note: All CSS styles must use the tag element we declared "my-product" or give each my-product tag a class and style the classes seperately for more flexibility.

<h4>Result</h4>
<p>The result is a powerful and modular framework that can help us write web design with a lot less code and make our web pages very efficient at the same time. Reactor JS is very useful for ecommerce applications and other apps that require long iterations. Instead of utilizing complex frameworks, reactor makes it intuitively easy and simple to design websites.

<h4>Downloads</h4>
You can download the entire framework with a demo as a zip file here: https://reactor-js.com/reactor/reactorjs_v2.3.5.zip

<h4>Conclusion</h4>
ReactorJS is free to use and under Open source license. However a credit is appreciated when using reactorjs.

For more details and applications on my ReactorJS Framework you can visit the official web page.


Website: https://reactor-js.com
Email: info@scorpionedge.com