An Introduction to Cloudflare Workers

Original Source: https://www.sitepoint.com/cloudflare-workers/?utm_source=rss

An Introduction to Cloudflare Workers

Cloud computing in its various incarnations — SaaS, PaaS, IaaS — has had big successes. Some of us still recall the $212 million purchase of PaaS provider Heroku in 2010, which at that time was — architecturally speaking — little more than a high-level deployment layer. It had a very posh gem for smooth and easy deployment of apps and frameworks like RoR, Python or Node apps running on Amazon’s infrastructure. The concept of Serverless Computing was born.

There have been a host of different models for cloud products ever since then. Various experiments have come and gone as providers looks for the sweet spot, with proliferation continuing and new terms being born, like BaaS and MBaaS.

Protocol Labs, a crypto startup looking to redefine the cloud model, collected $257 million in its 2017 ICO, breaking all records. Airtable, with its high-level, spreadsheet-meets-database products and api, reached a $1.1 billion valuation in its 2018 financing round.

Serverless Computing

Serverless computing is a subset term of cloud computing that makes a point of doing away with the classical server product, providing developers with a high-level environment to run their code, charged on an as-used basis, and freeing those developers from worrying about the underlying software stack.

Serverless computing has allowed further flexibility in paying for used processing power, rather than paying for pre-allocated packages as with classical cloud.

The term “serverless” is semantically wrong, because the code is still executed on a server, but users conceptually don’t have to deal with servers anymore. Provided certain conventions are adhered to, the underlying stack, and all the infrastructure and deployment issues, are handled by vendors.

The main type of product that sprang out from this is FaaS — a cloud execution environment, or a runtime that allows deployment of code without any boilerplate. Amazon’s Lambda, Oracle Fn and Alibaba’s Function Compute are some examples.

Cloudflare

Cloudflare is a San Francisco company that was started nine years ago. It’s a Content Delivery Network that provides delivery of static assets for websites from its global network of edge nodes. It also provides firewall and DDOS protection, and has a reputation for the fastest DNS service on the internet.

When talking about Cloudflare, and what it brings to the arena of serverless computing, it’s necessary to add one more term to the list of cloud buzzwords we used here — edge computing.

As explained on Wikipedia:

The post An Introduction to Cloudflare Workers appeared first on SitePoint.

10 Coolest Features in jQuery 3

Original Source: https://www.hongkiat.com/blog/jquery-3-new-features/

jQuery 3.0, the new major release of jQuery finally got released. The web developer community waited for this important step since October 2014, when the jQuery team began to work on the new major…

Visit hongkiat.com for full content.

Anicorn x TTT #2.5 The Redundant Watch by Ji Lee

Original Source: http://feedproxy.google.com/~r/abduzeedo/~3/tgvmVEwSXiw/anicorn-x-ttt-25-redundant-watch-ji-lee

Anicorn x TTT #2.5 The Redundant Watch by Ji Lee
Anicorn x TTT #2.5 The Redundant Watch by Ji Lee

AoiroStudioJul 03, 2019

We are announcing a collaboration from makers from Anicorn and their last creation: the Redundant Watch which is now live on Kickstarter. We love the products they make as we have featured previous endeavours on ABDZ. This collaboration began with the ‘Redundant Clock’ designed by Ji Lee, a Communication Designer at Facebook, and former designer and creative director at the Google Creative Lab. His clock design has a tremendous buzz on Reddit and now the Hong Kong-based team at Anicorn approached Ji to recreate the hit project in wristwatch form for their The Trio of Time series.

In their words

Time two times, it says time twice. After “Redundant Clock”, Ji Lee redundantly wants make a “Redundant Watch” with Anicorn Watches.

Anicorn x TTT #2.5 The Redundant Watch by Ji Lee

More Links

Support their Kickstarter
Shop Anicorn Watches

As we continue our Trio of Time (TTT) journey, but before moving to our next global destination, we proudly present TTT’s second New York City project—TTT #2.5, the Redundant Watch by Ji Lee.

What is the Trio of Time (TTT)?

The Trio of Time (TTT) is a collaboration where we visit different cities around the globe to partner with local designers and explore their perception of time.

How to read time redundantly

The Redundant Watch has no hour numbers. The watch face is formed entirely by clock hands. The still clock hands indicate the hour of the day (in terms of o’clock), and the running hands tell the minutes and hour.

Some Specs

The 40mm case is designed for both men and women.
Redundant runs on a Miyota GL20 Japanese Movement.
The watch has a 316L stainless-steel enclosed cang, available in black or silver.
The casing is ultra thin — only 7.5mm.
All straps are interchangeable with TTT series — Hidden Time Watch / Order — thanks to the smart docking system.
Anicorn x TTT #2.5 The Redundant Watch by Ji LeeAnicorn x TTT #2.5 The Redundant Watch by Ji LeeAnicorn x TTT #2.5 The Redundant Watch by Ji LeeAnicorn x TTT #2.5 The Redundant Watch by Ji LeeAnicorn x TTT #2.5 The Redundant Watch by Ji LeeAnicorn x TTT #2.5 The Redundant Watch by Ji LeeAnicorn x TTT #2.5 The Redundant Watch by Ji LeeAnicorn x TTT #2.5 The Redundant Watch by Ji LeeAnicorn x TTT #2.5 The Redundant Watch by Ji LeeAnicorn x TTT #2.5 The Redundant Watch by Ji LeeAnicorn x TTT #2.5 The Redundant Watch by Ji LeeAnicorn x TTT #2.5 The Redundant Watch by Ji LeeAnicorn x TTT #2.5 The Redundant Watch by Ji Lee

All images © Anicorn Watches x The Redundant Watch

More Links

Support their Kickstarter
Shop Anicorn Watches


How to Rescue Bad Brand Assets

Original Source: https://www.webdesignerdepot.com/2019/07/how-to-rescue-bad-brand-assets/

Just imagine it, you walk into your office, and you get a notification: your client has just dropped everything you need into your cloud storage provider of choice. The copy brings tears of joy to your eyes, the images are crisp, clean, and huge. The logo is a work of art, and the client has sent a note saying, “Actually, we don’t need you to finish up for another three months, but why don’t I just pay you double right now?”

And then you wake up.

The truth is that your deadline is the same, but they’re “just wondering if you could speed things up a little”, the provided images are 640×480 and just blurry enough to be annoying, the logo is an abomination made in Word, and the brand’s colors remind you of those awful school uniforms you used to wear.

some people have a talent for picking the absolute worst shades of brown, yellow, and green for their brand

Okay, now I’m just being mean, but it’s a sad reality that we often have to work with sub-par assets in web design projects. Logos don’t always look great, and some people have a talent for picking the absolute worst shades of brown, yellow, and green for their brand. It’s enough to make you throw your hands in the air flamboyantly and shout, “I just can’t work with this!”

But what about all those times when you don’t have a choice, and your clients refuse to let you completely redo their branding? You know, most of the time. Well, you do have a few options.

Ugly Logos

Just kind of ignore the logo as much as you can, really. I mean, obviously, it needs to be there, probably in the upper-left, or in the upper-middle. But just sort of… leave it there. There’s not much you can really do about a logo. The users need to see it, and the client will definitely be annoyed if it’s not there.

if there was ever a time to push back when the client asks you to make the logo bigger, this is it

However, if there was ever a time to push back when the client asks you to make the logo bigger, this is it. And where a lot of sites will incorporate the logo mark into other aspects of the design, this time, it’s staying in its designated spot. Maybe if the rest of the site looks drastically better than the logo, it will give the client pause, and perhaps even a reason to get it redone.

Thankfully, few logos are ever truly that ugly, at least among clients who can afford you. Overcomplicated and hard to see at small sizes? Yes. Generic and boring? Sure. But WordArt-ugly? Thankfully that’s not as common as it once was.

Ugly Colors

Colors are another story, and for every color combination that sparks joy, Marie Kondo-style, there’s a combination that sparks nausea. But hey, brand guides are brand guides, and you gotta follow the brand guide.

The best thing to do is to use the colors, but as sparingly as possible. Many colors are only truly terrible when they’re in close proximity to each other, so use some (probably literal) white space to your advantage. Keep them apart, and use them only for emphasis.

Will your client ever demand that you make the entire background puke-green? It’s possible. Even then, maybe you could get away with using a gradient to minimize any negative effects.

Low-Quality Images

Once again, embrace the white space. If all you have to work with are a bunch of very small images, make that small size look intentional. Make those tiny images the center of attention, and pray most of your users aren’t using retina screens. You can get away with a lot if you make it look like you planned it all from the very beginning.

if Instagram has taught us anything, it’s that excessive filtering can make any old photo look like it’s supposed to be art

Another way to do this is to use the images as large, blurry backgrounds. This works best with landscapes and macro shots, though. That company “team portrait” doesn’t work as well for background material, sadly.

Lastly, if Instagram has taught us anything, it’s that excessive filtering can make any old photo look like it’s supposed to be art. Sometimes. Add some film grain, desaturate the photos, and maybe throw in some harsh, spotty lighting. Users can’t judge what can barely be seen.

I’m only half joking.

Legacy UI Elements & Widgets

Now this is a rare situation, but on occasion, a client might have some leftover UI assets that they really, really love. Maybe they designed their first shiny Web 2.0 button in Xara 3D nearly twenty years ago, and they just have to use it. Maybe they have a favorite graph showing how their business works.

Again, this isn’t common, but you may find yourself having to work around it. For the example of the graph, I’d put a full-on skeuomorphic, photo-realistic picture frame around it. I’d treat it like a piece of the company’s history. An approach like this could also work for the example of the button.

When All Else Fails, Lean Into the Ugly

Brutalism is a thing. It’s like I said before: you can get away with a lot if you make it look like you fully intended to use butt-ugly color palettes, low-quality images, or even ‘90s clipart. That’s right, you can make clipart work. I’ve seen people do it.

Embrace the aesthetic, and call it retro, or call it ironic, I don’t care. I mean—and I admit, this is the example I use every time I talk about less-than-pretty design—people still love Craigslist. Making the website work is more important than making it beautiful. Giving the user what they want, when they want it, is worth a million high-resolution photos, and Jon-Hicks-designed logos.

 

Featured image via Unsplash.

Source

p img {display:inline-block; margin-right:10px;}
.alignleft {float:left;}
p.showcase {clear:both;}
body#browserfriendly p, body#podcast p, div#emailbody p{margin:0;}

The State of Video Marketing in 2019

Original Source: http://feedproxy.google.com/~r/Designrfix/~3/vshfJI_QOJo/the-state-of-video-marketing-in-2019

Featured image courtesy of Flickr. Video marketing has more than proven its worth over the past few years. It has turned into a staple in marketing, but it’s constantly changing and giving new opportunities to marketers to create entertaining content. Everyone is doing it and it’s easy to get into, so there’s no longer an […]

The post The State of Video Marketing in 2019 appeared first on designrfix.com.

Talk Tech with Us in Our New Discord Community

Original Source: https://www.sitepoint.com/talk-tech-with-us-in-our-new-discord-community/?utm_source=rss

Want a place to chat about coding, design, the web, and technology at large with likeminded people?

Or perhaps you work remotely and need a community that can travel with you?

SitePoint Discord serverWe’re opening our Discord to the public today. We wanted to create a casual place where we could chat about cool tech and getting stuff done, without the exhibitionism and divisive atmosphere of social media, but with that real-time sense of community.

Our server is a baby server, and there’s a lot of work to be done, but for now we have rooms for all sorts of conversation. Whether you want to puzzle out web development issues or talk games, we’ve got you covered.

Sign up to our Discord and start chatting with SitePoint staff, members, and the wider developer community!

It’s 100% free. Come on in and have chat with us!

⚡️ Join us for a chat now.

The post Talk Tech with Us in Our New Discord Community appeared first on SitePoint.

Collective #528

Original Source: http://feedproxy.google.com/~r/tympanus/~3/R12r3TtDq2k/

C528_bound

Bounds.js

Asynchronous boundary detection for lazy-loading, infinite scroll and more. By Christopher Cavalea.

Check it out

C528_Hover

This content is sponsored via Syndicate Ads
What is the Best Domain Name for a Developer?

Own the domain that took the dev world by storm in 2019! The .DEV domain is perfect for your coding projects, your personal website, or your GitHub.

Check it out

C528_number

Numverify

A global phone number validation and lookup JSON API that supports 232 countries.

Check it out

C528_animapi

CSS Animation Worklet API

The first draft of the CSS Animation Worklet API that allows for running scripted animations without impacting the main thread.

Read it

C528_imageformat

Using Basis Textures in Three.js

Learn about the new Basis Universal image format that was designed to produce very small file sizes and to be decoded on graphic cards instead of the CPU. An article by Ada Rose Cannon.

Read it

C528_stagger

Different Approaches for Creating a Staggered Animation

Daniel Benmore explores how to pull off staggered animations using different methods.

Read it

C528_customprop

CSS Custom Properties In The Cascade

In this article, Miriam Suzanne takes a deeper dive into the ‘CSS Custom Properties for Cascading Variables’ specification to ask, “Why are they called custom properties, how do they work in the cascade, and what else can we do with them?”

Read it

C528_36days

36 Days of Type – Reflector Digital

The amazing contributions of the Reflector Digital team to the 36 Days of Type project.

Check it out

C528_awesomehtml

HTML can do that?

Ananya Neogi collects some amazing things you can do with just HTML.

Check it out

C528_schedulecssgrid

Building a Conference Schedule with CSS Grid

Mark Root-Wiley shows how to pull off a very practical use case for CSS grid.

Read it

C528_electron

The Secret of Good Electron Apps

James Long created an excellent base project to encourage people to create truly local Electron apps.

Read it

C528_gamified

mentored.dev

A gamified learning platform to help you become a web developer. Read more about it in this tweet.

Check it out

C528_darkmode

darkmodejs

A utility package for managing Dark Mode on the web. By the Assortment team.

Check it out

C528_trees

How accessibility trees inform assistive tech

Hidde de Vries takes a look at how “good” client-side code improves the experience of users of assistive technologies, and how we can use accessibility trees to help verify our work on the user experience.

Read it

C528_statuscodes

HTTP Cats

In case you didn’t know about it: easy HTTP status code pages with meaningful cat images.

Check it out

C528_demozdog

Pipes w/ Zdog + GSAP

A cool Zdog experiment coded by Jhey.

Check it out

C528_urlpage

URL Pages

URL Pages is a proof of concept that works by storing the entire contents of a web page in the URL.

Check it out

C528_visualization

Data visualization

A set of guidelines for good data visualization as part of Google’s Material Design.

Read it

C528_access

a11y-css-reset

A small set of global CSS rules to make things accessible and reset default styling. By Mike Engel.

Check it out

C528_gan

GANPaint Studio

GANPaint Studio is a glimpse into the future of creative tools. It provides semantic photo manipulation with a generative image prior.

Check it out

C528_upload

Drag & Drop

A beautiful drag and drop interface made by Aaron Iker.

Check it out

C528_synth

Learning Synths

Learn about synthesizers via Ableton’s interactive website. Play with a synth in your browser and learn to use the various parts of a synth to make your own sounds.

Check it out

C528_bw

B/W Creative Coding Animations

Some creative interactive coding experiments made by David Darx.

Check it out

C528_program

ProGram

ProGram is a CLI based, self-hosted photo sharing app.

Check it out

Collective #528 was written by Pedro Botelho and published on Codrops.

Introducing Osore Shanghai Lightroom Presets inspired by Cyberpunk

Original Source: http://feedproxy.google.com/~r/abduzeedo/~3/Ryo0emBuKLQ/introducing-osore-shanghai-lightroom-presets-inspired-cyberpunk

Introducing Osore Shanghai Lightroom Presets inspired by Cyberpunk
Introducing Osore Shanghai Lightroom Presets inspired by Cyberpunk

AoiroStudioJul 02, 2019

François here from ABDZ, it’s been a little while since I last shared an update on my Osore Lightroom Presets. I was kept pretty busy with my personal life and building ABDZ at the same time. I did find some time to finally release my new Lightroom presets titled: Osore Shanghai. Three entirely re-designed presets customizable and made for Adobe Lightroom CC and Classic CC as a eulogy to my time in the city back in April. It was my first time in China and it’s quite an unconventional experience when compared to other countries like Japan for starters.

The modern technology and language became a barrier to tackle every day even though people thought I was a local. I definitely had a delightful time and as the night falls ‘Shanghai Neons’ would shine its gritty & obscure streets. The old and new structures make this city quite unparalleled in its culture, architecture but by keeping its traditional roots. To celebrate the launch, I am sharing a discount code! Use “nihao” at checkout and get 30% of everything in the store.

The old and new structures make this city quite unparalleled in its culture, architecture but by keeping its traditional roots

Introducing Osore Shanghai Lightroom Presets inspired by CyberpunkIntroducing Osore Shanghai

Links
Shop Osore Presets
Instagram
Osore Shanghai OS8
Introducing Osore Shanghai Lightroom Presets inspired by CyberpunkIntroducing Osore Shanghai Lightroom Presets inspired by CyberpunkIntroducing Osore Shanghai Lightroom Presets inspired by CyberpunkIntroducing Osore Shanghai Lightroom Presets inspired by Cyberpunk

Osore Shanghai OS9
Introducing Osore Shanghai Lightroom Presets inspired by CyberpunkIntroducing Osore Shanghai Lightroom Presets inspired by CyberpunkIntroducing Osore Shanghai Lightroom Presets inspired by CyberpunkIntroducing Osore Shanghai Lightroom Presets inspired by Cyberpunk

Osore Shanghai OS10
Introducing Osore Shanghai Lightroom Presets inspired by CyberpunkIntroducing Osore Shanghai Lightroom Presets inspired by CyberpunkIntroducing Osore Shanghai Lightroom Presets inspired by CyberpunkIntroducing Osore Shanghai Lightroom Presets inspired by Cyberpunk

Limited Code

Please use “nihao” at checkout and get 30% off everything in the store, enjoy! It’s for a limited time only!

Links
Shop Osore Presets
Stay Connected
ABDZ Facebook
ABDZ Instagram


CSS Custom Properties In The Cascade

Original Source: https://www.smashingmagazine.com/2019/07/css-custom-properties-cascade/

CSS Custom Properties In The Cascade

CSS Custom Properties In The Cascade

Miriam Suzanne

2019-07-01T12:30:59+02:00
2019-07-01T12:46:47+00:00

Last month, I had a conversation on Twitter about the difference between “scoped” styles (generated in a build process) and “nested” styles native to CSS. I asked why, anecdotally, developers avoid the specificity of ID selectors, while embracing “scoped styles” generated by JavaScript? Keith Grant suggested that the difference lies in balancing the cascade* and inheritance, i.e. giving preference to proximity over specificity. Let’s take a look.

The Cascade

The CSS cascade is based on three factors:

Importance defined by the !important flag, and style origin (user > author > browser)
Specificity of the selectors used (inline > ID > class > element)
Source Order of the code itself (latest takes precedence)

Proximity is not mentioned anywhere — the DOM-tree relationship between parts of a selector. The paragraphs below will both be red, even though #inner p describes a closer relationship than #outer p for the second paragraph:

See the Pen [Cascade: Specificity vs Proximity](https://codepen.io/smashingmag/pen/OexweJ/) by Miriam Suzanne.

See the Pen Cascade: Specificity vs Proximity by Miriam Suzanne.

<section id=”outer”>
<p>This text is red</p>
<div id=”inner”>
<p>This text is also red!</p>
</div>
</section>

#inner p {
color: green;
}

#outer p {
color: red;
}

Both selectors have the same specificity, they are both describing the same p element, and neither is flagged as !important — so the result is based on source-order alone.

BEM And Scoped Styles

Naming conventions like BEM (“Block__Element—Modifier”) are used to ensure that each paragraph is “scoped” to only one parent, avoiding the cascade entirely. Paragraph “elements” are given unique classes specific to their “block” context:

See the Pen [BEM Selectors & Proximity](https://codepen.io/smashingmag/pen/qzPyeM/) by Miriam Suzanne.

See the Pen BEM Selectors & Proximity by Miriam Suzanne.

<section class=”outer”>
<p class=”outer__p”>This text is red</p>
<div class=”inner”>
<p class=”inner__p”>This text is green!</p>
</div>
</section>

.inner__p {
color: green;
}

.outer__p {
color: red;
}

These selectors still have the same relative importance, specificity, and source order — but the results are different. “Scoped” or “modular” CSS tools automate that process, re-writing our CSS for us, based on the HTML. In the code below, each paragraph is scoped to its direct parent:

See the Pen [Scoped Style Proximity](https://codepen.io/smashingmag/pen/NZaLWN/) by Miriam Suzanne.

See the Pen Scoped Style Proximity by Miriam Suzanne.

<section outer-scope>
<p outer-scope>This text is red</p>
<div outer-scope inner-scope>
<p inner-scope>This text is green!</p>
</div>
</section>

p[inner-scope] {
color: green
}

p[outer-scope] {
color: red;
}

Inheritance

Proximity is not part of the cascade, but it is part of CSS. That’s where inheritance becomes important. If we drop the p from our selectors, each paragraph will inherit a color from its closest ancestor:

See the Pen [Inheritance: Specificity vs Proximity](https://codepen.io/smashingmag/pen/mZBGyN/) by Miriam Suzanne.

See the Pen Inheritance: Specificity vs Proximity by Miriam Suzanne.

#inner {
color: green;
}

#outer {
color: red;
}

Since #inner and #outer describe different elements, our div and section respectively, both color properties are applied without conflict. The nested p element has no color specified, so the results are determined by inheritance (the color of the direct parent) rather than cascade. Proximity takes precedence, and the #inner value overrides the #outer.

But there’s a problem: In order to use inheritance, we are styling everything inside our section and div. We want to target the paragraph color specifically.

(Re-)Introducing Custom Properties

Custom properties provide a new, browser-native solution; they inherit like any other property, but they don’t have to be used where they are defined. Using plain CSS, without any naming conventions or build tools, we can create a style that is both targeted and contextual, with proximity taking precedence over the cascade:

See the Pen [Custom Props: Specificity vs Proximity](https://codepen.io/smashingmag/pen/gNGdaO/) by Miriam Suzanne.

See the Pen Custom Props: Specificity vs Proximity by Miriam Suzanne.

p {
color: var(–paragraph);
}

#inner {
–paragraph: green;
}

#outer {
–paragraph: red;
}

The custom –paragraph property inherits just like the color property, but now we have control over exactly how and where that value is applied. The –paragraph property acts similar to a parameter that can be passed into the p component, either through direct selection (specificity-rules) or context (proximity-rules).

I think this reveals a potential for custom properties that we often associate with functions, mixins, or components.

Custom “Functions” And Parameters

Functions, mixins, and components are all based on the same idea: reusable code, that can be run with various input parameters to get consistent-but-configurable results. The distinction is in what they do with the results. We’ll start with a striped-gradient variable, and then we can extend it into other forms:

html {
–stripes: linear-gradient(
to right,
powderblue 20%, pink 20% 40%, white 40% 60%, pink 60% 80%, powderblue 80%
);
}

That variable is defined on the root html element (could also use :root, but that adds unnecessary specificity), so our striped variable will be available everywhere in the document. We can apply it anywhere gradients are supported:

See the Pen [Custom Props: Variable](https://codepen.io/smashingmag/pen/NZwrrm/) by Miriam Suzanne.

See the Pen Custom Props: Variable by Miriam Suzanne.

body {
background-image: var(–stripes);
}

Adding Parameters

Functions are used like variables, but define parameters for changing the output. We can update our –stripes variable to be more function-like by defining some parameter-like variables inside it. I’ll start by replacing to right with var(–stripes-angle), to create an angle-changing parameter:

html {
–stripes: linear-gradient(
var(–stripes-angle),
powderblue 20%, pink 20% 40%, white 40% 60%, pink 60% 80%, powderblue 80%
);
}

There are other parameters we could create, depending on what purpose the function is meant to serve. Should we allow users to pick their own stripe colors? If so, does our function accept 5 different color parameters or only 3 that will go outside-in like we have now? Do we want to create parameters for color-stops as well? Every parameter we add provides more customization at the cost of simplicity and consistency.

There is no universal right answer to that balance — some functions need to be more flexible, and others need to be more opinionated. Abstractions exist to provide consistency and readability in your code, so take a step back and ask what your goals are. What really needs to be customizable, and where should consistency be enforced? In some cases, it might be more helpful to have two opinionated functions, rather than one fully-customizable function.

To use the function above, we need to pass in a value for the –stripes-angle parameter, and apply the output to a CSS output property, like background-image:

/* in addition to the code above… */
html {
–stripes-angle: 75deg;
background-image: var(–stripes);
}

See the Pen [Custom Props: Function](https://codepen.io/smashingmag/pen/BgwOjj/) by Miriam Suzanne.

See the Pen Custom Props: Function by Miriam Suzanne.

Inherited Versus Universal

I defined the –stripes function on the html element out of habit. Custom properties inherit, and I want my function available everywhere, so it makes some sense to put it on the root element. That works well for inheriting variables like –brand-color: blue, so we might also expect it to work for our “function” as well. But if we try to use this function again on a nested selector, it won’t work:

See the Pen [Custom Props: Function Inheritance Fail](https://codepen.io/smashingmag/pen/RzjRrM/) by Miriam Suzanne.

See the Pen Custom Props: Function Inheritance Fail by Miriam Suzanne.

div {
–stripes-angle: 90deg;
background-image: var(–stripes);
}

The new –stripes-angle is ignored entirely. It turns out we can’t rely on inheritance for functions that need to be re-calculated. That’s because each property value is computed once per element (in our case, the html root element), and then the computed value is inherited. By defining our function at the document root, we don’t make the entire function available to descendants — only the computed result of our function.

That makes sense if you frame it in terms of the cascading –stripes-angle parameter. Like any inherited CSS property, it is available to descendants but not ancestors. The value we set on a nested div is not available to a function we defined on the html root ancestor. In order to create a universally-available function that will re-calculate on any element, we have to define it on every element:

See the Pen [Custom Props: Universal Function](https://codepen.io/smashingmag/pen/agLaNj/) by Miriam Suzanne.

See the Pen Custom Props: Universal Function by Miriam Suzanne.

* {
–stripes: linear-gradient(
var(–stripes-angle),
powderblue 20%, pink 20% 40%, white 40% 60%, pink 60% 80%, powderblue 80%
);
}

The universal selector makes our function available everywhere, but we can define it more narrowly if we want. The important thing is that it can only re-calculate where it is explicitly defined. Here are some alternatives:

/* make the function available to elements with a given selector */
.stripes { –stripes: /* etc… */; }

/* make the function available to elements nested inside a given selector */
.stripes * { –stripes: /* etc… */; }

/* make the function available to siblings following a given selector */
.stripes ~ * { –stripes: /* etc… */; }

See the Pen [Custom Props: Scoped Function](https://codepen.io/smashingmag/pen/JQMvGM/) by Miriam Suzanne.

See the Pen Custom Props: Scoped Function by Miriam Suzanne.

This can be extended with any selector logic that doesn’t rely on inheritance.

Free Parameters And Fallback Values

In our example above, var(–stripes-angle) has no value and no fallback. Unlike Sass or JS variables that must be defined or instantiated before they are called, CSS custom properties can be called without ever being defined. This creates a “free” variable, similar to a function parameter that can be inherited from the context.

We can eventually define the variable on html or :root (or any other ancestor) to set an inherited value, but first we need to consider the fallback if no value is defined. There are several options, depending on exactly what behavior we want

For “required” parameters, we don’t want a fallback. As-is, the function will do nothing until –stripes-angle is defined.
For “optional” parameters, we can provide a fallback value in the var() function. After the variable-name, we add a comma, followed by the default value:

var(–stripes-angle, 90deg)

Each var() function can only have one fallback — so any additional commas will be part of that value. That makes it possible to provide complex defaults with internal commas:

html {
/* Computed: Hevetica, Ariel, sans-serif */
font-family: var(–sans-family, Hevetica, Ariel, sans-serif);

/* Computed: 0 -1px 0 white, 0 1px 0 black */
test-shadow: var(–shadow, 0 -1px 0 white, 0 1px 0 black);
}

We can also use nested variables to create our own cascade rules, giving different priorities to the different values:

var(–stripes-angle, var(–global-default-angle, 90deg))

First, try our explicit parameter (–stripes-angle);
Fallback to a global “user default” (–user-default-angle) if it’s available;
Finally, fallback to our “factory default” (90deg).

See the Pen [Custom Props: Fallback Values](https://codepen.io/smashingmag/pen/jjGvVm/) by Miriam Suzanne.

See the Pen Custom Props: Fallback Values by Miriam Suzanne.

By setting fallback values in var() rather than defining the custom property explicitly, we ensure that there are no specificity or cascade restrictions on the parameter. All the *-angle parameters are “free” to be inherited from any context.

Browser Fallbacks Versus Variable Fallbacks

When we’re using variables, there are two fallback paths we need to keep in mind:

What value should be used by browsers without variable support?
What value should be used by browsers that support variables, when a particular variable is missing or invalid?

p {
color: blue;
color: var(–paragraph);
}

While old browsers will ignore the variable declaration property, and fallback to blue — modern browsers will read both and use the latter. Our var(–paragraph) might not be defined, but it is valid and will override the previous property, so browsers with variable support will fallback to the inherited or initial value, as if using the unset keyword.

That may seem confusing at first, but there are good reasons for it. The first is technical: browser engines handle invalid or unknown syntax at “parse time” (which happens first), but variables are not resolved until “computed-value time” (which happens later).

At parse time, declarations with invalid syntax are ignored completely — falling back on earlier declarations. This is the path that old browsers will follow. Modern browsers support the variable syntax, so the previous declaration is discarded instead.
At computed-value time the variable is compiled as invalid, but it’s too late — the previous declaration was already discarded. According to the spec, invalid variable values are treated the same as unset:

See the Pen [Custom Props: Invalid/Unsupported vs Undefined](https://codepen.io/smashingmag/pen/VJMGbJ/) by Miriam Suzanne.

See the Pen Custom Props: Invalid/Unsupported vs Undefined by Miriam Suzanne.

html {
color: red;

/* ignored as *invalid syntax* by all browsers */
/* – old browsers: red */
/* – new browsers: red */
color: not a valid color;
color: var(not a valid variable name);

/* ignored as *invalid syntax* by browsers without var support */
/* valid syntax, but invalid *values* in modern browsers */
/* – old browsers: red */
/* – new browsers: unset (black) */
–invalid-value: not a valid color value;
color: var(–undefined-variable);
color: var(–invalid-value);
}

This is also good for us as authors, because it allows us to play with more complex fallbacks for the browsers that support variables, and provide simple fallbacks for older browsers. Even better, that allows us to use the null/undefined state to set required parameters. This becomes especially important if we want to turn a function into a mixin or component.

Custom Property “Mixins”

In Sass, the functions return raw values, while mixins generally return actual CSS output with property-value pairs. When we define a universal –stripes property, without applying it to any visual output, the result is function-like. We can make that behave more like a mixin, by defining the output universally as well:

* {
–stripes: linear-gradient(
var(–stripes-angle),
powderblue 20%, pink 20% 40%, white 40% 60%, pink 60% 80%, powderblue 80%
);
background-image: var(–stripes);
}

As long as –stripes-angle remains invalid or undefined, the mixin fails to compile, and no background-image will be applied. If we set a valid angle on any element, the function will compute and give us a background:

div {
–stripes-angle: 30deg; /* generates the background */
}

Unfortunately, that parameter-value will inherit, so the current definition creates a background on the div and all descendants. To fix that, we have to make sure the –stripes-angle value doesn’t inherit, by resting it to initial (or any invalid value) on every element. We can do that on the same universal selector:

See the Pen [Custom Props: Mixin](https://codepen.io/smashingmag/pen/ZdXMJx/) by Miriam Suzanne.

See the Pen Custom Props: Mixin by Miriam Suzanne.

* {
–stripes-angle: initial;
–stripes: /* etc… */;
background-image: var(–stripes);
}

Safe Inline Styles

In some cases, we need the parameter to be set dynamically from outside CSS — based on data from a back-end server or front-end framework. With custom properties, we can safely define variables in our HTML without worrying about the usual specificity issues:

See the Pen [Custom Props: Mixin + Inline Style](https://codepen.io/smashingmag/pen/qzPMPv/) by Miriam Suzanne.

See the Pen Custom Props: Mixin + Inline Style by Miriam Suzanne.

<div style=”–stripes-angle: 30deg”>…</div>

Inline styles have a high specificity, and are very hard to override — but with custom properties, we we have another option: ignore it. If we set the div to background-image: none (for example) that inline variable will have no impact. To take it even farther, we can create an intermediate variable:

* { –stripes-angle: var(–stripes-angle-dynamic, initial); }

Now we have the option to define –stripes-angle-dynamic in the HTML, or ignore it, and set –stripes-angle directly in our stylesheet.

See the Pen [Custom Props: Mixin + Inline / Override](https://codepen.io/smashingmag/pen/ZdXMao/) by Miriam Suzanne.

See the Pen Custom Props: Mixin + Inline / Override by Miriam Suzanne.

Preset Values

For more complex values, or common patterns we want to re-use, we can also provide a few preset variables to choose from:

* {
–tilt-down: 6deg;
–tilt-up: -6deg;
}

And use those presets, rather than setting the value directly:

<div style=”–stripes-angle: var(–tilt-down)”>…</div>

See the Pen [Custom Props: Mixin + Presets](https://codepen.io/smashingmag/pen/LKemZm/) by Miriam Suzanne.

See the Pen Custom Props: Mixin + Presets by Miriam Suzanne.

This is great for creating charts and graphs based on dynamic data, or even laying out a day planner.

See the Pen [Bar chart in CSS grid + variables](https://codepen.io/smashingmag/pen/wLrEyg/) by Miriam Suzanne.

See the Pen Bar chart in CSS grid + variables by Miriam Suzanne.

Contextual Components

We can also re-frame our “mixin” as a “component” by applying it to an explicit selector, and making the parameters optional. Rather than relying on the presence-or-absence of –stripes-angle to toggle our output, we can rely on the presence-or-absence of a component selector. That allows us to set fallback values safely:

See the Pen [Custom Props: Component](https://codepen.io/smashingmag/pen/QXqVmM/) by Miriam Suzanne.

See the Pen Custom Props: Component by Miriam Suzanne.

[data-stripes] {
–stripes: linear-gradient(
var(–stripes-angle, to right),
powderblue 20%, pink 20% 40%, white 40% 60%, pink 60% 80%, powderblue 80%
);
background-image: var(–stripes);
}

By putting the fallback inside the var() function, we can leave –stripes-angle undefined and “free” to inherit a value from outside the component. This is a great way to expose certain aspects of a component style to contextual input. Even “scoped” styles generated by a JS framework (or scoped inside the shadow-DOM, like SVG icons) can use this approach to expose specific parameters for outside influence.

Isolated Components

If we don’t want to expose the parameter for inheritance, we can define the variable with a default value:

[data-stripes] {
–stripes-angle: to right;
–stripes: linear-gradient(
var(–stripes-angle, to right),
powderblue 20%, pink 20% 40%, white 40% 60%, pink 60% 80%, powderblue 80%
);
background-image: var(–stripes);
}

These components would also work with a class, or any other valid selector, but I chose the data-attribute to create a namespace for any modifiers we want:

[data-stripes=’vertical’] { –stripes-angle: to bottom; }
[data-stripes=’horizontal’] { –stripes-angle: to right; }
[data-stripes=’corners’] { –stripes-angle: to bottom right; }

See the Pen [Custom Props: Isolated Components](https://codepen.io/smashingmag/pen/agLaGX/) by Miriam Suzanne.

See the Pen Custom Props: Isolated Components by Miriam Suzanne.

Selectors and Parameters

I often wish I could use data-attributes to set a variable — a feature supported by the CSS3 attr() specification, but not yet implemented in any browsers (see the resources tab for linked issues on each browser). That would allow us to more closely associate a selector with a particular parameter:

<div data-stripes=”30deg”>…</div>

/* Part of the CSS3 spec, but not yet supported */
/* attr( , ) */
[data-stripes] {
–stripes-angle: attr(data-stripes angle, to right);
}

In the meantime, we can achieve something similar by using the style attribute:

See the Pen [Custom Props: Style Selectors](https://codepen.io/smashingmag/pen/PrJdBG/) by Miriam Suzanne.

See the Pen Custom Props: Style Selectors by Miriam Suzanne.

<div style=”–stripes-angle: 30deg”>…</div>

/* The `*=` atttribute selector will match a string anywhere in the attribute */
[style*=’–stripes-angle’] {
/* Only define the function where we want to call it */
–stripes: linear-gradient(…);
}

This approach is most useful when we want to include other properties in addition to the parameter being set. For example, setting a grid area could also add padding and background:

[style*=’–grid-area’] {
background-color: white;
grid-area: var(–grid-area, auto / 1 / auto / -1);
padding: 1em;
}

Conclusion

When we start to put all these pieces together, it becomes clear that custom properties go far beyond the common variable use-cases we’re familiar with. We’re not only able to store values, and scope them to the cascade — but we can use them to manipulate the cascade in new ways, and create smarter components directly in CSS.

This calls for us to re-think many of the tools we’ve relied on in the past — from naming conventions like SMACSS and BEM, to “scoped” styles and CSS-in-JS. Many of those tools help work around specificity, or manage dynamic styles in another language — use-cases that we can now address directly with custom properties. Dynamic styles that we’ve often calculated in JS, can now be handled by passing raw data into the CSS.

At first, these changes may be seen as “added complexity” — since we’re not used to seeing logic inside CSS. And, as with all code, over-engineering can be a real danger. But I’d argue that in many cases, we can use this power not to add complexity, but to move complexity out of third-party tools and conventions, back into the core language of web design, and (more importantly) back into the browser. If our styles require calculation, that calculation ought to live inside our CSS.

All of these ideas can be taken much further. Custom properties are just starting to see wider adoption, and we’ve only begun to scratch the surface of what’s possible. I’m excited to see where this goes, and what else people come up with. Have fun!

Further Reading

“It’s Time To Start Using CSS Custom Properties,” Serg Hospodarets
“A Strategy Guide to CSS Custom Properties,” Michael Riethmuller

Smashing Editorial
(dm, il)

Better Search UX Through Microcopy

Original Source: https://www.smashingmagazine.com/2019/06/better-search-ux-microcopy/

Better Search UX Through Microcopy

Better Search UX Through Microcopy

Andrew Millen

2019-06-28T12:30:59+02:00
2019-06-28T21:35:50+00:00

It’s hard to overstate the importance of web search. Searching is as old as the Internet itself, and by some measures, even older. A well-designed search benefits both you and your users; it increases conversions, reduces bounce rates, and improves the user experience.

Search is especially important on large scale sites and e-commerce experiences, where the majority of revenue comes from search-driven sessions. Studies show that up to 50% of users go straight to the internal search bar of a website, and that 15% outright prefer using the search function to browsing the hierarchical menu. This means that for all the love and care that goes into determining the information architecture of a site, just as much has to go into designing the search experience.

Complicating the problem is the fact that users’ search skills are flimsy at best, and incompetent at worst. Getting good results from a search engine often requires multiple attempts and reformulations, which users rarely do. And as search technology improves over time, users are increasingly likely to accept the results of a search as the answer to their question, even if their query was flawed. Users who favor searches tend to move quickly, scanning the page for that familiar-looking rectangle, and bouncing quickly when they don’t find what they’re looking for.

Communicating with those users “at speed” is a tricky job that requires a specialized tool: microcopy. The name ‘microcopy’ belies its own importance. It may be small, but big successes often hinge on it. It’s a place where voice can shine through, where good impressions are made, and where utility and branding intersect. With that in mind, let’s dive into the many ways that microcopy and contextualization can vastly improve a search experience.

Placing And Labeling Your Search

In accordance with Jakob’s Law, your first instinct when designing a search bar should be to put a rectangular box in the upper right or upper left corner. You should add a label or A11y-friendly placeholder text, and include a submit button that says “Search.”

Hiding the search bar behind a link, forgoing placeholder text, or opting for magnifying glass icon CTA instead of plain text are all valid design decisions in the right context. Just make sure you’re not abstracting the function of the search bar unnecessarily because searching already has a higher interaction cost than browsing.

Every barrier, however inconsequential you may find it as a designer, risks negatively affecting the UX and your bottom line. If there’s a risk your users may confuse the magnifying glass icon for a “zoom” button, you should mitigate that.

Placeholder Text

Placeholder text is a great place to enhance the experience. It can be informational, it can be a place for brand expression, and it can nudge wavering users in the right direction. Anytime I see a search bar that just says “Search,” I see a missed opportunity.

So what’s a better approach? It varies from site to site. First, familiarize yourself with your business goals, your brand, and your users’ existing habits. Then, consider how you can be the most helpful.

Nudge The User

A suggestive approach can reduce the user’s anxiety. Clue your users into the fact that they can search in multiple ways, especially if they may not be familiar with your full range of products or services. ASOS suggests searching for inspiration in addition to products and brands:

The search bar on the ASOS website

(Image source: ASOS) (Large preview)

Be Informative

Tell the user exactly what they’ll be getting when they hit submit. On Shutterstock, a site wholly devoted to the search of a massive photo archive, this placeholder text cleverly doubles as a tagline when paired with the logo:

The search bar on the Shutterstock website

(Image source: Shutterstock) (Large preview)

Reinforce The Brand

Home Depot’s search bar doesn’t lead the user, but instead presents a helpful, personal tone which I’m sure is in line with their brand voice guidelines. This is probably the best approach considering the size of their product catalog:

Home Depot’s search bar

(Image source: The Home Depot) (Large preview)

Using Search Logs To Your Advantage

If you’re not sure the best way to optimize your placeholder text, a good place to start is your search log database. Learning how to break down these results can be incredibly valuable when formulating helpful content design. You’ll be able to see first-hand the vocabulary people use to search your site, and more importantly, the gaps between what you offer and what your users are looking for.

Suggested, Related, And Recent Searches

During the search process, your copy should offer as much help along the way as possible without being overbearing. That includes everything from an obvious “Cancel” or “Clear” button to logging each user’s recent searches for surfacing later. When choosing the right microcopy to accompany these features, add a dash of brown sauce.

Autosuggestions

Users who use the search bar are doing so because they’re looking for something specific, which makes autosuggestions a valuable (and increasingly expected) tool. Specificity, in this case, may be as focused as “Women’s gray shoe size 9M” or as open-ended as “Sandwich shops near me.”

Autosuggestions also reduce the risk of returning bad results, alleviate the mental effort on the user, and present an opportunity to surface your most popular products.

Chewy

(Image source: Chewy) (Large preview)

Often these don’t require additional context or copy at all, but can just be listed below the search bar as the user types, as shown in the example above.

Related Searches

Showing related searches on the results page is another way to help guide users without getting in the way. A common pattern is providing a few clickable keywords related to the original query above the results. A little copy that states “Other users searched for” is a good way to incorporate social proof into the search experience.

Recent Searches

If your technology allows it, saving and resurfacing recent searches is another way to helpfully reduce the memory load on the user. Make sure you add context with copy, but it can be as straightforward as this:

The search bar on the Macy’s website

(Image source: Macy’s) (Large preview)

Handling Results

There are a two pieces of copy that I’d consider required when displaying search results:

The query itself.
If the search bar is highly visible, it can be displayed here. You can also create an H1 that states “Results for {{terms}}.”
The number of results.
If the results are paginated, you might also include the number of pages.

The search bar on the REI Co-op website

(Image source: REI Co-op) (Large preview)

No Results

Whether through their own error not, users will inevitably encounter a “no results” page at some point. Luckily, there are ways to handle this gracefully; in fact, with the right approach, this dead end can actually be a great opportunity for content discovery.

First of all, don’t expect your users to refine their search if they get no results — at least not without a UI that encourages it. Users are reluctant to reformulate their query and have trouble when trying to. They’re more likely to engage with whatever information they’re presented with and take it from there, or abandon the task entirely. (When was the last time you clicked through to the second page of Google search results?)

That said, it’s easy to see how a little copywriting and contextualization can improve the experience. Nielsen Norman Group has a comprehensive guide on how to handle No Results SERPs, with the gist being:

Make it obvious there are no results.
It’s easy to get cute and accidentally bury the lede. It’s also tempting to intentionally hide the “no results” messaging to obfuscate the error entirely. Either way, don’t trick the user.
Offer paths forward.
Suggest ways to refine the search query (such as checking your spelling), and also provide links to popular content or products that have the highest likelihood of connecting with the user.
Strike the right tone.
Use your brand voice, but don’t run the risk of exacerbating the situation with humor that might be ill-received by a frustrated user.

Also, bear in mind that empty SERPs may arise because a user mistakenly submitted without entering any query at all. You should have a content plan for this scenario as well rather than returning all items in the database, for example.

Wrapping Up

Writing a good search experience comes down to thoughtfulness. As designers, we’ve probably used and created hundreds of different web search experiences, so we breeze through the process. But when we consider every small step of the process (every microinteraction and every edge case), the minor changes we make can have a major impact on the experience. Next time you find yourself reaching for a visual solution to a search problem, consider using your words instead.

Further Reading on SmashingMag:

How To Run A Content-Planning Workshop
How Copywriting Can Benefit From User Research
Designing The Words: Why Copy Is A Design Issue
How To Deal With Redundant, Out-Of-Date And Trivial Content ROT

Smashing Editorial
(dm, yk, il)