Moving Rainbow Underlines

I absolutely love the design of the Sandwich site. Among many beautiful features are these headlines with rainbow underlines that move as you scroll. It's not scroll-jacking — it's just a minor design feature that uses scroll position to enact a little movement.

To draw the rainbows themselves, we could use a linear gradient with hard-stops, the same kinda concept as drawing stripes in CSS. That's a big ol' chunk of CSS, which is fine, but I see they've opted for a background-image instead. Here's that as an SVG, which is 661 bytes (tiny tiny). We can make it look like an underline by setting the background-size to limit the height and position it along the bottom with background-position.

We'll do it on an inline element so the underline breaks where the words break:

h1 {
  span {
    background-image: url(spectrum.svg);
    background-repeat: repeat-x;
    background-size: 100vw 0.2em;
    background-position: left bottom 5px; 
  }
}

To animate it, we move the background-position-x. Not a particularly performant thing to animate, but we're not really animating it anyway — it's just moving based on scroll position. Rather than manually manipulate the background-position-x, we'll set it with a custom property, then manipulate the custom property with JavaScript.

background-position-x: var(--scrollPos);

Updating that variable while the page scrolls is easy peezy:

window.addEventListener("scroll", e => {
  let scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop; 
  let newPos = scrollTop + "px";
  document.documentElement.style.setProperty('--scrollPos', newPos);
});

Here it is working!

See the Pen
Rainbow Underlines
by Chris Coyier (@chriscoyier)
on CodePen.

See that kinda janky line where I'm either using document.body or document.documentElement? That's a stupid cross-browser thing where the "scrolling element" is different in Safari versus everything else.

While doing this I learned that you can use document.scrollingElement instead to avoid the pain there. I'll leave a comment in the code about that, but leave the original line for posterity.

The post Moving Rainbow Underlines appeared first on CSS-Tricks.

A Whole Bunch of Places to Consider Contrast in a Single Paragraph

When we're thinking about choosing colors in design, we're always thinking about accessibility. Whenever colors touch, there is contrast and, if we're talking about the color contrast of text, it needs to be high enough to be readable. This benefits people with a variety of visual disabilities, but also everyone appreciates easily readable text.

Let's look at the color contrast considerations of just a single paragraph!

A link in a paragraph is probably set in another color to distinguish it as a link.

This link color has insufficient color contrast.

Focusable elements, like links, need to have focus styles as well. By default, we'll probably get a fuzzy blue outline, so we'll need to check that that has sufficient color contrast. And if we customize it, that customization will need good color contrast as well.

We'll also need a hover state for mouse users. Here, I'll use a background effect that covers about half the text. When you do something like that, the effect needs to be strong enough to be noticeable on hover, and the contrast needs to work on both backgrounds.

It's not ultra common, but you can style :visited links as well. The styling is somewhat limited (you can't change opacity or background, for example, because it's a security concern), but you can change the color. If you do that, it also needs proper contrast. Perhaps we could yank the color differentiation away with color: inherit; to somewhat de-emphasize the link but still indicate it.

Another thing to consider is people highlighting text. On my machine, I have it set up to highlight in an orange color by default (it's normally a light blue on macOS).

Hopefully, the link colors hold up under any highlight color choice a user might have. They tend to be very light shades.

The text selection colors on macOS Catalina

You can control text selection color through CSS as well with ::selection { background: purple; }. If you've done that, you have to check all your colors again to make sure you've gotten sufficient contrast.

You can try to take measures into your own hands by changing both color and background.

But note that the link inside the text has lost some of its contrast here. We could keep going down the rabbit hole by setting new colors on a::selection and every other element that has its own colorations within the text.

I'd say a good rule of thumb is to go very light if you're going to do a custom highlighting color and then not do any further customizations specifically for the selected text.


The idea for this post came from some bug reports I've gotten from people reporting that links are hard to read on this site when highlighting text, then focusing a link. I tried fixing it by getting more elaborate, but there are limits to what you can do.

::selection a:focus { /* nope */ }
a:focus::selection  { /* nope */ }
a::selection:focus  { /* nope */ }

It's better handled by doing less than more.


I recently read Ethan Muller's Designing for Design Systems post and he makes a similar point about contrast, but across a color spectrum rather than across contexts. For example, your blue link color might work just fine on a few of your design system colors, but not so much on others.

There are a couple things that might help with this.

  • The generic advice of "every time you declare a background-color, declare a color" might help.
  • I've used parent-level classes like on-light to change colors of things broadly inside light-colored containers.
  • I've used a Sass mixin to help make it easier to change links and the link states, so I'm more apt to do it when changing backgrounds.
@mixin linkStyleText($linkColor) {
  a {
    // Update generic link styles with $linkColor
    &:hover,
    &:focus {
      // Also change the hover/focus styles, probably by altering $linkColor programatically
    }
  }
}

.variation {
   background: $someNewBGColor;
   linkStyleText($someNewLinkColor)
}

Well, thanks for coming on this journey with me. It just occurred to me that color contrast isn't quite as simple as checking a single link color on a background to make sure it passes. There might be a dozen or more things to check depending on how many things you colorize in your body copy.

The font in these screenshots is Ibarra Real Nova, which was just recently released on Google Fonts.

The post A Whole Bunch of Places to Consider Contrast in a Single Paragraph appeared first on CSS-Tricks.

AMI and Snapshot Management Using AWS Lambda

Create AMIs automatically with AWS Lambda

Automating tasks and continuously improving workflows are key parts of DevOps. In a CI/CD pipeline, being able to simplify processes is a huge plus. Not only will simplifying systemic processes make life easier for you as a developer, but there are other added benefits to gain as well. For example, you can significantly reduce the cost of running services in the cloud with refined and automated scaling of infrastructure.

Rank Math SEO Plugin Adds WordPress Block Editor Support

The team behind the Rank Math SEO plugin released an update that includes full support for the block editor on December 18. The update includes around two dozen features, improvements, and fixes. The biggest feature update was the inclusion of a new plugin sidebar for the block editor.

Some of the new features include a filter for unlimited focus keywords, an email notification each time the plugin is automatically updated, and a warning when using the review Schema type. It also improved compatibility with the Elementor plugin’s sitemap module and added Advanced Custom Fields integration to the sidebar. A full list of features is available in the plugin’s public change log.

The team has a public demo available for end-users to test the plugin without having to install it on their sites.

Bhanu Ahluwalia, co-founder and CMO at Rank Math, said that everyone on the team had been experimenting with the Gutenberg plugin since the first beta was released. “We had some experience with Gutenberg, but working on Rank Math has taught us so many things and helped us on so many levels,” he said.

It was not always a smooth journey. Ahluwalia said the team wanted to keep the plugin lightweight and not sacrifice speed with new technologies. “We had to learn React, Webpack, ES6, etc.,” he said. “In essence, we had to re-learn patterns, practices, and pitfalls of Gutenberg, and we had to do it all with little-to-no documentation available. We had to dive deep into the code and get ourselves familiar with every line of code to ensure nothing interfered with the existing functions of our plugin.”

Testing the Block Editor Sidebar

Screenshot of the Rank Math sidebar in the block editor.
Rank Math sidebar as seen in the block editor.

Immediately upon activating the update, I noted the Rank Math button at the top right of the editor. Admittedly, I was not happy with the space the button took up or its difference in design when compared to other plugin sidebar buttons. Instead of a simple icon, the button includes both an icon and an SEO score. As more and more plugins and themes begin adding sidebars of their own, this space could become cluttered quickly. I would like to see this scaled back to simply be an icon and not take up precious screen real estate.

The plugin manages to pack a ton of options and information into a tight spot. Once viewing the plugin sidebar, it presents four sub-tabs (General, Advanced, Schema, and Social), each with custom panels or sections. While I am not generally a fan of complex SEO plugins and prefer solutions such as Slim SEO, the plugin handles the interface gracefully.

In comparison to the old meta boxes, the interface is a huge step up. The meta box system used in previous versions of the plugin or with the current Classic editor is cumbersome at best. The team had to get more creative to pull off a solution for the sidebar, which forced them to tighten up the interface.

Not all users were happy with the narrow space provided by the new sidebar. The Rank Math team was ahead of the game and included a filter hook to disable this feature. Disabling will return the old-style meta box at the bottom of the post-editing area.

“Supporting both the Classic Editor and Gutenberg at once with a single plugin is hectic to say the least,” said Ahluwalia. “We would rather put our energy into a single editing experience, but seeing how WordPress is evolving after Gutenberg, we have to double our efforts to offer a consistent user experience.”

At the moment, the team plans to continue supporting the classic editor until at least 2022. “Depending on the user feedback and the acceptance of the Classic editor, we can continue to support it even further,” said Ahluwalia.

The Rank Math also team shared a video of block editor support on Twitter:

Apple Launches Open Bug Bounty Program

Apple has announced an open bug bounty program. Until now, Apple's bug bounty program was limited to selected researchers who received an invitation from Apple. That private bug bounty program only accepted reports for iOS. The new program is open to all security researchers and covers iPadOS, macOS, tvOS, watchOS, and iCloud.

How to Lead a Blockchain Engineering Team

Santiago Palladino is a team leader at OpenZeppelin, a company based in Buenos Aires that creates development tools for blockchain and also audits blockchain applications for security. He shared with us his methods for overcoming the unique challenges of leading teams working with a distributed Blockchain development team.

Short on time? Here are three key takeaways from Santiago’s interview which outline what he does to build and maintain effective development teams for a large and complex product:

Worker Threads: Node Parallelism

Concurrency vs Parallelism

Node.js has long excelled at concurrency. With the recent release of Node 13.0, Node now has a stable answer to parallelism as well. 

Concurrency can be thought of as switching between async processes, which all take turns executing, and, while idle, return control back to the event loop. On the other hand, parallelism is the ability for a process to separate and run simultaneously on multiple threads. There are other solutions in JavaScript that have tried to address this problem. For an in-depth comparison, I found this article useful.

A Tutorial on Firebase Hosting

If you are looking to host your NextGen web app safely, Firebase from Google can put you at ease by providing fast, reliable, and secure static hosting for your web app. Offering production-grade web content hosting, Google Firebase enables you to effortlessly deploy web apps and static web page content and connect to a CDN (content-delivery network) with a single command.

Furthermore, with Firebase as an all-in-one hosting solution, you are exempt from sizing up various available cloud-based hosting service providers.

Stream-Crossing Confusion

Should I use WordPress or React hooks?
Should I use D3 or CSS?
Should I use Markdown or JSON?
Can I use flexbox in Gatsby?
Can I use custom properties in Jekyll?
Should I use HTML or the cloud?
How do I add dark mode to my Vue site?

These are tongue-in-cheek, but there is a point to be made here. It's one challenge to understand a technology, and another challenge to understand how technologies fit together.

While some of the combinations of technologies above might seem confusing, you're lucky that you know enough to find them confusing. That means you understand the technologies enough that you know they aren't relevant either/or choices or that they do or don't have anything that prevents them from going together.

I see this kind of confusion fairly often in beginners, and it's really nothing to be ashamed of. It's all part of the process.

I also see this type of confusion with readers of this site, because we often write about pretty base-level web technologies and don't get into how they might then fit into different abstractions, like JavaScript frameworks or CMSs. For example, check out this post about building a slider. It doesn't even touch JavaScript; it's just vanilla HTML and CSS.

Perhaps an experienced front-end developer will understand they can use this slider code just about anywhere, as it doesn't depend on anything else. But there are also developers who will be like it's not in JSX so I can't really use it. Or, is it on npm? I've forever had people ask me if some of the ideas and techniques they find here on the site would be usable on their WordPress site.

So, how would you use this slider code on a WordPress site? Well, as it's just HTML and CSS, you could use the HTML in any of your templates, put the CSS in your site's stylesheet, and it will work. But perhaps you'd like to manage the slides somehow within WordPress itself rather than editing template files. Maybe you have a custom post type of "Slide" then a custom page that outputs the content of those posts within the divs of the slider. Much more complicated, but essentially the same idea. If you wanted the slider to work in React, it's probably a matter of changing some class attributes to className and putting the CSS wherever you do styling for your React site. We often stay with the base level technologies on CSS-Tricks because it makes things more generically useful, but it's still interesting and another skill to learn how to port concepts to other technologies.

Lemme take a crack at those questions above.

Should I use WordPress or React hooks?

WordPress is a CMS you would choose to help you build out structured content and likely to build the entire site. You could build a site with React, and that's getting more and more popular, but it's still not that common. React is a way to build the front end of sites with components built in JavaScript to help with templating and logic. React hooks are a way to share functionality between components. So, this question isn't an either/or — you can do both or either.

Should I use D3 or CSS?

CSS is used on all websites to do styling. D3 is a JavaScript library for doing data visualization. There is some crossover because you could, for example, build a bar chart with just HTML and CSS, or build that same bar chart in D3. But generally, D3 is doing very fancy drawing that CSS isn't capable of, and CSS is doing layout of elements on a site that SVG (what D3 outputs) isn't capable of.

Should I use Markdown or JSON?

Markdown is a language for writing content that compiles to HTML. For example, you might write a blog post in Markdown because it's cleaner to write and look at and sort of discourages you getting to fancy with HTML in a place you shouldn't. JSON is a format for storing data in a format that a lot of programming languages, particularly JavaScript, have an easy time dealing with. JSON has a nested key/value pair syntax that is fairly intuitive. You could put Markdown within JSON if it was useful to store the data in that way. There is some interesting crossover in that there are special varieties of Markdown that can have metadata as part of the file, called Front Matter. This Front Matter data is also in a key/value pair format, although a bit of a different syntax. Still, these are generally pretty different technologies. An API would commonly return JSON, but not Markdown, and you'd commonly blog in Markdown, not JSON.

Can I use flexbox in Gatsby?

Sure. Flexbox is a CSS thing and Gatsby is a React framework. Gatsby doesn't care what CSS you use on the site. Since Gatsby is React-based, there is a whole world of CSS-in-JS libraries that might also be in use, so if you're having trouble, it might be something related to that. For example, if the styling is being set via a JavaScript object format, you might have to use something like flexGrow instead of flex-grow, and the like.

Can I use custom properties in Jekyll?

Jekyll is a Ruby-powered static site generator, largely for producing blogs out of Markdown files. Much like Gatsby doesn't care about your CSS, Jekyll doesn't either. Custom properties are a CSS thing, so you are free to use them in your CSS that, in turn, is a part of your Jekyll site.

Should I use HTML or the cloud?

"The cloud" has a somewhat nebulous meaning, but generally refers to servers attached to the internet. And not just a single server, but a large network of them with a strong ability to scale and have redundancy. HTML is the base language of websites. Every website starts with a request for the HTML from a web server. They relate in that cloud-based servers might serve up those requests for HTML files! But they aren't an either/or thing. You might write HTML that is served by a server that isn't particularly "cloudy," and you might use a cloud server for something unrelated to HTML (like storing large data files).

The post Stream-Crossing Confusion appeared first on CSS-Tricks.

Highlights of the HTTP Archive Web Almanac

I recently looked at the CSS chapter of the Web Alamanc and had some thoughts. Here, Stefan Judis looks at the whole thing and rounds up the most interesting bits to him. Here are most of them:

  • 20% of sites don't compress their JavaScript.
  • React is on 5% of sites while jQuery is on 85% of sites. (Hence my tongue-in-cheek Tweet)
  • Native JavaScript imports are under 1% (we're all still bundling, which for the time being, we're told is the way to go).
  • Flexbox usage is at 50% and grid only 2%. (I previously remarked at how wild I think this is, with browser support being not terribly different and grid being, IMO, generally more useful.)
  • 20% of sites use responsive images. (Interesting as WordPress does it out of the box, and powers some 34% of the web. Maybe a lot of really old outdated WordPress versions out there?)
  • font-display usage is at 26%, which blows me away as it's fairly new and a little esoteric (as much as I love it).
  • HTTPS at 80%. Also surprising considering what a pain in the butt it is if your host doesn't make it a default part of their offering.
  • 4 of 5 sites ship with color contrast issues. Not suprising, but I wonder how many false positives are in here. I've seen a lot of that with automated tooling.
  • 1 of 4 sites don't specify a lang attribute.
  • 4 of 5 forms don't ship with labels for their input elements. WHATTTTTT.
  • 0.44% sites use a service worker. I'm a fan, but they are (1) too hard and (2) feel too dangerous to dabble in.
  • 2 of 3 pages have a huge content shift while loading. (Remember to put width and height attributes on images now, which prevents content shifting. Huge.)
  • We hear about WordPress powering 1/3 of the web, but another interesting related stat is that if you're using a CMS, there is a 75% chance it's WordPress.
  • Only 20% of sites use a CDN (for the HTML). I'm sure it's higher for assets.
  • We're still pushing around a 2MB average page size. Everything depends, but if we're trying to be consious people in general, let's say we aim for half that.

Direct Link to ArticlePermalink

The post Highlights of the HTTP Archive Web Almanac appeared first on CSS-Tricks.

Software Testing in 2020: 7 Biggest Trends

The huge demand for high-quality products created in the shortest time possible made testing a critical success factor of the software development process. Because of the continually evolving technology and competitive market QA specialists are in constant search of new relevant testing techniques, so they can stay relevant and meet the rising customer demands. As a result, new approaches are steadily emerging. Here are some of the most important software testing trends to watch for in 2020.

Testing for Agile and DevOps

Agile and DevOps should be definitely mentioned among some of the most popular concepts in software development. Since both DevOps and Agile practitioners work on improving the quality of the products, testing becomes a common area of interest for two groups. In the competitive software development world more and more companies choose popular Agile methodologies which, in turn, has an impact on testing practices. In particular, Agile methodology ensures that testing becomes an inevitable part of the development process rather than a separate stage. At the same time, DevOps, which implements a continuous improvement cycle is aimed at reducing the duration of the testing processes. In the future, more and more companies will adopt DevOps philosophy to improve the quality of released products which will have a huge impact on how the testing is done.

File-Based Integration: Spring Integration vs Ballerina

Introduction

File-based integration is one of the most popular and widely used approaches in data integration. Many software systems work with files — i.e., they either take in files as input, give their results as files, or do both — and working with multiple disparate systems requires connecting those systems together. Newer software systems also provide API-based access to information, and API-based integration is one of the approaches in connecting such systems. Although APIs provide advantages over traditional file-based systems, such as complex data structures and fine-grained security, many legacy software systems, and even modern ones, often use file-based approaches to export and import data. 

Integration requires ensuring that two separate systems understand each other. And, although file structures and data types will likely be different in different software systems, we need an integration mechanism to map, transform, filter, and cleanse data in order for software systems to understand each other. Some of the most popular file formats used in general scenarios are CSV, EDI, JSON, and XML.

Caching in MyBatis With Redis

MyBatis is an open-source, lightweight persistence framework for the Java programming language. With MyBatis, users can map Java methods to stored procedures or SQL statements. The transactional query caching feature in MyBatis allows users to cache their queries, reducing lookup times and improving performance.

Java developers often use MyBatis together with Redis, an open-source, in-memory data structure store that is often used to build NoSQL databases. But how do developers implement caching in MyBatis with Redis?

The RPA Revolution: How Automation Will Redefine Work in the 2020s

2019 marked the year we crossed the tipping point for robotic process automation (RPA) adoption. A recent report from Futurum Research — commissioned by Automation Anywhere — discovered that more than half of North American businesses today have adopted intelligent automation.  

These findings show that RPA is no longer an emerging technology but rather a mission-critical component for businesses, driving immense value due to its ability to automate labor-intensive tasks so that humans can refocus their efforts to work that drives impact and satisfaction.