Archive

Archive for August, 2021

How I Made a Generator for SVG Loaders With Sass and SMIL Options

August 26th, 2021 No comments

While learning Vue.js, I started building free web tools that involved the exploration of SVG, with the goal of learning something about both! Let’s take a look at one of those tools: a generator that makes SVG loaders and lets you choose between SMIL or Sass animation, different styles, colors, shapes, and effects. It even lets you paste in a custom path or text, and then download the final SVG, copy the code, or open a demo over at CodePen.

How it started

Three coincidences led me to build a generator for SVG loaders.

Coincidence 1: Sarah Drasner’s book

The first time I read about Sass loops was in Sarah Drasner’s SVG Animations. She shows how to stagger animations with a Sass function (like the does in Chapter 6, “Animating Data Visualizations”).

I was inspired by that chapter and the possibilities of Sass loops.

Coincidence 2: A GIF

At that same point in life, I was asked to replicate a “loader” element, similar to Apple’s old classic.

A round segmented spinner where each segment fades in and out in succession to create a circling effect.
This is a mockup of the loader I was asked to make.

I referenced Sarah’s example to make it happen. This is the Sass loop code I landed on:

@for $i from 1 to 12 {
  .loader:nth-of-type(#{$i}) {
    animation: 1s $i * 0.08s opacityLoader infinite;
  }
}
@keyframes opacityLoader {
 to { opacity: 0; }
}

This defines a variable for a number (i) from 1 to 12 that increases the delay of the animation with every :nth-child element. It was the perfect use case to animate as many elements as I wanted with only two lines of Sass, saving me CSS declarations for each of the delays I needed. This is the same animation, but written in vanilla CSS to show the difference:

.loader:nth-of-type(1) {
  animation: 1s 0.08s opacityLoader infinite;
}
.loader:nth-of-type(2) {
  animation: 1s 0.16s opacityLoader infinite;
}

/* ... */

.loader:nth-of-type(12) {
  animation: 1s 0.96s opacityLoader infinite;
}
@keyframes opacityLoader {
  to { opacity: 0; }
}

Coincidence 3: An idea

With these things going on in my head, I had an idea for a gallery of loaders, where each loader is made from the same Sass loop. I always struggle to find these kinds of things online, so I thought it might be useful for others, not to mention myself.

I had already built this kind of thing before as a personal project, so I ended up building a loader generator. Let me know if you find bugs in it!

One loader, two outputs

I was blocked by my own developer skills while creating a generator that produces the right Sass output. I decided to try another animation approach with SMIL animations, and that’s what I wound up deciding to use.

But then I received some help (thanks, ekrof!) and got Sass to work after all.

So, I ended up adding both options to the generator. I found it was a challenge to make both languages return the same result. In fact, they sometimes produce different results.

SMIL vs. CSS/Sass

I learned quite a bit about SMIL and CSS/Sass animations along the way. These are a few of the key takeaways that helped me on my way to making the generator:

  • SMIL doesn’t rely on any external resources. It animates SVG via presentation attributes directly in the SVG markup. That’s something that neither CSS nor Sass can do.
  • SMIL animations are preserved when an SVG is embedded as an image or as a background image. It is possible to add a CSS block directly inside the SVG, but not so much with Sass, of course. That’s why there is an option to download the actual SVG file when selecting the SMIL option in the generator.
  • SMIL animations look a bit more fluid. I couldn’t find the reason for this (if anyone has any deeper information here, please share!). I though it was related to GPU acceleration, but it seems they both use the same animation engine.
Two spinners, one left and one right. They are both red and consist of circles that fade in and out in succession as an animated GIF.
SMIL (left) and Sass (right)

You might notice a difference in the chaining of the animations between both languages:

  • I used additive="sum" in SMIL to add animations one after the other. This makes sure each new animation effect avoids overriding the previous animation.
  • That said, in CSS/Sass, the W3C points out that [when] multiple animations are attempting to modify the same property, then the animation closest to the end of the list of names wins.

That’s why the order in which animations are applied might change the Sass output.

Working with transforms

Working with transformations in the loader’s styling was a big issue. I had applied transform: rotate inline to each shape because it’s a simple way to place them next to each other in a circle and with a face pointing toward the center.

<svg>
  <!-- etc. -->
  <use class="loader" xlink:href="#loader" transform="rotate(0 50 50)" />
  <use class="loader" xlink:href="#loader" transform="rotate(30 50 50)" />
  <use class="loader" xlink:href="#loader" transform="rotate(60 50 50)" />
  <!-- etc. -->
</svg>

I could declare a type in SMIL with (e.g. scale or translate) to add that specific transform to the original transformation of each shape:

<animateTransform
  attributeName="transform"
  type="translate"
  additive="sum"
  dur="1s"
  :begin="`${i * 0.08}s`"
  repeatCount="indefinite"
  from="0 0"
  to="10"
/>

But instead, transform in CSS was overriding any previous transform applied to the inline SVG. In other words, the original position reset to 0 and showed a very different result from what SMIL produced. That meant the animations wound up looking identical no matter what.

The same two red spinners as before but with different results. The SMIL version on the left seems to work as expected but the Sass one on the right doesn't animate in a circle like it should.

The (not very pretty) solution to make the Sass similar to SMIL was to place each shape inside a group () element, and apply the inline rotation to the groups, and the animation to the shapes. This way, the inline transform isn’t affected by the animation.

<svg>
  <!-- etc. -->
  <g class="loader" transform="rotate(0 50 50)">
    <use xlink:href="#loader" />
  </g>
  <g class="loader" transform="rotate(30 50 50)">
    <use xlink:href="#loader" />
  </g>
  <!-- etc. -->
</svg>

Now both languages have a very similar result.

The technology I used

I used Vue.js and Nuxt.js. Both have great documentation, but there are more specific reasons why I choose them.

I like Vue for lots of reasons:

  • Vue encapsulates HTML, CSS, and JavaScript as a “single file component” where all the code lives in a single file that’s easier to work with.
  • The way Vue binds and dynamically updates HTML or SVG attributes is very intuitive.
  • HTML and SVG don’t require any extra transformations (like making the code JSX-compatible).

As far as Nuxt goes:

  • It has a quick boilerplate that helps you focus on development instead of configuration.
  • There’s automatic routing and it supports auto-importing components.
  • It’s a good project structure with pages, components, and layouts.
  • It’s easier to optimize for SEO, thanks to meta tags.

Let’s look at a few example loaders

What I like about the end result is that the generator isn’t a one-trick pony. There’s no one way to use it. Because it outputs both SMIL and CSS/Sass, there are several ways to integrate a loader into your own project.

Download the SMIL SVG and use it as a background image in CSS

Like I mentioned earlier, SMIL features are preserved when an SVG is used as a background image file. So, simply download the SVG from the generator, upload it to your server, and reference it in CSS as a background image.

CodePen Embed Fallback

Similarly, we could use the SVG as a background image of a pseudo-element:

CodePen Embed Fallback

Drop the SVG right into the HTML markup

The SVG doesn’t have to be a background image. It’s just code, after all. That means we can simply drop the code from the generator into our own markup and let SMIL do its thing.

CodePen Embed Fallback

Use a Sass loop on the inline SVG

This is what I was originally inspired to do, but ran into some roadblocks. Instead of writing CSS declarations for each animation, we can use the Sass loop produced by the generator. The loop targets a .loader class that’s already applied to the outputted SVG. So, once Sass is compiled to CSS, we get a nice spinning animation.

CodePen Embed Fallback

I’m still working on this

My favorite part of the generator is the custom shape option where you can add text, emojis, or any SVG element to the mix:

The same circle spinner but using custom SVG shapes: one a word, one a poop emoji, and bright pink and orange asterisk.
Custom text, emoji, and SVG

What I would like to do is add a third option for styles to have just one element where you get to work with your own SVG element. That way, there’s less to work with, while allowing for simpler outputs.

The challenge with this project is working with custom values for so many things, like duration, direction, distance, and degrees. Another challenge for me personally is becoming more familiar with Vue because I want to go back and clean up that messy code. That said, the project is open source, and pull requests are welcome! Feel free to send suggestions, feedback, or even Vue course recommendations, especially ones related to SVG or making generators.

This all started with a Sass loop that I read in a book. It isn’t the cleanest code in the world, but I’m left blown away by the power of SMIL animations. I highly recommend Sarah Soueidan’s guide for a deeper dive into what SMIL is capable of doing.

If you’re curious about the safety of SMIL, that is for good reason. There was a time when Chrome was going to entirely deprecated SMIL (see the opening note in MDN). But that deprecation has been suspended and hasn’t (seemingly) been talked about in a while.

Can I use SMIL?

This browser support data is from Caniuse, which has more detail. A number indicates that browser supports the feature at that version and up.

Desktop

Chrome Firefox IE Edge Safari
5 4 No 79 6

Mobile / Tablet

Android Chrome Android Firefox Android iOS Safari
92 90 3 6.0-6.1

The post How I Made a Generator for SVG Loaders With Sass and SMIL Options appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

One Way to Convert Code Indentation

August 25th, 2021 No comments

A question:

If you copy a code sample that uses two-space indentation and you want to convert it to four-space indentation, what’s the *fastest* and easiest option?

Matt Stauffer, Twitter

I wrote about doing this in Sublime Text a few years back. It’s not terribly different in VS Code, I don’t think.

But here’s another way: Use CodePen.

Step 1: Copy and paste to CodePen

Say you found some code elsewhere, just copy and paste it in:

Step 2: Adjust code indentation settings

If you already have a CodePen account, you’ve probably already got it set up, so the default is how you like it. But if it’s not yet, adjust it in the Pen Settings area:

Showing the Pen Settings modal open in CodePen over a demo. the settings show code indentation options for spaces and tabs and for indentation width.
The code was 2-spaces as copy/pasted, and now we’re changing that to 4-spaces as a setting.

Step 3: Format the code

You can manually do it here:

You may not have to use that option at all if you save the Pen and have the “Format on Save” option on, as it will automatically happen.

It’ll kick over to that new 4-space preference right quick:


CodePen uses Prettier under the hood to do this. So you could do this anywhere you have access to a working version of Prettier, but it might be easier on CodePen since there’s nothing like editing config or anything to adjust how you want it. Prettier has its own playground as well, which is likely just as easy as CodePen, except that on CodePen you might already have your preferences set up, saving a step.


The post One Way to Convert Code Indentation appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

7 Essential Design Tips for a Killer “About Us” Page

August 25th, 2021 No comments

Creating an incredible brand experience for an end-user is about more than just designing the right home page or lining up a series of great product pages. 

Effective website design conveys crucial information about a company, through everything from font styles, to image choices. Nowhere is this representation of brand identity more important than on the about page. 

People frequently confuse the about page with the contact page or fail to leverage it correctly simply because they don’t know what to say. However, creating an about page that speaks to an audience can be immensely powerful. 

What is an About Page?

The first step in designing a great about page is understanding the purpose of the space. This isn’t just a page on a website explaining what a company does. 

The about page is an introduction to a company’s story, its brand essence, and personality. 

Done correctly, this page will demonstrate a crucial sense of affinity between a business and its customers. It will highlight values that resonate with a customer and make it easier for clients to trust businesses.

The Yellow Leaf hammocks company starts its about page with a video.

As you scroll through the interactive site, you discover new elements of the company’s tale, including what prompted the birth of the business to begin with and the brand’s mission. 

Yellow Leaf lets its visitors know what the company is all about by using authentic images of real people to external content and bold quotes. 

There are even snippets from customer case studies for social proof. 

About pages are relevant because they give customers a way to build a real human connection with a business. Harvard professors say that 95% of purchasing decisions are emotional; we don’t buy things just because we need them. Instead, we look for companies that we feel connections with to solve problems. 

Using an about page to convey an attitude, personality, or just what makes a business special is how designers can ensure that end-users will care more about the business. 

How to Make an About Page Stand Out

So, how do you make an about page stand out?

Since every company is different, there’s no one-size-fits-all strategy for everything.  However, there are a few essential steps to consider as you move through the design process. 

Here are some pro tips for successfully attracting attention with the about page…

Step 1: Decide What to Include

It’s tempting to assume that a complicated about page will lead to a stronger relationship between a brand and its customers. After all, the longer the story, the more the customer knows about the company – right?

While it’s essential to include plenty of valuable information in an about page, it’s also worth remembering that today’s customers are short on time. They don’t want to spend hours scrolling through one part of a website. Instead, they want access to quick, convenient snippets of information. 

The Joseph Payton about page is effective because it cuts the story down into bite-sized chunks. Each piece of information highlights valuable insights for the customer. Plus, hand-drawn images and animations make the experience feel like you’re getting to know Joe on a deeper level. 

Before you begin designing, ask yourself:

  • How much text does the page need? How much space does there need to be for copy? How can you spread the content out in a visually engaging way?
  • What sections should the page include? For example, does there need to be a link to the contact us page or a contact form somewhere?
  • How does the page connect to the rest of the website? For example, can you link to things like case studies and reviews with quotes to tie more of the website together?

Step 2: Make the Mission Statement Clear

In a world where emotion influences buyer behavior, clients and customers want to buy from companies they believe in. It’s not enough to have the right product or price point anymore. People want to know that they have a human connection with a business. 

On some about pages, it’s difficult to pinpoint the real mission of the company. It seems like you have to scroll through endless paragraphs of text to make your own assumptions about what matters to the company. However, a well-designed about page puts this crucial info front and center. 

For instance, on the Apptopia about us page, the subheading tells you everything you need to know about the brand. This heading instantly tells the audience whether it’s worth reading on to find out more. 

The best about us pages often include a lot more than just a single sentence of text. But it’s worth pinpointing some of the essential details from these pages and drawing extra attention to them. A larger font or a different font color could be perfect for this purpose. 

Alternatively, if it’s difficult to refine the company’s mission down into one message, it might be worth creating a whole segment at the top of the page dedicated to this information. That’s what the Toms shoe company does.

Step 3: Invest in the Right Trust Elements

People aren’t always sure who they can trust these days. 

There are millions of websites out there and billions of companies. Not all of them are going to appeal to every customer. Since an about page is all about making a crucial human connection between a business and its client, it’s important to implement as much trust as possible. 

The good news is that there are many trust elements you can embed into an about page to make it more reputable. Star ratings taken straight from companies like Trusted Reviews and Google are a great way to show that a company is already impressing its followers. 

Quotes plucked from your customers or segments of case studies that you can place throughout the About Page copy is another great way to show your authenticity. 

You could even take the same approach as Aja Frost here and embed genuine data and graphs into the about page.

One particularly helpful way to make a website’s about page more trustworthy without eating up too much space is to implement trust stickers. Badges that show all the right groups and regulators approve a company are a great start. 

Even showcasing the logos of companies that the business worked for before on a slideshow could be an excellent opportunity to add depth to their authority. 

Step 4: Convey Brand Personality

Brand personality is reflected in the tone of voice that a company uses for its content. You can see a company’s personality in the choice of colors it has on its website. It’s in the fonts that convey a message, and the videos, images, and other unique strategies that each business uses. 

Although a brand personality needs to shine through in everything the company does, it’s imperative on the about page. This is the environment where a customer is getting to know a business for the first time. As a result, the consumer should instantly recognize what kind of brand archetype they’re working with. 

Take a look at the Eight Hour Day about page, for instance. The first thing you see is a picture of two people laughing. That means you instantly get a sense of friendliness.

As you scroll through the page, you’re greeted by friendly, informal copy combined with bright colors and snippets of useful information. Everything feels comfortable and reassuring. 

When you reach the bottom of the page, you find a bunch of data that makes the company seem more trustworthy. There are links to its social media pages and a partial client list showcasing brands like JCPenny, Wired, and Purina.

Using the right combination of font, copy, and imagery, this About page tells you exactly what to expect before you begin interacting with the company. 

Step 5: Take Visitors on a Journey Through Time

Showing customers where a business is going with things like brand mission statements and values are great. However, it’s also worth giving people an insight into where a brand has already been. 

Many of today’s shoppers aren’t comfortable buying from brands that haven’t spent much time in their chosen industry. They want to see that the people they’re working with have experience, heritage, and plenty of background knowledge. 

What better way to demonstrate all of these things than with a timeline of accomplishments? Here’s an example of how Marshall showcases its history by mentioning various crucial historical milestones.

A timeline of events doesn’t have to be this complex, however. If you don’t want to overwhelm visitors with a wall of text, an actual timeline that offers quick and easy insights into what the business has done over the years could be a better option. 

Another option could be to have a few key statements from the company’s timeline, then link out to a separate “History” page for people who want to find out more. 

Step 6: Show the Human Side

People don’t buy from businesses; they buy from other people. 

An about page isn’t just a chance to show customers what a company does. It’s also an introduction to the people behind that organization. Showcasing the team members that contributed to the growth and continued development makes that organization more attractive. 

Obviously, if there are hundreds or thousands of employees in a team, you might not be able to mention them all on an about page. However, the page should generally include some insights into the c-suite and significant members of staff. 

A selection of company photos is a good way to introduce your team. However, you can consider other options too. For instance, to maintain their unique brand, the Tunnel Bear team designed to draw their own bear icons that represented their personalities.

The design is adorable, and it’s a wonderful way to showcase what makes the company so unique. At the same time, using this kind of illustration means you can avoid the hassle of trying to get all of your business photos to look consistent. 

Step 7: Show Values with Visuals

Finally, as we’ve mentioned frequently throughout this guide, an about page is an essential place to showcase the values of your business. These are the core principles that guide you in everything that you do. They help tell customers what matters most to you and prevent you from moving in the wrong direction. 

However, you’re not restricted to highlighting your values through copy and nothing else. You can also introduce customers to the things that matter most to you through visuals too. Graphics or illustrations that highlight important aspects of your business are a great way to share information without relying too heavily on text. 

Videos are another brilliant option, particularly if you have a lot to say but not a lot of time to say it in. That’s what Ben & Jerrys does.

You can also find a stream of “issues” the company cares about on the website too. This means that people can get more information on things like Democracy, Racial Justice, Fair trading, and what Ben & Jerry’s is doing about all of those things. 

Visual elements like this are a great way to give an about page more pizazz. Plus, they appeal to people who want to learn about your company but don’t want to spend forever reading through the text. 

Create Better About Pages

An about page shouldn’t be an afterthought. 

It’s a crucial part of showcasing a company’s unique style and personality. Used correctly, these pages convey crucial information about everything a business stands for. 

Use the tips above to give more meaning to your about page design, and remember to pay attention to how much your traffic and conversions evolve with every update you make. A better about page could even help you to drive more conversions.

Source

The post 7 Essential Design Tips for a Killer “About Us” Page first appeared on Webdesigner Depot.

Categories: Designing, Others Tags:

How You Can Improve Business Responsiveness and Customer Service with Virtual Receptionists

August 25th, 2021 No comments

Your inbound inquiries are coming in quickly, but you’re unable to respond to them promptly because you’re too busy working or are short-staffed. 

Are these common challenges that you regularly face with your business? Well, you’re not entirely alone, but you’ve likely been slow to address these problems head-on and it’s likely costing you potential revenue. We truly understand these issues and have the advice to help you immediately. 

Your customers will communicate directly with your business via online forms, calls, chats, SMS messages, social media, emails, and any other channel that they’re comfortable using. But, just as important as responding quickly to inbound inquiries, being readily available 24/7 to your customers is an expectation that many now demand. And if you’re not meeting this demand, they will find another business that is. 

Research from HubSpot’s consumer report paints a grim outlook for businesses that are not responding quickly enough to new leads and existing clients. 

The report found:

  • 82% of consumers expect an immediate response to a sales inquiry. 
  • 82% of consumers expect to be responded to immediately and 90% of consumers expect it on a support request.
  • 80% of consumers say they’ve stopped doing business with a company because of a poor experience. 

Businesses, especially solo, small, and medium-sized businesses, with limited staff and availability are expected to be available to respond promptly to all inbound inquiries. This can be rather unrealistic as the same staff is also responsible for thousands of other existing projects and client deliverables making it difficult to be responsive during all hours.  

Outsource your responsiveness

Fortunately, businesses that are feeling squeezed due to limited staff and availability to respond to inquiries have available solutions that’ll enable them to outsource and delegate front-line communication responsibilities to others. Outsourced 24/7 answering services staffed by virtual receptionists offer businesses a breath of fresh air as they’re better positioned and equipped to handle prompt lead responsiveness. 

Using a 24/7 virtual receptionist service lets businesses outsource their call and chat answering needs during business hours, nights, and weekends. Virtual receptionists can also serve as a backup answering option during peak hours and seasons for your business — or even just during lunchtime, when staff members are away from their desks. 

The role of virtual receptionists

Virtual receptionists support businesses with screening calls and blocking potential spammers, qualifying leads and conducting client intake, answering customer support requests, responding to text messages, and transferring calls to the appropriate employee to handle, freeing up staff members to focus on existing tasks without losing potential revenue from new leads as they come in. 

You might be thinking about the financial impact of not responding promptly to inquiries and how a virtual receptionist service can help alleviate that concern right now. Well, there is data to provide more clarity on that. 

Harvard Business Review audited 2,241 U.S. companies and their responsiveness to web leads by measuring how long each company took to respond to a web-generated test lead. 

The study found:

  • 37% responded to their lead within an hour
  • 16% responded within one to 24 hours
  • 24% took more than 24 hours
  • 23% of the companies never responded at all

The average response time, among companies that responded within 30 days, was 42 hours.

The study also uncovered that organizations that respond within 1 hour to a lead query are seven times more likely to qualify the lead than those who responded in just 2 hours, and 60 times more successful than those who responded within 24 hours. In fact, 78% of sales go to the first company to respond to a lead! 

To quickly recap the above study, businesses shouldn’t be caught napping at the wheel when responding to leads as it can limit their growth. So, if you’re slow to respond, you’ll be putting your business at risk of succeeding for simply not responding quickly enough to inquiries. Rather than assuming that risk, consider using solutions and services that’ll help ensure you’re responsive 24/7. 

Using virtual receptionists as your SDRs

Traditionally, businesses have used virtual receptionists to primarily handle inbound support and lead qualification. However, virtual receptionists are able to provide much more value for your business and free you up to focus on productive work and client deliverables. 

Outsourced receptionists have the unique ability to serve as an extension of your sales development team. This can be extremely valuable for solo and small businesses that are limited by time and resources to promptly follow up with potential new clients. Imagine sending a quick note to your answering service to make an outbound call and scheduling the qualified lead within minutes of them completing your online web form. Well, you’re in luck as that’s all it takes!

Conclusion

Businesses interested in growth should consider improving their lead responsiveness as it pays to be the first to answer their inquiry. One option to improve the speed of answering is by delegating your frontline communications to an answering service capable of not only handling inbound calls but making outbound calls to your potential clients.

You’ll likely start seeing more scalable and sustainable growth in converted leads as your responsiveness increases. Don’t leave your next big client hanging!

Categories: Others Tags:

Scrollbar Reflowing

August 24th, 2021 No comments

This is a bit of advice for developers on Macs I’ve heard quite a few times, and I’ll echo it: go into System Preferences > General > Show scroll bars and set to always. This isn’t about you, it’s about the web. See, the problem is that without this setting on, you’ll never experience scrollbar-triggered layout shifts, but everyone else with this setting on will. Since you want to design around not causing this type of jank, you should use this setting yourself.

Here’s Stefan Judis demonstrating that usage of viewport units can be one of the causes:

There, 100vw causes horizontal overflow, because the vertical scrollbar was already in play, taking up some of that space. Feels incredibly wrong to me somehow, but here we are.

Stefan points to Kilian Valkhof’s article about dealing with this. The classic fixes:

The easy fix is to use width: 100% instead. Percentages don’t include the width of the scrollbar, so will automatically fit.

If you can’t do that, or you’re setting the width on another element, add overflow-x: hidden or overflow: hidden to the surrounding element to prevent the scrollbar.

Kilian Valkhof, “How to find the cause of horizontal scrollbars”

Those are hacks, I’d say, since they are both things that aren’t exact matches for what you were wanting to do.

Fortunately, there is an incoming spec-based solution. Bramus has the scoop:

A side-effect when showing scrollbars on the web is that the layout of the content might change depending on the type of scrollbar. The scrollbar-gutter CSS property —which will soon ship with Chromium — aims to give us developers more control over that.

Bramus Van Damme, “Prevent unwanted Layout Shifts caused by Scrollbars with the scrollbar-gutter CSS property”

Sounds like the trick, and I wouldn’t be surprised if this becomes a very common line in reset stylesheets:

body {
  scrollbar-gutter: stable both-edges;
}

That makes me wonder though… it’s the when dealing with this at the whole-page level, right? Not the ? That’s been weird in the past with scrolling-related things.

Are we actually going to get it across all browsers? Who knows. Seems somewhat likely, but even if it gets close, and the behavior is specced, I’d go for it. Feels progressive-enhancement-friendly.


The post Scrollbar Reflowing appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

Architecting With Next.js

August 24th, 2021 No comments

(This is a sponsored post.)

Free event hosted by Netlify coming up next week (Wednesday, August 25th): Architecting with Next.js. It’s just a little half-day thing. No brainer.

Join us for a special event where we’ll highlight business teams using Next.js in production, including architecture deep dives, best practices and challenges. Next.js is the fastest-growing framework for Jamstack developers. With a compelling developer experience and highly performant results, it’s an emerging choice for delivering customer-facing sites and apps.

Next.js is such a nice framework, it’s no surprise to me it’s blowing up. It’s in React, a framework familiar to tons of people, thus enabling component-based front-ends, with common niceties built right in, like CSS modules. It produces HTML output, so it’s fast and good for SEO. It has smart defaults, so you’re rarely doing stuff like schlubbing your way through webpack config (unless you need that control, then you can). It does basic routing without you having to code it. Good stuff.

Direct Link to ArticlePermalink


The post Architecting With Next.js appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

Introduction to the Solid JavaScript Library

August 24th, 2021 No comments

Solid is a reactive JavaScript library for creating user interfaces without a virtual DOM. It compiles templates down to real DOM nodes once and wraps updates in fine-grained reactions so that when state updates, only the related code runs.

This way, the compiler can optimize initial render and the runtime optimizes updates. This focus on performance makes it one of the top-rated JavaScript frameworks.

I got curious about it and wanted to give it a try, so I spent some time creating a small to-do app to explore how this framework handles rendering components, updating state, setting up stores, and more.

Here’s the final demo if you just can’t wait to see the final code and result:

Getting started

Like most frameworks, we can start by installing the npm package. To use the framework with JSX, run:

npm install solid-js babel-preset-solid

Then, we need to add babel-preset-solid to our Babel, webpack, or Rollup config file with:

"presets": ["solid"]

Or if you’d like to scaffold a small app, you can also use one of their templates:

# Create a small app from a Solid template
npx degit solidjs/templates/js my-app
 
# Change directory to the project created
cd my-app
 
# Install dependencies
npm i # or yarn or pnpm
 
# Start the dev server
npm run dev

There is TypeScript support so if you’d like to start a TypeScript project, change the first command to npx degit solidjs/templates/ts my-app.

Creating and rendering components

To render components, the syntax is similar to React.js, so it might seem familiar:

import { render } from "solid-js/web";
 
const HelloMessage = props => <div>Hello {props.name}</div>;
 
render(
 () => <HelloMessage name="Taylor" />,
 document.getElementById("hello-example")
);

We need to start by importing the render function, then we create a div with some text and a prop, and we call render, passing the component and the container element.

This code then compiles down to real DOM expressions. For example, the code sample above, once compiled by Solid, looks something like this:

import { render, template, insert, createComponent } from "solid-js/web";
 
const _tmpl$ = template(`<div>Hello </div>`);
 
const HelloMessage = props => {
 const _el$ = _tmpl$.cloneNode(true);
 insert(_el$, () => props.name);
 return _el$;
};
 
render(
 () => createComponent(HelloMessage, { name: "Taylor" }),
 document.getElementById("hello-example")
);

The Solid Playground is pretty cool and shows that Solid has different ways to render, including client-side, server-side, and client-side with hydration.

Tracking changing values with Signals

Solid uses a hook called createSignal that returns two functions: a getter and a setter. If you’re used to using a framework like React.js, this might seem a little weird. You’d normally expect the first element to be the value itself; however in Solid, we need to explicitly call the getter to intercept where the value is read in order to track its changes.

For example, if we’re writing the following code:

const [todos, addTodos] = createSignal([]);

Logging todos will not return the value, but a function instead. If we want to use the value, we need to call the function, as in todos().

For a small todo list, this would be:

import { createSignal } from "solid-js";
 
const TodoList = () => {
 let input;
 const [todos, addTodos] = createSignal([]);
 
 const addTodo = value => {
   return addTodos([...todos(), value]);
 };
 
 return (
   <section>
     <h1>To do list:</h1>
     <label for="todo-item">Todo item</label>
     <input type="text" ref={input} name="todo-item" id="todo-item" />
     <button onClick={() => addTodo(input.value)}>Add item</button>
     <ul>
       {todos().map(item => (
         <li>{item}</li>
       ))}
     </ul>
   </section>
 );
};

The code sample above would display a text field and, upon clicking the “Add item” button, would update the todos with the new item and display it in a list.

This can seem pretty similar to using useState, so how is using a getter different? Consider the following code sample:

console.log("Create Signals");
const [firstName, setFirstName] = createSignal("Whitney");
const [lastName, setLastName] = createSignal("Houston");
const [displayFullName, setDisplayFullName] = createSignal(true);
 
const displayName = createMemo(() => {
 if (!displayFullName()) return firstName();
 return `${firstName()} ${lastName()}`;
});
 
createEffect(() => console.log("My name is", displayName()));
 
console.log("Set showFullName: false ");
setDisplayFullName(false);
 
console.log("Change lastName ");
setLastName("Boop");
 
console.log("Set showFullName: true ");
setDisplayFullName(true);

Running the above code would result in:

Create Signals
 
My name is Whitney Houston
 
Set showFullName: false
 
My name is Whitney
 
Change lastName
 
Set showFullName: true
 
My name is Whitney Boop

The main thing to notice is how My name is ... is not logged after setting a new last name. This is because at this point, nothing is listening to changes on lastName(). The new value of displayName() is only set when the value of displayFullName() changes, this is why we can see the new last name displayed when setShowFullName is set back to true.

This gives us a safer way to track values updates.

Reactivity primitives

In that last code sample, I introduced createSignal, but also a couple of other primitives: createEffect and createMemo.

createEffect

createEffect tracks dependencies and runs after each render where a dependency has changed.

// Don't forget to import it first with 'import { createEffect } from "solid-js";'
const [count, setCount] = createSignal(0);
 
createEffect(() => {
 console

Count is at... logs every time the value of count() changes.

createMemo

createMemo creates a read-only signal that recalculates its value whenever the executed code’s dependencies update. You would use it when you want to cache some values and access them without re-evaluating them until a dependency changes.

For example, if we wanted to display a counter 100 times and update the value when clicking on a button, using createMemo would allow the recalculation to happen only once per click:

function Counter() {
   const [count, setCount] = createSignal(0);
   // Calling `counter` without wrapping it in `createMemo` would result in calling it 100 times.
   // const counter = () => {
   //    return count();
   // }
 
   // Calling `counter` wrapped in `createMemo` results in calling it once per update.
// Don't forget to import it first with 'import { createMemo } from "solid-js";'
   const counter = createMemo(() => {
       return count()
   })
 
   return (
       <>
       <button onClick={() => setCount(count() + 1)}>Count: {count()}</button>
       <div>1. {counter()}</div>
       <div>2. {counter()}</div>
       <div>3. {counter()}</div>
       <div>4. {counter()}</div>
       <!-- 96 more times -->
       </>
   );
}

Lifecycle methods

Solid exposes a few lifecycle methods, such as onMount, onCleanup and onError. If we want some code to run after the initial render, we need to use onMount:

// Don't forget to import it first with 'import { onMount } from "solid-js";'
 
onMount(() => {
 console.log("I mounted!");
});

onCleanup is similar to componentDidUnmount in React — it runs when there is a recalculation of the reactive scope.

onError executes when there’s an error in the nearest child’s scope. For example we could use it when fetching data fails.

Stores

To create stores for data, Solid exposes createStore which return value is a readonly proxy object and a setter function.

For example, if we changed our todo example to use a store instead of state, it would look something like this:

const [todos, addTodos] = createStore({ list: [] });
 
createEffect(() => {
 console.log(todos.list);
});
 
onMount(() => {
 addTodos("list", [
   ...todos.list,
   { item: "a new todo item", completed: false }
 ]);
});

The code sample above would start by logging a proxy object with an empty array, followed by a proxy object with an array containing the object {item: "a new todo item", completed: false}.

One thing to note is that the top level state object cannot be tracked without accessing a property on it — this is why we’re logging todos.list and not todos.

If we only logged todo` in createEffect, we would be seeing the initial value of the list but not the one after the update made in onMount.

To change values in stores, we can update them using the setting function we define when using createStore. For example, if we wanted to update a todo list item to “completed” we could update the store this way:

const [todos, setTodos] = createStore({
 list: [{ item: "new item", completed: false }]
});
 
const markAsComplete = text => {
 setTodos(
   "list",
   i => i.item === text,
   "completed",
   c => !c
 );
};
 
return (
 <button onClick={() => markAsComplete("new item")}>Mark as complete</button>
);

Control Flow

To avoid wastefully recreating all the DOM nodes on every update when using methods like .map(), Solid lets us use template helpers.

A few of them are available, such as For to loop through items, Show to conditionally show and hide elements, Switch and Match to show elements that match a certain condition, and more!

Here are some examples showing how to use them:

<For each={todos.list} fallback={<div>Loading...</div>}>
 {(item) => <div>{item}</div>}
</For>
 
<Show when={todos.list[0].completed} fallback={<div>Loading...</div>}>
 <div>1st item completed</div>
</Show>
 
<Switch fallback={<div>No items</div>}>
 <Match when={todos.list[0].completed}>
   <CompletedList />
 </Match>
 <Match when={!todos.list[0].completed}>
   <TodosList />
 </Match>
</Switch>

Demo project

This was a quick introduction to the basics of Solid. If you’d like to play around with it, I made a starter project you can automatically deploy to Netlify and clone to your GitHub by clicking on the button below!

This project includes the default setup for a Solid project, as well as a sample Todo app with the basic concepts I’ve mentioned in this post to get you going!

There is much more to this framework than what I covered here so feel free to check the docs for more info!


The post Introduction to the Solid JavaScript Library appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

How To Boost Your Brand Promotion

August 24th, 2021 No comments

Today’s consumers have so many different businesses to choose from and this can be overwhelming.

For any business to succeed in this competitive market, they need to take care of brand recognition so they can become recognizable by their logo, slogan, or anything else related to their brand.

But building this recognition takes a lot of work and it takes approximately 5-7 interactions with a brand for people to start remembering it. So, to get your business to the top of your ideal customers’ priorities and into their minds and hearts, you need to prioritize brand promotion.

Use your social media right

It’s impossible to find a business with great brand recognition that doesn’t have a social media presence, and there’s a good reason for that. There are many reasons your brand needs an unmissable social media presence.

Social media platforms have billions of users, people interact with them daily, and no matter what your target audience is, you can find them on social media.

However, not all social media platforms work well for every business. To figure out what platforms you should use, do some research. See where your target audience is, how they usually interact with that platform, and what they like to see from their favorite brands on social media.

Let’s say, for instance, that your ideal customers consist of a younger audience. If that’s the case, you should have a strong presence on Instagram. Not only should you post regularly but you should always reply to every message quickly and accurately. 

You can do that if you use a tool such as Instagram chat API. This tool will allow you to provide great customer service on Instagram by automating all of the busywork and giving you features such as auto-replies, quick replies, and no-code chatbots. It will also keep all of your channels in one view and provide you with useful statistics.

Have a presence on LinkedIn

Image source

Creating brand recognition amongst other businesses is just as important as creating it amongst your customers. And what better place to do that than the only social media outlet for professionals? LinkedIn has 722 million members and that’s more than enough for brand promotion in a professional setting.

One of the recently added features on LinkedIn is its publishing tool, which allows you to publish posts, spread brand awareness, and establish yourself as an industry leader. Content is king, and the more content you have about your brand, the better.

Publishing content will get you noticed and help you make more connections. And when all of those requests and messages start coming in, you should have a LinkedIn automation service that will help you with messaging, event invitations, automated replies, profile auto-follows, and much more.

Appear locally as much as you can

Every company’s ultimate goal is to create brand recognition worldwide, but before you can do that, you need to start small and aim to be recognized in your local community.

When you get together with potential leads and similar businesses in your area, you can network, get to know your competition, and introduce your brand face-to-face. Additionally, you can use this opportunity to hand out swag and get your company’s name and logo out there.

When mingling with your local community, you can emphasize the meaning and purpose of your brand, and the best way to do that is to explain what your mission is. 

To do that, you need a great mission statement. This is a simple and short description of your businesses’ purpose which explains why your organization exists in the first place. A compelling mission statement can be memorable and impactful, and that’s exactly what you’re hoping to achieve with brand promotion.

Have a unique and fun personality

Image source

For as long as there have been businesses, there have been boring businesses. Even if you have a lot to offer, if you don’t know how to present your offer memorably, you will be lost in a sea of competitors. If you want your brand identity to be memorable, you should make it fun and unique.

This will work great if you work in an industry where not many companies dare to stand out. Being different isn’t bad or something people will look down on. Unique expression is popular right now, and if you take a look at some brands that dare to be fun and silly, you will see how much uniqueness pays off.

Let’s take a look at Old Spice, for example. Their ads are popular in the entire world and people often watch them online because they’re silly and entertaining. These hilarious ads always leave an impression, but more importantly, they also drive sales.

Create remarketing campaigns

Remarketing campaigns involve creating advertisements that will be shown to the people who have already visited your website in the past. This is a great brand promotion strategy because it brings attention to your brand with people who have already had contact with it.

Remarketing ads are usually placed on the websites your customers visit after they leave your website. So before they know it, they are seeing your brand everywhere. This will give them the impression your brand is larger than they knew and will ultimately increase your conversion rates.

Final thoughts

No matter how good your products are, how well you execute your marketing campaigns, or how much you invest in any aspect of your business, you won’t go far unless you put focus on brand promotion.

When you get your brand in front of enough people and can be sure that it’s recognizable, it will be smooth sailing from then on.

Categories: Others Tags:

Detecting Media Query Support in CSS and JavaScript

August 23rd, 2021 No comments

You can’t just do @media (prefers-reduced-data: no-preference) alone because, as Kilian Valkhof says:

[…] that would be false if either there was no support (since the browser wouldn’t understand the media query) or if it was supported but the user wanted to preserve data.

Usually @supports is the tool for this in CSS, but that doesn’t work with @media queries. Turns out there is a solution though:

@media not all and (prefers-reduced-data), (prefers-reduced-data) {
  /* ... */
}

This is a somewhat complex logic puzzle involving media query syntax and how browsers evaluate these things. It’s nice you can ultimately handle a no-support fallback situation in one expression.

Direct Link to ArticlePermalink


The post Detecting Media Query Support in CSS and JavaScript appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

20 Best New Sites, August 2021

August 23rd, 2021 No comments

Often, when designing a website or branding, it is easy to get wrapped up in the details–typography, graphics, color, the grid–and lose the bigger picture. Of course, these things are vitally important, but they are building blocks that go together to form a greater whole.

A good website creates an impression; it tells a story. And all the various elements involved, from copy to hero image to type choices, combine to create that story. Telling a story can mean taking a user through a linear narrative of how a company or a product came about, using a narrative to make a point, or simply creating an environment or experience that shows the user what a brand is all about.

We have selected examples of different kinds of storytelling for this month’s collection–we’ve even included an actual story. Enjoy!

Black Dog 

Black Dog is a rather beautiful picture book project showcasing the developer’s WebGL skills.

Right to Breathe

Right to Breathe highlights the dangers of passive smoking in a way that is engaging and intriguing.

Superglow

Creative agency Superglow focuses on clients in the music industry, and their particular aesthetic is clearly demonstrated in their portfolio site.

Instabase

Instabase is an enterprise productivity platform for complex data. Not the most glamorous product to sell, but this site does a good job of engaging the user through good layout and colorful graphics.

Bake Inc.

Bake Inc.’s corporate site makes good use of diagonals to break up content and to provide a sense of energy to the flow. Plus it features some fairly mouth-watering photographs.

Julia Johnson

This portfolio site for photographer, director, and creative director Julia Johnson, is simple but with very nice details, such as the color backgrounds for image loading.

Pitchfork Music Festival

While yellow text on a multi-color background doesn’t sound like a great idea, it works on this site for Pitchfork Music Festival.

Little Yawn Collective

Some sweet illustrations and a soothing color scheme set the mood for Little Yawn Collective, which offers natural sleep solutions for children.

Pine

Production company Pine takes a bold approach, showing the work with very little text beyond contact information.

Bloomers

Bloomers describes itself as a knowledge consultancy offering branding and strategy. To illustrate its philosophy of connecting past and present, it has gone for Victoriana.

Fox Computers

With its slightly muted palette and a very businesslike feel, this site for web agency Fox Computers gives the impression of competent and safe, without being boring.

Forest Gum

Forest Gum makes natural chewing gum — from tree sap instead of plastic. There are lots of greens and bubblegum pink here and a bold, irregular display type for a modern, young feel.

Felt

Although Felt online — a collaborative mapping tool – is currently in private beta, this promotional site does a good job of creating interest while doubling as a recruitment notice/job advert.

Help Dad

Help Dad is a micro-site from Oatly, aimed at UK customers. In terms of visual design, it adheres to the same style as all of Oatly’s sites. However, what stands out here is the quality of the content, tailored for the UK market.

Epicurrence

Epicurrence, the 4-day not-conference for creatives, is back for 2021, and this time it’s at Outer Banks, NC. The site keeps the content simple and to the point, livened up by illustration.

Marram

With some great photography and a soft color palette, this site for Marram boutique hotel manages to create an impression of soft, almost golden, light and calm.

Re-Forme

Re-Forme makes recyclable and biodegradable food packaging. The site is in a style used a lot by companies whose focus is sustainability – simple illustration, strong colors, color transitions, and large type. There’s a nice little arrow detail in their logo.

Miti Navi

You could be forgiven for thinking Miti Navi has been included because we want one of their sailing boats to “test.” After seeing how they are presented here, who wouldn’t?

Under Armour

Sportswear brand Under Armour has just updated its website. Visually the difference isn’t startling, but the usability and navigation have been improved.

The Longest Road Out

The Longest Road Out site promotes a travel map and journal based on its creators’ own road trip around Britain and Ireland (plus the outlying islands). The site is charming.

Source

The post 20 Best New Sites, August 2021 first appeared on Webdesigner Depot.

Categories: Designing, Others Tags: