Tag Archives: JavaScript

Winning with CSS Variables

Some cool ideas of things to do with CSS variables; now supported by all modern browsers

 

CSS variables now enjoy wide cross-browser support. But what are they and why should we use them?

Any CSS property — color, size, position, etc. — can be stored in a CSS variable. Their names are all prefixed with –, and you declare them by adding them to an element right where you add its other styles.

Read more from the source: vgpena.github.io

CSS Custom Properties and Theming

Update css variable values using JavaScript and update all stylesheet rules that reference that variable

 

Chris Coyier writes:

We posted not long ago about the difference between native CSS variables (custom properties) and preprocessor variables. There are a few esoteric things preprocessor variables can do that native variables cannot, but for the most part, native variables can do the same things. But, they are more powerful because of how they are live-interpolated. Should their values ever change (e.g. JavaScript, media query hits, etc) the change triggers immediate change on the site.

Cool, right? But still, how actually useful is that? What are the major use cases? I think we’re still seeing those shake out.

Read more from the source: CSS-Tricks

TypeScript at Slack: how we converted and what we learned

Case study of converting a large codebase from JavaScript to TypeScript: it is not as painful as you might think.

 

On the Slack Engineering Blog, Felix Rieseberg writes:

We decided to use Microsoft’s TypeScript, which combines static type analysis with a compiler. Modern JavaScript is valid TypeScript, meaning that one can use TypeScript without changing a single line of code. This allowed us to use “gradual typing” by enabling the compiler and the static analysis early, without suspending work on critical bug fixes or new features.

In practice, switching the analysis and the compiler on without changing code means that TypeScript will immediately attempt to understand your code. It uses built-in types and type definitions available for third party dependencies to analyze the code’s flow, pointing out subtle errors that went previously unnoticed. Wherever TypeScript cannot understand your code, it will assume a special type called “any” and simply move on.

Read more from the source: Several People Are Coding

CSS Animations vs the Web Animations API: A Case Study

Controlling CSS keyframes, transitions and animations from JavaScript: pretty intuitive

 

Last week, I wrote about how I created the bitsofcode logo animation with CSS. After that, it was suggested that I attempt a comparison between a CSS animation and the Web Animations API, so here it is! Introduction to the Web Animations API As with last week, I’ll start this

Read more from the source: bitsofcode

Yarn: A new package manager for JavaScript

Facebook fixes several problems with npm; will yarn become the new standard, will npm make changes, or will developers not care?

 

We’ve used the npm client successfully at Facebook for years, but as the size of our codebase and the number of engineers grew, we ran into problems with consistency, security, and performance. After trying to solve for each issue as it came up, we set out to build a new solution to help us manage our dependencies more reliably. The product of that work is called Yarn — a fast, reliable, and secure alternative npm client.

Read more at Facebook Code