Friday, September 22, 2017

11 Lessons from the 100 Best Marketing Blog Designs [infographic]

Digital Marketing is like an open-book test in high school…The answers are all there, you just need to know where to look. Every decision your business faces – choosing between a red or green purchase button or redesigning your website – has been encountered by hundreds of marketers before...

[ This is a content summary only. Visit our website http://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Web Desk via Digital Information World

To Redux or Not: the Art of Structuring State in React Apps

One common trend I find among most Redux developers is a hatred towards setState(). A lot of us (yes, I've fallen into this trap many times before) flinch at the sight of setState() and try to keep all the data in our Redux store. But, as the complexity of your application grows, this poses several challenges.

In this post, I'll walk you through various strategies to model your state, and dive into when each of them can be used.

Getting Started

Redux works with the principle of being the single source of truth for your application state. A new Game of Thrones season is airing now, and I'm sure everyone's excited to know how this is going to unfold. Let's build a fun Game of Thrones fan listing page, to understand these concepts in detail.

Note: I'll be using yarn to run the app. If you don't have yarn set up, replace yarn with npm.

Before we dive in, download the basic skeleton from the repo and run:

yarn install
yarn run start

You should see a basic list page with some of your favorite GoT characters listed.

Note: We'll be using the ducks pattern to write our application. It reduces unnecessary module imports and cuts down on a lot of boilerplate.

Intro to Redux

The scope of this article is to help you structure your Redux apps. It assumes a basic knowledge of the library. I'll give a brief overview of Redux concepts that will help you follow the rest of the article better. If you're familiar with how these works, feel free to skip this section.

All Redux apps make use of four important constructs: actions, reducers, a store, and containers.

Actions

An action is an intent to update the state. It could be triggered by a network call, or a user clicking a button. Actions have two parts:

  1. Action type. A unique identifier representing an action.
  2. Payload. Any metadata that's associated with the action. For instance, if we make a network request to fetch a list of movies, the response from the server is the payload.

For this example, we'll be using a library called redux-actions to create actions.

Reducers

A reducer is a function that listens for an action and returns a new state representation.

Store

An application can be divided into many reducers, representing various parts of the page. A store brings all these together and keeps the app state intact.

Containers

Containers connect your app state and actions with the component, passing them down as props.

To get a deep understanding of how this works, I'd encourage you to first look at the free introduction series by Dan Abramov.

Split App Data and UI State

The list page is nice, but the names don't give any context to people who are new to the GoT universe. Let's extend the component to render the character description as well:

//GoTCharacter.js

export const CharacterRow = ({character}) => (
  <div className="row">
    <div className="name">{character.name}</div>
    <div className="description">{character.description}</div>

  </div>
);

While this solves the problem, our designers feel that the page looks clumsy, and it's a better idea to collapse this information till users want it. There are three different approaches we can take to solve this problem.

The setState approach

The simplest way to achieve this in React is using setState() to store the data within the component itself:

//GoTCharacter.js

export class StatefulCharacterRow extends Component {
  constructor() {
    super();
    this.state = {
      show_description: false
    }
  }

  render() {
    const {character} = this.props;
    return (<div className="row">
      <div className="name">{character.name}</div>
      <a href="#" onClick={() => this.setState({
        show_description: !this.state.show_description})} >
        {this.state.show_description ? 'collapse' : 'expand'}
      </a>
      {this.state.show_description &&
        <div className="description">{character.description}</div>}

    </div>);
  }
};

The Redux approach

Using setState() is fine as long as the state we're dealing with is only local to the component. If, for instance, we want to put in place an "expand all" function, it will be difficult to handle this with just React.

Let's see how we can move this to Redux:

// FlickDuck.js

// …
export const toggleCharacterDescription = createAction(
  FlixActions.TOGGLE_CHARACTER_DESCRIPTION, (character) => ({character})
);

export default (current_state, action) => {
  const state = current_state || default_state;

  switch (action.type) {
    case FlixActions.TOGGLE_CHARACTER_DESCRIPTION:
      return {...state, characters: state.characters.map(char => {
        if (char.id === action.payload.character.id) {
          return {...char,show_description: !char.show_description};
        }

        return char;
      })}
    default:
      return state
  }
}

// GoTCharactersContainer.js

import { connect } from 'react-redux';
import GoTCharacters from './GoTCharacters';
import {toggleCharacterDescription} from './FlickDuck';

const mapStateToProps = (state) => ({
  ...state.flick
});

const mapDispatchToProps = (dispatch) => ({
  toggleCharacterDescription : (data) => dispatch(toggleCharacterDescription(data))
});

export default connect(mapStateToProps, mapDispatchToProps)(GoTCharacters);

// GoTCharacters.js

const GoTCharacters = ({characters,toggleCharacterDescription}) => {
  return (
    <div className="characters-list">
      {characters.map(char => (
        <CharacterRow
          character={char}
          toggleCharacterDescription={toggleCharacterDescription}
          key={char.id}/>
      ))}
    </div>
  );
};

export const CharacterRow = ({character, toggleCharacterDescription}) => (
  <div className="row">
    <div className="name">{character.name}</div>
    <a href="#" onClick={toggleCharacterDescription.bind(null, character)} >
      {character.show_description ? 'collapse' : 'expand'}
    </a>
    {character.show_description &&
      <div className="description">{character.description}</div>}

  </div>
);

We're storing the state of the description field inside the character object. Our state will look like this now:

state = {
  characters: [{
    id: 1,
    name: "Eddard Ned Stark",
    house: "stark",
    description: "Lord of Winterfell - Warden of the North - Hand of the King - Married to Catelyn (Tully) Stark",
    imageSuffix: "eddard-stark",
    wikiSuffix: "Eddard_Stark",
    show_description: true
  },
  {
    id: 2,
    name: "Benjen Stark",
    house: "stark",
    description: "Brother of Eddard Stark - First ranger of the Night's Watch",
    imageSuffix: "benjen-stark",
    wikiSuffix: "Benjen_Stark",
    show_description: false
  }]
}

This is a general pattern a lot of developers follow when they're starting out with Redux. There's nothing wrong with this approach, and it works great for smaller apps.

So far, we've been dealing with the characters from the first chapter of GoT, and the universe is about to get a whole lot bigger. When it does, our app will become slow. Imagine looping through 1000 characters to update one row.

Let's see how to scale this for a larger dataset:

// FlickDuck.js

// …
case FlixActions.TOGGLE_CHARACTER_DESCRIPTION:
  const {character} = action.payload;
  return {
    ...state,
    character_show_description: {
      ...state.character_show_description,
      [character.id]: !state.character_show_description[character.id]
    }
  }
// …

And in GoTCharacters.js:

export const CharacterRow = ({character, character_show_description, toggleCharacterDescription}) => (
  <div className="row">
    <div className="name">{character.name}</div>
    <a href="#" onClick={toggleCharacterDescription.bind(null, character)} >
      {character_show_description[character.id] ? 'collapse' : 'expand'}
    </a>
    {character_show_description[character.id] &&
      <div className="description">{character.description}</div>}
  </div>
);

When the user clicks on the expand link, we update the character_show_description with the current character id. The state looks like this now:

state = {
  characters: [...],
  character_show_description: {
    1: true,
    2: false
  }
}

Now we can update the UI state without looping over all the characters.

Continue reading %To Redux or Not: the Art of Structuring State in React Apps%


by Vasu K via SitePoint

A Violent Act

Engaging and impressive One Pager investigating the famous 2003 student murders in Sydney. The long scrolling site gives the unique perspective of two people with interactive content switchers. The research is thorough and the design is beautiful featuring tons of gritty textures and subtle animations as you scroll. This is the fifth Most Loved award in a row now for SBS. Respect 👏

Full Review | Direct Link


by Rob Hope @robhope via One Page Love

Website Hosting: Everything You Need to Get Started

Whether you’re starting a new project or your existing blog has moved beyond the WordPress.com or Medium world, at some point you’re going to want to dive into the world of hosting. This is a one-stop shop that’ll give you the information you need to get started. Whether you’re deciding whether to take the hosting […]

Continue reading %Website Hosting: Everything You Need to Get Started%


by Adam Roberts via SitePoint

The Ultimate Beginner’s Guide to Setting Up & Running a WordPress Site

So you've decided to run a WordPress site but have no idea where to start? This tutorial is aimed at absolute beginners. Some IT knowledge will help but I presume you want to learn the essentials within a few hours. Let's get started.

Step 1: What Do You Want to Achieve?

A little planning goes a long way. Be honest with yourself: why are you considering WordPress? Do you want to:

  • create a business website?
  • document your life, hobby or interests?
  • start an amazing web design agency?
  • learn to write code?
  • do something else?

WordPress is flexible and runs almost a third of the web — but it's not ideal for every situation. A website or article library is perfect. Creating a social network or online shop is possible but there may be better options. Using WordPress to learn PHP could be a frustrating experience.

Presuming WordPress is appropriate, are you interested in the technicalities or would you simply prefer to write content? If it's the latter, a managed WordPress plan from SiteGround or an account at WordPress.com will get you running without the hassles of installation and server management.

The moral: define the problem before choosing a solution!

Step 2: Plan Your Content

Ideally, you should have all your content written before building a site. It's the best way to plan a structure and will influence your design. No one ever does that, but at least plan a few general concepts so you have somewhere to start.

Step 3: Purchase a Domain Name

A domain name is your primary web address, e.g. www.mysite.com. Keep it short and use keywords appropriate to your content. This can be tougher than it sounds; most good names were registered years ago.

Use a reputable domain registrar. Prices vary across countries and top-level-domain types (.com, .net, .org, .ninja etc), but expect to pay around $25 for a new domain for a couple of years. Buying a decent pre-registered domain from someone else can be considerably more expensive.

Step 4: Purchase a Hosting Plan

Your site needs to be hosted somewhere. Its files must be placed on a device which understands how to deal with web requests: a web server. You could serve everything from your desktop PC but it quickly becomes impractical.

Buy a suitable plan from a respected host such as SiteGround. A WordPress-compatible shared hosting plan costs a few dollars a month and you can upgrade disk space and bandwidth as traffic grows.

You will then need to 'point' your domain at your new web space. This is normally done by logging into your domain registrar's control panel then either:

  1. Setting the host as the DNS nameserver, or
  2. Changing the domain's DNS A records to point at the host's IP address.

All hosts and domain registrars provide guidance but you may need to seek expert assistance. Domain changes can take up to 48 hours to propagate so you may need to wait before moving to the next step.

Step 5: Set Up SSL

Secure Socket Layer (SSL) certificates enable cryptographic protocols on your website so it is served over an https:// address rather than http://. All communication between your server and the user's browser is encrypted so it cannot be (easily) intercepted by a third party.

Configuring SSL is an optional step but highly recommended:

  1. Browsers warn when a site is not secure especially when completing forms or sending data.
  2. Search engines rank secure sites higher than non-secure equivalents.
  3. SSL is essential if you eventually want a Progressive Web App which allows your site to be "installed" and work offline.
  4. Adding SSL later is considerably more difficult. You may need to reinstall WordPress and search engine indexing can be affected.
  5. There are no disadvantages. HTTPS can be added for free and is negligibly slower than unencrypted HTTP (it can be considerably faster when used with HTTP/2).

Hosts often allow you to install a certificate purchased elsewhere, but it's easier to use their own service. For example, SiteGround provides a free Let's Encrypt option in the security section of your site's cPanel. Click that, hit Install and SSL is enabled.

enable SSL

Step 6: Install WordPress

WordPress is a complex application which requires:

  1. A back-end MySQL database where your configuration, posts, comments and other information is retained. This must be installed and configured first. A database user ID and password must be defined so applications can store and retrieve data.
  2. A large set of PHP files which form the WordPress application. These must be copied to the server prior to running a set-up procedure. This requests the database credentials before creating the database tables and initial data.
  3. After installation, WordPress communicates with the database using the ID and password to enable editing and presentation of pages.

The majority of hosts provide cPanel - a popular website management facility. You can create your database, upload WordPress and install manually. For full instructions, refer to How to Create WordPress MySQL Databases on cPanel.

Fortunately, there is an easier option. Search or browse for the WordPress options in cPanel:

Install WordPress via cPanel

Click the WordPress Installer to open the installation panel:

WordPress installation options

Define the following settings:

  • https:// for the protocol if you enabled SSL in step 5. (You can also choose whether the domain uses the initial 'www' or not).
  • Your primary domain. (There will only be one choice unless you have multiple domains pointed at the hosting plan).
  • The directory should be left blank to install WordPress in the root folder. Only change this if you want to run it from another folder, e.g. http://ift.tt/2xAiIXx
  • The name and description of your new site.
  • Keep Multisite unchecked unless you're intending to run more than one WordPress site on the same space.
  • Enter an Admin Username and Password. You will use these to log into WordPress so ensure they're strong (NOT 'admin' and 'password'!) and you keep them in a safe place.
  • Enter your Email. WordPress uses this to send you notifications when necessary.

The other options can normally be left as the default settings. Hit Install and wait a few minutes for the installation process to complete. You will be given a link to the main site (https://mysite.com/) and the WordPress control panel (http://ift.tt/1VgZ4m9) where you can log in with your administrative username and password.

Step 7: Initial WordPress Configuration

Don't be tempted to start publishing content just yet! It's best to configure WordPress from the Settings menu before going further:

WordPress settings

The following sections describe the basic WordPress settings but note that installed themes and plugins can override these options.

General

This pane allows you to change various aspects about your installation. The primary settings to change include:

  • The Timezone. This may default to UTC so choose an appropriate city instead.
  • The Date Format. Choose an appropriate option or enter a custom string using PHP's date format
  • The Time Format. Similarly, choose an option or enter your own.

Remember to hit Save Changes once finished.

Writing

The main settings to change in this pane are:

  • The Default Post Category. Post categories are defined in Posts > Categories.
  • The Default Post Format. WordPress themes often provide different post types such as standard articles, galleries and video pages. Choose whichever you will use most often.

Reading

The Front page displays setting allows you to set whether your latest posts or a static page is presented on the home page.

The other default settings are normally fine, although you may want to temporarily disable Search Engine Visibility during the initial stages of building your site. Don't forget to enable it before going live!

Discussion

This pane controls commenting. The main setting is Allow people to post comments on new articles which you may want to disable if you don't require comments.

Continue reading %The Ultimate Beginner’s Guide to Setting Up & Running a WordPress Site%


by Craig Buckler via SitePoint

CanvasFlip Live

Long-scrolling Landing Page with trendy gradients and drop-shadowed elements promoting CanvasFlip Live – a service that livestreams user interactions with your prototype.

Full Review | Direct Link


by Rob Hope @robhope via One Page Love

#353: Quantifying Detectable Bugs in JS

This week's JavaScript newsRead this e-mail on the Web
JavaScript Weekly
Issue 353 — September 22, 2017
A summary of an academic paper that concludes both Flow and TypeScript are good at preventing bugs that could end up in committed code.
Adrian Colyer

Plenty of JS terminology explained, along with code examples, in this thorough guide.
Manuel Beaudru

JavaScript telemetry gives a timeline of browser events leading to an error, including interaction events, like clicks, inputs, navigation and console messages + more. Debug better w/ telemetry and know why your app crashed.
ROLLBAR   Sponsor

This new release of the controversial compile-to-JS language preserves its clean syntax but bridges the gap with ES6 and beyond.
CoffeeScript

The CEO of Ionic suggests that incompatibility between component models results in framework churn and that Web Components will provide a resolution.
Max Lynch

An example-driven tour of the key features of ES6/ES2015, if you’re not quite there yet.
Łukasz Kyć

Using the new `script type=”module”` approach gives us some benefits merely beyond loading ES modules alone - it guarantees ES6/ES2015 support.
Philip Walton

Jobs Supported by Hired.com

Can't find the right job? Want companies to apply to you? Try Hired.com.

In Brief

Angular v5 Release Delayed to October news
It was originally due this week.
Dor Moshe

Upcoming TypeScript Changes in Vue 2.5 news
Evan You

How to Build Your Own Fax Machine with Tessel, JavaScript and Twilio tutorial
The death of fax has been greatly exaggerated! Twilio Programmable Fax allows you to send and receive fax in the cloud.
Twilio  Sponsor

Modern Ways to Use C++ in JavaScript Projects tutorial node
Maga D. Zandaqo

Subclassing Arrays in ES2015 tutorial
David Tang

U Go Hue Go: Controlling Philips Lights with Angular & Kendo UI tutorial
Tara Manicsic

5 Favorites in Emerging Web Standards 
SitePen  Sponsor

How I Cut My Webpack Bundle Size in Half story
Justin Duke

Using ReactJS, ES6 & JSX to Build a UI (the rise of MERN) 
Part 5 of our Modern Application Stack series - Why ReactJS is driving the development of modern applications.
MONGODB  Sponsor

billboard.js: A Simple Chart Library Based on D3 V4 code
v1.1.0 has just been released.
Naver Corp

Vuetify: A Material Design Component Framework for Vue.js 2 code

Dexie 2.0: A Minimalistic Wrapper for IndexedDB code
Provides a neater API and error handling for the IndexedDB browser database API.
David Fahlander

mongoist: A MongoDB Driver for Node Built with async/await In Mind code
Christoph Walcher

ngraph.path: Fast Path Finding for Arbitrary Graphs code
Demo here.
Andrei Kashcha

winamp2-js: A Reimplementation of Winamp 2.9 in HTML5 & JavaScript code
‘Whipping the llama’s ass’ with JS. Demo here.
Jordan Eldredge

Nano Events: A 119 Byte Event Emitter Library code
Andrey Sitnik

AR.js: Efficient Augmented Reality for the Web code
Jerome Etienne

Bosket: Tree View Components for React, Angular, Vue and Riot code
Julien Elbaz

Wretch: A Tiny Wrapper Around Fetch with an Intuitive Syntax code
Julien Elbaz

Curated by Peter Cooper and published by Cooperpress.

Like this? You may also enjoy: FrontEnd Focus : Node Weekly : React Status

Stop getting JavaScript Weekly : Change email address : Read this issue on the Web

© Cooperpress Ltd. Fairfield Enterprise Centre, Lincoln Way, Louth, LN11 0LS, UK


by via JavaScript Weekly