A tutorial about creating some WebGL experiments where the viewer seemingly travels through a textured tunnel powered by Three.js
by via jQuery-Plugins.net RSS Feed
"Mr Branding" is a blog based on RSS for everything related to website branding and website design, it collects its posts from many sites in order to facilitate the updating to the latest technology.
To suggest any source, please contact me: Taha.baba@consultant.com
A tutorial about creating some WebGL experiments where the viewer seemingly travels through a textured tunnel powered by Three.js
It’s that time again to get learning! As before, I’ve collected a number of different learning resources, including guides, docs, and other useful websites to help you get up to speed in different areas of front-end development.
So please enjoy the twelfth installment of our Docs and Guides series and don’t forget to let me know in the comments of any others that I haven’t yet included.
A compilation of React Patterns, techniques, tips and tricks. Includes sections on design patterns, ant-patterns, performance tips, and styling. This looks like a really good reference for those wanting to dig deep into React.
This cheat sheet is available as a simple PDF with a quick reference to the different features or as a fully interactive guide. The interactive guide works as a shortcut to the official Vue.js documentation, opening each link in an overlaid iframe.
The W3C’s new Grid Layout module features have really been picking up steam of late since browser support improved. This interactive guide is a pretty complex little app with a ton of options. This might not be a great guide for beginners but maybe a good option for those already familiar with Grid Layout basics.
Flexbox (the other hotness in CSS layout) is represented in this cheatsheet. From what I can tell, this one is using the same descriptive info as the spec, but with some interactive code examples to help visualize the different features.
This site is technically a blog, but works well as both a pattern library and a superb example of an accessible site. So far only two entries have been posted in the “library”, but both cover their topics exhaustively, so there’s plenty to take in and this is a good one to keep an eye on for future posts if you are concerned about accessibility (and you should be!).
“The A11Y style guide comes with pre-populated accessible components that include helpful links to related tools, articles, and WCAG guidelines to make your site more inclusive. These components also serve as a guide for both HTML markup and SCSS/CSS code, to inform designers, front-end and back-end developers at every stage of the website’s creation.” Sections include forms, media, navigation, and more.
Continue reading %20+ Docs and Guides for Front-end Developers (No. 12)%
It doesn't matter if the main focus of your app is to capture an amazing landscape, or just an innocent selfie. What is important to developers is to let users make the most out of the camera and do it painlessly. To that end, Apple has done a remarkable work presenting AVCapturePhotoOutput
in iOS 10. In this article I will show how to implement some of its features. The full project can be downloaded from GitHub.
Surely, iOS apps were able to use the camera before. However, the framework has new features and improved the existing ones.
Continue reading %How to Use AVCapturePhotoOutput’s Best Photo Features%
This article was sponsored by Acuity Scheduling. Thank you for supporting the partners who make SitePoint possible.
I recently wrote an article about building an online system to book lessons with a driving instructor. Teaching someone to drive is relatively unique, in that it's guaranteed to be a one-to-one class — or at least, if you did find yourself sharing an instructor's time, then you'd have every right to feel short-changed.
Most other types of class, though, tend to have multiple participants. Unless they're delivered online, they'll most likely have a limit on the number of students due to logistical considerations.
Cookery classes usually have a very well-defined limit on the number of students — you can only really teach as many people as you have cooking stations or cookers. That's going to be the theme of this article — managing those "slots" in a cookery class. The principles remain the same for all sorts of other forms of tuition.
As before, we're going to take advantage of Acuity Scheduling in order to manage bookings for our classes, and everything that entails.
All of the code for this tutorial is available on Github.
Thanchanok delivers Thai cookery classes. There's a general introductory course, as well as two more specialised courses - one covering the many and varied Thai curry pastes, and one that focuses specifically on the region in which she was brought up — the swelteringly hot Northern region around Chiang Mai. She owns a specially fitted-out kitchen to deliver these classes. Each has eight cooking stations. She typically runs around four classes a week — two of those slots for the introductory class which, as you might expect, is by far her most popular.
Currently her website includes an email address and telephone number for making bookings, but there are a number of issues with that. First is that it's easy to forget to update the website to indicate that it's fully-booked, which on occasion has left potential attendees disappointed and with a poor impression of the company.
The second is that she has to rely on good old-fashioned pen-and-paper to manage her list of pupils, along with their contact details and whether they've paid for the lesson ahead of time. She'd very much like to add a feature to her website that allows people to view class availability as well as book online, and to then help her class schedule and attendee lists. That's what we're going to do in the course of this tutorial.
Let's break down the requirements as far as the public-facing website is concerned:
By integrating all of this with Acuity Scheduling, we effectively get the back-end requirements handled without having to develop it ourselves:
Let's get started.
The first thing you'll need to do, if you haven't already, is to sign up at Acuity Scheduling. The free trial will be perfectly adequate for following along.
The next thing we need to do is set up the three classes. In Acuity terminology these are appointment types.
If you've just signed up, click the Create your Appointment types button at the top of the screen, or click Appointment Types under Business Settings on the sidebar.
Next, click the New Type of Group Class button.
You'll need to name the class. For the purposes of this tutorial we'll call them Introduction to Thai Cookery, Thai Curry Pastes and Taste of the North, but you can call them whatever you want.
Enter a duration in minutes — for example, 180 — and optionally provide a price. In order to keep things simple, we won't be covering payment.
Click the Create Appointment Type button to save the information. Once we've created the appointment type — i.e., the class — we need to provide some dates and times. To do this, click the Offer Class button.
Enter the date and time that the course will run. If it's a regular thing then you can set it as recurring — this allows you to enter multiple dates in bulk. Thanchanok offers the introductory class twice weekly at 1pm, and the other two courses once per week.
Next, go to the Appointment Types and check the three URLs to the newly-created classes. They contain an id
query parameter which we'll need shortly, so make a note of those now.
The final step on the Acuity side is to get the API credentials for our integration:
Copy and paste the User ID and API Key for use later.
For the purposes of this tutorial we're going to use Lumen, although the principles are pretty much the same whatever your framework of choice happens to be.
Start by creating the project from the command-line:
composer create-project --prefer-dist laravel/lumen thaicookery
Create a file in your project folder named .env
and add the following lines, replacing the values appropriately:
ACUITY_USER_ID=your_user_id
ACUITY_API_KEY=your_api_key
APP_DEBUG=true
This will allow you to retrieve the user ID and API key like this:
$userId = env( 'ACUITY_USER_ID' );
$apiKey = env( 'ACUITY_API_KEY' );
As I hinted at earlier, we're going to integrate with Acuity Scheduling via the API. This is even easier with an SDK.
There are SDKs for Node.js and PHP on the developer site; we're going to be using the one for PHP. It's avalailable on Packagist, so we simply need to install it using Composer:
composer require acuityscheduling/acuityscheduling
Now we need to make the Acuity Scheduling SDK available throughout the site. The ideal way to do this is to use a service provider to inject it into the application's service container.
Open up app/Providers/AppServiceProvider.php
and add a use
statement to the top of the file:
use AcuityScheduling;
Then add the following to the register()
method:
$this->app->singleton( 'AcuityScheduling', function ( $app ) {
return new AcuityScheduling( [
'userId' => env( 'ACUITY_USER_ID' ),
'apiKey' => env( 'ACUITY_API_KEY' ),
] );
} );
Now register the service provider by opening up bootstrap/app.php
and uncommenting the following line:
$app->register(App\Providers\AppServiceProvider::class);
The next step is to define the classes for displaying them on the site. In practice you'd probably store these in a database, but for the purposes of this exercise we'll simply hard-code them in an array as a property of the base controller — you'll find this in app/Http/Controllers/Controller.php
.
Create the array, being sure to substitute your own appointment type IDs:
protected $classes = [
[
'name' => 'Introduction to Thai Cookery',
'key' => 'introduction-to-thai-cookery',
'description' => 'A basic introduction to Thai cookery, which teaches you to make three popular Thai dishes - Tom Yum, a ferocious hot and sour prawn soup, a fragrant green chicken curry and a dessert of mangoes with cocounut and sticky rice"',
'acuity_id' => 3027517,
],
[
'name' => 'Thai Curry Pastes',
'key' => 'thai-curry-pastes',
'description' => 'Pestle and mortar at the ready, as we take a look at Thai curry pastes, the foundation of all Thai curries. Specifically, the course teaches you to make red, green and Panang curry pastes. We will also be cooking a roast duck red curry with sticky rice.',
'acuity_id' => 3027529,
],
[
'name' => 'Taste of the North',
'key' => 'taste-of-the-north',
'description' => 'An in-depth look at the cusine of the North of Thailand.',
'acuity_id' => 3027535,
],
];
As you can probably gather from the code, we're defining a key for identifying each course in an SEO-friendly manner, along with some basic information about each class and that all-important appointment type ID that allows us to integrate with Acuity.
Now all of that's set up, it's time to integrate with Acuity Scheduling.
The first thing we need to do is list the classes, and the dates on which each class is offered. We've already set all of that up on the Acuity side, along with our meta-data, so the next step is to call the API to get the availability. The endpoint for this is availability/classes
. The SDK makes calling this a breeze.
availability/classes
gives you the classes for a specified month. By default it only includes those classes with available slots, although you can override that behaviour. We'll do that, but mark the ones with no available slots appropriately.
Create a new controller class — app/Http/Controllers/HomeController
— and add the following method:
/**
* Get the available classes for the given month
*
* @param Carbon $month
* @return array
*/
public function getAvailablity( $month )
{
return app( 'AcuityScheduling' )->request(
'availability/classes',
[
'query' => [
'month' => $month->format( 'Y-m' ),
'includeUnavailable' => 'true',
],
]
);
}
Now for the homepage. Create a new method called index()
, and we'll begin by getting the availability for the current and next month:
/**
* The homepage
*
* @return \Illuminate\View\View
*/
public function index( )
{
// Get the dates for this month...
$availability = $this->getAvailablity( Carbon::now( ) );
// ...and next month
$availability += $this->getAvailablity( Carbon::now( )->addMonth( ) );
}
This will return an array of results. Before we render that out, let's use the power of Lumen's collections to do two things:
time
appointmentTypeID
propertyHere's the code for that:
// Now go through and inject the date as a Carbon instance, then group by the class
$instances = collect(
$availability
)->map( function( $instance ) {
$instance[ 'date' ] = Carbon::parse( $instance[ 'time' ] );
return $instance;
} )->groupBy( 'appointmentTypeID' );
Finally, return the page:
The layout template isn't included here for brevity, but you can grab a copy from GitHub.
// Return the rendered homepage
return view( 'home.index', [ 'classes' => $this->classes, 'instances' => $instances ] );
Now create a new file in resources/views/home/index.blade.php
:
@extends( 'layouts.default' )
@section( 'content' )
<p>We offer three different classes, detailed below.</p>
@foreach( $classes as $class )
<h2></h2>
<p></p>
<ul class="instances">
@foreach( $instances->get( $class[ 'acuity_id' ] ) as $instance )
<li>
<h5>
<time datetime=""> at </time>
@if ( $instance[ 'slotsAvailable' ] == 0 )
<span class="badge badge-danger">Fully booked</span>
@elseif ( $instance[ 'slotsAvailable' ] < 2 )
<span class="badge badge-warning">Only available</span>
@else
<span class="badge badge-success"> slots available</span>
@endif
</h5>
@if ( $instance[ 'slotsAvailable' ] > 0 )
<a href="////book" class="btn btn-primary btn-sm">Book Now</a>
@endif
</li>
@endforeach
</ul>
@endforeach
@stop
The code should be relatively straightforward. We're iterating through the available classes and displaying the information about them. Then we're going through and listing the actual classes along with a label that provides some information about availability, and finally showing a button for booking into classes which have available slots.
You can take what we've done so far for a spin — fire up Terminal and enter:
Continue reading %Booking Cookery Classes with Acuity Scheduling and Lumen%
Color plays a critical role in our lives; from differentiating between objects, to understanding traffic signals, to using tools correctly.
What’s even more interesting is the huge impact that color has on our cognition and mood. Recently I read a short research article that explains how different people perceive color and the impact that they can have on their mood and emotions. They cited a study in which workers lifting boxes that were painted black complained that they were too heavy – but when the same boxes were painted green, they felt lighter.
Similarly, in regards to websites, colors can have a significant impact on the usability and cognition of users. While each design element contributes to the usability of a website, a designer needs to be extra careful when choosing which colors to use on them.
Let's took a look.
Background and foreground elements on a screen/webpage must be different colors. When both are the same, it's difficult to identify the foreground elements right away. Obvious, right? Yes, but there's more.
Not all combinations of foreground and background colors are suitable for use, but with that in mind, how do we know which colors to choose? Answer: choose colors that contrast each other well.
Source: Color Interaction and Color Effects
In the image above, even though the color used on the background square is very different from the one used on the foreground square, it's nonetheless extremely uncomfortable to look at, despite the high level of contrast. If the foreground was text, it would be unreadable as well as uncomfortable, and the same applies when there is low contrast as well.
Is there a sweet spot?
Yes there is – keep reading.
The solution is to choose a color combination with sufficient contrast. According to the WCAG 2.0 guidelines, the contrast ratio for text should be at least 4.5:1. For example, it would be quite difficult to read the text if the contrast ratio was 1.26:1; however, if the contrast ratio was 7.58:1, it would be more legible and readable.
Is there a tool that helps you check the contrast ratio of background and foreground colors for apps and websites? Yes! WebAIM tool.
Color contrast also matters when you need to divert a user’s attention to a specific element, like a call-to-action button (also known as a CTA).
In an experiment, two A/B variations of a webpage were created. The first variation had a blue background and used a different shade of blue for the call-to-action, the other had a navy background with an orange CTA. Users were asked to click on the element that draws their attention the most. The orange CTA received more clicks than the blue CTA because the orange-navy contrast was higher than that of the first variation.
The variation with blue background had a contrast ratio of 1.39:1, which is a little below the "sweet spot". In the second variation, the contrast ratio is 4.73:1, which means that the orange-navy combination contrasted better than the other version.
When choosing a color for a call-to-action, we need to choose one that contrasts well with the background color. But how do we know which colors create the most contrast? For that we can use a color wheel to find "opposite colors". For instance, in the above case study, orange is opposite to navy on the wheel, and thus the contrast is stark (i.e. more effective).
As individuals, we all experience color in different ways. Some of us have a vision deficiency called color blindness, which is described as the inability to distinguish between certain colors (most commonly between red and green, or blue and yellow). In fact, it's estimated that 1 in 12 men and 1 in 200 women suffer from this type of blindness.
Colorblind users will have difficulty perceiving certain colors. For example, a blue CTA might appear as desaturated blue, and this may cause the contrast between the CTA and the background to appear quite low, which in turn would make the CTA far less attention-grabbing.
Here's an example of a sign-in screen viewed using a colorblind simulator.
The solution is, once again, contrast. By using high-contrasting colors you can make CTA's accessible regardless of the actual colors used!
Continue reading %How to Boost Usability with Intelligent Color Choices%