Monday, July 10, 2017

HyperApp: The 1 KB JavaScript Library for Building Front-End Apps

The problem is creating sophisticated web applications and dealing with the complexity of the tools we have at our disposal.

HyperApp was born out of the attempt to do more with less. We have aggressively minimized the concepts you need to understand while remaining on par with what other frameworks can do. What makes HyperApp unique among the alternatives like React, Preact, and Mithril, is its compact API, built-in state management, and the unrivaled, small bundle size.

In this article, I'll introduce you to HyperApp and walk you through a few code examples to help you get started. Experience with other frameworks is not required, but since you are interested in HyperApp, I'll assume you have some knowledge of HTML and JavaScript.

What is HyperApp?

HyperApp helps you build interactive web applications. It follows many of the principles popularized by React like one-way data flow, JSX, and Virtual DOM.

HyperApp is based on the Elm Architecture. This means that application design is like application design in Elm or React/Redux.

Try it online

import { h, app } from "hyperapp"

app({
  state: "Hi.",
  view: state => <h1>{state}</h1>
})

The examples in this article use JSX for familiarity, but you are not required to use JSX with HyperApp.

Here is the example above using Hyperx and ES6 template literals.

Try it online

import { h, app } from "hyperapp"
import hyperx from "hyperx"

const html = hyperx(h)

app({
  state: "Hi.",
  view: state => html`<h1>${state}</h1>`
})

And for completeness, here is the example again without using external libraries.

Try it online

import { h, app } from "hyperapp"

app({
  state: "Hi.",
  view: state => h("h1", null, state)
})

Concepts

Virtual Nodes

HyperApp exposes h, a function that follows the HyperScript signature and is used to create virtual nodes.

h("div", { id: "app" }, [
  h("h1", null, "Hi.")
])

A virtual node is a JavaScript object that describes an HTML/DOM tree. The example above produces the following object:

{
  tag: "div",
  data: {
    id: "app"
  },
  children: [{
    tag: "h1",
    data: null,
    children: ["Hi."]
  }]
}

JSX is a JavaScript language extension used to represent dynamic HTML. Hyperx is an ES6, standards compliant alternative. Both boil down to the same h function call behind the scenes.

Hyperx/JSX in:

<main id="app">Hi.</main>

Vanilla out:

h("main", { id: "app" }, "Hi.")

The state, view, and actions

'Hello World' gets boring fast. Here is an interactive example using the essential ingredients of every HyperApp application.

Try it online

app({
  state: 0,
  view: (state, actions) => (
    <main>
      <h1>{state}</h1>
      <button onclick={actions.add}>+</button>
      <button onclick={actions.sub}>-</button>
    </main>
  ),
  actions: {
    add: state => state + 1,
    sub: state => state - 1
  }
})

The state represents the entire data model of your application. In this case, it is a number and its initial value is 0.

state: 0

When the app function runs, the state is passed to the view and its value is displayed inside an <h1> tag.

<h1>{state}</h1>

There are also two buttons in the view that have onclick handlers attached to them. The handlers are the actions that get passed to the view as the second argument.

<button onclick={actions.add}>+</button>
<button onclick={actions.sub}>-</button>

Notice that neither actions.add or actions.sub update the state directly, instead, they return a new state.

add: state => state + 1,
sub: state => state - 1

When the state is updated as a result of calling an action, the view function is called and the application is rendered again.

Visualizing the architecture

Users call actions by interacting with the application and they are the only available mechanism to update the state. Under the hood, HyperApp injects actions with code that knows when to render the application.

Actions that have no side effects are also known as reducers. If you are coming from Redux, this will make sense right away. A reducer is a pure function that receives the current state of the application and some data to compute a new state.

Visualize a chain in which each link represents a state configuration. The most recent link in the chain is the current state. The view function receives the current state and actions and uses them to construct the DOM tree. When an action is called, a new link in the chain is created.

Side effects

You can call multiple actions inside an action. You can call actions inside a callback passed to an asynchronous function like fetch too.

HyperApp knows that if an action returns null or undefined the state does not need to change and it skips the render pipeline. Incidentally, if an action returns a Promise, HyperApp does not update the state either and leaves it up to the resolve callback to figure out what to do, e.g., call other actions.

Examples

GIF search box

Let's build a GIF search box using the Giphy API. In this example, we'll demonstrate how to update the state asynchronously.

Try it online

Continue reading %HyperApp: The 1 KB JavaScript Library for Building Front-End Apps%


by Jorge Bucaran via SitePoint

The 5 Best WordPress Themes for SEO Visibility

The 5 Best WordPress Themes for SEO Visibility

This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible.

Theme selection to optimize your website’s SEO is more important than you might think. SEO can easily be negatively affected by poorly written themes. Specifically, the following points can hurt your SEO or the user experience causing your search engine rankings to suffer:

  • The inability to remove spammy links. Too often free or low-cost WordPress themes are given away in some campaign to generate leads and come with code and links that can hurt your organic search visibility.
  • Poor usability can result in higher bounce rates
  • Non-mobile friendly designs will suffer to Google’s SEO scrutiny
  • Poor design will result in a lower average time per page which tells Google your content isn’t relevant resulting in a lower ranking
  • Slow loading time from a bloated them will also go against Google's best practices for SEO
  • Regular updates and ongoing support. Very few free or low-cost themes are patched for security purposes or upgraded when new versions of WordPress rollout. This leaves your site open to all sorts of vulnerabilities from hacking to poor SEO performance.

These all contribute to the overall user experience, and will consequently affect your SEO. With that knowledge as a base, we set out to find the top five WordPress themes for SEO visibility. This list will outline our top five and give you insights into how they will strengthen your site’s SEO performance.

1. SEO WP

SEO WP

According to Brian Dean, renowned SEO expert, SEO WP is his top recommendation for SEO optimized WordPress themes. What makes it so special?

  • From the minute you download it, you a get blazing fast theme load time of only three seconds, which greatly improves the SEO of the website and the overall user experience.
  • Your website is fully responsive and will look great on any webpage. They validate every site with a Google mobile-friendly check.
  • Consistently updated each month to have the best written code for SEO and to make sure it is free of all known bugs.
  • Lightweight design and code cuts the average size of your site in a third.

In addition to a solid SEO foundation the theme comes with a free live composer page builder which allows you to customize the theme to any layout you desire.

SEO WP

Read more about the SEO WP theme or read user reviews and try it out on ThemeForest.

2. BoomBox

BoomBox

BoomBox is a solid theme choice right out of the box. It was designed specifically for SEO because its purpose is to cater towards creating viral content and building popular websites that generate a large amount of traffic each day.

Continue reading %The 5 Best WordPress Themes for SEO Visibility%


by Jacob McMillen via SitePoint

Here are the 5 Things Great Designers Do Differently

Demand for UX designers is rising every year. General Assembly estimates that UX design will be one of the most-promising careers in 2020, but with more demand…comes more supply. Here are the 5 things great designers do differently to beat their competition.

———

Pretty much every sector from health, to finance, to tech, and even retail, needs user experience designers—these master problem-solvers are geniuses at creating both online and offline experiences that prioritize the needs of the users.

Looking to hire a great UX designer? Here's what one looks like:

1. Great Designers Write Damn Good Microcopy

Have you ever felt lost at sea when using a website or app because the UI text was too vague? What about when you're filling out a form and it's not quite clear what it is that you need to do? Well, this confusion is a direct result of bad microcopy.

As Joshua Porter says, “Microcopy is small yet powerful copy. It’s fast, light, and deadly. It’s a short sentence, a phrase, a few words. A single word. It’s the small copy that has the biggest impact. Don’t judge it on its size…judge it on its effectiveness.”

When microcopy is too vague or robotic-sounding, the user doesn't resonate with the communication as well as they would do with a more conversational, humanlike tone of voice. Great designers understand that writing interface microcopy is a core aspect of the design process, and it’s just as important as prototyping, visual design or user research.

Let's take this form design by Tumblr, for instance. Do you see where it says, “(you can change this at any time)”? Just this short snippet of microcopy tells the user: "Hey, don’t work yourself up about it, you can come back to this step later". It's informative, it's empathetic, and it gives the user options. Without this microcopy, the user might force themselves to think of a suitable URL.

Form design for Tumblr with microcopy

2. Great Designers Learn the Rules…and Break Them

Great designers do more than think outside the box—as technology evolves and the needs of users change, they learn how to redefine the entire space when necessary. Great designers learn as much as humanly possible about the box before deciding to break the rules, as they know that reinventing the wheel is costly and sometimes risky.

Having a fair amount of knowledge about the users before designing the experiences, allows designers to deviate from these so-called design rules when necessary. Knowing these rules, and why they were established to begin with, means being able to understand the consequences of breaking them (both the risks and benefits).

Great designers are innovative. When they do break the rules, they come up with fresh ideas to solve the issues that users are having, when the usual solutions aren't working. The implementation of these ideas is how design trends are born!

3. Great Designers Steal

Yes, you read that correctly. Great designers steal, then they improve. And I'm not the first to make this claim. As it turns out, Picasso, one of the most influential fine artists of the 20th century, felt the same way.

"Good artists copy. Great artists steal." ~ Pablo Picasso.

In the example below, Smena created this snazzy paper shredder image.

Paper shredder image, original

Hanna Jung, a designer at Google, restyled the image slightly and added animation to it. It's quite clear that Jung did not come up with the original concept, but was nonetheless inspired to tweak it and make it into something even better.

Paper shredder image, inspired example

We find another example in Brandon Termini’s fresh take on the navigation system for a technology company’s web site.

Navigation concept, original concept

Inspired by Termini's navigation concept, Ilya Kostin decided to try something similar and the result was nothing short of elegant.

Navigation concept, inspired example

4. Great Designers Declutter Ruthlessly

"The ability to simplify means to eliminate the unnecessary so that the necessary may speak." ~ Hans Hofmann.

What's usually deemed as unnecessary in interface design is visual noise, too much text, over-animated objects, and basically anything that steals the spotlight from the necessary elements. Great designers knows this—they experiment various ideas, then reduce the overall design to declutter.

Continue reading %Here are the 5 Things Great Designers Do Differently%


by Tobi Abdulgafar via SitePoint

Essential Meteor Tips

33 Alfred Place

33 Alfred Place

Long scrolling One Pager for the newly refurbished office suites at 33 Alfred Place near Tottenham Court Road, London.

by Rob Hope via One Page Love

How to Do a Facebook Live Split-Screen Interview

Want to interview guests on your Facebook Live show? Looking for a tool that lets you bring a remote guest into your Facebook Live video? In this article, you’ll discover how to broadcast a Facebook Live interview with a split screen. Why Create a Facebook Live Interview Show? When your video is live, you can [...]

This post How to Do a Facebook Live Split-Screen Interview first appeared on .
- Your Guide to the Social Media Jungle


by Erin Cell via

Tim Roussilhe Portfolio

Creative Developer and Designer living in Brooklyn. I like to mix code, surprising visuals and pleasing interactions.
by via Awwwards - Sites of the day