Build Custom Date Range Picker For Angular 8

Build Custom Date Range Picker For Angular 8

In this post, we'll Build a Month Range Picker in Angular 8, like your favorite travel site

Material Design features pretty cool widgets for date range selection, but if you are just like me, a curious learner, you could implement a widget like that with some CSS/HTML and TypeScript.

Step 1. Design the Experience

Let’s constrain ourselves with a use case that I found and helped to resolve at Stack Overflow which had the following criteria:

  • User can switch between different years.
  • User can see the current year’s 12 months (in black) and six months of the past year, as well as six months of the next year (in gray).
  • Hovering over each month highlights it with a blue-colored circle.
  • User can select a range between any month, in any order.
  • The first click highlights the start of the range, the second click draws the range, with a milder blue color highlight in between selected months.

At a high level, there seem to be a few components here:

  • Outer card with a shadow.
  • Top panel with two buttons to switch between the years.
  • Content panel with 24 (6+12+6) months inside the view.
  • Each individual month has a round highlight and a dimmed highlight.
Step 2. Implement All Components

Implement all components mentioned above with the first iteration to roughly position everything.

<div class="outerCard">
  <div class="topPanel">
    <button class="prevYearButton">
      <i class="arrow left"></i>
    </button>
    <span class="yearLabel">CURRENT YEAR</span>
    <button class="nextYearButton">
      <i class="arrow right"></i>
    </button>
  </div>
  <div class="contentPanel">
    <div class="monthItem">
      <div class="monthItemHighlight">
        MON
      </div>
    </div>
  </div>
</div>

As seen above, we created basic elements and added classes according to the components we mentioned. Now, let's add some CSS to make it all look close to what we need:

.outerCard {
  touch-action: none;
  overflow: hidden;
  width: 400px;
  height: 400px;
  box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
}
.topPanel {
  width: 400px;
  height: 50px;
  text-align: center;
  line-height: 50px;
}
.prevYearButton {
  float: left;
}
.nextYearButton {
  float: right;
}
button {
  width: 50px;
  height: 50px;
  background:none;
  border:none;
  margin:0;
  padding:0;
  cursor: pointer;
}
button:focus {outline:0;}
i {
  border: solid black;
  border-width: 0 3px 3px 0;
  display: inline-block;
  padding: 6px;
}
.right {
  transform: rotate(-45deg);
  -webkit-transform: rotate(-45deg);
}
.left {
  transform: rotate(135deg);
  -webkit-transform: rotate(135deg);
}
.topPanel.yearLabel {
  display: inline-block;
  margin: 0 auto;
}
.contentPanel {
  padding: 24px 8px;
}
.monthItem {
  display: inline-block;
  height: 64px;
  width: 64px;
  cursor: pointer;
  text-align: center;
  line-height: 64px;
  margin-top: 1px;
  margin-bottom: 1px;
}

Some highlights of the above:

  • We use touch-action: none to prevent default actions such as text select. Since we will add listeners ourselves, this makes interaction with the component cleaner.
  • We use text-align, line-height, and margin: 0 auto magic to position text elements horizontally and vertically centered.
  • We are creating a simple list here using inline-block — this helps to render all 24 months line-by-line, forming a table-like view (without actually creating a table), this way our months are just an ordered list and we do not have to worry about actual rows and columns.
  • We left top and bottom margins at 1px since there should be some gap between month rows.
  • Finally, for the left and right arrow, we are using a simple 45-degree transform rotation trick.

Let’s add some TypeScript and let’s also use *ngFor in our template to replicate all 24 months and see what things look like:

.import { Component } from '@angular/core';
@Component({
  selector: 'month-picker',
  templateUrl: 'month-picker.component.html',
  styleUrls: ['month-picker.component.scss']
})
export class MonthPickerComponent  {
  years: Array<number>;
  months: Array<string>;
ngOnInit() {
    this.years = [ 2018, 2019, 2020, 2021, 2022, 2023, 2024 ];
    this.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
  }
  
}

We declare properties with their type and we initialize the values inside the ngOnInit Hook. Let’s not worry about these being “hardcoded” for now. It is indeed a tech debt and we will deal with it later in the article.

<div class="outerCard">
  <div class="topPanel">
    <button class="prevYearButton">
      <i class="arrow left"></i>
    </button>
    <span class="yearLabel">{{ years[0] }}</span>
    <button class="nextYearButton">
      <i class="arrow right"></i>
    </button>
  </div>
  <div class="contentPanel">
    <div class="monthItem" *ngFor="let month of months">
      <div class="monthItemHighlight">
        {{ month }}
      </div>
    </div>
  </div>
</div>

Our template is now a thing, but we need to start working on the next set of challenges here:

  • Create a data model that can help us track each month’s state. (Is it in range? Is it at the start of the range? Is it at the range’s end? Which year does this month belong to? What is its label?)
  • Implement the state of our range. (Is the first edge selected? Is the second edge selected and do we have a range? Has it reset again?)
  • Figure out how we want to show only a part of the entire list of all the months for all the years. (Since, remember, I wanted to implement the month’s data layer as a flat array.)
Step 3. Implement Required Data Structures

First, let’s create monthsData property that will store the list of all the months with their current state:

monthsData: Array<{
    monthName: string,
    monthYear: number,
    isInRange: boolean,
    isLowerEdge: boolean,
    isUpperEdge: boolean
}>

It is an array of objects (Month) that can help us track important states. Next, we will create the list of all the months for all the years we have so far (2018–2024):

initMonthsData() {
    this.monthsData = new Array();
    this.years.forEach( year => {
      this.months.forEach( month => {
        this.monthsData.push({
          monthName: month,
          monthYear: year,
          isInRange: false,
          isLowerEdge: false,
          isUpperEdge: false
        })
      })
    })
  }
ngOnInit() {
    this.years = [ 2018, 2019, 2020, 2021, 2022, 2023, 2024 ];
    this.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
    this.initMonthsData();
}

In the snippet above, we are iterating over our initial months and years properties to create our monthsData array in its initial state. Since we might need to use such a data “reset” in our component, we wrapped this operation inside the initMonthsData method.

Next, we can update our view (HTML) to read from this entire (huge) list:

<div class="contentPanel">
    <div class="monthItem" *ngFor="let month of monthsData">
      <div class="monthItemHighlight">
        {{ month.monthName }}
      </div>
    </div>
</div>

OK, good stuff. Next, we need a simple way to track the state of our range, for this I chose (you will see later on why) to use a simple array with two values representing the indexes of a chosen “range start” month and “range end” month:

rangeIndexes: Array<number>;
initRangeIndexes() {
    this.rangeIndexes = [ null, null ];
};

The null value is intentional and will help us track the range’s state. As with our monthsData — we are adding this method into our ngOnInit Hook.

Step 4. Let’s Make It All Interactive

Alright, now we need to add a method that we will call each time a user clicks on a month:

onClick(indexClicked) {
    if (this.rangeIndexes[0] === null) {
      this.rangeIndexes[0] = indexClicked;
    } else
    if (this.rangeIndexes[1] === null) {
      this.rangeIndexes[1] = indexClicked;
      this.rangeIndexes.sort((a,b) => a-b);
      this.monthsData.forEach((month, index) => {
        if ((this.rangeIndexes[0] <= index) && (index <= this.rangeIndexes[1])) {
          month.isInRange = true;
        };
        if (this.rangeIndexes[0] === index) {
          month.isLowerEdge = true;
        };
        if (this.rangeIndexes[1] === index) {
          month.isUpperEdge = true;
        };
      })
    } else {
      this.initRangeIndexes();
      this.initMonthsData();
      this.onClick(indexClicked);
    };
  }

The logic here should be straightforward:

  • We check if the first index of our range is null, this means our months are in their initial state and we then add the selected month index to the rangeIndexes.
  • If the first index exists (not a null) now, we have reason to believe there is already a month selected and we can now: a) capture the second selected month’s index, b) sort the array (since the user could have gone back to a month in the past, this is why array is useful here), or c) knowing the range indexes, we can now browse through the entire list and update months accordingly (in range, is lower edge, is upper edge).
  • Lastly, if there was a range already -> we reset and start a new one.

Alright, the above gives us data model changes but our widget does not yet handle any changes based on model changes. We will leverage ngClass to bind data states to the CSS classes that will help alter the view:

<div class="outerCard">
  <div class="topPanel">
    <button class="prevYearButton">
      <i class="arrow left"></i>
    </button>
    <span class="yearLabel">{{ years[0] }}</span>
    <button class="nextYearButton">
      <i class="arrow right"></i>
    </button>
  </div>
  <div class="contentPanel">
    <div (click)="onClick(i)" class="monthItem" *ngFor="let month of monthsData; let i = index" [ngClass]="{ isEdge: rangeIndexes[0]===i || rangeIndexes[1]===i }">
      <div class="monthItemHighlight" [ngClass]="{ inRange: month.isInRange, isLowerEdge: month.isLowerEdge, isUpperEdge: month.isUpperEdge }">
        {{ month.monthName }}
      </div>
    </div>
  </div>
</div>

The isEdge class will now be auto-added to our month at .monthItem level if it equals the index of our range edges.

Month highlight is a bit trickier: here we need to know which month represents the lower edge vs. the upper edge as the class we are adding is specific — we are using the “gradient” CSS trick to only color one half of the highlight div.

See the full CSS classes here:

.monthItem:hover {
  border-radius: 100%;
  background-color: #1474a4;
  color: white;
}
.isEdge {
  border-radius: 100%;
  background-color: #1474a4;
  color: white;
}
.inRange {
  background-color: #1474a4;
  opacity: 0.5;
  color: white;
}
.isLowerEdge {
  background-color: none;
  background: linear-gradient(to right, transparent 50%, #1474a4 50%);
}
.isUpperEdge {
  background-color: none;
  background: linear-gradient(to right,  #1474a4 50%, transparent 50%);
}

Cool, now our range is sort of operational, we can actually select a range of months. Still, three problems remain for us to solve:

  1. We need to somehow restrict rendering of the list to 24 months max, with 12 months of the current year to be colored black and the adjacent six months (previous and next year) to be colored gray.
  2. We need to implement the logic for switching between the years.
  3. And we need some basic logic to emit selections to other components.

Let’s push for the last few steps, we are almost there!

Step 5. Restricting the View to a ‘Slice’ of the Total List

Since we need to display 6+12+6 = 24 months for each year, I decided to leverage the Array.slice method and periodically slice our source of truth (monthsData) and display it to our user, which will require new functionality and some refactoring for what we already created:

  • It’s time to get rid of the hardcoded value and refactor the way we obtain months and years labels.
  • We also need a programmatic way to obtain the current year.
  • Then, we need a method to initialize/configure those view slices (initViewSlices).
  • And, really important, a method of actually slicing our monthsData array as well as new methods for our arrow buttons to increment/decrement the current year in the view.
  • Finally, we need to add a new CSS class to support “not in current year” months to be colored in gray and add [ngClass] changes to our template.

It seems like a lot. Let’s start:

  1. Getting rid of hardcoded arrays and allowing them to be generated off the actual current date of our user:
initYearLabels() {
    const currentYear = (new Date()).getFullYear();
    const range = (start, stop, step) => Array.from({ length: (stop - start) / step + 1}, (_, i) => start + (i * step));
    this.years = range(currentYear-1, currentYear + 5, 1)
  };
initMonthLabels() {
    this.months = new Array(12).fill(0).map((_, i) => {
      return new Date(`${i + 1}/1`).toLocaleDateString(undefined, {month: 'short'})
    });
  };

2. Obtaining the current year’s index:

this.currentYearIndex = this.years.findIndex(year => year === (new Date()).getFullYear());

3. The InitViewSlices method will create a simple array that will contain offset for each year (0, 6, 18, 30, 42, 54, 66). The offset basically tells us where to start slicing our global data model (monthsData) and we know where to finish it already (it is always going to be == 24, which is the number of month delegates in our view):

initViewSlices() {
    this.monthViewSlicesIndexes = [];
    this.years.forEach((year,index) => {
      if (index===0) { this.monthViewSlicesIndexes.push(0) } else
      if (index===1) { this.monthViewSlicesIndexes.push(6) } else
     this.monthViewSlicesIndexes.push(this.monthViewSlicesIndexes[index-1]+12);
    })
  };

4. Slicing data into the view and implementing increment/decrement per year:

sliceDataIntoView() {
    this.globalIndexOffset = this.monthViewSlicesIndexes[this.currentYearIndex];
    this.monthDataSlice = this.monthsData.slice(this.globalIndexOffset,this.globalIndexOffset+24);
  };
incrementYear() {
    if (this.currentYearIndex !== this.years.length-1) {
      this.currentYearIndex++
      this.sliceDataIntoView()
    };
  };
decrementYear() {
    if (this.currentYearIndex !==0) {
      this.currentYearIndex--;
      this.sliceDataIntoView()
    };
  };

5. Added the missing notCurrentYear class (.notCurrentYear { color: #c4cbd6;}) and added all the changes to our template which is now final:

<div class="outerCard">
  <div class="topPanel">
    <button class="prevYearButton" (click)="decrementYear()">
      <i class="arrow left"></i>
    </button>
    <span class="yearLabel">{{ years[currentYearIndex] }}</span>
    <button class="nextYearButton" (click)="incrementYear()">
      <i class="arrow right"></i>
    </button>
  </div>
  <div class="contentPanel">
    <div (click)="onClick(i)" class="monthItem" *ngFor="let month of monthDataSlice; let i = index" [ngClass]="{ isEdge: rangeIndexes[0]===globalIndexOffset+i || rangeIndexes[1]===globalIndexOffset+i, notCurrentYear: currentYearIndex===0? i > 11:(i < 6 || i > 17)}">
      <div class="monthItemHighlight" [ngClass]="{ inRange: month.isInRange, isLowerEdge: month.isLowerEdge, isUpperEdge: month.isUpperEdge }">
        {{ month.monthName }}
      </div>
    </div>
  </div>
</div>
Step 6. Last Step

The last step is actually refactoring everything (just a bit) to support the logic of sliced views. Specifically, we needed changes with the onClick method, which now looks like this:

onClick(indexClicked) {
    if (this.rangeIndexes[0] === null) {
      this.rangeIndexes[0] = this.globalIndexOffset+indexClicked;
    } else
    if (this.rangeIndexes[1] === null) {
      this.rangeIndexes[1] = this.globalIndexOffset+indexClicked;
      this.rangeIndexes.sort((a,b) => a-b);
      this.monthsData.forEach((month, index) => {
        if ((this.rangeIndexes[0] <= index) && (index <= this.rangeIndexes[1])) {
          month.isInRange = true;
        };
        if (this.rangeIndexes[0] === index) {
          month.isLowerEdge = true;
        };
        if (this.rangeIndexes[1] === index) {
          month.isUpperEdge = true;
        };
      })
      let fromMonthYear = this.monthsData[this.rangeIndexes[0]];
      let toMonthYear = this.monthsData[this.rangeIndexes[1]];
      this.emitData(`Range is: ${fromMonthYear.monthName} ${fromMonthYear.monthYear} to ${toMonthYear.monthName} ${toMonthYear.monthYear}`)
    } else {
      this.initRangeIndexes();
      this.initMonthsData();
      this.onClick(indexClicked);
      this.sliceDataIntoView();
    };
  };

As seen above, now we are supporting a global index offset and we reset the view before each new range.

For convenience, I added a simple event emitter as well…

Thakn you for reading !

Top 19 Front-End Web Development Tools to Consider in 2020

Top 19 Front-End Web Development Tools to Consider in 2020

In this post, we are putting curated list of top tools with key features and download links "Top 19 Front End Web Development Tools to Consider in 2020"

Front-End development is one of the critical skill for web developers as there is a lot of demand for programmers with excellent front-end development skills.

If you've never experienced client-side web development, learning the plethora of front-end technologies can be difficult, but you can achieve your target.

The one thing which I want to tell you that a good knowledge of HTML, CSS, and JavaScript is a must for any front-end developer. Even though we are living in the era of frameworks and libraries, but knowledge of these fundamental technologies cannot be undermined.

In this post, we are putting curated list of top tools with key features and download links "Top 19 Front End Web Development Tools to Consider in 2020"

1. TypeScript:

TypeScript is an open-source front end scripting language. It is a strict syntactical superset of JavaScript which adds optional static typing. It is specially designed for development of large applications and compiles to JavaScript.

Features:

  • TypeScript supports other JS libraries
  • It is possible to use this Typescript on any environment that JavaScript runs on
  • It supports definition files that can contain type information of existing JavaScript libraries, such as C/C++ header files
  • It is portable across browsers, devices, and operating systems
  • It can run on any environment that JavaScript runs on

Download link: https://www.typescriptlang.org/index.html#download-links

2. Backbone:

Backbone.js gives structure to web applications by offering models with key-value binding and custom events.

Features:

  • Backbone.js allows developers to develop one-page applications
  • Backbone.js has a simple library used to separate business and user interface logic
  • This tool makes code simple, systematic and organized. It acts as a backbone for any project
  • It manages the data model which also includes the user data and display that data on the server side
  • It allows developers to create client side web applications or mobile applications

Download link: http://backbonejs.org/

3. jQuery:

jQuery is a widely used JavaScript library. It empowers front-end developers to concentrate on the functionality of different aspects. It makes the things easy like HTML document traversal, manipulation, and Ajax.

Features:

  • QueryUI facilitates to make highly interactive web applications
  • It is open source and free to use
  • It provides a powerful theme mechanism
  • It is very stable and maintenance friendly
  • It offers an extensive browser support
  • Helps to create great documentation

Download link: http://jquery.com/download/

4. AngularJS:

AngularJS is another must-have tool for front-end developers. It is an open-source web application framework. It helps to extend the HTML syntax for web applications. It simplifies front-end development process by developing accessible, readable and expressive environment.

Features:

  • It is an is open source, completely free, and used by thousands of developers around the world
  • It offers to create RICH Internet Application
  • It provides option to write client side application using JavaScript using MVC
  • It automatically handles JavaScript code suitable for each browser

Download link: https://angularjs.org/

5. HTML5 Boilerplate:

HTML5 Boilerplate help in building fast, robust, and adaptable web apps or sites. It is a set of files that developers can download, which provide a foundation for any website.

Features:

  • It allows developers to use HTML5 elements
  • It is designed by keeping progressive enhancement in mind
  • Normalize.css for CSS normalizations and common bug fixes
  • Apache Server Configs to improve performance and security
  • It offers optimized version of the Google Universal Analytics snippet
  • Protection against console statements causing JavaScript errors in older browsers
  • Extensive inline and accompanying documentation

Download link: https://html5boilerplate.com/

6. ONE Subscription

ONE Subscription is an effective web-development kit that allows getting access to a great number of top-quality digital products. It boasts tons of high-quality items that make it possible to launch fully-fledged blogs, online-stores, landing pages, and other websites. In general, you will be provided with thousands of themes and templates, different plugins and graphic elements, additional services, and other advantages.

Features:

  • professional support for all items;
  • regular updates;
  • security (you can easily cancel your subscription within 14 days after its starts if you have not downloaded anything from the database);
  • unlimited yearly license;
  • useful services (as an example, template customization or installation).

Download link: https://one.templatemonster.com/

7. Npm:

Npm is the Node package manager for JavaScript. It helps to discover packages of reusable code and assemble them in powerful new ways. This web development tool is a command-line utility for interacting with a said repository that aids in the package.

Features:

  • Discover and reuse over 470,000 free code packages in the Registry
  • Encourage code discovery and reuse within teams
  • Publish and control access to namespace
  • Manage public and private code using the same workflow

Download link: https://www.npmjs.com/

8. CodeKit:

Codekit is a front-end web development tool. This tool provides support to build websites faster. It combines, minifies and syntax-checks JavaScript. It also optimizes images.

Features:

  • CSS changes are injected without need of reloading the entire page
  • Combine scripts to reduce HTTP requests.
  • Minify code to reduce file sizes
  • Works automatically with most languages without trouble

Download link: https://codekitapp.com/

9. Sass:

Sass is the most reliable, mature, and robust CSS extension language. This tool helps to extend the functionality of an existing CSS of a site like variables, inheritance, and nesting with ease.

Features:

  • It is straightforward and easy to use front end tool to write any code
  • Supports language extensions such as variables, nesting, and mixins
  • Many useful functions for manipulating colors and other values
  • Advanced features like control directives for libraries
  • It offers well-formatted, customizable output

Download link: http://sass-lang.com/

10. WebStorm:

WebStorm brings smart coding assistance for JavaScript. It provides advanced coding assistance for Angular, React.js, Vue.js and Meteo. It also helps developers to code more efficiently when working with large projects

Features:

  • WebStorm helps developers to code more efficiently when working with large projects
  • It provides built-in tools for debugging, testing and tracing client-side and Node.js applications
  • It integrates with popular command line tools for web development
  • Spy-js built-in tool allows tracing JavaScript code
  • It provides a unified UI for working with many popular Version Control System
  • It is extremely customizable to perfectly suite various coding style
  • It offers built-in debugger for client-side code and Node.js apps

Download link: https://www.jetbrains.com/webstorm/download/#section=windows

11. Chrome Developer Tools:

The Chrome Developer Tools are a set of debugging tools built into Chrome. These tools allow developers to do wide varieties of testing which easily saved lots of time.

Features:

  • It allows adding custom CSS rules
  • Users can view Margin, Border, and Padding
  • It helps to Emulate Mobile Devices
  • Possible to use dev tools as editor
  • User can easily disable browser's caching when dev tool is open

Download link: https://developer.chrome.com/devtools

12. Grunt:

Grunt is a popular task runner on NodeJS. It is flexible and widely adopted. It is preferred tool when it comes to task automation. It offers lots of bundled plugins for common tasks.

Features:

  • It makes the workflow as easy as writing a setup file
  • It allows automating repetitive tasks with minimum effort
  • It has a straightforward approach. It includes tasks in JS and config in JSON
  • Grunt includes built-in tasks for extending the functionality of plugins and scripts
  • It speeds up the development process and increase the performance of projects
  • The ecosystem of Grunt is huge; so it is possible to automate anything with very less effort
  • This web development tool reduces the chance of getting errors while performing repetitive tasks

Download link: https://gruntjs.com/

13. CodePen:

CodePen is a web development environment for front-end designers and developers. It is all about faster and smoother development. It allows to build, deploy website and build test cases.

Features:

  • It offers to build components to use elsewhere later
  • It includes some awesome features to write CSS faster.
  • Allows live view and live sync
  • Prefill API feature allows adding links and demo pages without need to code anything

Download link: https://codepen.io/

14. Jasmine:

Jasmine is a behavior-driven js for testing JavaScript code. It does not depend on any other JavaScript frameworks. This open source tool does not require a DOM.

Features:

  • Low overhead, no external dependencies
  • Comes out of the box with everything need to test code
  • Run browser tests and Node.js tests using the same framework

Download link: https://jasmine.github.io/index.html

15. Foundation:

Foundation is front-end framework for any device, medium, and accessibility. This responsive front-end framework makes it easy to design responsive websites, apps, and emails.

Features:

  • It offers the cleanest markup without sacrificing the utility and speed of Foundation
  • Possible to customize the build to include or remove certain elements. As it defines the size of columns, colors, font size.
  • Faster development and page load speed
  • Foundation is optimized truly for mobile devices
  • Customizability for developers of all levels
  • It takes responsive design to the next level, with the much-needed medium grid accommodating for tablets

Download link: http://foundation.zurb.com/sites/download.html/

16. Sublime Text:

Sublime Text is a proprietary cross-platform source code editor. This app development tool natively supports many programming languages and markup languages.

Features:

  • Command palette feature allows matching keyboard invocation of arbitrary commands
  • Simultaneous editing allows making the same interactive changes to multiple areas
  • Offers Python-based plugin API
  • Allows developers to give project specific preferences
  • Compatible with many language grammars from TextMate

Download link: https://www.sublimetext.com/

17. Less

Less is a pre-processor that extends the support for CSS language. It allows developers to use techniques to make CSS more maintainable and extendable.

Feature:

  • It can freely download and use
  • It offers higher-level style syntax, which allows web designers/developers to create advanced CSS
  • It easily compiles into standard CSS, before the web browser begins rendering a web page
  • Compiled CSS files can be uploaded to the production web server

Download link: http://lesscss.org/

18. Modaal:

Modal is front end development plugin which gives quality, flexibile, and accessibile modals.

Features:

  • Optimized for assistive technologies and screen readers
  • Fully responsive, scaling with browser width
  • Customizable CSS with SASS options
  • It offers full-screen and viewport mode
  • Keyboard control for gallery open and closing modal
  • Flexible close options and methods

Download link: https://github.com/humaan/Modaal

19. Github:

GitHub is a web development platform inspired by the way you work. This tool allows developers to review code, manage projects, and build software.

Features:

  • Coordinate easily, stay aligned, and get done with GitHub's project management tools
  • It offers right tools for the job
  • Easy documentation alongside quality coding
  • Allows all code in a single place
  • Developers can host their documentation directly from repositories

Download link: https://github.com/

Thank for reading!

Which is JavaScript Frameworks for Front-End Development in 2020

Which is JavaScript Frameworks for Front-End Development in 2020

React vs Vue vs Angular vs Ember vs Backbone.js: Which is best JavaScript framework For Front-End Development in 2020?

Front-end developers might know this game already: you type “top JavaScript frameworks” into Google and you get so many JavaScript frameworks from which to choose.

There are always more choices for JavaScript frameworks. And it's always tough to choose a JavaScript framework for front-end development.

So, what are front-end developers looking for in their tech stacks? As a full-time developer, I know it comes down to rapid development and easy-to-make UIs.

Rather than try to be decisive, we, 450+ developers at ValueCoders software development company voted and shortlisted a few of the best JavaScript frameworks.

And, Our Vote Goes to React

I was not surprised to see this.Most of our developers voted for React as one of the best JavaScript frameworks. There have been plenty of projects along the way that our front-end developers are handling that highlighted the strengths of the JS framework. React provides a combination of the following:

  • Reusable components
  • Synchronization of state and view
  • Routing and template system

Our developers implement front-end logic by relying heavily on React. At the same time, I was surprised by how simple it was to create applications with React.

Overview of App

The application is simple. It’s a studio management app for music teachers that helps them focus more on their teaching and less on the management of their music studio.

The key challenge was creating one ‘Activity Dashboard’ for teachers where they could manage all their students' activities and track their progress over time. We overcame this challenge by using Redux libraries to build the platform. We built a teacher’s studio from where they could manage their students' progress, showcase new music lessons, chat with them, compare students music playing with live music, and provide them feedback.

So, this is my experience with React JS. But many would argue that Vue is one of the best front-end JavaScript frameworks with many useful tools.

Front-end developers are the ones deciding which JavaScript framework will do the job. In doing so, they face a lot of challenges because they need to decide what they’ve always needed. Often, we have to choose JavaScript frameworks now, not after a week of research. In that case, most developers go with what they know. But maybe the stacks you’re familiar with are no longer cutting it in terms of performance.

Even just choosing among Angular, React, & Vue, it is difficult for new developers. Rather than making it more exhaustive for you, here is the list of top JavaScript frameworks for front-end developers.

The Big 5

The five JavaScript frameworks that currently dominate the market in terms of popularity and usage are:

  • React
  • Vue
  • Angular
  • Ember
  • Backbone.js.

They each have large communities. If you are a front-end developer or are going to start your new project on front-end technologies, these five are your best bets. Here’s a look at the npm trends over the last six months.

1. React

React is a definite leader in the JS world. This JavaScript framework uses a reactive approach and also introduces many of its own concepts for frontend web development.

To use React , you’ll have to learn to use a plethora of additional tools to reach high flexibility in front-end development. For example, here's a less exhaustive list of libraries you can use with React: Redux, MobX, Fluxy, Fluxible, or RefluxJS. React can also be used with jQuery AJAX, fetch API, Superagent, and Axios.

Concurrent Mode

React is constantly working towards improving concurrent mode. To take this forward, React Conf 2019 wrapped up last month where the React team talked about improving Concurrent Mode and the Suspense model. Both the features make React apps more responsive by rendering trees without blocking threads. This allows React to focus on high priority tasks like responding to user input.

Suspense

React also introduced Suspense to improve the developer’s experience when handling asynchronous data fetching on React apps. In short, the new update to Suspense lets the component wait until the condition is met.

The React team is also working on Hooks which was one of the most awaited features of React. As per the latest updates, React hooks will be designed in a way that it supports all the important features: server-side rendering, accessibility, concurrent mode, and suspense.

React applications are divided into multiple components that contain both business logic and HTML markup functions. To improve the communication between components, developers can use either Flux or a similar JavaScript library.

React also introduced objects, like state and props. With the state and props objects, you can simply pass data from a component to the layout or from a parent component to a child component.

Introduction to the React ecosystem:

  • The React library plus React router for implementing routes.
  • React-DOM for DOM manipulation.
  • React developer tools for Firefox and Chrome browsers.
  • React JSX, a markup language that mixes HTML into JavaScript.
  • React Create App command line interface to set up a React project.
  • Redux and Axios libraries to organize communication with the backend team.

No doubt, React is one of the most popular JavaScript frameworks. And, I think that React can be your first choice for creating advanced-grade apps.

2. Angular 2 to Angular 9

Angular 9 will mark a turning point revealed by the Angular team at the recent AngularConnect 2019. According to the update, the team is planning to make the Angular Ivy compiler available for all apps. The main benefit of Angular Ivy is that it is able to reduce the size of applications.

Angular today has become very advanced and modular to use for front-end development. Previously you could insert a link to the AngularJS library in the main HTML file, but now you can do the same by installing separate modules.

Angular's flexibility is commendable. That’s why Angular's 1.x versions are still in demand. However, many current developers rely on Angular 2+ because of its MVC architecture that has substantially changed to a component based architecture.

Angular has a couple of additional challenges. You're almost obliged to use TypeScript to ensure type safety in Angular apps. TypeScript makes the Angular 2+ framework not so pleasant to work with.

Angular’s ecosystem is comprised of:

  • For quick project setup, Angular's command line interface is helpful.
  • Developers will get a set of modules for Angular projects: @angular/common, @angular/compiler, @angular/core, @angular/forms, @angular/http, @angular/platform-browser, @angular/platform-browser-dynamic, @angular/router, and @angular/upgrade.
  • Angular uses Zone.js a JavaScript library to implement zones in Angular apps.
  • TypeScript and CoffeeScript both can be used with Angular.
  • For communication with server-side apps, Angular uses RxJS and the Observable pattern.
  • Angular Augury for debugging Angular apps.
  • Angular Universal for creating server-side apps with Angular.

Angular2 is a complete JavaScript framework with all the tools a modern front-end developer needs. You can choose Angular if you don’t like to work with additional libraries as with React.

3. Vue

The Snyk JavaScript framework report for 2019 is out. The report mainly focused on security risks in both React and Angular.

The concept of Vue has been taken from Angular and React, but Vue is better in many ways. I’ll talk about its features, but first check out what the Synk report says about Vue's front-end security. Vue has been downloaded 40 million times this year and records only four direct vulnerabilities. All of them have been fixed.

For any front-end developer unfamiliar with Vue, let’s clarify several points.

With Vue you store component logic and layouts along with stylesheets in one file. This the same way React works, without stylesheets. To let components talk to each other, Vue uses the props and state objects. This approach also existed in React before Vue adopted it.

Similar to Angular, Vue wants you to mix HTML layouts with JavaScript. You have to use Vue directives such as v-bind or v-if to interpolate values from the component logic to templates.

One of the reasons why Vue is worth considering instead of React is because of the Redux library that’s often used in large-scale React applications. As explained in the React section, when a React+Redux app grows bigger, you’ll spend a lot of time applying small changes to multiple files instead of actually working on features. The Vuex library – a Flux-like state management tool designed for Vue – seems less unwieldy than Redux.

If you're choosing between Vue and Angular, the reasons to opt for Vue over Angular can be reduced to the following: Angular is an over-complicated, full-fledged framework with a restrictive nature; Vue is much simpler and less restrictive than Angular.

Another advantage of Vue over Angular and React is that you don’t have to learn JavaScript once more.

An introduction to the VueJS ecosystem:

  • Vuex comes with a dedicated library for application management.
  • Vuex is similar to the concept of Flux.
  • You will get Vue-loader for components and vue.js devtools for Chrome and Firefox browsers.
  • Vue-resource and Axios tools for communication between Vue and the backend source.
  • Vue.js support Nuxt.js for creating server-side applications with Vue; Nuxt.js is basically a competitor to Angular Universal.
  • You will get a Weex JavaScript library with Vue syntax that is used for mobile app development.

Vue is excellent in terms of its workflow to other frameworks. I might opt for Vue because it’s less complicated than React and Angular JS and a great choice for developing enterprise-level apps.

4. Ember

Ember 3.13 released this year with some new updates and features. Ember is just like Backbone and AngularJS, and is also one of the oldest JavaScript frameworks. But with the new update, Ember 3.13 is compatible with new bug fixes, performance improvements, and deprecation. Tracked property updates have also been introduced that allow simpler ways of tracking state change in the ergonomic system of Ember apps.

Ember has a relatively intricate architecture, which will allow you to quickly build huge client-side applications. It realizes a typical MVC JavaScript framework, and Ember’s architecture comprises the following parts: adapters, components, controllers, helpers, models, routes, services, templates, utils, and addons.

One of Ember’s best features is its command line interface tool. The Ember CLI helps front-end developers be highly productive and lets them complete projects on time. You can not only create new projects with ready setups, but you can also create controllers, components, and project files using automatic generation.

The EmberJS ecosystem is comprised of:

  • Ember CLI tool for quick prototyping and managing dependencies.
  • Ember server built into the framework for the development of apps.
  • You'll get Ember.js library and Ember Data for data management.
  • Handlebars template engine for Ember applications.
  • QUnit testing framework for Ember.
  • Ember Inspector development tool for Chrome and Firefox browsers.
  • Ember Observer for public storage and Ember addons to implement generic functionalities.

Although Ember is underrated, it's perfect for creating complex client-side apps.

5. Backbone.js

Backbone is a JavaScript framework based on the MVC architecture. Backbone’s View part carries out the responsibilities of the Controller. The View helps implement component logic similarly to a Controller in MVC. Backbone view can use engines like Mustache and Underscore.js.

Backbone is an easy to use JavaScript framework that allows for quick development of single page applications. To use Backbone.js to the fullest extent, you’ll have to choose tools: Chaplin, Marionette, Thorax, Handlebars or Mustache, and so on.

If you need to design an app that has different type of users, Backbone collections (arrays) can be used here to separate the models. Backbone.Events, can be used with Backbone models, collections, routes, and views.

Introducing the BackboneJS ecosystem:

  • The Backbone library consists of events, models, collections, views, and router.
  • Underscore.js, a JavaScript library with helper functions that you can use to write cross-browser JavaScript.
  • You can use template engines such as Mustache and jQuery-tmpl.
  • BackPlug online repository with a lot of ready solutions for Backbone-based apps.
  • Backbone generator CLI for building Backbone apps.
  • Marionette, Thorax, and Chaplin JavaScript libraries to develop an advanced architecture for Backbone apps.

Backbone.js is a perfect choice for frontend and backend development as it supports REST APIs that are used to synchronize the frontend and backend.

Need More Help?

All front-end developers out there, if you need help with JavaScript frameworks, feel free to get in touch. Or, you can also contact us to hire ReactJS developers, Vue developers or Angular developers.

Remember this article gives you a general roadmap on JavaScript frameworks. Tell me if I have missed something, and we can discuss that. I hope it will also help achieve your front-end development goals.