Monday, July 13, 2015

Web Design Weekly #194

Headlines

Seeing the Extensible Web Manifesto Through

Mat Marquis writes an open letter to browser representatives and implementers stressing the need to adapt to the realities of the way we all work to help push the Extensible Web Manifesto to the next level. (bocoup.com)

Craft Your Design Without Code

The NEW Webydo makes it easier for professional designers to design, manage and deliver pixel perfect responsive websites for their clients, completely code free. (webydo.com)

Articles

Performance audit – Reddit’s mobile site

Paul Irish looks into the loading performance of the Reddit mobile site. An amazing amount of tips that can be used for your next performance audit. (github.com)

Practical Techniques On Designing Animation

Sarah Drasner writes about how we can bake animation into the core of our user experience process to create exciting and engaging work that pushes boundaries on the web. (smashingmagazine.com)

Component Independence

Jonathan Snook explores a few reasons why creating independent modules with CSS can be difficult. (medium.com)

React + Performance = ?

Nothing like a good performance post to stir the pot. Paul Lewis dives into a few examples to see if React is as fast as everyone says it is. Also the code examples are now on GitHub. (aerotwist.com)

1px is not enough

A nice detailed post that offers some sound advice about why dithering can really help improve the quality of assets. (bjango.com)

Why motion matters

Justin Cone dissects Benjamin De Cock CSS Conf talk on why motion matters. Justin looks at various sections of the talk, like best practices for animation, rules for web animation, skeuomorphism and animation and much more. (motionographer.com)

How to choose and hire product people (medium.com)

Tools / Resources

Material Design Lite Released

Material Design Lite lets you add a Material Design look and feel to your websites with ease. It doesn’t rely on any JavaScript frameworks and aims to optimize for cross-device use, gracefully degrade in older browsers and offer an experience that is immediately accessible. Also Addy Osmani wrote a small post introducing it which is worth a read. (getmdl.io)

Mondrian

Mondrian is a smart and easy-to-learn vector graphics web app. It is also open sourced on GitHub which is tops. (mondrian.io)

Slick – the last carousel you’ll ever need

A fully responsive, easy to customise carousel that just works. (kenwheeler.github.io)

Styling Visited Links with SVG (demosthenes.info)

Testing with ReactJS (medium.com)

Command Line Tips (youtube.com)

Inspiration

Productivity Tips From The World’s Top Designers

Staying productive can be tough in today’s online world. If you are having productivity issues (or are looking to procrastinate), maybe this post that features many top designer tips will help get you back into the groove. (fastcodesign.com)

Jobs

WordPress Front End Developer

We’re looking for a talented freelance WordPress theme & frontend developer in North America. The opportunity calls for a mixed set of skills. We need someone with expert level CSS skills, impeccable WordPress experience, and solid JavaScript, PHP & MySQL skills. (tri.be)

Front End Developer Extraordinaire at Pusher

Do you want to design something that makes developers’ lives better? At Pusher we’re looking for a designer-developer who believes that design can make a meaningful difference and cares about how it is implemented. Join us! (pusher.com)

Need to find passionate developers? Why not advertise in the next newsletter!

Last but not least…

Mobile W3C Mobile Checker (w3.org)

10 Reasons To Use HTTPS (medium.com)

The post Web Design Weekly #194 appeared first on Web Design Weekly.


by Jake Bresnehan via Web Design Weekly

Edgar Schmitz

opl-small

Just love this unique interactive spotlight concept in this One Pager for London-based artist, 'Edgar Schmitz'. Upon clicking and holding down - your cursor turns into a spotlight that you need to move around to reveal the content and images. Each click mysteriously shows a different item of his work.

by Rob Hope via One Page Love

Fast WordPress Customizer Options Development with Kirki

One thing WordPress users have grown accustomed to, is easy, no code required theme customization options. The idea is: download a theme, activate it in the Themes panel, access the Customize panel, and start tweaking the theme’s colors, layout, fonts, etc., with just a mouse click.

WordPress offers theme developers the Customizer API. This is a clean, object-oriented set of methods that facilitate the creation of a consistent customization interface. On the Customize panel, users can easily make changes and live-preview them without having to mess with PHP or CSS code.

Developing theme options using the Customizer API, while being a straightforward and logical process, involves writing a certain amount of repetitive code. To cut down on some of the steps required to build functioning and safe Customizer options, Aristeides Stathopoulos has been developing a free and open-source plugin, Kirki.

In this post I’m going to show how to integrate Kirki into your WordPress theme and how to use it to build a few Customizer options.

What is Kirki?

Let’s hear what Kirki is about from the developer behind it:

Kirki is not a framework. It’s a toolkit allowing WordPress developers to use the Customizer and take advantage of its advanced features and flexibility by abstracting the code and making it easier for everyone to create beautiful and meaningful user experiences.

Kirki Documentation

I’d like to drive home two points about this toolkit.

Continue reading %Fast WordPress Customizer Options Development with Kirki%


by Maria Antonietta Perna via SitePoint

Form-Based Directives in AngularJS

Enforcing complex business constraints against user submitted data poses unique challenges to a significant number of developers. Recently, my team and I were faced with such a challenge while writing an application at GiftCards.com. We needed to find a way to allow our customers to edit multiple products in a single view within our application, where each product had a unique set of validation rules.

This proved challenging because it required us to have multiple <form> tags within the HTML source and maintain a validation model per form instance. We tried many approaches, such as using ngRepeat to display the child forms, before settling on a solution. We would create one directive per product type (where each directive would have a <form> in its view) and have the directive bind to its parent controller. This allowed us to take advantage of Angular’s child / parent form inheritance to ensure the parent form was only valid if all child forms were valid.

In this tutorial we will build a simple product review screen (which highlights the key components of our current application). We will have two products, each with their own directive and each with unique validation rules. There will be a simple checkout button that will ensure that both forms are valid.

If you’re anxious to see this in action, you can jump straight to our demo, or download the code form our GitHub repo.

A Word about Directives

A directive is a block of HTML code that runs through AngularJS’s HTML compiler ($compile) and is appended to the DOM. The compiler is responsible for traversing the DOM looking for components it can turn into objects using other registered directives. Directives work within an isolated scope and maintain their own view. They are powerful tools that promote reusable components that can be shared across an entire application. For a quick refresher check out this SitePoint article or the AngularJS docs.

Directives solved our fundamental issue in two ways: first, each instance has an isolated scope, and second, the directive uses a compiler pass, whereby the compiler identifies a form element in the view’s HTML using Angular’s ngForm directive. This inbuilt directive allows multiple nested form elements, accepts an optional name attribute to instantiate a Form Controller, and will return with the form object.

And a Word about Form Controllers

When the compiler identifies any form object in the DOM, it will use the ngForm directive to instantiate a Form Controller object. This controller will scan for all input select and textarea elements and create the appropriate controls. The controls require a model attribute to set up two-way data binding and allow instant user feedback via various pre-built validation methods. Providing instant feedback to the consumer allows them to know which information is valid before making a HTTP request.

Pre-Built Validation Methods

Angular comes packaged with 14 standard validation methods. These include validators for min, max, required to name but a few. They are built to understand and operate with nearly all HTML5 input types and are cross-browser compliant.

[code language="js"]

Size:

The value is required!

[/code]

The example above shows the usage of the ngRequired directive validator in Angular. This validation ensures that the field is filled out before it is considered valid. It does not validate any of the data, just that the user has entered something. Having the attribute novalidate indicates that the browser should not validate upon submission.

Pro Tip: Do not set an action attribute on any Angular form. This will prevent Angular’s attempts to ensure the form is not submitted in a round trip manner.

Custom Validation Methods

Angular provides an extensive API to assist in the creation of custom validation rules. Using this API gives you the ability to create and extend your own validation rules for complex inputs not covered in the standard validations. My team and I rely on a few custom validation methods to run complex RegEx patterns that are used by our server. Without the ability to run the complex RegEx matchers we would potentially be sending incorrect data to our backend server. This would present the user with errors which causes a undesirable user experience. Custom validators use the directive syntax and require ngModel to be injected. More information can be found by consulting AngularJS’s Documentation.

Creating the Controller

With that out of the way, we can make a start on our application. You can find an overview of the controller code here.

The controller will be the heart of things. It only has a handful of responsibilities—its view will have a form element named parentForm, it will have only one property and its methods will consist of registerFormScope, validateChildForm, and checkout.

Controller Properties

We will need one property in the controller:

[code language="js"]
$scope.formsValid = false;
[/code]

This property is used to maintain a boolean state of the overall validity of the forms. We are using this property to disable the state of the “Checkout” button after it has been clicked.

Method: registerFormScope

[code language="js"]
$scope.registerFormScope = function (form, id) {
$scope.parentForm['childForm'+id] = form;
};
[/code]

When registerFormScope is called it will be passed a Form Controller along with the unique directive id created in the directive instantiation. This method will then append the form scope to the parent Form Controller.

Method: validateChildForm

This is the method that will be used to coordinate with the backend server which performs validation. It is is invoked when the user is editing content and it needs to go through additional validation. We conceptually don’t allow directives to perform any external communication.

Please note that I have omitted the backend component for the purposes of this tutorial. Instead I am rejecting or resolving a promise, based on whether the amount a user enters falls within a certain range (10 - 50 for product A and 25-500 for product B).

[code language="js"]
$scope.validateChildForm = function (form, data, product) {
// Reset the forms so they are no longer valid
$scope.formsValid = false;
var deferred = $q.defer();

// Logic to validate the form and data
// Must return either resolve(), or reject() on the promise.
$timeout(function () {
if (angular.isUndefined(data.amount)) {
return deferred.reject(['amount']);
}

if ((data.amount < product.minAmount) ||
(data.amount > product.maxAmount)) {
return deferred.reject(['amount']);
}

deferred.resolve();
});
return deferred.promise;
}
[/code]

Using the $q service allows the directives to adhere to an interface with a success and failure state. The nature of the application interface alters between “Edit” and “Save” depending on the editing of the model data. It should be noted that the model data is updated as soon as the user starts typing.

Method: Checkout

Clicking “Checkout” indicates a user has finished editing and desires to checkout. This actionable item will need to validate that all the forms loaded within the directives pass validation, before sending the model data to the server. The scope of this article will not cover the methods used to send data through to the server. I encourage you to explore using the $http service for all your client to server communications.

[code language="js"]
$scope.checkout = function () {
if($scope.parentForm.$valid) {
// Connect with the server to POST data
}
$scope.formsValid = $scope.parentForm.$valid;
};
[/code]

This method uses Angular’s ability for a child form to invalidate a parent form. The parent form is named parentForm to clearly illustrate its relationship to the child forms. When a childForm uses its $setValidity method, it will automatically ascend to the parent form to set the validity there. All forms within the parentForm must be valid for its internal $valid property to be true.

Creating Our Directives

Our directives must follow a common interface that allows complete interoperability and extensibility. The names of our directives depend on the product they contain.

You can find an overview of the directive code here (Product A) and here (Product B).

Isolated Directive Scope

Every directive that’s instantiated will obtain an isolated scope which is localized to the directive and has no knowledge of external attributes. AngularJS does however allow directives to be created that utilize parental scope methods and properties. When passing external attributes into the localized scope, you can indicate you want two-way data binding to be setup.

Our application will need a handful of external two-way data bound methods and properties:

[code language="js"]
scope: {
registerFormScope: '=',
giftData: '=',
validateChildForm: '=',
product: '='
},
[/code]

Method: registerFormScope

The first property in the directive’s local scope is the method which registers the local scope.form with the controller. The directive needs a conduit to pass the local Form Controller object to the main Controller.

Object: giftData

This is the centralized model data that will be used within the directive views. This information will be two-way data bound to ensure that the updates that happen in the Form Controller will propagate to the main Controller.

Continue reading %Form-Based Directives in AngularJS%


by Chad Smith via SitePoint

Streaming a Raspberry Pi Camera Into VR With JavaScript

I spent the week tinkering with a Raspberry Pi Camera and exploring ways to get it to stream images to a web browser. In this article, we'll explore the simplest and most effective way I found to stream images into client side JavaScript. In the end, we'll stream those images into the Virtual Reality viewer built in my earlier article on Filtering Reality with JavaScript and Google Cardboard.

What You'll Need

For this demo, you'll currently need a Raspberry Pi (I used the Raspberry Pi 2 Model B) with Raspbian installed (NOOBS has you covered here), an Internet connection for it (I recommend getting a Wi-Fi adaptor so your Pi can be relatively portable) and a Camera module.

If your Pi is brand new and not currently set up, follow the instructions on the Raspberry Pi NOOBS setup page to get your Pi ready to go.

If you've got a bunch of stuff on your Pi already, please make sure you back everything up as the installation process replaces various files. Hopefully everything should play nicely but it's always important to be on the safe side!

The Code

Our demo code that uses the camera data is accessible on GitHub for those eager to download and have a go.

Attaching Your Pi Camera

If you are new to the Raspberry Pi and attaching a camera, I'll cover it quickly here. Basically, there is a plastic container (called the flex cable connector) around the opening which you'll want to gently open. To do so, pull the tabs on the top of the connector upwards and towards the Ethernet port. Once you've got it loosened, you'll be able to slot in your camera's flex cable. The cable has a blue strip on it on one side, connect it so that side is facing the ethernet port. Be careful to keep the cable straight (don't place it into the slot at an angle, it should fit straight in). Here's a photo of my camera flex cable connected correctly to show what we're looking for here:

Raspberry Pi Camera Connected

RPi Cam Web Interface

The easiest way I've found to stream images from the Pi camera was to use the RPi Cam Web Interface. You run a few basic terminal commands to install it and then it sets up your camera on an Apache server ready to use.

If you've installed Raspbian from scratch already, you may have also already enabled the camera in the config screen that appeared afterwards. If not, you can get to it by typing in the following command:

[bash]sudo raspi-config[/bash]

On that screen, you'll be able to select "Enable Camera", click that option and and choose "Enable" from the screen that appears.

Raspberry Pi Camera Enable Screen

Next up, make sure your Raspberry Pi is up to date (before doing this, I want to reiterate - back things up to be safe). We start by downloading the latest repository package lists:

[bash]sudo apt-get update[/bash]

We then make any updates to existing repositories on our Pi that we might have found:

[bash]sudo apt-get dist-upgrade[/bash]

Finally, we update our Raspberry Pi software itself too:

[bash]sudo rpi-update[/bash]

Then, we install the RPi Cam Web Interface itself from its GitHub repo. Go to the location on your Pi that you'd like to clone the repo to and run the git clone command:

[bash]git clone http://ift.tt/1RuxXWz]

This will create a RPi_Cam_Web_Interface folder ready with a bash installer. Firstly, go to that directory:

[bash]cd RPi_Cam_Web_Interface[/bash]

Update the permissions on the bash file so you can run it:

[bash]chmod u+x RPi_Cam_Web_Interface_Installer.sh[/bash]

Then run the bash install program:

[bash]./RPi_Cam_Web_Interface_Installer.sh install[/bash]

The install program has slightly more of a visual interface. I personally installed it via the Apache server option (the first option), so the following will all focus on that method. If you prefer to use an Nginx server, you can. I'd imagine much of the process is relatively similar though.

Raspberry Pi Cam Install Screen

You'll then specify where you'd like to place the RPi Cam Web Interface on your server's /var/www directory. If you don't list anything, it will install in the root /var/www folder. I installed it in a folder called picam to keep it separate.

Cam Installation Location Screen

On the next screen, I selected "yes" to whether I wanted the camera to auto start on boot time.

Camera boot at start prompt

Continue reading %Streaming a Raspberry Pi Camera Into VR With JavaScript%


by Patrick Catanzariti via SitePoint

The Ultimate Guide to Online Communities for Entrepreneurs

Human beings are naturally tribal. Unlike those holier-than-thou sea turtles, we bipeds are drawn toward other members of our species with similar interests, characteristics and backgrounds. Fortunately, this biological quirk isn’t thwarted by the anonymity of cyberspace. There are an unimaginable number of online communities floating around your silly human head right now, some of […]

Continue reading %The Ultimate Guide to Online Communities for Entrepreneurs%


by Joshua Kraus via SitePoint

Caching Hat-trick: Varnish, Memcached and PHP libraries

Previously, we looked at some common caching mechanisms we can easily utilize to make our apps faster. In this part, we’ll walk through some of the additional software that we can use with PHP for caching.

Abstract image with text cache

Memcached

Memcached is an in-memory key-value store. You can use it to store things like strings, numeric values, objects and arrays.

Installing Memcached

You can execute the command below to install memcached on ubuntu or other debian based OS:

sudo apt-get install memcached

To make it work with PHP, you also need to install the PHP extension:

sudo apt-get install php5-memcached

To check if memcached is working, look for ‘memcached’ in the output returned when you call the phpinfo() method from a page. You should see something similar to the following:

Continue reading %Caching Hat-trick: Varnish, Memcached and PHP libraries%


by Wern Ancheta via SitePoint