Tuesday, May 3, 2016

Browser Trends May 2016: Firefox Finally Overtakes IE

April brought us a shower of Samsung surprises so can the latest StatCounter browser statistics be similarly exciting?…

Worldwide Desktop & Tablet Browser Statistics, March to April 2016

The following table shows browser usage movements during the past month.

Browser March April change relative
IE (all) 12.54% 12.13% -0.41% -3.30%
IE11 9.40% 9.02% -0.38% -4.00%
IE10 0.80% 0.81% +0.01% +1.30%
IE9 0.87% 0.85% -0.02% -2.30%
IE6/7/8 1.47% 1.45% -0.02% -1.40%
Edge 1.98% 2.10% +0.12% +6.10%
Chrome 56.51% 56.89% +0.38% +0.70%
Firefox 14.29% 14.24% -0.05% -0.30%
Safari 4.17% 4.20% +0.03% +0.70%
iPad Safari 5.25% 5.26% +0.01% +0.20%
Opera 1.87% 1.83% -0.04% -2.10%
Others 3.39% 3.35% -0.04% -1.20%

Continue reading %Browser Trends May 2016: Firefox Finally Overtakes IE%


by Craig Buckler via SitePoint

Exploring Mailgun: The Email Engine for Developers

Quick Tip: Use Background White Noise for Greater Productivity

Vinyl player

In this age of endless information and clutter, productivity Nirvana has been searched for by so many, yet achieved by so few. While there is no ultimate solution that fits everybody, there are various processes and tools which have differing levels of impact for different people.

Noisli is one of these tools. It’s basically a background noise generator that helps you drown out annoying noises and that lets you create your perfect environment for working and relaxing. Noisli allows you to mix different sounds to create your very own sound environment tailored to your personal needs and taste. If you are one of those people who try out some new music playlist or radio station every week, Noisli might cater to your needs. In fact, I wrote this very article while Noisli was playing in the background.

Let’s have a look at its features.

Sounds

Noisli Sounds

Noisli features 13 environment looped sounds and three additional noises (White Noise, Brown Noise, Pink Noise). The fun thing is that you can activate one or more sounds and change the relative volume to create an always different, pleasing sound environment.

Timer

Noisli also offers a Timer function, which you can use to implement time management methods such as the Pomodoro Technique. It’s said to be a more efficient time management approach that cuts down on distraction and prevents burnout.

You can use the Timer to break down work into different sessions, traditionally 25 minutes in length separated by short breaks of five minutes. After four sessions you should take a longer break of 20 to 30 minutes.

Bonus: If you activate the “Fade out” function, the sound will gently stop and fade out at the end of the timer.

Continue reading %Quick Tip: Use Background White Noise for Greater Productivity%


by Elio Qoshi via SitePoint

The Divi Builder Plugin for Any WordPress Theme

As a WordPress user and developer, I can definitely say that I am into frameworks. I like trying out different frameworks and plugins, because it fascinates me as to what I can pull off with WordPress. When you dive deep into it, you can pull off some pretty amazing stuff.

One aspect of WordPress that I’ve felt has always been a little weak is their selection of page builders. WordPress drag and drop page builders range in quality, but most of the time they cause trouble. You try to integrate them, and they either break the theme, or their styles are overridden by the theme itself. There have always seemed to be limitations to WordPress theme page builders.

A theme I have always liked is Divi (I've covered Divi previously on SitePoint), which has its own page builder. I always thought Elegant Themes should create a separate plugin from their page builder. Apparently, they must have read my mind, because they just released their page builder as a plugin.

Advantages

I have a library of specific themes I go to when I need to turn around a project quickly. The problem is that preset themes don’t offer that much flexibility. I can go in and customize a WordPress theme all day long. Just because I can do something doesn’t mean I want to. It can be more cost effective, especially for lower budget or more time sensitive projects, to implement a customizable system for your project.

It Works with Any Theme

You can drop the new page builder plugin into any theme. This means that if you find just the right theme, you can easily customize it. This is especially great for specialty themes that do something specific. You won’t fall victim to trying to hack a theme to make it look how you want it to.

Continue reading %The Divi Builder Plugin for Any WordPress Theme%


by James George via SitePoint

How to Build a Todo App Using React, Redux, and Immutable.js

This article was rewritten on 3rd May, 2016. Comments relating to mistakes in the original article have been removed.

The way React uses components and a one-way data flow makes it ideal for describing the structure of user interfaces, however its tools for working with state are kept deliberately simple; to help remind us that React is just the View in the traditional Model-View-Controller architecture.

There's nothing to stop us from building large applications with just React, but we would quickly discover that to keep our code simple, we'd need to manage our state elsewhere.

Whilst there's no official solution for dealing with application state, there are some libraries that align particularly well with React's paradigm. Today we'll pair React with two such libraries and use them to build a simple application.

Redux

Redux is a tiny library that acts as a container for our application state, by combining ideas from Flux and Elm. We can use Redux to manage any kind of application state, providing we stick to the following guidelines:

  1. Our state is kept in a single store
  2. Changes come from actions not mutations

At the core of a Redux store is a function that takes the current application state and an action and combines them to create a new application state. We call this function a reducer.

Our React components will be responsible for sending actions to our store and in turn our store will tell the components when they need to re-render.

ImmutableJS

Because Redux doesn't allow us to mutate the application state, it can be helpful to enforce this by modeling application state with immutable data structures.

ImmutableJS offers us a number of immutable data structures with mutative interfaces and they're implemented in an efficient way, inspired by the implementations in Clojure and Scala.

Demo

We're going to use React with Redux and ImmutableJS to build a simple todo list that allows us to add todos and toggle them between complete and incomplete.

See the Pen React, Redux & Immutable Todo by SitePoint (@SitePoint) on CodePen.

The code is also available on GitHub.

Setup

We'll get started by creating a project folder and initializing a package.json file with npm init. Then we'll install that dependencies that we're going to need.

npm install --save react react-dom redux react-redux immutable
npm install --save-dev webpack babel-loader babel-preset-es2015 babel-preset-react

We'll be using JSX and ES2015, so we'll compile our code with Babel and we're going to do this as part of the module bundling process with Webpack.

First we'll create our Webpack configuration in webpack.config.js.

module.exports = {
  entry: './src/app.js',
  output: {
    path: __dirname,
    filename: 'bundle.js'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: { presets: [ 'es2015', 'react' ] }
      }
    ]
  }
};

And finally we'll extend our package.json by adding an npm script to compile our code with source maps.

"script": {
  "build": "webpack --debug"
}

We'll need to run npm run build each time we want to compile our code.

React & Components

Before we implement any components, it can be helpful to create some dummy data. This helps us get a feel for what we're going to our components to render.

const dummyTodos = [
  { id: 0, isDone: true,  text: 'make components' },
  { id: 1, isDone: false, text: 'design actions' },
  { id: 2, isDone: false, text: 'implement reducer' },
  { id: 3, isDone: false, text: 'connect components' }
];

For this application, we're only going to need two React components, <Todo /> and <TodoList />.

// src/components.js

import React from 'react';

export function Todo(props) {
  const { todo } = props;
  if(todo.isDone) {
    return <strike>{todo.text}</strike>;
  } else {
    return <span>{todo.text}</span>;
  }
}

export function TodoList(props) {
  const { todos } = props;
  return (
    <div className='todo'>
      <input type='text' placeholder='Add todo' />
      <ul className='todo__list'>
        {todos.map(t => (
          <li key={t.id} className='todo__item'>
            <Todo todo={t} />
          </li>
        ))}
      </ul>
    </div>
  );
}

At this point, we can test these components by creating an index.html file in the project folder and populating it with the following markup. (You can find a simple stylesheet here on GitHub).

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="style.css">
    <title>Immutable Todo</title>
  </head>
  <body>
    <div id="app"></div>
    <script src="bundle.js"></script>
  </body>
</html>

We'll also need an application entry point at src/app.js.

// src/app.js

import React from 'react';
import { render } from 'react-dom';
import { TodoList } from './components';

const dummyTodos = [
  { id: 0, isDone: true,  text: 'make components' },
  { id: 1, isDone: false, text: 'design actions' },
  { id: 2, isDone: false, text: 'implement reducer' },
  { id: 3, isDone: false, text: 'connect components' }
];

render(
  <TodoList todos={dummyTodos} />,
  document.getElementById('app')
);

Compile the code with npm run build, then navigate your browser to the index.html file and make sure that it's working.

Redux & ImmutableJS

Now that we're happy with the user interface, we can start to think about the state behind it. Our dummy data is a great place to start from and we can easily translate it into ImmutableJS collections.

import { List, Map } from 'immutable';

const dummyTodos = List([
  Map({ id: 0, isDone: true,  text: 'make components' }),
  Map({ id: 1, isDone: false, text: 'design actions' }),
  Map({ id: 2, isDone: false, text: 'implement reducer' }),
  Map({ id: 3, isDone: false, text: 'connect components' })
]);

ImmutableJS maps don't work in the same way as JavaScript's objects, so we'll need to make some slight tweaks to our components. Anywhere there was a property access before (e.g. todo.id) needs to become a method call instead (todo.get('id')).

Continue reading %How to Build a Todo App Using React, Redux, and Immutable.js%


by Dan Prince via SitePoint

grafi.js – JavaScript Image Processing Library

grafi.js is a library intended for learning about how image processing works. Each modules are intentionally kept small and users are encouraged to read the source code to learn about different methods and algorithms.


by via jQuery-Plugins.net RSS Feed

Introducing the CSS Grid Layout

[caption id="attachment_129426" align="aligncenter" width="700"]CSS Grid Layout feature image Artwork by SitePoint/Natalia Balska.[/caption]

Grids are important when creating complex websites. The importance of grids in modern web design is clear from the number of frameworks that implement the grid system to speed up development.

With the introduction of the CSS Grid Layout spec, you will not need to include a separate stylesheet just to use the grid system. Another advantage is that you will not have to rely on properties like inline and float to lay out the elements on a web page. In this tutorial, we will cover the fundamentals of the grid system and create a basic blog layout.

Browser Support

At present, only IE 10+ and Edge support Grid Layout — you cannot use it on a commercial website just yet.

It can be enabled in Chrome through the "Experimental Web Platform features" flag in chrome://flags. You can enable it in Firefox using the layout.css.grid.enabled flag.

Another option is to use a polyfill. A CSS Grid Polyfill does exist! Using the various options above, you can start experimenting and learn as much about the Grid Layout as you can while it is still in its infancy.

Note: Internet Explorer has currently implemented the older version of the spec. Unfortunately, this means that it is not entirely compatible with the latest spec. When going through the examples in this tutorial I suggest you use Chrome or Firefox with appropriate flags enabled.

Grid System Terminology

The CSS grid system is similar to tables when it comes to laying out elements. However, it is much more powerful and flexible. In this section, I will discuss a few terms that you will need to keep in mind when working with grids:

The fr unit: This unit is used to specify a fraction of available space. It is meant to be used with grid-rows and grid-columns. According to the spec —

The distribution of fractional space occurs after all 'length' or content-based row and column sizes have reached their maximum.

Lines: Lines define the boundaries of other elements. They run vertically as well as horizontally. In the figure below, there are four vertical and four horizontal lines.

Tracks: Tracks are the space between parallel lines. In the figure below, there are three vertical and three horizontal tracks.

Cells: Cells are the building block of grids. In the figure below, there are nine cells in total.

Areas: An area is a rectangular shape with an arbitrary number of cells. So, a track is an area and so is a cell.

Cell, track and area in CSS grid layouts

Positioning Elements in a Grid

Let's begin with the basics. In this section, I will teach you how to position elements at a certain location using grids. To use CSS Grid Layout, you need a parent element and one or more child elements. For the sake of demonstration, I will use the following markup for our grid system:

[code language="html"]
<div class="grid-container">
<div class="grid-element item-a">A</div>
<div class="grid-element item-b">B</div>
<div class="grid-element item-c">C</div>
<div class="grid-element item-d">D</div>
<div class="grid-element item-e">E</div>
<div class="grid-element item-f">F</div>
</div>
[/code]

After you are done with the markup you need to apply display:grid or display:inline-grid on the parent element along with other styling like this:

[code language="css"]
.grid-container {
display: grid;
grid-template-columns: 200px 10px 0.3fr 10px 0.7fr;
grid-template-rows: auto 20px auto;
}
[/code]

The grid-template-columns and grid-template-rows properties are used to specify the width of various rows and columns. In the above example, I have defined five columns. The 10px columns act as gutters to provide required spacing between elements. The first column is 200px wide. The third column takes up 0.3 parts of the remaining space. Similarly, fifth column takes up 0.7 parts of the remaining space.

Using auto for the first row in grid-template-rows allows the row to expand as necessary based on the content inside it. The 20px row acts as a gutter.

At this point, the elements are packed closely together as evident from the following demo.

See the Pen CSS Grid Layout Demo 1 by SitePoint (@SitePoint) on CodePen.

Observe that element B is in the second column that we were planning on using as a gutter. If you don't specify the position of child elements inside the grid, the browser puts one element per cell until the first row is completely filled, the rest of the elements then go in the next row. This is the reason that we are left with four spare columns in the second row.

To move elements to a specific cell in the grid you need to specify their position in CSS. Before I explain how to move elements around using grid system, take a look at the following image.

Grid Layout Spacing Example

In this example, we will be using "line-based placements". Line-based placement means that the lines in our grid system will act as guidelines to place and confine elements. Let's take element B as an example. Horizontally, it starts at column line 3 and ends at column line 4. Along the vertical axis, it is located between the line at row 1 and the line at row 2.

We use grid-column-start to specify the starting vertical line for an element. In this case, it would be set to 3. grid-column-end indicates the ending vertical line for an element. This property would be equal to 4 in this case. Corresponding row values will also be set similarly.

With all of the above in mind, to move element B to the second cell you would use the following CSS:

[code language="css"]
.element-b {
grid-column-start: 3;
grid-column-end: 4;
grid-row-start: 1;
grid-row-end: 2;
}
[/code]

Similarly, to move element F to the sixth cell you would use the following CSS:

[code language="css"]
.element-f {
grid-column-start: 5;
grid-column-end: 6;
grid-row-start: 3;
grid-row-end: 4;
}
[/code]

After these changes in CSS, the elements should be spaced properly like they are in this demo:

See the Pen CSS Grid Layout Demo 2 by SitePoint (@SitePoint) on CodePen.

Continue reading %Introducing the CSS Grid Layout%


by Nitish Kumar via SitePoint