Wednesday, October 11, 2017

Lottery.js – Simple Javascript Lottery App

Lottery.js is a simple javascript lottery app with following features:

  • Flexible
  • Out of the box
  • Interesting Animation Effects

by via jQuery-Plugins.net RSS Feed

How Facebook is Changing Your Internet [video]

Behind the scenes, Facebook is involved in high-stakes diplomatic battles across the globe that have begun fragmenting the internet itself.

[ This is a content summary only. Visit our website http://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Web Desk via Digital Information World

How to Use Warnings and Errors in Sass Effectively

The following is a short extract from our book, Jump Start Sass, written by Hugo Giraudel and Miriam Suzanne. It's the ultimate beginner's guide to JavaScript. SitePoint Premium members get access with their membership, or you can buy a copy in stores worldwide.

Our incredible journey through Sass is slowly coming to an end, and so far you’ve been doing great! There’s one technical chapter left before we look at project architecture, and then you’ll be fully equipped to write Sass code in your own projects.

Now we’re going to look at warnings and errors. Both form a one-way communication system between the program (in this case, Sass) and the developer (you). If you’re wondering about the point of errors in the CSS world, remember that you already know the answer. Whenever you forget a semicolon or use a function incorrectly, Sass throws an error at you, explaining what you’ve done wrong and how you can fix it, thankfully! It would be a real pain to have to dig into the code to figure out what’s gone wrong.

Sass has long provided a way to emit warnings from stylesheets, but it’s only recently added support to throw errors as well—and for good reason! Over the last few years, Sass has allowed authors to build complex systems to abstract difficult or repetitive patterns and concepts, such as grids. These systems must be able to communicate with authors, stopping the compilation process with a custom error message if anything ever goes wrong.

Both warnings and errors are emitted in the current output channel. When compiling Sass by hand or by using a tool through a command line interface (CLI) such as Grunt or Gulp, the output stream is the console. For tools that include a user interface, such as Codekit or Prepros, it’s likely that they catch and display warnings and errors as part of their interface. Online playgrounds such as CodePen and SassMeister manage to catch errors but not warnings, so don’t be alarmed if you’re unable to test them in there.

Warnings

As has been stated, the ability to emit warnings in Sass is not new. It’s possible to display messages or the value of any SassScript expression to the standard output stream through the @warn directive.

A warning has no impact on the compilationprocess; it does not prevent compiling to pursue or change it in any way. Its only purpose is to display a message in the console.

There are a lot of reasons to use warnings in Sass. Here are a couple, but you’re likely to find your own:

  • informing the user of an assumption made about the code in order to avoid surprise and hard-to-track bugs
  • advising about a deprecated function or mixin as part of a library or framework

Sending a warning is dead simple to do: start with the @warn directive, then state whatever it is. Warnings are usually made to provide some information and context, so they often feature a sentence explaining the situation. That being said, you don’t have to use a string; you can warn with a number, a list, a map—whatever. Here, we print a string:

@warn 'Uh-oh, something looks weird.';

Using a regular CLI client, this warning will emit the following output:

WARNING: Uh-oh, something looks weird.
         on line 1 of /Users/hgiraudel/jump-start-sass/warning.scss

Hey, that’s nice, isn’t it? Although this warning is far from helpful. It says that something looks weird but does not say what, why, or what can be done to stop it from looking weird. We’ll discuss how we can improve on warnings further on.

Let’s move on to a more serious example now that we know how to use he feature. Imagine we have a Sass custom function that attempts to convert a pixel value in em unit:

@function px-to-em($value, $base-font-size: 16px) {
  @return ($value / $base-font-size) * 1em;
}

// Usage
.foo {
  font-size: px-to-em(42px); // 2.625em
}

All good. Now, what happens when passing a unitless number—such as 42—to the function? Maybe you’ve guessed it, but as it’s not quite obvious I’ll give you the answer:

2.625em/px isn’t a valid CSS value.

This happens because you’re trying to perform a calculation between incompatible units (px and em). What we could do to circumvent this issue is assume the unitless value be expressed in pixels and convert it first:

@function px-to-em($value, $base-font-size: 16px) {
  @if unitless($value) {
    @warn 'Assuming value `#{$value}` to be in pixels; attempting to convert it.';
    $value: $value * 1px;

  }

  @return ($value / $base-font-size) * 1em;
}

The function is expecting a value expressed in pixels. We can still make it work with a unitless value; however, we cannot be sure that this is the expected behavior. We can only assume that it’s good enough.

Because we’re assuming what is the correct behavior for our function, it’s important to let the developer know what we’re doing and why. Otherwise it could lead to bugs that are hard to track, which is not
what you should be aiming for.

Another practical example would be to warn against the usage of a deprecated function or mixin. You might have already heard of or used Bourbon, a lightweight mixin library for Sass. Bourbon is actively maintained, and sometimes requires removing helpers from the library. To avoid suddenly breaking a person’s ode, Bourbon warns about future deprecations way before it actually removes mixins:

@mixin inline-block {
  display: inline-block;

  @warn 'The `inline-block` mixin is deprecated and will be removed in the next major version release.';
}

Clever! People who still use the inline-block mixin from Bourbon are aware that the library will remove it completely in the next version, so they know to start updating their codebase to remove the mixin.

The Difference between @warn and @debug

You may or may not be familiar with the @debug directive, which prints the value of a SassScript expression to the standard output stream in the same fashion as @warn. You might be wondering why there are two features performing the same task, and what could possibly be the difference between the two.

Continue reading %How to Use Warnings and Errors in Sass Effectively%


by Hugo Giraudel via SitePoint

🚀 #311: What devs need to know about Microsoft Edge for iOS and Android

Frontend Focus
Issue 311 — October 11, 2017
“WebRender isn’t really about making rendering faster. It’s about making it smoother.” A great look at improvements coming to Firefox soon.
Mozilla Hacks

A collection of CSS snippets to create fast, complex image effects, such as pencil drawing, watercolor painting, and the intriguing ‘flannel’.
Bennett Feely

MPEG-DASH or HLS? Cloud encoding or Hardware encoding? HEVC, VP9 or H.264? Find out what developers are using now, and what they will be using in 2018.
Bitmovin   Sponsor

A deep dive into the latest Bootstrap’s new approach to style resetting, as well as some history of style resets overall.
Nicholas Cerminara

An extensive overview of techniques, best practices, and things learnt by Grammarly, creators of a popular browser extension.
Igor Kononuchenko

Smashing Magazine ran a CSS Grid design challenge and here are the results. A good look at what’s possible with CSS Grid today.
Smashing Magazine

Microsoft Edge is coming to iOS and Android using WebKit on iOS and Blink on Android.
Sean Lyndersay

Jobs

In Brief

Blink's Intent to Implement: 'async' Attribute On 'img' Elements news
A potential future way to increase responsiveness.
blink-dev

Bringing WebVR to Everyone with The Windows 10 Fall Creators Update news
Lewis Weaver

CFP for Munich Frontend Conference Ends This Sunday news
PaperCall

$20 Free on a new Linode account 
Linux cloud hosting starting at 1GB of RAM for $5/mo. Get $20 credit on a new account.
Linode Cloud Hosting  Sponsor

Filtering Images using the Web Audio API tutorial
Creative experiments with arrays of sound and vision.
Rafael Specht da Silva

(S)CSS Best Practices You May Have Not Yet Known tutorial
A few nice tips for writing robust and maintainable styles.
Mirosław Ciastek

Making a Pure CSS Play/Pause Button tutorial
Daniel Abilla

Implementing A Service Worker For Single-Page App WordPress Sites tutorial
Leonardo Losoviz

A Fearless Guide to Using CSS Grid tutorial
Brenda Storer

Building Your Core Accessibility Team in 5 Steps tutorial
Dennis Lembree

Troubleshoot slow web apps with Datadog 
Get alerts for performance problems and find the bottleneck in your application with end-to-end request tracing.
Datadog  Sponsor

Blasting React Into Space: Building Fluid Interfaces with React and WebGL video
Ashi Krishnan

Bringing Back The 1990s: The Revenge of JavaScript Style Sheets video
Steve Kinney

What Is The Least/Most Common Color Used On Web Pages? opinion
HTTP Archive


by via Frontend Focus

Funky Media

A digital agency making brands grow through innovative content and creative design.


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

Studio GNS

Studio Tecnico Galleni Niccoletti Sigali is a leadership team of a broader professional organisation, that benefits from further expertise.


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

Clingendael Institute

Clingendael – the Netherlands Institute of International Relations – is a leading think tank and academy on international affairs which aims to contribute to a secure, sustainable and just world.


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