2019-01-01 Web Designer UK
2019-01-01 Web Designer UK
udini? Anim
t is Ho ate
Wha SVG
fr mea s urem
ding e
sibil
ity bo a r
ory
ces nt u
n it
St
ac
Grid &
ISSUE 282
EA
nsitions
M
ra
s
t
utout
SS
grid
C
O
-tem
y c
p
la
la
C
te-rows
Disp
E
ANIMATION TIPS
B
MASTER SASS
CSS Layou
OOCSS, ACSS, SMACSS or BEM?
t API
ms interview
YOU
y Willia
ssid
CSS
Ca
Tra
nsform
L L
s
A
les
Anima
tion API CSS Variab
am es
Co
f r
key
mbin
CS S
me e
tho
CSS Clip path
do log
ies
Meta
Welcome
Welcome
THE WEB DESIGNER MISSION
To be the most accessible and inspiring voice for the industry, offering cutting- Steven Jenkins
edge features and techniques vital to building future-proof online content Editor
I
f you are reading this then there is a keyframes, performance and SVG animation along the
good chance you know what CSS is. We way. Want to know the ins and outs of CSS Grid? Then
like to call it the king of styling, but head to page 52 as we take you through the basics and
Cascading Style Sheets in 2018 have so beyond, and offer a few tips along the way.
much more to offer than simple styling. Not as sexy as animation but just as important is
This issue we decided it was time to optimisation. Head to page 58 to get quick and easy tips
show off some of the immense talents to lighten the code load and get faster-loading sites. CSS
that CSS has to offer and give an insight preprocessors let you extend CSS and make it even more
into some of the lesser-known but still essential powerful. We take a closer look at the very popular
“
Using a CSS methodology, or a combination of
many, can save you hours of development and debug
characterises us more
than any singular
piece of work
”
time, leading to more organised code
”
Web Designer finds out what’s going on at
Code and Theory. Page 32
Assets
from Killersites(shop.killervideostore.com)
– 24LuminousPresets and10iPadPro(3G)mockups from
Sparklestock(sparklestock.com)
– Tutorial files andassets
www.filesilo.co.uk/webdesigner
welcome ________________________________________________ 3
Meta
Contributors
about the featured writers and contributors… Senior Art Editor Will Shum
Production Editor James Price
Contributors
Ahmed Abuelgasim, Mark Billen, Leon Brown, Matt Crouch,
Tam Hanna, Christian Heilmann, David Howell, Simon
Jones, Richard Mattka, Steven Roberts, Andy Salter, Mark
³ǝɖǔˢƺƫȒɎɎȒȅً!ƏɀɀǣƳɵáǣǼǼǣƏȅɀ
Photography
James Sheppard
All copyrights and trademarks are recognised and respected
Advertising
Media packs are available on request
Commercial Director Clare Dove
[email protected]
Steven Roberts Advertising Manager Mike Pyatt
[email protected]
Steven is a digital creative 01225 687538
Account Manager Chris Mitchell
from Stockton-on-Tees. He is [email protected]
“animation,
Digital Editions Controller Jason Hudson
While it may seem a limited/lesser tool when it comes to Production Manager Nola Cokely
Management
CSS is actually really powerful and is capable of Brand Director Matthew Pierce
!ǝǣƺǔ!ȒȇɎƺȇɎ ǔˡƬƺȸ Aaron Asadi
4 __________________________________________________experts
Meta
C ntents
Inside issue 282
16 Lightbox
A showcase of inspirational sites and the
techniques used to create them
24 Back issues
Catch up on any issues of Web Designer that
you’ve missed by downloading a digital edition
26 Bon Voyage
Green Chameleon captain a site redesign for
superyacht experience-providers Asaro
32 Decoded Design
Web Designer talks to Code and Theory about
how they work and craft digital landscapes
92 Hosting listings
An extensive list of web hosting companies.
Pick the perfect host for your needs
94 Course listings
Want to start learning? Check out
what courses are out there with this list
98 Next month
What’s in the next issue of Web Designer 16 20
6 ________________________________________________ contents
TUTORIALS FILESILO
42 CSS animation tips & tricks 96 Get the latest must-have
-FBSO UIF ŢJOFS QPJOUT PG $44 BOJNBUJPO BOE resources and videos
how to implement them into a project s /FX DIBQUFST PG FYQFSU 1)1 WJEFP
guides from Killersites
52 Build with CSS Grid s -VNJOPVT QSFTFUT BOE J1BE 1SP
Discover the basics and beyond. Get essential mockups from Sparklestock
tips and techniques for better layouts
42
58 Get blazingly fast CSS
Cut out unnecessary code and slim down your
stylesheets for faster-loading sites
Subscribe
today and
save
https://bit.ly/2sGwB3h
32
contents _________________________________________________ 7
News
CONTACT US AT: [email protected] | @WebDesignerMag
A 32.18%
longside HTML and CSS, these developers come from? The largest wanted to learn. Sitting in second place
JavaScript is the key contributor is the US with nearly 25 per was Vue.js, closely followed by Angular.
technology that is driving cent of respondents, with Australia and One interesting point was that over 46 per Down 3% on the same
forward web development. Germany offering over 5 per cent of cent wanted to learn to use Vue.js while time as last year
It is always moving forward, with new respondents. The UK contributed 3.78 per 33.8 per cent had used Angular but would
frameworks, tools and variations cent. Africa had the fewest respondents, not use it again. The remaining
seemingly making an appearance almost with Libya, Somalia, Angola and frameworks in the top six were Preact,
weekly. While new additions add more Mozambique only having one respondent Ember and Polymer, with around 25 per Apple
power and panache to a designer’s or each. As might be expected, the vast cent of respondents keen to learn Preact
%
developer’s arsenal, the hard part is
deciding which ones you need to be
paying attention to. Who are the big
majority – over 18,000 – of those who
participated in the survey were male.
There were 931 female respondents. A
and Polymer. But what other libraries got a
mention? The two standouts were Svelte
and Aurelia, with jQuery still hanging on in
28.81
Almost identical to the
players? Who are the newcomers to watch representation of how the market stands? there. Looking at back-end frameworks, previous year
out for? Who’s going to be the one that JS developers rarely use a single library Express is way out in front, with nearly 65
pays the big bucks? Choosing the right or framework. Even the popular choices per cent saying they had used it and would
path is not an easy task, so any help have a companion. For example, React again. Next was Next.js with nearly 9 per
newcomers and established developers users also connect with Redux, Express, cent. Looking at mobile and desktop it was Huawei
%
15.45
can get is always welcome. Mocha, Jasmine, Jest and of course ES6. close between Electron and React Native,
The State of JavaScript survey is an So what are the popular front-end with over 50 per cent keen to learn both.
annual report that provides a wealth of frameworks? As might be expected React The State of JavaScript survey is a
information on what developers are using, tops the charts, with 65 per cent using and goldmine of JS-related information, a On the rise, 4% up
on last year
what they’re happy with and what they happy to use it again. It’s not all roses fascinating read and beautifully presented.
want to learn. The latest report surveyed though, as 6.7 per cent had used it and We have only scratched the surface here
over 20,000 developers. So where do all would not use it again. But 19 per cent so look at 2018.stateofjs.com to see in full.
Xiaomi
creativebloq.com
3.78%
A low rise, 2% up
on last year
In-depth tutorials,
expert tips,
cutting-edge
features, industry
interviews, LG
inspiration and
%
opinion. Make
sure to get your
daily dose of e
3.72
Slight downward spiral,
by less than 1%
creativity, design
and development. today and save
40%
Source: http://gs.statcounter.com
(correct as of November 2018)
https://bit.ly/2qLxVl4
8 _____________________________________________________ news
HEAR FROM THE PROS
SIGN UP TO THE
NEWSLETTER TODAY!
DA RY
FRI T EVE
Y
OU
01.
03.
#DE4477
#B57CA5
#A092AC
#8EABAF
10 ____________________________________________ Inspiration
Header
Comment
Keeping up with
the web industry
Web Designer recently caught up with Christian Heilmann at Reasons.to
A
lthough there is definitely value in social media, there is an issue with the
amount of noise it generates. On Twitter, the problem is exacerbated by the
fact that the timeline is not in sync any longer. It’s just a random presentation
of what might be interesting for you, which means you miss a lot. I’ve got
64,000 followers on Twitter, and yet I get all my resources via RSS feeds. I can’t
find much on Twitter because it gets lost in the noise.
The other problem that social media has caused is that instead of learning from each other,
people try to create resources that get the most likes or retweets. We try to shortcut a lot. The
priority is to make a cool headline that will get shared. I’ve blogged since 2005, and my blog posts
are always long. This used to work, but now people just zone out. We’ve become less patient with
learning. We’ve seen too many things come and go, and it feels like the investment in learning is
not worthwhile given the speed of changes in the market.
It’s not all bad, though. There’s a lot of good stuff happening on Slack groups. And, although it’s
not easy to use, I’d recommend trying Mastodon, which is like a more organised Twitter. There are
also a lot of learning resources on GitHub. There are training courses you can take on other
platforms, but GitHub is where people are channelling a lot of their efforts now. It also tends to get
the most edits, so content there is generally up-to-date.
If you want to get started, taking part in open source projects is the best way. Helping with a
typo or a bit of documentation, or making a demo for a product and asking the owner if they want
to have it on the GitHub repo is a great way to get your name known. People publish great things
as open source but often don’t have time to show the implementations or write documentation.
Although these platforms provide a good place for people to get involved in the industry, we
need to work on being more welcoming to newcomers. The web industry is not accepting of
people who don’t speak the right language. People and tutorials hide behind massive terms and
clever-sounding messages. This could be a natural thing. When you’re an expert and you want to
talk to other experts, sooner or later you develop a defined lingo, and that’s fine. But starting with
this lingo and overwhelming newcomers that want to learn something is annoying. People are
repeating the same sentences that they don’t even understand, just trying to fit in with the crowd.
Christian Heilmann Because of this peer pressure, newcomers often don’t dare to speak up when they don’t
christianheilmann.com understand. I love that, as somebody who is in the know, I can do that for them. I interfere and say,
Twitter: @codepo8 “OK, but what does that mean?” I’m happy to pretend (or sometimes be honest) that I don’t know
things, just to be an example for other people so they might find the courage to do the same.
This is a particular problem with new technologies and buzz phrases. People make a lot of
money by saying half-clever things about a technology rather than showing what it can be used
for. Everything is Blockchain right now. 90 per cent of people on the planet can’t explain what
I’m happy to Blockchain is. “We’re using Blockchain for that” – of course. The same way we used ‘the cloud’.
Being on the bleeding edge is interesting, but we’re chasing our own tails a bit and not giving
pretend (or new technologies enough time to mature and become useful. I want to see more products being
created with these technologies. I’m currently working on a W3C proposal for Machine Learning
sometimes be in the browser. It would mean you could do facial recognition, audio recognition and similar ‘AI’
tasks on your own machine, rather than having to send it to Amazon, Google or Microsoft to get it
honest) that I don’t analysed there. That way the privacy of your own data is much more given. There’s an open
standard for the file format but not an open standard for the access to it. That’s something we’re
know things, just to proposing right now, and that’s what I want to see much more of.
be an example for
Everybody sells their current solutions as magic rather than explaining them. I know graffiti
painters who learned how to paint on canvas first because they need to know the craft before
other people they can do the art. They are stunning at what they do as they chose to subvert the original art.
We’re not patient enough right now to learn the ropes before calling ourselves experts.
Comment______________________________________________ 11
webkit Discover the must-try resources that
will make your site a better place
SVG Filters
yoksel.github.io/svg-filters/#
Want to see SVG filters in action without
applying lines and lines of code? Then this
rather neat online tool enables you to add
GaussianBlur to see the filter in action. Like
it? Copy the code and use in your project.
Experiment with the other filters to get the
different filters with a single click. Add look you want.
TOP 5
CODEPENS
Be inspired by this collection of smart
and interesting codebases
12 _____________________________________________ resources
Header
Resources
CONTACT US AT: [email protected] | @WebDesignerMag
resources ______________________________________________13
webkit Discover the must-try resources that
will make your site a better place
sitespeed.io
sitespeed.io
Sitespeed.io is a set of open source tools you
might or might not have heard of that make it
easy to monitor and measure the
helpful instructions on how to install and
which tools to use for what. Only interested
in timing metrics, then use Browsertime.
performance of your website. Includes Want to find issues, use The Coach.
TOP 5
WORDPRESS
THEMES
Need a new page design fast? Then
check out this collection of themes
14 _____________________________________________ resources
Header
Resources
CONTACT US AT: [email protected] | @WebDesignerMag
SoundJS Colorblindly
createjs.com/soundjs https://bit.ly/2DJKa8o
A JavaScript library that helps make working with Accessibility is important, and this Chrome extension
audio “a breeze”. It offers a simple API that abstracts simulates what users with colourblindness will see in
HTML5 sound implementation. the web browser. It offers eight different settings.
Lookback Vyoo
lookback.io veed.io/vyoo
Want to know how people are using your site or app? This is simple. It offers beautiful, free vertical videos,
Of course you do. Do real-time video testing, remote with new ones uploaded every week. Download the
testing and in-person testing. video or edit with Veed.
resources ______________________________________________15
Land Life Company landlifecompany.com
16 ________________________________________________ lightbox
LightBox
Designer:
Qikker Online www.qikkeronline.nl
Based in
Amsterdam
and
operating
across 25
countries,
Land Life
Company’s
mission is to
help reforest
2 billion
hectares of
degraded
land
Colours
#888208 #726959
#D79C62 #DAA90E
Tools
WordPress, PHP, Yahoo UI
(JavaScript), YouTube
Fonts
lightbox_________________________________________________17
Above
Project locations are plotted on a
rollover world map, with key area
hotspots highlighted for viewing
details on click
Far left
Projects can also be viewed in a
more linear layout, stacking a
stream of photos and quotes under
links for quick navigation
Left
Beyond the opening header, a
minimal colour palette is employed
to allow beautiful location
photography to be more impactful
18 ________________________________________________ lightbox
LightBox
g
Land Life Company
Create a cursor-controlled
interactive spotlight effect
A spotlight effect allows users to search and reveal additional parts of background imagery
lightbox________________________________________________ 19
The Adventure of
Detective Moustachio zbeul.studio
20 _______________________________________________ lightbox
LightBox
Designers:
Renaud Rohlinger, Developer Sofiane Hocine, Art Lucas Fiorella, Music
renaudrohlinger.com
More
interactive
experience
than website,
Detective
Moustachio is
a pixelated,
side-scrolling
platform
game
optimised for
desktop and
mobile
Colours
#E67F46 #571874
#1DB5FD #FD0481
Tools
GSAP, core-js, Babel,
Amazon AWS
Fonts
lightbox_________________________________________________21
Top
A skippable 'cut scene' intro
presents what this HTML5 version
of the game has in store for
Detective Moustachio
Left
Essentially an auto-run platform
game, player controls are kept
simple on all devices, despite some
clever upside-down physics at times
Above
The select level menu tracks
progress, showing special coins
collected and also enabling players
to plot their own path
22________________________________________________ lightbox
LightBox
g
The Adventure of Detective Moustachio
1. Initiate the document enables any child elements to be placed in relation to display: block;
The first step is to define the HTML document – i.e. the their position, along with height and width properties position: absolute;
webpage. This consists of the HTML document container, becoming available. These are all required for the top: 0;
which stores the head and body sections. The head animation defined in step 7. left: 0;
section is used to load the external CSS file, and the body .blipbox{ background: rgba(0,0,0,.5);
is used to store the webpage content created in step 2. display: inline-block; width: 100%;
<!DOCTYPE html> position: relative; height: 100%;
<html> } opacity: 0;
<head> }
<title>Blip Animation</title> 5. Blip hover
<link rel="stylesheet" type="text/css" A style rule is required to trigger an animation to 7. Blip animation
href="styles.css" /> elements using the 'blipbox' class whenever they are The animation is required to move the 'after' element
</head> hovered over by the mouse cursor. This animation is from the top left corner to slightly behind the top left
<body> applied to a virtual 'after' element, hence the use of the corner while increasing its size. This provides the effect of
*** STEP 2 HERE 'hover' and 'after' CSS selectors. The animation attribute the element increasing its size over the element. Another
</body> specifies the name of the @keyframes animation and the part of the blip effect is how the animation changes the
</html> duration to play it. . opacity from fully visible to invisible.
.blipbox:hover::after{ @keyframes blipAnim{
2. Page content animation: blipAnim .7s; from{
The page content consists of an article and two } top: 0;
containers. The effect can be applied to any element left: 0;
using the 'blipbox' class. Images act in a way that stops 6. Overlay styling opacity: 1;
the blip effect, and this example wraps each image inside The default settings of the 'blipbox' overlay are created }
a span element so the blip effect can work with images. using the CSS 'after' virtual element – as also referenced to{
<article class="blipbox"> in step 5. This element is required to have default settings opacity: 0;
<h1>Hello</h1> to define the starting state of the animation. It will cover top: -10%;
</article> the full area of the element, with semi-transparent black left: -10%;
<span class="blipbox"><img src="img/photo1. background. Opacity is set to zero in order to hide the width: 120%;
jpg" /></span> element until the animation is triggered from step 5. height: 120%;
<span class="blipbox"><img src="img/photo2. .blipbox::after{ }
jpg" /></span> content: ""; }
3. CSS: article
The example article is set to cover half of the vertical
display space, with margin settings set to guarantee it to
be centrally positioned. The styling for this element is
separate and independent from the blip effect, although
it is required to show how the effect would work with a
content container element.
article{
display: block !important;
margin: 2em auto 2em auto;
border: 1mm solid #000;
padding: 1em;
width: 50%;
clear: both;
}
4. Blipbox definition
Elements using the 'blipbox' class are required to display
as inline-block elements using relative positioning. This
lightbox________________________________________________ 23
NEVER MISS AN ISSUE!
Issue 280
30 best HTML, CSS and JS APIs and
elements, research your keywords,
interactive JS charts and What is the
Web of Things?
SAVE UP
Issue 281 TO 43% Issue 275
Design, develop and create with
top Google tools, add glitch WITH A DIGITAL 50 must-try tools for designers and
SUBSCRIPTION
developers, how to add awesome
effects with CSS, animate with audio, Progressive Web Apps and
https://apple.co/1hsGYgl
CATCH UP ON ANY ISSUES YOU’VE MISSED BY DOWNLOADING
OUR DIGITAL EDITIONS https://bit.ly/2rh73Xk
Issue 279
Pro tips to build animation for the
Issue 278
What’s new in JavaScript, say hello
Issue 277
Hot new CSS properties for today,
Issue 276
Build your own augmented reality
web, 23 ways to make your app to Google Flutter, build with CSS build interactive 3D, streamline your app, get started with Three.js,
shine, work with variable fonts and Grid, work with WebRTC and create design workflow with Sketch and power up with Sass and Stylus and
what’s new in Node 10 patterns with CSS code a real-time React app generate web components
Issue 274
The new rules and top tools for UX,
Issue 273
SEO Today, 20 hot new libraries and
Issue 272
Build with Web Components,
Issue 271
28-page design special. Create the
5 hot new CSS properties, use the frameworks, ten pages of ReactJS 8 WordPress security secrets, perfect colour palette, top type
CSS Paint API, add particle effects tutorials, get started with Rust and Web Accessibility, convert visitors to trends, design and build grid layouts
and discover JSX build a WebGL racing game customers and data visualisations and automate your workflow
https://tinyurl.com/yalm3wul https://bit.ly/2xPbv4p
26__________________________________________design diary
SUPERYACHT EXPERIENCE-PROVIDERS ASARO CHOSE GREEN CHAMELEON TO
CAPTAIN A WEBSITE REDESIGN THAT WOULDN’T LEAVE GUESTS ALL AT SEA
f you mused on the virtues of professional web design today, a big attraction must
ASARO be variety. Because the internet and digital is now so vital and so ubiquitous in
asaro.co.uk marketing, businesses and organisations of all conceivable kinds require quality
websites. Take, for instance, a company that creates luxury immersive experiences
by
on superyachts and megayachts – Asaro. This company designs and delivers
Green Chameleon bespoke, immersive theatrical experiences on an unimaginable scale all around the world.
So when a client like that seeks out an online revamp, whoever answers the SOS call is in
craftedby c.com for a pretty diverse ride.
In this instance, the agency it reached out to is well-known within Web Designer pages
Project duration for adapting to any project environment. Bristol-based Green Chameleon is a creative
4 months production studio that specialises in crafting extraordinary brand experiences that stand
out, not blend in. Founded in 2012, this agency comprises a growing ‘crew’ of 13 talented
designers, animators, developers, videographers and account managers. “We were
People involved approached by Asaro to redesign their website and help them better reflect their position
within the seven-star luxury world,” recalls GC’s Design Director Nathan Riley. “They
Nathan Riley needed a creative way to visually represent their exclusive service offering, as
Design Director
photography was scarce due to the private nature of their events.”
Asaro’s audiences would be the captains, crew and owners of these immense vessels, as
Tom Anderson well as the guests who commission and enjoy the events they organise. So in order to
Creative Director speak their language while being discreet, the designers employed custom CGI renders,
created to represent the client’s event genres. “Inspired by water drop photography, we set
Dan Linthwaite out to create a striking and memorable aesthetic that embodied the spirit of each event
Art Director and encapsulates the mystery and adventure weaved into all of Asaro’s offerings.”
Jack Harvatt
Designer
Jake Whiteley
Senior Back-end Developer
Jesper Landberg
Front-end Developer (Twotwentytwo)
28__________________________________________design diary
BON VOYAGE
30 _________________________________________design diary
BON VOYAGE
of thumb, the GC developers used plugins and two parties. The finishing line would arrive in the
third-party code as little as possible, preferring to form of the Monaco Yacht Show, an exclusive
build purpose-driven solutions in-house. event for superyacht owners, charterers and
decision-makers in the yachting and luxury
JQUERY MAROONED industries. The client, Asaro, was naturally
“With Asaro being so JavaScript heavy, this led attending the show, with a view to launch their
us to completely drop jQuery for the project, exciting new rebrand.
which threw a lot of traditional WordPress form “The main challenge was ensuring that
solutions out the window,” begins Senior everything, from the business cards to the
Back-end Developer Jake Whiteley. “We used printed brochure, and most importantly the
the popular Axios library to handle the form website, were all finalised and perfectly polished
submission, along with our custom framework in time for the show,” says Tom Anderson. “Plus,
to implement Laravel-like request validation on remember that the emphasis on the website’s
the backend.” This decision to throw jQuery speed and performance was even greater in the
overboard would actually prove to be very instance of this project because we were
popular with the developers, becoming a tactic constrained by the 3G or 4G connections at sea.
they intend to actively pursue on future projects. With the majority of the target audience being
Keen to be as agile as possible, the GC coders captains of superyachts, we had to ensure the
also tried to keep back and front-end site’s load speeds were fast and optimised for
development happening in parallel. “Working in mobile and tablet viewing, as well as desktop.”
parallel enables us to respond to site structure Similarly, it was never going to be a case of
and content changes as quickly as possible, and just pushing the finished site out into the ocean
works well with our interaction design process. of the world wide web. As part of such a
Plus the transference of ideas from our shipshape relationship, there was a commitment
designers’ heads into working animations can to keep the thing afloat after setting sail. “Along
involve a lot of fine-tuning, and parallel with managing the hosting of the Asaro website,
development ensures that progress is being we’re also on hand for any additions or
made, regardless of any blockers. With Asaro maintenance that our designers or developers
having such a tight turnaround time, this meant are required to provide support with,” Nathan
front-loading the back-end efforts to ensure that concludes. “The site was built on WordPress and
the site content structure was in place before so the majority of content is editable, which
the main bulk of work started.” purposefully gives the client full control for
future developments. However, we encourage
FIT FOR LAUNCH an ongoing relationship with all our clients and
Such a strategy was of course pivotal given the have already begun discussing with the Asaro
tight four-month deadline agreed between the people about what’s on the horizon next!”
WHO
Code and Theory
WHAT
interactive products,
campaigns, advertising,
branded experiences,
design, branding, user
experience, interface
design, graphic design,
strategy, engineering,
product UI, website
design and development,
motion graphics, rich
media, and social media
WHERE
1 World Trade Center,
62nd Floor, New York,
NY 10007
WEB
www.codeandtheory.com
KEY CLIENTS
[1] adidas
[2] Comcast
[3] NBC
[4] Nasdaq
32 ___________________________________________________profile
DESIGN
With extensive experience in crafting digital landscapes, Code
and Theory defines the relationship brands have with their
customers across multiple channels. Connecting design and
technology, Code and Theory creates user experiences that
reinvent how companies can digitally transform
The Code and
Theory team
admiring the
inspirational view
from their New
York offices
an Gardner, the CEO of Code and additional offices in San Francisco, London
profile___________________________________________________ 33
D e co d e d D e s ig n
Keisha Brescia (COO, PMX Agency), Larry Muller (Chief Operating Officer),
Naomi Soviecke (Financial Operations Manager), Naren Persaud (Financial
Controller), Jonathan Chan (PMX) (Controller) and two other colleagues
from PMX thrash out a new proposal
informative site: “It’s what guides the first work just for the sake of new business. That
impression when someone is looking into us, so being said, we’ve been extremely fortunate to
we think it’s very important. Not only is the work with clients who trust us with work that
website a window into our agency, employees, has allowed us to challenge and expand our
culture, work and clients, but we also receive a core capabilities, and we’ve been able to hire
lot of inquiries on our site from prospective into those new projects.
clients, job candidates and press. Truthfully, we “We like to think of ourselves as ambitious,
spend so much more time on our clients’ work since we do aim pretty high. Not to say we
and their websites than we do our own, but I won’t ever take on smaller projects, but they
don’t think that’s unique to a company like are usually a stepping stone into a larger
ours, where we put our heart and soul into our engagement or, more often than not, a project
“ Built upon a history of using clients’ initiatives and strive for continuous or challenge we feel very passionate about.”
digital as the catalyst for larger improvement. That said, we have been working Passion coupled with a deep understanding
organisational change, the projects to overhaul our site and hope to launch a new of today’s digital communications channels
that enable us to take on thought- one soon.” means Code and Theory has been able to forge
As an established agency, Code and Theory a reputation as not only technical experts but
provoking questions that engage
has been able to use its reputation across the also a group of like-minded individuals that
the development of our capabilities marketplace to enjoy a steady stream of clients. shape the digital landscapes we all traverse
are the ones that define who we “We’re fortunate enough to have built a very every day.
are. The types of work we have put good reputation in the industry over the years, Dan explains their typical approach to each
out are intentionally very broad so we receive a lot of referrals from current or unique account they work on: “As a digital-first
across verticals and expressions. former clients as well as inbound inquiries on creative agency, we help our clients across the
We believe that broadness our site,” says Dan. “Additionally, we proactively board to drive change and thrive in a time of
characterises us more than any identify verticals, clients, and most importantly digital disruption – so there really isn’t one
new challenges that we want to work with, as project that encompasses who we are as a
singular piece of work ” well as participate in RFPs (requests for company. Built upon a history of using digital
Dan Gardner proposals) and pitches.” as the catalyst for larger organisational change,
CEO and co-founder With a diverse portfolio of work and clients, the projects that enable us to take on thought-
Code and Theory has been able to choose provoking questions that engage the
which clients they work with. The selection development of our capabilities are the ones
process is detailed, involving a deep dive into that define who we are. The types of work we
the client’s needs in order to understand how have put out are intentionally very broad
the project benefits both the potential client across verticals and expressions. We believe
and Code and Theory. that broadness characterises us more than any
“Typically, we’re very selective to ensure that singular piece of work.”
the relationship with the client is a true fit and As no two accounts are the same, Code and
that we genuinely connect with the company Theory is nothing if not flexible in its approach
and the work,” explains Michael. “We are also to each commission it takes on. David DiCamillo
very realistic about our capabilities and (Partner, Operations) explains how they
resources, so we won’t take on any piece of manage a varied portfolio of clients: “Timelines
34___________________________________________________profile
D e co d e d D e s ig n
NBC NEWS
today.com
profile___________________________________________________ 35
D e co d e d D e s ig n
XFINITY MOBILE
delivered an integrated customer journey
xfinity.com/mobile
When Comcast wanted to enter the fiercely would address challenges related to reflected by the customer and independent
competitive mobile provider market, they in-home activation, custom order logistics, feedback, the final design, experience and
asked Code and Theory to define, design procedural implementation of technology brand integrity scored high marks. The
and develop their mobile offering. They and evolving mobile standards. Solving unboxing experience itself was met with the
needed substantial support – from refining these issues required that essential highest customer acceptance response
the vision and product concepts, information was supplied at efficient across the entire brand journey.
establishing key value propositions and instances, metered through employing an This partnership with Comcast extended
unique selling propositions to deal with the elegantly simple, yet remarkably flexible to nearly every touchpoint for Xfinity
competition and overcome negative unboxing experience. Mobile, defining an end-to-end consumer
marketplace perceptions. In between online order placement and journey. Code and Theory designed and
Xfinity mobile’s e-commerce model successful activation lie a series of logistical developed the complete mobile-first
necessitated the creation of an alternative and user-dependent steps that must be experience and created a packaging system
product experience to contend with those correctly completed. Not only does this based on the unique footprint of the phones
employed by its retail competitors. A process require itself to be concrete, but the themselves – including a special edition for
personalised solution was needed that brand experience must also follow suit. As the first 20,000 customers.
36___________________________________________________profile
D e co d e d D e s ig n
2001
Dan Gardner and Brandon Ralph found Code
and Theory.
Employees: 2
2002
Code and Theory develops the first-ever Flash
Player website, for Sony Classical, and create the
first Flash videos for Sony Music, setting off years
of Flash video being the dominant way to consume
online video.
Employees: 3
2006
Code and Theory opens its San Francisco office,
brings one of the first large-scale content
catalogues online for Charlie Rose and launches
the largest online live streaming events in history
at the time for Dr. Pepper.
Employees: 15
2007
The vertigo-inducing Working beyond digital, Code and Theory launches
view from the Code an animation series in partnership with McCann
and Theory offices in Erickson for the Subway.
New York Employees: 15
2008
and process vary greatly depending on the prototype in InVision or Principle based on the Launch of The Daily Beast , bringing together core
scope of a project. However, every single one of fidelity of the prototype that we need to create. strengths – advertising and content delivery – to
our projects is structured around a tight and Sketch actually slowly worked its way into our execute the vision of Tina Brown and Barry Diller to
dedicated interdisciplinary team we call ‘Pods’. design process a few years ago, after putting it reimagine online news and advertising.
Employees: 15
“The Pods consist of, but are not limited to, through a lot of testing. There was a kind of
skills such as Creative Strategy, Production, breaking point with Sketch through one
Content Strategy, Experience Strategy, particular software update in which almost 2012
Interaction Design, Visual Design, Data/ everything we were waiting for was Mashable: first-ever page-to-page continuous
scroll on (‘The Transporter module’) launches,
Analytics and Technology. When the project implemented all at once, so we immediately
which is now standard behaviour on most
requires additional scale or speciality outside switched over to Sketch. publishing platforms (a world first).
the Pod, we add Flex Resources based on the “Prior to Sketch, we were using Photoshop or Employees: 15
requirements of the project phase. Within a InDesign for our responsive design work, which
Pod, we designate someone as the Directly sometimes caused friction between projects 2013
Responsible Individual (DRI) to help drive and designer taste. Both Photoshop and Code and Theory establishes its Industrial Design
leadership and vision across the team to InDesign did the job just fine, but neither were practice, the first digital-first agency to move into
prevent ‘design by committee’ decision- truly built for modern digital design needs. physical hardware design.
making, as well as ensure accountability for There was a grey area missing in the tools we Employees: 15
project success.” were in need of that Sketch filled for us. There
David concludes: “Depending on the scale are a number of reasons why we are sticking 2014
and complexity of a project, the time- with Sketch, but what stands out the most is Launches its first 23 magazine solution (Hearst:
consuming part can vary. Sometimes that is how much more productive we have become Cosmo, Esquire , Elle , Good Housekeeping , etc.).
more in the strategic upfront to identify or as a team since using it. It has greatly Launches the first Olympics site for the Sochi
Winter Games (NBC). Launches latimes.com, at
solve the problem, or sometimes it could be in streamlined designing across platforms, to the time the largest fully responsive news site in
the technology if there is some complexity or exporting assets, to working faster with the world.
scale in the digital expression of the solution. developers. Unlike the Adobe suite of products, Employees: 15
Most importantly, we don’t let process dictate Sketch was built specifically for what we do in
an outcome to get to success – we use process the product design space.” 2015
as a facilitator to success.” Chris concludes: “We have also done away Code and Theory is named one of Fast Company’s
As an agency that creates digital with the time-consuming style guide process. 10 Most Innovative Companies in Design for work
communication assets that both fulfil their which used to eat up a lot of time and money, creating publishing platforms. Code and Theory
client briefs and also advance the digital by adopting Zeplin app into our process, which acquires Mediacurrent.
Employees: 15
environment, Code and Theory has a varied has cut the style guide production time down
toolset it wields with absolute confidence, as by 90 per cent. For content creation, we will
Chris Delia (Group Creative Director) explains to use the Adobe suite. This is anything from 2018
Web Designer: “Our product design work is photo composites, touch-ups, GIF creation, Code and Theory moves its NY HQ to 1 WTC
Employees: 310
strictly done in the Sketch app, while we video effects, etc. For 3D we use Cinema 4D
profile___________________________________________________ 37
D e co d e d D e s ig n
3
4X
X
2XC
9XC
L
S
I
O
IN
E
ESS DEVE
O
T
T SERV EGY
ENT S
P YWR
TRAT
ICES
ITIN
LOPMEN
29
N
TIV
ES browser environment, but they also have to
TR
AT
EG
account for more elaborate rules and flows.
Y “JavaScript is evolving quickly to be on par
with these expectations: ES6 is introducing
10 X
DATA advanced notions, such as collections,
AGENCY
, ANA
LYTIC promises, advanced inheritance, etc. that bring
S, RE
SEAR
CH it closer to more traditional languages. This is
8 X EXPE
RIENCE S all meant to allow for more complex
BREAKDOWN
TRATEGY
experiences, which in turn means that these
technologies will be more prevalent in the
future. Frameworks such as AngularJS and
74XTECHNOLOGY
17 X FINANCE React are already used by most major sites, in
order to capture data from different sources
and render the right experience for the user.
ESIG
N Others, such as Three.js or D3.js, help
4 X HR IAL D
DUS T R developers create visually engaging
PLUS 70 EMPLOYEES AT 2 X IN
MEDIACURRENT, WHOLLY OWNED DES
IGN experiences with advanced visual effects.”
N
SUBSIDIARY AGENCY FOCUSED ON TIO AC Mobile digital devices have clearly had a
TER
OPEN SOURCE (DRUPAL) X IN
19 profound impact on digital communications.
T
EN
T
EN
NCE
AL
IT
EM
RE OU
EG
2X
URA
3 X RES
ASS
MA
DUCTION
38___________________________________________________profile
D e co d e d D e s ig n
profile___________________________________________________39
CSS Conic gradients
animation
6 0 fp s
int API
CSS Pa
B E C O MEA
sso r
roce
prep
NEED TO
CSS Layo
OOCSS, ACSS, SMACSS or BEM?
u t API
ms interview
y Willia
ssid
CSS
Ca
Tra
nsform
s
U
les
40 _________________________________________________feature
O
Com
A
f
key
bi n
CSS
e me
tho
CSS Clip path
dolog ies
ans i t ions Grid &
r
C SS t ac
ces
sibil
ity
ate -rows
m p l
What’s inside?
-te
grid St
ory
bo a r
ding
42 CSS animation
me
c u to u
lay 52 Build with CSS Grid
preprocessor Sass
76 Cutting-edge CSS
i m
feature _________________________________________________ 41
CSS ANIMATION
42__________________________________________________feature
CSS ANIMATION
USE PERCENTAGES TO
REPRESENT PROGRESS
Percentages when used to represent
progress are a great place to use animation.
Watching a bar or shape fill up is rewarding;
visually representing a user’s goal can
subtly encourage them to complete it.
---------------------------------------------------------------
feature _________________________________________________ 43
CSS ANIMATION
CSS TRANSITIONS
CSS transitions can be used to achieve a number of animated
effects, from a simple colour change to more complex transitions
Upon hover the colour changes The menu items light up The middle icon changes colour The triangular corner is animated
44 _________________________________________________feature
CSS ANIMATION
CSS KEYFRAMES
CSS keyframes are used for complex or repeatable animations
feature _________________________________________________45
CSS ANIMATION
ANIMATION PERFORMANCE
Animating too much or too many properties will cause animations to stutter
46 _________________________________________________feature
CSS ANIMATION
ANIMATING SVG
SVG enables us to create intricate drawings and images, where all of the elements
inside SVG are also animatable using CSS
feature _________________________________________________ 47
CSS ANIMATION
1 2
The initial state of the animation, with the arm placed off the record The first thing that happens is the arm moves into position over the
and the record not moving record, and halfway through this animation the record begins to spin
3 4
Once our arm is in position and the record has rotated slowly once, we When the user stops interacting the record spins backwards slowly and
then spin the record faster, infinitely the arm moves back to its original position
We’ll be creating a record player animation OPTIMISE OUR SVG transform-origin: -1px 11px;
where the arm of the record player moves When we have the exported code from our }
into position over the record, as well as editor we need to optimise that code to #record-container {
rotating the record itself at two different make it easier for us when creating our transform: translate(7px, 0)
speeds. We’ll create the animation using animation. Firstly we’ll run it through rotate(0deg);
SVG transitions and keyframes, and we’ll be SVGOMG (jakearchibald.github.io/ transform-origin: 24px 24px;
using custom properties in order to make svgomg) making sure to only optimise the }
our animation configurable. parts we need. Once we’ve done this we’ll #record {
paste our code into CodePen and create transform: rotate(0deg);
CREATE AND EXPORT OUR SVG some basic page styles. We’ll be using Sass transform-origin: 24px 24px;
The first step is to create and export our to take advantage of the nesting capability. }
SVG code. You can do this using many https://bit.ly/2PZVbd6 https://bit.ly/2r7alya
different graphics editors (the example is
Sketch for Mac). The shapes being used are -------------------------------------------------------------- --------------------------------------------------------------
simple – mostly straight and poly lines
combined with circles. We want to create EDIT BY HAND ANIMATE THE ARM
the SVG in the initial state of our animation. Next we will need to edit our SVG by hand. We can achieve most of what we are trying
We are going to need to remove any inline to do using transitions. We will start with
transforms on elements that we are going the record arm and animating the arm into
to animate into our CSS. Doing this will position over the record. To do this we will
make it easier to animate, because we’ll be need to rotate the arm of the record from
able to see all of our transform properties in ‘-90deg’ to ‘0deg’. In order to transition
one place. rotation we need to use the transform
#arm-top { property. This means we also need to keep
transform: translate(9.5px, 3px) any other transform properties the same
-------------------------------------------------------------- rotate(-90deg); when changing the rotation.
48 _________________________________________________feature
CSS ANIMATION
1s 500ms linear;
transition: transform We can do this by setting our custom
properties on the root element in our CSS. TWITTER ACCOUNTS
}
}
:root {
5 TO FOLLOW
https://bit.ly/2Rcpw4r --background-color: #2A2A2A;
--record-colour: white;
SARAH DRASNER
-------------------------------------------------------------- --record-size: 12rem;
} @sarah_edo
SPEED UP THE ROTATION Sarah is the author of the O’Reilly book
In order to speed up the rotation, and for it We can then apply them to the property SVG Animations .
to repeat infinitely, we’ll need to use a values where needed, making sure to
keyframe animation. The animation we need provide a fallback for each one. RACHEL NABORS
to create is simple, we just need to rotate .container {
@rachelnabors
the record 360 degrees. max-width: var(--record-size, 15rem);
@keyframes rotate-record { max-height: calc(var(--record-size,
Interactive storyteller, cartoonist and
to 15rem) * 1.166); author of Animation at Work .
{ ...
transform: rotate(360deg); } VAL HEAD
} @vlh
} We can also use custom properties as part Author of Designing Interface Animation
Then when we’re applying our animation, of ‘calc()’ functions, which is particularly
and curator for ‘UI Animation Newsletter.
we need to make sure to set the delay useful for sizing and for creating durations
correctly so our animation starts at the end and delays.
of the container stopping. LISI LINHAR
#record-svg:hover, #record-svg:active, @lisi_linhart
#record-svg:focus She is passionate about web animation
{ and talks about ‘Practical Web Animation’.
#record {
animation: 400ms linear
CODEPEN
1250ms infinite rotate-record;
}
@CodePen
} Tweets great examples of animation that
https://bit.ly/2zsKhCe https://bit.ly/2zq9xck have the code for you to learn from.
feature _________________________________________________49
The perfect gift
*
from just £24.99
PLUS
FREE
KITSOUND
RACE
WIRELESS
EARPHONES
WORTH
£14.99
SU J y 6
O e
M ver
B US m o
SC T nt
R £2hs*
IB 4
Reasons
E .9
to subscribe
9*
Saving up to 41%
against the shop price
Never miss an issue
Free delivery to
your door
The gift that keeps
delivering
Upgrade to
include digital
for only £5
Increase your
saving to 63%
SEE THE
FULL RANGE AND
ORDER ONLINE AT
www.myfavouritemagazines.co.uk/pin/xmas182
Call UK 0344 848 2852 or overseasגגڷ٨٩ۭאדזאזגזגגבquote xmas182
*Terms and conditions: Savings calculated against the full RRP (single issue price x frequency). You can write to us or call us to cancel your subscription within 14 days of purchase.
Gift is only available for new UK subscribers. Gift is subject to availability. Please allow up to 60 days for the delivery of your gift. In the event of stocks being exhausted we reserve the right
ɎȒȸƺȵǼƏƬƺɯǣɎǝǣɎƺȅɀȒǔɀǣȅǣǼƏȸɮƏǼɖƺِçȒɖȸɀɖƫɀƬȸǣȵɎǣȒȇǣɀǔȒȸɎǝƺȅǣȇǣȅɖȅɎƺȸȅɀȵƺƬǣˡƺƳƏȇƳɯǣǼǼƺɴȵǣȸƺƏɎɎǝƺƺȇƳȒǔɎǝƺƬɖȸȸƺȇɎɎƺȸȅِ¨ƏɵȅƺȇɎǣɀȇȒȇٮȸƺǔɖȇƳƏƫǼƺƏǔɎƺȸɎǝƺגƳƏɵ
ƬƏȇƬƺǼǼƏɎǣȒȇȵƺȸǣȒƳɖȇǼƺɀɀƺɴƬƺȵɎǣȒȇƏǼƬǣȸƬɖȅɀɎƏȇƬƺɀƏȵȵǼɵِçȒɖȸɀɎƏɎɖɎȒȸɵȸǣǕǝɎɀƏȸƺȇȒɎƏǔǔƺƬɎƺƳِǼǼǕǣǔɎɀɖƫɀƬȸǣȵɎǣȒȇɀɯǣǼǼɀɎƏȸɎɯǣɎǝɎǝƺˡȸɀɎǣɀɀɖƺǣȇhƏȇɖƏȸɵ¨ِחאȸǣƬƺɀƬȒȸȸƺƬɎƏɎȵȒǣȇɎ
ȒǔȵȸǣȇɎƏȇƳɀɖƫǴƺƬɎɎȒƬǝƏȇǕƺِIɖǼǼƳƺɎƏǣǼɀȒǔɎǝƺ(ǣȸƺƬɎ(ƺƫǣɎǕɖƏȸƏȇɎƺƺƏȸƺƏɮƏǣǼƏƫǼƺȒȇȸƺȷɖƺɀɎِIȒȸǔɖǼǼɎƺȸȅƏȇƳƬȒȇƳǣɎǣȒȇɀȵǼƺƏɀƺɮǣɀǣɎيƫǣɎِǼɵٖȅƏǕɎƏȇƳƬِ ǔǔƺȸƺȇƳɀבɀɎ(ƺƬƺȅƫƺȸِזא
CSS GRID ENABLES YOU TO DEFINE ADVANCED CONTENT LAYOUT FOR
RESPONSIVE DESIGN WITHOUT THE COMPLICATED FORMATTING
52 __________________________________________________feature
CSS Grid
BROWSER SUPPORT
An example of this would be
MODERN FEATURES FOR using a vertical one-
MODERN BROWSERS dimensional layout for
small-screen devices, and
using a two-dimensional
layout for view on big screens,
Grid and flexbox were not 1 2 3 4 5 such as a desktop. Flexbox
1
always part of the CSS does not offer the ability to
specification, meaning that adapt for this requirement,
there is no support in older Item
whereas grid does.
browsers. All of the major Both flexbox and grid are
browsers have supported the 2 compatible with the content
full grid specification since ordering feature, so changing
2017. The main concern for from flexbox to grid should
Subitem
compatibility are Microsoft not be a significant problem if
browsers (IE and Edge), which it's required.
3
have high usage in businesses. Make sure that you keep
They introduced limited styling in a stylesheet
support in Internet Explorer separate from the main HTML
10, but full support has only content if you want to
been available since Edge 16. maximise maintainability.
feature _________________________________________________ 53
ESSENTIAL CREATE A QUICK BASIC GRID
Examples of using CSS Grid to create a series of simple layouts
PROPERTIES
THE PROPERTIES YOU NEED TO KNOW
FOR CREATING GRID-BASED LAYOUTS 1. HTML CONTENT
To start, link the external CSS file, e.g. <link
rel="stylesheet" type="text/css" href="1.css" />.
Everything CSS Grid goes in the <body>. Three
GRID-AUTO-FLOW sections are defined – one for each example
Enables you to define the flow grid. The data-grid attribute is used to provide
of grid cell layout using each section with a unique reference value that
horizontal 'column' or vertical can be used by the CSS. Each child element of
'row', making the grid act the grid will be become a cell of the grid.
similar to a table. <section data-grid="1"> 3
<div>1</div>
GRID-GAP <div>2</div> available space, so the middle column will be
Apply this to the grid <div>3</div> three times wider than the outer columns.
container to set spacing </section> [data-grid="1"] {
between each grid cell. The background: red;
default sets no spacing <section data-grid="2"> grid-template-columns: 1fr 3fr 1fr;
between cells. <div>1</div> }
<div>2</div> ---------------------------------------------------------------
GRID-COLUMN <div>3</div>
Sets the specific column to </section> 4. VERTICAL ROWS
place the grid cell. Use this to The second grid is set to display with a vertical
target specific cells via class, <section data-grid="3"> cell flow. As this is not the default flow for grid
ID or selector. <div>1</div> cells, the grid-auto-flow attribute is set to 'row'.
<div>2</div> The same approach is used to define the height
GRID-ROW <div>3</div> of each row, using the fr unit measurement.
Sets row location to place the <div>4</div> [data-grid="2"] {
grid cell. Use this to reference <div>5</div> background: green;
specific cells via class, ID or </section> grid-auto-flow: row;
selector. --------------------------------------------------------------- grid-template-rows: 1fr 3fr 1fr;
}
GRID-AREA 2. CSS GRID DEFINITION ---------------------------------------------------------------
Defines the grid area for a cell Create a file called '1.css'. This step sets
to cover using co-ordinates in formatting to be shared by all elements using 5. MIXED GRID
the format startX/startY/endX/ the 'data-grid' attribute. Display is set as grid to The final grid is presented with a layout allowing
endY or a cell reference name. make their first-level children act as the cells of for both vertical and horizontal content. Auto
the grid. Default background colour and text flow is set to 'column', setting the cells to flow
GRID-TEMPLATE-AREAS alignment for these grid cells are also set. horizontally. The first cell is set to span over two
A more advanced method for [data-grid]{ grid rows, guaranteeing the cells to flow
defining the grid layout using display: grid; horizontally over two rows.
grid-area reference names margin-top: 2em; [data-grid="3"] {
given to the created content padding: 1em; background: blue;
cells. grid-gap: 1em; grid-auto-flow: column;
} }
GRID-TEMPLATE-ROWS [data-grid="3"] > *:first-child{
Used to specify [data-grid] > * { grid-row: span 2;
measurements for individual background-color: #fff; }
rows within the design of the text-align: center;
grid layout. border: 1px solid #000;
}
GRID-TEMPLATE-COLUMNS ---------------------------------------------------------------
Similar to grid-template-rows,
but used to specify 3. HORIZONTAL COLUMNS
measurements for individual The columns template for grid 1 is set to contain
columns within the design of three cells. Measurements for the cells use the
the grid layout. fr unit to describe their width as a fraction of the
CSS Grid
2. GRID HTML
The grid must be defined in a way that will allow menu content content side
its container and child cells to be referenced by
CSS. This example uses semantic tags that have
a unique name for each content area, although menu footer footer footer
you could decide to use class names, data
attributes or IDs as an alternative.
<article> “menu footer footer footer”;
<section>Content</section> } MEASUREMENT
PROPERTIES
<header>Header</header> ---------------------------------------------------------------
<aside>Side</aside>
<footer>Footer</footer> 5. CONTAINER FORMATTING AND ATTRIBUTES
<nav>Menu</nav> With the grid layout now in place, the next step
</article> is to define additional presentation for the grid. The grid feature offers many ways to define
--------------------------------------------------------------- This step sets the grid container’s colours, along measurements for its cells, enabling you to
with the maximum width and minimum height. define both fixed and responsive layouts
3. CSS: REFERENCE NAMES Some padding is also added to enable the grid
Create a new file called '2.css'. This step to have a surrounding border space.
references each of the content elements inside article { FR
the article container and uses the grid-area max-width: 25em; The fr measurement unit specifies the
attribute to provide a unique reference name. min-height: 20em; width or height of a grid cell as a fraction of
This reference name will be used in the next step background-color: #333; the remaining space.
when defining the layout template for the grid. color: #444;
--------------------------------------------------------------- padding: 1em;
font-size: 150%; SPAN
article > aside { grid-area: side; } } Sets the width or height of a cell to cover
article > nav { grid-area: menu; } --------------------------------------------------------------- more than one cell space within the
article > section { grid-area: content; } defined grid template.
article > header { grid-area: header; } 6. CELL FORMATTING
article > footer { grid-area: footer; } The final step is to set the formatting of the grid
--------------------------------------------------------------- cells. This tutorial sets colours for the text and REPEAT
background, but you can add other CSS Used as shorthand to repeat the same
4. GRID SETUP presentation attributes to meet your width or height definition across multiple
The article in the HTML is used as the grid requirements. No new rules or limitations apply cells within the grid template.
container. The grid-template-areas attribute to grid cells, meaning you are still able to use
defines the layout of the grid using the grid-area your existing knowledge of CSS.
reference names identified in step 3. The setup article > *{ MINMAX
works like cells within a spreadsheet, where background: #fff; Allows you to define the minimum and
names that are vertically or horizontally adjacent color: #000; maximum height or width of a grid cell;
create one grid cell area. } useful for controlling responsive layouts.
article {
display: grid; header 6
grid-gap: .5em; PX / CM / MM / EM
grid-template-areas: Fixed unit measurements can be used in
“menu header header header” menu content side combination with fr, which results in
“menu content content side” fractional spaces being measured from the
“menu content content side” remaining space.
footer
“menu content content side”
feature _________________________________________________ 55
CSS Grid
WHAT ELSE DO I NEED TO KNOW? Six tips to get more from CSS Grid
1. LAYERING 5. CONTENT ORDERING
The z-index attribute can be applied to Grid allows you to order content independently
individual grid cells to allow them to be layered from the HTML definition, enabling you to
above or below other grid cells. optimise HTML for SEO while also providing
control for responsive design.
2. ALTERNATIVE LAYOUTS 5
Make use of CSS media queries to modify or 6. MAINTAINABILITY
redefine grid definitions for different screen sizes Use the grid flow attributes to allow future
or media types. adaptions of the HTML to automatically adapt 1 2
the grid without needing to update the CSS.
3 4
3. TEMPLATE ATTRIBUTES 1
Properties whose name begins with 'grid- header
template' are used to define the design of the overlay
grid layout. 1
content side
2
4. CELL ATTRIBUTES 3
footer 4
Properties that don’t start with 'grid-template'
6
are used to place cells within the grid. 5
1 2 3 4 5
Page 1 Page 2
Content Head Content Head
56__________________________________________________feature
CSS Grid
a1 a1
main
main
aside2 aside2
The ability of grid to keep layout against unexpected changes that by providing full control to the using nested grid, it is the feature’s
definition entirely independent from could otherwise escalate to derail designers for defining the layout ability to adapt parent grids without
the HTML content is not only good your schedule and budget without concern for the HTML. concern for their content that will
for responsive design and SEO but planning. An example of this would Future additions to the grid benefit your ability to be agile by
also for project management. A lot be a change request to alter the feature will allow advanced layouts eliminating risk and reducing
of talk exists about agile position of content, which would to be defined with lower complexity. testing requirements. In addition,
development being a project traditionally require you to modify One example of this is the proposed the automatic management of
management methodology, but it’s both the CSS and HTML. This can subgrid feature, which will enable subgrids by the browser will help to
as much about how you implement be problematic for large projects cells to act as a subgrid that keep formatting simple and
your design and its code. where design and content are automatically inherits the required consistent across all developers,
By using CSS grid effectively, you responsibilities of separate people cell layout from its parent. While providing better ability to adapt
are able to protect your project or teams. Grid resolves this issue subgrid layout is already possible your CSS whenever required.
RESOURCES
W3C SPECIFICATION GRID POLYFILL GRID LAYOUT EXAMPLES
w3.org/TR/css-grid-2 smashingmagazine.com/2018/07/ github.com/FremyCompany/ gridbyexample.com/examples
The latest details of the CSS grid css-grid-2 css-grid-polyfill A selection of pre-made grid
specification. Includes details Learn about the proposed subgrid One of several polyfills available layouts that you can use to
about proposed features, such as feature in more detail, complete to bridge compatibility with older kickstart your web design or
subgrid that will be implemented with full examples for using the browsers. Make sure to take a look content section layout. Examples
by future browser releases. proposed specification. at the full description of its include both simple and advanced
capabilities and limitations. layout designs.
feature _________________________________________________ 57
Tutorials
58__________________________________________________tutorial
Tutorials
C
SS must pass through a relatively entire website after replacing your CSS files with the </style>
complex pipeline, just like HTML and minified ones – one never knows what mistakes the </head>
JavaScript. The browser must download optimiser caused. <body>
the files from the server and then proceed <div class="blue">
to parsing and applying them to the DOM. Due to 5. Inline critical CSS Hello, world!
extreme levels of optimisation, this process is usually Loading external stylesheets costs time due to latency </div>
pretty fast – for smaller web projects not based on – anyone remember the ‘flash of unstyled content’? The
frameworks, CSS usually makes up just a small part of most critical bits of code can therefore go into the header 6. Permit antiparallel parsing
total resource consumption. tag. Make sure not to overdo it, however. Keep in mind @import adds structure to your CSS code. Sadly, the
Frameworks upset this equilibrium. Include a that the code must also be read by humans performing benefits are not for free: as imports can nest, parsing
JavaScript GUI stack like jQuery UI, and watch CSS, JS and maintenance tasks. them in parallel is not possible. A more parallelisable
HTML sizes skyrocket. Often, developers usually feel the <html> way uses a series of <link> tags, which the browser can
pinch last – when seated behind a powerful eight-core <head> fetch at once.
workstation with T3 internet, no one cares about speed. <style> @import url("a.css");
This changes as latencies or CPU-constrained devices .blue{color:blue;} @import url("b.css");
come to play.
Optimising CSS requires a multi-dimensional approach.
While hand-written code can be slimmed down using
various techniques, going over framework code by hand
is inefficient. In these cases, using an automated
minimiser yields better results – developer time is not an
unlimited resource.
The following steps will take us on a journey through
the world of CSS optimisation. Not every single one might
be directly applicable to your project, but do keep them
in mind.
1. Use shorthand
The fastest CSS clause is one that never gets parsed.
Using shorthand clauses, such as the margin declaration
shown below, radically reduces the size of your CSS files.
A lot of additional shorthand forms can be found by
googling ‘CSS Shorthand’.
p { margin-top: 1px;
margin-right: 2px;
margin-bottom: 3px;
margin-left: 4px; }
1
p { margin: 1px 2px 3px 4px; }
3. Do it in a more
comfortable fashion
Navigating through the line-by-line analysis is not
necessarily comfortable. Chrome’s Web Performance
Audit returns similar information – simply open it from
the toolbar, View>Developer>Developer Tools>Audits
and let it run. When done, a list of problematic elements
will pop up.
tutorial _________________________________________________ 59
Tutorials
Make your websites run faster with optimised CSS
Not every hex code can be shortened. Typically code has to be in pairs to work
60 _________________________________________________tutorial
Tutorials
Make your websites run faster with optimised CSS
Simplify
debugging
Finding errors in minified or
optimised CSS is tedious and
should be avoided at all costs.
The safest workaround involves
using the unoptimised CSS files
during debugging, generating
an optimised version only as
the website is pushed live.
Should this be unworkable for
some reason, limit yourself to
auto-generated optimisations.
Many if not most optimisers
produce so-called MAP files
during execution. These can then
be loaded into your debugger
– when done, the debugger can
correlate the optimised code to
the unoptimised files found at
another location in the file system.
11 box-shadow
transform
filter
:nth-child
position: fixed;
etc.
Don’t go crazy
Premature optimisation is a dangerous game.
While attempting to squeeze out the last bit of
performance from your CSS is intellectually
challenging, check if lower-hanging fruit are
available before committing your time.
tutorial _________________________________________________ 61
Tutorials
Make your websites run faster with optimised CSS
16
Essential resources
----------------------------------------------------
On the problems of
automated CSS analysis
css-tricks.com/heres-the-thing-about-unused-css-tools
----------------------------------------------------
All about HTTP/2
developers.google.com/web/fundamentals/performance/
http2
----------------------------------------------------
62__________________________________________________tutorial
31
O EC
D
FF E
The perfect
ER MB
EN
S
*
gift from just $23
8
FROM $23 EVERY 3 MONTHS ($93 PER 13 ISSUES YEARLY)
www.myfavouritemagazines.co.uk/pin/xmas187
ORDER HOTLINE: גגڷ٨٩אדזאזגזגגב
PLEASE QUOTE XMAS187 WHEN ORDERING BY PHONE
nXz0³«0 ¨0zx z(çٳI«X(çזxÁ ¨וxz(³ÁÈ«(çxÁ ¨אx٨JxÁ٩
*Terms and conditions: Savings calculated against the full RRP (single issue price x frequency). Dollar prices quoted are for the United States, other global territory dollar pricing may vary.
ÁǝǣɀȒǔǔƺȸǣɀǔȒȸȇƺɯɀɖƫɀƬȸǣƫƺȸɀȒȇǼɵِçȒɖƬƏȇɯȸǣɎƺɎȒɖɀȒȸƬƏǼǼɖɀɎȒƬƏȇƬƺǼɵȒɖȸɀɖƫɀƬȸǣȵɎǣȒȇɯǣɎǝǣȇגƳƏɵɀȒǔȵɖȸƬǝƏɀƺِçȒɖȸɀɖƫɀƬȸǣȵɎǣȒȇǣɀǔȒȸɎǝƺȅǣȇǣȅɖȅɀȵƺƬǣˡƺƳƏȇƳɯǣǼǼƺɴȵǣȸƺƏɎɎǝƺ
end of the current term. Payment is non-refundable after the 14 day cancellation period unless exceptional circumstances apply. Your statutory rights are not affected. Prices correct at point
of print and subject to change. Full details of the Direct Debit guarantee are available on request. For full term and conditions please visit: bit.ly/magtandc. Offer ends 31st December 2018
Tutorials
Style a site
using Sass
Sass is a style sheet language that extends CSS. It’s common to
take advantage of a CSS ‘preprocessor’ like Sass to make styling
easier, and in this tutorial we’ll show you how
Y
ou can do a lot with CSS – perhaps more 3. Command line compilation 6. The main stylesheet
than you might think – but the Now we can run the Sass compiler at the command We’re using styles.css as our main CSS entry point, which
venerable style sheet language has its line to convert our .scss file into CSS output. You’ll later on we’ll use to import other modules. This means we
limitations. In a modern web project, with notice in the output file that the variables are gone and need to tell Sass to generate this file, so we also need to
npm modules, JavaScript frameworks, ES6 and more, it we’re just left with standard CSS syntax that is usable create a styles.scss file in our src/sass folder. If you’re running
can feel somewhat anachronistic to fall back to writing by the browser. “sass --watch” as before, this will automatically be compiled
vanilla CSS. sass sass-input.scss css-output.css into CSS in the ‘public/css’ folder, and refreshing your site will
Fortunately, there are options out there that allow you show its changes. Try making some modifications and
to use other languages that compile to CSS. Referred to 4. Automating build refreshing the HTML page in the browser as you go.
as ‘preprocessors’, these tools integrate into your web This is great, but you don’t want to run the Sass // styles.scss
build process and generate usable style sheets from compiler manually every time you make changes. One body {
whatever extension language you’ve chosen. option is to have it listen for changes to files in a font-family: sans-serif;
Sass (Syntactically Awesome Style Sheets) is one of the directory and automatically recompile the output to a text-align: center;
most popular of these options. Sass adds many valuable different directory (preserving filenames). This also }
new language features that aren’t (currently) available in effectively lets you segregate your source .scss file from
CSS to help make your sites and apps more maintainable. your built CSS. 7. Colour scheme
These include things like ‘mixins’ and ‘control directives’, mkdir src Let’s look at how Sass can help us manage a colour
which sound daunting but are actually quite mkdir src/sass scheme for the site. It’s common to have a palette of 5 or
straightforward, and we’ll look at these in this tutorial. mkdir public 6 colours for a webpage. We can externalise these in
There are actually two different syntaxes for Sass, one mkdir public/css ‘_colours.scss’. The underscore prefix tells Sass not to
that uses a ‘.scss’ file extension, and one that uses ‘.sass’. sass --watch src/sass/:public/css/ compile this into a new HTML file (a ‘partial’). But we can
The former looks more like CSS (in fact, all .css files are use it in a slightly different way.
valid .scss files), while the latter eliminates CSS’s brackets 5. A starter site // _colours.scss
and semicolons in favour of indentation and newlines. Now let’s look at a simple starter site, which we can $colour-primary: #231651;
We’ll focus on .scss, but the choice is simply down to use to play around with Sass styling. We can get $colour-secondary: #2374AB;
personal preference. started by cloning an unstyled example site. The key $colour-light: #D6FFF6;
thing to note is that our HTML page knows nothing $colour-highlight1: #4DCCBD;
1. The compiler about Sass. It has a single CSS file entry point, which $colour-highlight2: #FF8484;
Using Sass essentially requires a compiler. The simplest we’ll create next.
way to do this would be at the command line. You can cd public
do so using Homebrew. The Sass compiler is curl -o index.html https://raw.
implemented in several different languages, and githubusercontent.com/simon-a-j/sass-
Homebrew will install the Dart version, which is fast. tutorial/
brew install sass/sass/sass master/public/index.html
Build pipeline
We’ve looked at the simplest possible command-
line usage of Sass, but in many real-world
scenarios, you’ll want it more neatly integrated
into your build pipeline. A lot of popular
framework starter kits do this already, but you can
also set it up yourself with, say, Node – in which
case you can use gulp or npm scripts and the
node-sass module.
The official Sass website, which has many useful resources and comprehensive documentation
tutorial _________________________________________________65
Tutorials
Style a site using Sass
10 11
66 _________________________________________________tutorial
Tutorials
Style a site using Sass
Other preprocessors
Sass is just one of the CSS preprocessors out there,
and you might want to consider checking out the
competition. Preprocessing is largely a stylistic
preference, and the best choice is really the one that
you find best suits your personal development style (or
integrates most easily with other tooling you use).
Less (Leaner Style Sheets) is, like Sass, an extension
of CSS that maintains backward compatibility. It’s
written in JavaScript so requires Node.
Stylus has flexible syntax support, letting you write
either regular CSS, .sass style CSS, or omit braces,
semicolons and colons completely and write very
concise style sheets.
PostCSS takes a slightly different approach to the
competition, allowing you to pick and choose which
language extensions you need via a plugin system,
rather than shipping everything at once.
The features supported by most of the preprocessing
solutions are fairly similar – you’ll generally get
variables, nesting, mixins, functions and imports.
tutorial _________________________________________________ 67
with Cassidy Williams
LET’S BREAK DOWN HOW TO MAKE ART WITH CSS BY MAKING A CUTE ICE
CREAM BAR GRAPHIC, GOING THROUGH TECHNIQUES STEP BY STEP
68 _________________________________________________feature
CSS Art
WHERE CAN
I FIND…?
Want to make
graphics after this
article and not sure
where to start?
Check out Dribbble,
Behance and
CodePen Challenges
for inspiration. If you
end up using one of
the graphics or ideas
you find on those
sites, don’t forget to
credit the work!
feature _________________________________________________69
CSS Art
70 _________________________________________________feature
CSS Art
YOU’RE AN ARTIST!
We made something really fun
together today. If you’d like to check
out my final result, you can find it on
my CodePen profile (codepen.io/
cassidoo/pen/QJmxWX). Making
CSS art is really just a matter of
applying the concepts we talked
about in interesting and fun ways.
You can take these techniques and
run with them, and even add your
own animations with keyframes and
transitions. All this being said, I hope
you learned something new, and
this motivated you to try your hand
at making something beautiful.
feature __________________________________________________71
r ones and how
hodology
t Potato
__________________________________________________
CSS METHODOLOGIES
MANAGE SPECIFICITY
Another potential problem experience
projects is managing specificity. CSS as
each style rule, so when multiple rules
same element, the highest weighted ru
more specific and is therefore applied.
equal-weight rules are used the lowest
is calculated using four number groups
0-0-0-0, where numbers do not overf
to another, so 0-12-21-5 is valid. Each ele
element in a selector increments the ri
‘h1’ is 0-0-0-1 and ‘div::before’ is 0-0-0
attribute or pseudo-class increments t
‘.some-class.another-class’ is 0-0-2-0 a
some-class .another-class:hover’ is 0-0
the next group, e.g. ‘#some-id#anothe
‘ul#some-id img.some-class:active’ is 0
applied using HTML style attributes inc
group and are therefore the most speci
higher the overall number, the more sp
So if one developer uses ‘div.some-clas
an element, it is not possible to overrid
the code using ‘.some-class’ on its ow
common practice to use only single-cla
possible.
To solve these and other CSS imple
groups of coders around the world h
different CSS methodologies, or sets
practices, each with their own focuse
disadvantages. They are not framew
rather rules for writing CSS code that encourage
developers to stick to conventions that make code easier
to write and maintain, saving hours of development time.
These methodologies are not mutually exclusive and can
be used together in a way that best suits developers.
In this article we will take a look at a few of the most
popular CSS methodologies, highlighting their pros and Methodologies
cons, and how they can be combined together in a provide rules for
writing CSS code
custom methodology.
feature _________________________________________________ 73
CSS METHODOLOGIES
Popular CSS methodologies Of the vast number of CSS methodologies, we will explore the
most popular, discussing their advantages and disadvantages
__________________________________________________
CSS METHODOLOGIES
html,
body { height: 100%; }
a
{
&, &:active, &:focus, &:hover,
&:visited {
text-decoration: none;
}
}
feature _________________________________________________ 75
THE CUTTING EDGE OF
76__________________________________________________feature
THE CUTTING EDGE OF CSS
BI-DIRECTIONAL SCROLLING
deanbradshaw.com
Unexpected scrolling always grabs the user’s attention.
Photographer Dean Bradshaw’s website moves subtle
background text horizontally across the screen as the user
scrolls downwards.
feature _________________________________________________ 77
THE CUTTING EDGE OF CSS
WHAT’SHOTRIGHT NOW Here’s three CSS properties for you to try today
TO FOLLOW
margin to accommodate these cutouts. Web designers
often like to use the full screen, and now there is a way to
do that, with Chrome leading the way. Add this meta tag
to the document:
RACHEL ANDREW <meta name=’viewport’ content=’initial-scale=1,
@rachelandrew viewport-fit=cover’>
Rachel is a CSS working group
expert and has been a strong Then use the CSS safe environment variables to layout
advocate for web standards. your content:
She is currently vocal in .content {
promoting the use of CSS Grid padding: 16px;
to design pages. padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
ANA TUDOR }
@anatudor Now you just have to test your design in landscape and
Ana is an international speaker, portrait on the device.
covering workshops on
78__________________________________________________feature
TH C T N EDGE F C
WHAT IS HOUDINI?
Every web designer has probably
tried to implement a new feature
of CSS but has been unable to
because browser support isn’t
Its plan is to there. Houdini is here to end that
The hello Houdini mini site has some good
visual examples. Here you can see a saw
introduce a new Houdini is a new W3C task force, and its
goal is to take away the problem of poor
tooth edge being used
power of CSS to the JavaScript for the first time. This means that
CSS features can be coded by the designer
browser in JavaScript or developer and have all the native speed CSS-TRICKS
for the first time. This of regular CSS. All of this might sound a
little like overkill, to suddenly enable
@css
CSS-Tricks has long
means that CSS designers to extend CSS, but it will allow for
consistent coverage of a new CSS feature
Ana Tudor shows how Houdini can be used
to animate, transform and create some
established itself as a website
that showcases CSS features in
features can be
sophisticated 3D animation
and reduce the need for complicated great detail. Its Twitter account
CSS API
There are six APIs associated with what
CSS AWARDS
@cssawards
Houdini offers to the browser. Here three
of those are explored Selecting the best websites
that are developed with CSS
LAYOUT API PAINT API from around the world, this
CONTROLLING ANIMATION
adhere to the same standards.
it is a great resource on the
WITH SCROLLING
latest CSS.
houdini.glitch.me/animation CODROPS
This not only demonstrates the scrolling effect on the @codrops
page but also shows exactly how it was created, with a Codrops is a useful resource
tutorial explaining how the Animation API works. The for all things web
page also contains customisable code to experiment design-related, but more
with. Changing values will cause elements to scroll at specifically codrops has a
different speeds on the page. The rest of the site has strong slant towards the
great resources for explaining Houdini APIs. design styling of CSS.
feature _________________________________________________79
ON THE WEB SVG support is finally where is should be. So if you’re still
using PNG for logos, icons or interact elements, it’s high
time you learn about the power of Scalable Vector Graphics
80 _________________________________________________feature
SVG ON THE WEB
1 PIXEL-PERFECT SCALING
Using PNGs or rasterised
images means you are
restricted to pixels. It also
3 SMALL FILE SIZE
PNGs can get large very
quickly, especially when you
need high-definition. The
WHAT IS SVG USED FOR?
LOGOS, UI ELEMENTS, ICONS AND ARTWORK ALL FIT THE PROFILE
means you are likely to have larger the file size, the SVG is heavily underused, partly because it took a long time for widespread support
multiple images for various longer it takes to load and to across browsers. With a desire for fast, responsive experiences, SVG can make
retina devices or resolutions. render. JPGs are better but dramatic improvements to your site. There are several great times to use SVG.
SVG is not affected by also large. That means
resolution or whether or not slower sites. SVG is just LOGOS AND ICONS ANIMATIONS
you have a retina display. SVG code, which means very Logos and icons often share a need to be SVG can work with CSS animations, so
images scale and always look small file sizes. Use it for clear and sharp at any size. Whether it’s a you don’t have to learn new animation
perfect because they are icons, logos and anything simple button or a large, screen-filling skills. SVG can also use its own built-in
drawn with code, not pixels. that can be created as billboard, you want the quality consistent and SMIL animation ability, which is even
vector art. crisp. SVG enables precise control of every more robust if you want to make really
2 MODIFIABLE shape, line and element. SVG icons and logos creative results.
SVG can be animated and 4 ACCESSIBILITY are more accessible, which means they’re
styled with CSS. You can SVG files are text-based and easier to position and manipulate in real-time. TRADITIONAL DRAWINGS & ILLUSTRATIONS
change colours, sizes, fonts and can be searched and indexed. Many traditional illustrations translate
so much more. Elements within This makes them readable by CHARTS, GRAPHS, INFOGRAPHICS really well to SVG, provided they are not
the SVG can be responsive as screen readers, search SVG can be updated dynamically to plot overly complex in details. Sketches and
well to use interaction. engines and other devices. data based on user actions or other diagrams to explain features of a
Animations that you use on Each element within the SVG data-driven events. This makes SVG product or illustrate a concept can work
HTML elements can also be is also accessible for search perfect for things like interactive maps very well.
used on SVG elements. but also manipulation. or graphics that illustrate data.
INTERFACES AND APPLICATIONS
Raster Vector VISUAL EFFECTS SVG is ideal for complex interfaces that
.jpeg .gif .png .svg Many real-time visual effects can be created can be integrated with web-based
using SVG, including shape morphing and applications and rich internet
transitioning from one shape to another. applications (RIAs). They are lightweight,
You can transform letters into shapes, logos easy to animate, and each element can
into other logos and much more. capture user interaction events.
BROWSER SUPPORT MOST MODERN WEB BROWSERS SUPPORT SVG. GREEN IS GOOD
Android Blackberry Chrome for
IE Egde Firefox Chrome Safari Opera iOS Safari Opera Mini Browser Browser Opera Mobile Android
2.1 - 2.3
11 17 63 70 12 56 12 ALL 67 10 46 69
source; caniuse.com
18 64 - 65 71 - 73 TP
feature _________________________________________________ 81
SVG ON THE WEB
CODING SVG
xmlgraphics.apache.org/batik
Batik toolkit is written in JavaScript
YOU CAN CODE SVG IN ANY TEXT EDITOR and offers almost complete SVG
SVG uses an XML-based language for describing vector images. It’s a markup language, like HTML, support. Batik includes a viewer
except that you have a wide variety of elements for defining the shapes to create these images, along (Squiggle), a rasteriser for PNG
with effects to apply to these shapes as well. output, an SVG pretty printer to
You can code SVG right along with your HTML in your favourite code editor. You can code them as format SVG files, and a TrueType-
separate files and include them, or you can code them inline in your HTML. As a simple example, the to-SVG-Font converter.
following code creates a circle and a rectangle:
<svg version=”1.1”
baseProfile=”full”
width=”300” height=”200”
xmlns=”http://www.w3.org/2000/svg”>
<rect width=”100%” height=”100%” fill=”black” />
<circle cx=”150” cy=”100” r=”90” fill=”blue” />
</svg>
82__________________________________________________feature
SVG ON THE WEB
CIRCLES 1
There are three attributes to use to The <path> element is extremely powerful for making shapes. You can
create a circle. They include: use it to create lines, curves, arcs and more. You can even use it with
r - The radius of the circle. text to create text that flows along paths.
cx - The x position of the centre
of the circle. DRAWING LINES
cy - The y position of the centre To draw a line or curve, you use the path element and ‘define’ the path
of the circle. using the ‘d’ attribute. You can ‘move’ the start of a line using the ‘M’
command for absolute positioning and the lower case ‘m’ for relative
The code to draw a circle is very easy positioning. You use the ‘L’ command to draw a line to a new point. Here
to use. You can set the stroke colour is a quick example of a line:
and fill colour inline or separately as
well. Here’s an example: <path d=”M 10,10 L 250,250” fill=“transparent”
stroke=“black”/>
<svg width=”200” height=”250”>
2
<circle cx=”400” cy=”300” Here is an example of multiple lines, to show you how easy it is:
r=”200” stroke=”red” fill=
”transparent” stroke- <path d=”M 10,10 L 250,250 30,100 150, 50”
width=”5”/> fill=”transparent” stroke=”black”/>
</svg>
RECTANGLES
In a similar way to making circles,
you can create rectangles, using x
and y for position, then height and
width attributes to define the size.
The code looks like this:
3
<rect x=”100” y=”100” width=
”400” height=”300” stroke=
”black” fill=”transparent” DRAWING CURVES
stroke-width=”5”/> You can also use the ‘C’ command to draw curves. Use the ‘M’
command to set the start position, and then list the start, the anchor
LINES point and the end point like this:
Lines in SVG are for straight lines.
They take as attributes two points <path d=”M50 50 C 50 50, 150 100, 250 50” stroke=”black”
that specify the start and end point fill=”transparent”/>
of the line. Here’s an example:
You can also string curves together using the ‘S’ command to make
<line x1=”100” x2=”500” y1= even more complex curves like this:
”110” y2=”450” stroke=”orange”
stroke-width=”5” /> 4 <path d=”M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80”
stroke=”black” fill=”transparent”/>
POLYGONS
You can also create any kind of
polygon shape using the polygon
element, which will conveniently
return to the first point for you
after the end of your list of points.
Here’s a quick example of drawing
a polygon:
<polygon points=”50 160, 55 There are plenty of curves and paths you can create. There is a great
180, 70 180, 60 190, 65 205, resource for learning even more about paths here: developer.mozilla.
50 195, 35 205, 40 190, 30 org/en-US/docs/Web/SVG/Tutorial/Paths
180, 45 180”/>
feature _________________________________________________83
SVG ON THE WEB
MOZILLA DE ELOPER
Making text is easy in SVG. You use <text> NETWORK (MDDN)
the <text> tag to define it. Here is This is <tspan font-weight= developer.moziilla.o
a org/kab
g kab/docs/
an example: ”bold” fill=”red”>bold and Web/SVG
red</tspan> A greatt resource for learning the
<text x=”10” y=”10”> </text> We use the direction style and set it ins and outs of SVG, with many
This is text.</text> to ‘rtl’, which means right to left. We examples to help get you up
also have to set the unicode-bidi and running.
The x and y determine the position style to ‘bidi-override’.
of the text. Like with the shape CSS-TRICKS -
elements, text can be colourised USING TEXTPATH EVERYTHING YOU NEED
with the fill attribute and given a You can also set strokes, fills, This element uses the xlink:href TO KNOW ABOUT SVG
stroke with the stroke attribute. You rotations, direction and much more. attribute to connect to a path and css-tricks.com/lodge/svg
can even use gradients and patterns Here is a quick example of setting aligns the characters along this path. CSS-Tricks hosts a complete SVG
as strokes and fills. the text to draw outlines only, and to This enables you to draw virtually video tutorial series here. It
switch the direction of the text: any path you wish, and then attach covers what SVG is, why use it,
SETTING FONT PROPERTIES your text to it, so it follows it. Here’s how to use it and much more.
Each of the following properties <text x=”350” y=”50” an example:
can be set as an attribute or via a style=”fill: none; stroke: ENVATOTUT
V S-
CSS declaration: font-family, #000000; font-size: 48px; <path id=”my_path” d=”M 40,40 HOW TO HAND CODEE SV
S VG
font-style, font-weight, font-variant, direction: rtl; unicode-bidi: C 200,100 10,100 520,200” webdesigngn.tutsp
tutspluss.com/
font-stretch, font-size, font-size- bidi-override;”> fill=”transparent” /> tutorial
als/how-to-hand-code-svg--
adjust, kerning, letter-spacing, This is text <text> cms-330368
word-spacing and text-decoration. </text> <textPath xmlns:xlink=” envato otuts
uts hass a nice in-depth
th
Like the <span> elements <tpsan> http://www.w3.org/1999/xlink” tutori
rial that dives into many
can also be used to select web xlink:href=”#my_path”> gre
eat examples of hand-codin ng
sections of your text. A typical This Text is Curved SVGG, including rreusing SVG in
use-case might be to bold some </textPath> yourr page.
text like this: </text>
recommendation stage,
=”bold” fill=”red”>bold height=”400” viewBox=”0 0 400 deprecates some features of SVG 1.1
and red</tspan> 400”> and incorporates new features from
which means it is not </text>
<style><![CDATA[
<rect class=”box” x=”0”
y=”0” width=”400” height=
HTML5 and Web Open Font Format.
SVG 2.0 removes several font
supported by browsers text{ ”400” fill=”#56A0D3” /> elements, such as glyphs, and they
improvements </svg>
Notice we had inline colouring
September 2016. The latest draft
was released on 18 October 2018.
and features You can also use CSS separately,
just like with any other elements
that we then overrode with our
CSS. Pretty cool!
You can read more about it and
follow its progress here: w3.org/TR/
SVG2
84 _________________________________________________feature
The number one
destination for web design
news, views and how-tos.
Get Creative
Bloq direct to
your inbox with
our weekly
web design
newsletter
www.creativebloq.com
Tutorials
Manage React
application data
with Redux Create an API-powered state application and discover
the benefits of a centralised data store
T
he appetite for single-page applications to the directory in the command line and install the 4. Set up root reducer
is greater than ever. Instead of a dependencies. Yarn is required to manage those A reducer is a function that knows how to update the
complete page reload each time the user dependencies, if this hasn’t been downloaded already. store. The store only deals with one reducer. We can use
clicks a link or fills a form in, we can Then start the development server. Redux’s ‘combineReducers’ method to split that into
provide real-time feedback using JavaScript and do the > yarn separate, smaller reducers that each have a specific role,
heavy lifting in the background. As developers, we have > yarn start such as storing information about the photos or the state
greater control over the data that gets transferred, and of the interface. Our first reducer will hold the photos
the user enjoys a faster, seamless experience – it’s a 2. Initialise the store within the gallery. Open up ‘reducers/root.js’ and import
win-win. The store is the heart of Redux. It holds the state of the that reducer in.
But without that constant connection back to the application and orchestrates all communication to and import { combineReducers }
server, the state of the application has to live on the from it. There should only ever be one store per from "redux";
client-side. Frameworks like React are great at storing application. Open up ‘index.js’ and create a store. This is import photos from "./photos";
state at a component level but start to struggle when done using the ‘createStore’ function from Redux. Pass in const rootReducer = combineReducers({
dealing with large sets of application-wide data. Explicitly the root reducer, which we will come to later. photos
passing that data through as props can clutter up the import { createStore } from "redux"; });
code and increases the surface area for bugs to appear. import rootReducer from export default rootReducer;
Redux takes the state of an application and places it in "./reducers/root";
one location. By combining with React, we can have the const store = createStore( 5. Create photos reducer
whole interface powered by a centralised data store. This rootReducer); When a reducer is called, it gets passed the current state
makes an application more reliable, more testable, and from the store and an object describing a change to the
when issues do arise they become easier to replicate. 3. Pass in the store state known as an ‘action’. The return value of the reducer
This tutorial is the first in a five-part series where we will Before React can use any data from the store, it needs to is what then becomes the store’s new state. Open up
be building PhotoShare – an application that allows be given access to it. The ‘react-redux’ package has a ‘reducers/photos/photos.js’ and create our first reducer.
visitors to comment directly on a set of photos. While it <Provider> component that can provide access to any For now, every action will return the state straight back
seems simple on the outside, there is lots to keep track of, component that requests it. Import the <Provider> without any updates.
from photos to the users and their comments. component and wrap it around the rendered content. const initialState = {};
In this part of the tutorial we will cover the basic Now we can start pulling in the state data wherever the export const reducer =
concepts around Redux, such as actions, reducers and application needs it. (state = initialState, action) => {
the data store. Later in the series we will use these import { Provider } from "react-redux"; return state;
concepts to power interactions such as form filling or […]
server communication. ReactDOM.render(
1. Install dependencies
<Provider store={store}>
<BrowserRouter>
Use more than switch
Redux does not specify the shape of a reducer.
Before we get started, we need to download all the files <App /> While a switch statement is most common, use
needed to run this application. Inside ‘package.json’ we </BrowserRouter> what makes sense for the application. The
can see the dependencies, including React, Redux and </Provider>, structure does not matter so long as the state
the ‘react-redux’ package that deals with the connection document.getElementById("root") object is returned.
between the two. Download the project files, then head );
Above
Starting the development server
should also open up the application in
the default browser. If it does not, head
to http://localhost:3000
Right
While developing the application it will
display full-screen errors as well as
the usual console ones. When built for
production, these do not appear
tutorial _________________________________________________ 87
Tutorials
Manage React application data with Redux
}; photos/photos.js’ and create a selector that gets all the export const mapStateToProps =
export default reducer; photos for the gallery. state => ({
export const getGalleryPhotos = photos: getGalleryPhotos(state)
6. Apply initial state state => Object.values(state.photos); });
Each reducer is likely to have data stored in an expected export default connect(mapStateToProps)
shape, such as an array or an object to hold specific 8. Connect with Redux (GalleryContainer);
information about that part of the state. We can initialise it For React components to access the store we created in
with a set of values from the outset. For this application step 3, we need to connect them to Redux. To do this we 10. Select a photo
we will pre-fill the photo data locally. Usually this would use ‘connect’ from the ‘react-redux’ package. ‘connect’ is With the gallery complete, we still need a way to view
come from a remote server and would initially be empty. an example of a higher-order component – an established specific photos in more detail. Clicking a photo in the
Import the example response and provide it as initial state React pattern that provides functionality to a passed gallery shows us a <Photo> component on its own page,
to the reducer. component. Head to ‘components/container/Gallery/ but it’s currently blank. Create another selector in
import exampleResponse from Gallery.js’, import ‘connect’ and use it to replace the ‘selectors/photos/photos.js’ to select a specific photo. We
"../../example-response"; exported component. can re-use the logic of ‘getGalleryPhotos’ like we would
const initialState = exampleResponse; import { connect } from "react-redux"; any other function.
[…] export const getPhoto = (state, id) =>
7. Select the photos export default getGalleryPhotos(state)
While not strictly required by Redux, selector functions connect()(GalleryContainer); .find(photo => photo.id === id);
are a useful way to get exactly what you need out of the
store. They filter out the rest of the data to leave only what 9. Map state to props 11. Link single photo
is needed for each component. Open up ‘selectors/ There are two parameters we can pass to ‘connect’. The As this component is not linked to <Gallery>, we need to
first is a special function that allows us to pass parts of the connect it to Redux separately. We can use the same
state from Redux into components. The ‘connect’ approach to pull information out using ‘mapStateToProps’
How many function gets the state from the store and passes it to and the new selector. Open ‘components/container/
connections? selectors. Selectors then get what they need and return it
to the component as a prop. Create this
Photo/Photo.js’ and connect this component to the store.
import { connect } from "react-redux";
Connecting too many components couples an
application closer to Redux, while too few ‘mapStateToProps’ function and use it to pass the ‘photos’ import { getPhoto } from
re-renders parent components unnecessarily. It’s prop into <GalleryContainer>. We can now see the images "../../../selectors";
important to find a balance that works best in start to appear in the gallery. export const mapStateToProps =
each application. import { getGalleryPhotos } (state, props) => ({
from "../../../selectors"; photo: getPhoto(state)
88 _________________________________________________tutorial
Tutorials
Manage React application data with Redux
tutorial _________________________________________________89
Tutorials
Manage React application data with Redux
Debugging with
Redux DevTools
With Redux quietly running in the
background, it can be difficult to know
exactly what’s going on. We could log
out each new state as an action comes
in, but this seems unsuited and noisy.
Thankfully there is a browser
extension available that can tap into a
Redux store and even manipulate it in
real time. Not only can it track actions
and show the current store state, but
also undo those actions to help see
how the application changes.
It taps into the store through an
‘enhancer’ – a module with access to
the API behind Redux to extend its
behaviour. It is recommended that this
enhancer is removed when building
the application for production.
The extension is available for
Chrome and Firefox. For more
information head to github.com/
zalmoxisus/redux-devtools-
extension
import ui from "./ui"; import { connect } from "react-redux"; import { HIDE_COMMENT, SHOW_COMMENT }
const rootReducer = combineReducers({ import { isCommentOpen } from from “../../constants/actions”;
photos, "../../../selectors"; […]
ui
}); export const mapStateToProps = case HIDE_COMMENT:
(state, props) => ({ return {
17. Create an open selector isCommentOpen: isCommentOpen( ...state,
With the UI state now in place, we can check to see which state, props.id) commentOpen: undefined
comment is open. Go to ‘selectors/ui/ui.js’ and add an }); };
‘isCommentOpen’ selector. By passing the ID of the
current comment, we can check it against the state. If the export default connect(mapStateToProps) case SHOW_COMMENT:
comment is open, then the selector returns true and (CommentContainer); return {
the comment appears. ...state,
export const isCommentOpen = 19. Toggle comment actions commentOpen: action.payload };
(state, id) => To tell Redux which comment should be visible, we
state.ui.commentOpen === id; need to dispatch an action to the reducers. By using 21. Dispatch new actions
action creator functions, we can be sure that the action The ‘connect’ higher-order component takes a second
18. Connect the comments object looks the same each time. Add a couple of function, which gives access to the ‘dispatch’ method
Now everything is set up, we can connect each action creators in ‘actions/ui/ui.js’ to show and hide a from Redux. In short, this ‘mapDispatchToProps’ function
<Comment> component to the store, like with <Gallery>. comment by ID. We use constants for the type so they works similar to ‘mapStateToProps’ but allows us to
Head over to ‘components/container/Comment/ can match up with the reducer later on. dispatch actions. Back in ‘components/containers/
Comment.js’ and connect everything up like before. Pass import { HIDE_COMMENT, SHOW_COMMENT } Comment/Comment.js’, hook up ‘mapDispatchToProps’
the new selector inside ‘mapStateToProps’. from "../../constants/actions"; to pass through functions that can be called when a
export const hideComment = () => ({ comment is clicked.
15 type: HIDE_COMMENT import { hideComment, showComment }
}); from “../../../actions”;
90 _________________________________________________tutorial
Discover another of our great bookazines
From science and history to technology and crafts, there
are dozens of Future bookazines to suit all tastes
Get your listing in our directory
To advertise here call the ads team on 01225 442244
HOSTING LISTINGS
Featured host: Netcetera
netcetera.co.uk
03330 439780
About us
Formed in 1996, Netcetera is one of infrastructures. A state-of-the-art data
“ Premier provider of
data centre colocation, cloud
hosting, dedicated servers
Europe’s leading web hosting service centre environment enables Netcetera and managed web hosting
services in the UK
”
providers, with customers in over 75 to offer your business enterprise-level
countries worldwide. colocation and hosted solutions.
As the premier provider of Providing an unmatched value for your
data centre colocation, cloud hosting, budget is the driving force behind our
dedicated servers and managed web customer and managed infrastructure
hosting services in the UK, Netcetera services. From single server to fully
offers an array of services designed to customised data centre suites, we focus
more effectively manage IT on the IT solutions you need.
92__________________________________________________ listings
Supreme hosting SSD web hosting
cwcs.co.uk bargainhost.co.uk
0800 1 777 000 0843 289 2681
CWCS Managed Hosting is the UK’s Since 2001, Bargain Host have
leading hosting specialist. They offer a campaigned to offer the lowest possible
fully comprehensive range of hosting priced hosting in the UK. They have
products, services and support. Their achieved this goal successfully and built
highly trained staff are not only hosting up a large client database, which includes
experts, they’re also committed to many repeat customers. They have also
delivering a great customer experience won several awards for providing an
and are passionate about what they do. outstanding hosting service.
sShared hosting
sColocation hosting sCloud servers
sVPS sDomain names
s100 per cent network uptime Budget hosting with high-performance hosting products
as well as the infrastructure for the
efficient operation of sites. A combination
UK-based hosting of stable technology, attractive pricing, Agency hosting specialist
flexible support and services has enabled
hetzner.com Hetzner Online to strengthen its market
+49 (0)9831 505-0 position nationally and internationally.
Hetzner Online is a professional web nimbushosting.co.uk
cyberhostpro.com hosting provider and experienced data sDedicated/shared hosting 02031266781
0845 5279 345 centre operator. Since 1997, the company sColocation racks Nimbus Hosting have partnered with
Cyber Host Pro are committed to has provided private and business clients sSSL certificates agencies to develop our revolutionary
providing the best cloud server platform STORM. With a team dedicated
hosting in the UK; they are obsessed to outstanding support, our 5-star Google
with automation. If you’re looking for a reviews truly speak for themselves. Join
hosting provider who will provide you the thousands of agencies and
with the quality you need to help your freelancers who are benefitting from a
business grow, then look no further control panel that speeds up your website
than Cyber Host Pro. developement as well as your client’s
websites. Supercharge your digital
sCloud VPS servers projects today with STORM.
sReseller hosting s TFDPOE 8PSE1SFTT JOTUBMM
sDedicated servers s %FQMPZ EJSFDUMZ GSPN (JU)VC
s &BTZ UFBN NBOBHFNFOU
fasthosts.co.uk elastichosts.co.uk
0808 1686 777 All-inclusive hosting operates across ten countries. With a 020 7183 8250
6,CBTFEBOEPQFSBUJOHGSPN comprehensive range of high- ElasticHosts offer simple, flexible and
dedicated UK data centres. Fasthosts performance and affordable products, 1&1 DPTUFŇFDUJWF DMPVE TFSWJDFT XJUI
keep over 1 million domains running offers everything from simple domain high performance, availability and
smoothly and safely each day. Services registration to award-winning website scalability for businesses worldwide.
can be self-managed through the 1and1.co.uk building tools, eCommerce packages and Their team of engineers provide
Fasthosts Control Panel. 0333 336 5509 powerful cloud servers. excellent support 24/7 over the phone,
1&1 Internet is a leading hosting by email and with a ticketing system.
sDedicated servers provider that enables businesses, sEasy domain registration s Cloud servers with any OS
sCloud servers developers and IT pros to succeed sProfessional eShops s Linux OS containers
sHosted email online. Established in 1988, 1&1 now s)JHIQFSGPSNBODFTFSWFST s 24/7 expert support
listings__________________________________________________
Get your listing in our directory
To advertise here call the ads team on 01225 442244
COURSE LISTINGS
Featured:
Northcoders
northcoders.com
Twitter : @northcoders
“
Facebook: Northcoders
No matter what your
About us
Northcoders is the coding bootcamp full-time bootcamp, or fit their course
background, you can
for the north, based in the heart of around your life with their 24-week fast-track your career and
Manchester and built upon northern
values of grit, determination and
part-time bootcamp. Their internal
career support team will help find you
become a web or software
developer in 12 weeks
”
community spirit. No matter what work as a developer, setting up .
your background, you can fast-track interviews with your choices of
your career and become a web or Northcoders Hiring Partners across
software developer in 12 weeks at their the north of England.
What we offer
s 'VMMUJNF s 1BSUUJNF
Fast-track your career Fit our curriculum around
in just 12 weeks your life in 24 weeks
Becoming part of this vibrant, caring community was Northcoders delivered their part of the bargain in spades.
something I hadn’t expected before the course, but They provided tremendous assistance in turning me into
now I couldn’t be without it. To be a Northcoder is to the full product – a well-rounded, capable future tech
be enlightened, inspired and supported employee – and they have the contacts to deliver the
Joanne Imlay opportunities for such people.
Primary school teacher to software developer at Careicon Joe Mulvey
Maths teacher to software developer at Auto Trader
94 _________________________________________________ listings
WE GOT CODERS
UDEMY
udemy.com wegotcoders.com
[email protected]
Twitter: @udemy We Got Coders is a consultancy that
Facebook: udemy provides experts in agile web
development, working with startups,
The inspiration for Udemy began in a agencies and government. Take one of
small village in Turkey, where founder their 12-week training courses that covers
Eren Bali grew up frustrated by the all that is required to become a web
limitations of being taught in a developer, with highly marketable
one-room school house. Realising full-stack web development skills.
the potential of learning on the internet,
he set out to make quality education sClassroom-based training
more accessible. Udemy is now a sReal-world work experience
global marketplace for learning and sEmployment opportunities
teaching online. Students can master
new skills by choosing from an
extensive library of over 40,000 FUTURELEARN
courses, including HTML, CSS, UX,
JavaScript and web development.
listings__________________________________________________95
Free with
your magazine
Essential assets Exclusive Tutorial Plus, all of this
and resources video tutorials project files is yours too…
Get textures, fonts, Learn to code/create $OOWKHDVVHWV\RX·OOQHHG $OOQHZWXWRULDOILOHVWRKHOS\RX
backgrounds and more with HTML, CSS & JS to follow our tutorials PDVWHUWKLVLVVXH·V+70/&66
and JavaScript techniques
1HZFKDSWHUVIURP.LOOHUVLWHV
expert PHP video courses
(shop.killervideostore.com)
/XPLQRXVSUHVHWVDQGL3DG
Pro hi-res mockups from
Sparklestock worth $36
(www.sparklestock.com)
Get started
Everything you need to
know about accessing
your FileSilo account
Unlock
every
issue