Wednesday, September 2, 2015

JAIL – jQuery Asynchronous Image Loader

JAIL is a jQuery plugin that lazy load images making your page load faster. Images are downloaded when they are visible or when they become visible inside the viewport


by via jQuery-Plugins.net RSS Feed

Color Alchemy with Less: Creating Color Schemes and Palettes

Color is one of the most important elements in any visual design. When properly used, it can have great impact on your web site or application. But knowing color theory solely is not enough to achieve such impact. You need to have the right tool belt to operate easily and successfully with the multitude of colors. Fortunately, Less solves this practical problem by providing plenty of color functions to work with.

In this tutorial, I’ll explore how to use some of these color functions, in conjunction with other Less features, to produce flexible and reusable mixins for color manipulation.

Creating Color Schemes

When attempting to create color schemes with Less, most people take the most obvious approach, which looks like this:

[code language="scss"]
@base-color: #00ff00;
@triad-secondary: spin(@base-color, 120);
@triad-tertiary: spin(@base-color, -120);
[/code]

This method uses variables and Less’s spin() function to create a color scheme (triadic, in our case). This works fine, but for me it’s not particularly reusable and not flexible enough. Fortunately, the issue can be resolved by using mixins. Let’s see what I mean.

[code language="scss"]
.analog(@color, @variant, @property) {
@first: spin(@color, 30);
@second: spin(@color, -30);
@list: @first, @second;
@return: extract(@list, @variant);
@{property}: @return;
}

.triad(@color, @variant, @property) {
@first: spin(@color, 120);
@second: spin(@color, -120);
@list: @first, @second;
@return: extract(@list, @variant);
@{property}: @return;
}

.quad(@color, @variant, @property) {
@first: spin(@color, 90);
@second: spin(@color, -90);
@third: spin(@color, 180);
@list: @first, @second, @third;
@return: extract(@list, @variant);
@{property}: @return;
}
[/code]

The above code creates three types of color schemes. I’ll explain only the last one, because the first two have the same structure and they don’t need individual explanations.

The .quad() mixin takes three parameters. The first one sets the base color for the scheme. The second one tells the mixin which color variant to return. And the third one defines which CSS property to use when Less compiles the code. Inside the mixin’s body, the spin() function creates the three available color variants in a quad scheme, then these variants are put in a list. The extract() function gets the desired variant, defined in the second parameter. And finally, with the help of variable interpolation, the color variant is assigned to the defined CSS property.

We can now put the above code in a separate file called color_schemes.less and use it as follows:

[code language="scss"]
@import "color_schemes.less";

@base-color: #00ff00;

div {
width: 200px;
height: 100px;
border: thick solid;
.quad(@base-color, 3, border-color);
.quad(@base-color, 2, color);
.quad(@base-color, 1, background-color);
}
[/code]

Here we import the file with the color schemes, and then we define the base color for our website or application. The last three lines in the div rule set, define the colors for the border-color, color, and background-color properties.

As you can see, the mixin can be used with any property whose expected value is a color. Besides, it’s super easy to see for which property a particular statement is used; just take a look at the end, and boom, we know it. For example, in the last statement you can clearly see that the first color variant of the quad scheme will be used as the value for the background-color property. Pretty cool, huh?

Continue reading %Color Alchemy with Less: Creating Color Schemes and Palettes%


by Ivaylo Gerchev via SitePoint

Watch: Adding a Lap Logger to a React Stopwatch

Adding a lap-timer is no walk in the park, but what good is a stopwatch that only tracks one lap? We'll take all we've learned about state, lists, and conditional rendering to add this new feature. When we're done you'll be running laps of joy around your computer and timing them accurately.

This is part 3 of the Building a Stopwatch in React series.

Loading the player...

Continue reading %Watch: Adding a Lap Logger to a React Stopwatch%


by Michael Chan via SitePoint

Creating and Publishing an Android Library

iTunes Gift Card

Buy an iTunes Gift Card without having to link any debit or credit cards


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

Prime Union

We are a digital studio specialized in web design and mobile apps. Our team consists of experienced people, who during the years of working together were building their knowledge about designing and implementing new media projects and more. Our work


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

This Week's HTML5 and Browser Technology News (Issue 204)


Read this e-mail on the Web
HTML 5 Weekly
Issue 204 — September 2, 2015
Ilya Grigorik
A detailed look at ‘client hints’ (supported in Chrome 46) which lets the browser send extra hints via HTTP headers as to the sort of images it wants back.


Tal Ater
An offline first library that hides the complexity of using Service Workers and the new Caching API, and lets developers easily create sites that are accessible both online and offline.


Dudley Storey
Frequently ignored and often abused, these elements contribute greatly to creating a semantically and typographically rich page when used correctly.


Frontend Masters  Sponsored
14-day $5 trial of front-end training with industry legends. Upgrade for 38% off our original price, or cancel in 10 seconds. Until September 10th at midnight ONLY. See page for details.

Frontend Masters

Dr. Axel Rauschmayer
While much of the initial excitement over Web Components has died down, the technology is still very much alive. This post summarizes the story so far.


Google Developers
It’s now possible to manage whether scroll positions of pages are restored or not when navigating back through history.


W3C
How content is displayed is important to its understanding, and so we ask much of CSS. This document covers priorities for new CSS features.


Robin Whittleton
A look at the varying behaviors of browsers when rendering resized radio buttons and checkboxes.


Paul Lewis
requestIdleCallback is a new performance-oriented function for scheduling work to be performed when the user is idle, in order to keep pages fast and responsive.


Google Developers
The Chrome team are focusing on reducing Chrome’s memory footprint this year. Addy Osmani explains what’s involved, what they’re doing, and how you can help.


Jobs

In brief

Curated by Peter Cooper and published by Cooper Press.
Send feedback by simply replying to this mail.
Want to sponsor an issue? See our media kit.
Want to post a job? E-mail us or use our self-serve system.

Unsubscribe : Change email address : Read this issue on the Web

© Cooper Press Ltd. Office 30, Lincoln Way, Louth, LN11 0LS, UK
Email policy Privacy policy


by via HTML5 Weekly