Entries by admin

Why Are We Talking About CSS4?

Original Source: https://www.smashingmagazine.com/2020/03/css4-pros-cons-discussion/

Why Are We Talking About CSS4?

Why Are We Talking About CSS4?

Rachel Andrew

2020-03-04T11:30:00+00:00
2020-03-04T13:07:05+00:00

There has been some discussion recently about whether there should be a CSS4, as in a defined “next version” of CSS. In this article, I take a look at the discussions around this, the pros and cons of creating a feature release for CSS, and the potential problems in deciding what goes into it.

I’m using the term CSS4 as that is how the discussion was started, and not attempting to discuss what the naming should actually be, should this approach be taken forward. Bikeshedding naming is an excellent distraction from the discussion of whether we should do this at all, so I will use CSS4 as a placeholder for the version of CSS we are proposing to define, and CSS5 for the next one along the line.

The Issue

A discussion around whether we should define a CSS4 has been raised in the community, and Jen Simmons then raised a CSS Working Group issue which neatly rounds up some of that existing debate. Outside of the actual issue that we are discussing, it is fantastic to see so many people who are not part of the CSS WG replying on this thread, and I hope that having commented once, people will be happy to come and comment on some of our other issues.

In order to understand why there is no CSS4, we need to look at a little bit of web platform history. The initial versions of CSS were as a single, monolithic specification. These specifications contained every possible CSS property and value. This worked well as there wasn’t a lot of CSS to detail. CSS1 mostly covered features for formatting text documents, additional features and clarifications were added to CSS2 and CSS2.1 however CSS was still a relatively small specification.

CSS3

At the point the CSS Working Group began work on CSS3, it was decided to split the big spec into modules. These modules would each cover part of CSS. Not all of CSS was immediately placed into a new module. Many things remained defined in CSS2.1 as there were no changes or additions to them. For this reason, you will still find links to the CSS2 specification in modern modules, if the thing that is being referenced is still defined in CSS2. However, any new CSS is created in separate modules. This modularization continues today as new CSS is being created. For example, several of the features that make up the Box Alignment specification initially started life in the Flexbox spec. Once it became apparent that they could apply to other layout methods such as Grid Layout, they were moved into a new module to be defined for that other method too.

We stopped referring to new specifications as CSS3 Specifications, partly because it didn’t make a lot of sense. The way that modules are versioned is that the modules which were a progression of CSS2, for example Selectors, became a Level 3 module. Brand new CSS, for example CSS Grid Layout, did not exist at all in CSS2 and so start life as a Level 1 module. Some of those initial modules are now at Level 4 or even Level 5. Therefore, calling all new CSS CSS3 doesn’t map to the level numbers anymore, and is potentially rather confusing.

Specification Maturity Levels

In addition to specification levels, each individual level goes through a staged process from the initial draft to becoming a W3C Recommendation, the steps in the process are referred to as Maturity Levels. A W3C Recommendation is what you might think of as a “web standard”, however many of the things we use daily in our work are defined in specifications that are not at that maturity level yet. You can see the list of specifications and their status on the CSS WG Current Work page.

Explaining The Missing CSS4

Many of us involved with the process saw the confusion about CSS3 or the apparent lack of progress to CSS4 and began to write articles, post videos, and try to help people understand a bit about how the process actually worked. That said, while it was important to share this information so that people teaching CSS would explain it correctly, I am not sure how much this information matters to the average web developer. What level a specification is at, or the internal W3C process of specification maturity, is far less important to a web developer than the issue of what CSS can actually be used in browsers.

“There Is No Such Thing As CSS4,” Tab Atkins-Bittner
“Why There Is No CSS4: Explaining CSS Levels,” Rachel Andrew
“Where Is CSS4? When Is It Coming Out?,” Layout Land (video)

What Are The Benefits Of Versioning CSS?

Looking through the responses to the issue, and the discussion around the web, there are certainly some potential benefits of having a clear version number for CSS.

As a writer of books and a producer of educational materials, I would probably benefit from CSS version numbers. It’s an excuse to publish an updated book that covers the latest and greatest version of CSS. On the other side of that, it is a way for the purchasers of books and courses to be sure that what they are buying is reasonably up to date – although the publishing date is arguably a better indication of that than anything else.

One thing we did lose by moving away from a version number of all of CSS, was the ability to do something like the Acid Test. The Acid 1 Test tested for support of CSS1, Acid 2 for support of CSS2.1. These tests were reasonably well known and seen as a good benchmark for browser support of web standards. A version 3 test was developed, however, it tested for a range of features and was less tightly tied to the Level 3 CSS Modules than previous tests had been to CSS1 and 2.1. A definite line drawn around a set of features would allow for user agents to declare their level of support for those features.

Some commenters on the issue have mentioned that a version would allow them to push for dropping of older browser versions because they “don’t support CSS4”.

“[…] perhaps CSS4 could help to push their mindset towards a more secure and better web. During pitch meeting, it’s hard to tell them we can’t support IE10 because we want CSS Variables and Grid Layout. Stakeholders do not know and do not care. They just want to support as many browsers as they could (very typical FOMO mindset) and they have the dollars to throw.

However, if we could tell them we can’t support IE10 because it doesn’t have the latest CSS4 technology and throw them the “Are you sure you want your newly created website to be behind your competitors because of that?” question, that might ponder them (of course, on top of the fact that IE10 is completely obsolete and vulnerable).”

There is an argument that defining a version gives developers a clear set of things to learn. In opening the issue on the CSS WG Jen Simmons said,

“I see a lot of resistance to learning the CSS that came after CSS3. People are tired and overwhelmed. They feel like they’ll never learn it all, never catch up, so why try, or why try now? If the CSSWG can draw a line around the never-ending pile of new, and say ‘Here, this. This part is ready. This part is done. This part is what you should take the time to learn. You can do this. It’s not infinite.’ I believe that will help tremendously.”

What Are The Problems Of Versioning CSS?

The first issue is that any collection of “ready for the primetime” CSS, is not as straightforward as selecting a set of specifications. Many specifications are partially implemented, with great support for some properties and none for others. There are features which many web developers would see as mature, sat in specifications still at Working Draft status alongside features which are still being debated and clarified in the Working Group.

If we take Multiple-column Layout as an example. The majority of properties have had widespread browser implementation for many years. However, the column-span property has only recently been implemented in Firefox, and there are a number of features that have recently been clarified, such as column-fill.

We could decide to ignore specifications altogether and look at properties. That isn’t straightforward either due to the fact that we have partial implementations across layout methods. The Box Alignment Properties are an excellent example. These are defined for all layout methods, where the property makes sense in that layout method. However support for Box Alignment is currently only seen in Grid and Flexbox. Therefore is justify-self, which is defined for block-level boxes, absolutely-positioned boxes, and grid items stable? Yes in a Grid context, no in a Block Layout context.

Box Sizing is another area, we have support for the intrinsic sizing value fit-content() in CSS Grid Layout for track sizing, yet not as a value for width. Then, none of the intrinsic sizing keywords are implemented for flex-basis by browsers other than Firefox.

Finally, if we return to multicol, many of the problems people have with multicol are nothing to do with the properties themselves, but are to do with poor support of fragmentation across browsers. This makes multicol seem to behave badly despite there being excellent support of the various properties. Disentangling all of these dependencies to come up with a set of features is going to be quite a difficult job.

CSS Is Not Just For Web Browsers

As I and one other commenter have mentioned, CSS is not just for web browsers. There are a whole raft of user agents that take CSS and HTML and output printed documents by way of creating a print-ready PDF. They typically have excellent support for the Paged Media specification, fragmentation and so on. However, they often lag behind browsers in terms of implementing newer CSS, for example Grid Layout. How do they fit into CSS4?

People Expect A Feature Release To Include Currently Non-Existent Features

Something interesting that has happened in the discussion on the issue, is that a number of people have commented saying that their expectations of a CSS4 are that it would contain certain features that are not yet part of CSS at all. Joshua Lindquist, in his excellent roundup of the comments notes that,

“When discussing authors that do not keep up with the latest developments, I think this approach will be simple to understand. Everything will feel like it’s brand new to them, even though some of these features, like Grid and Flexbox, have been in browsers for years.

But anyone who does keep up will likely be confused about why there is a ‘new’ specification full of things that are actually old.”

Who Would Decide What Makes The Cut?

Given the fact that the features that would make up CSS4 are not completely straightforward, someone is going to have to make the decision as to what is included.

The CSS Working Group has criteria for stability via the Maturity Levels already discussed. Once a spec has two implementations of each feature it can progress from Candidate Recommendation Status to become a Recommendation. However, as detailed above, it can take some time for that to happen, and while we are waiting for some features in a spec to have implementations, other may have widespread and stable browser support. If we were to say that CSS4 was only those specifications that were at Recommendation Status it would include:

CSS Color Level 3
CSS Namespaces
Selectors Level 3
CSS Level 2 Revision 1
Media Queries
CSS Style Attributes
CSS Fonts Level 3
CSS Writing Modes Level 3
CSS Basic User Interface Level 3
CSS Containment Level 1

So, no Grid, Flexbox, Box Alignment, and many more specifications that most of us are using.

If we are going to define a version of CSS, that is separate to the existing specification levels and maturity that we already have as part of the W3C process, then there needs to be a group with the time and resources to work on this. That group not only needs to define CSS4, but needs to do that as part of developing a framework to make these decisions this time, and for the next n versions of CSS. Otherwise, we will be having this discussion again in another two years, about the fact that no-one has shipped CSS5. I don’t believe the CSS Working Group is the right venue for that, even if only that there is other work that the WG needs to be doing to actually develop and define new CSS. There are already more jobs to be done than we have time to do. In addition, having another consideration when working on specifications will make decisions around each spec harder. Currently, we have situations where parts of a spec are marked as at-risk if their inclusion might prevent the spec from progressing to a Recommendation. It was for this reason that subgrid was bumped to Level 2 of Grid. If we have this additional level of abstraction, which doesn’t really fit into the process, will this just be another thing to consider and thus delay work on specifications?

What Problem Are We Trying To Solve?

In many of the responses to this issue, web developers brought up browser support as being key to what should be included in a CSS4, and I think that the issue we face is less one of CSS versioning and more of web developers being clear as to which collection of features should generally be considered usable in their projects.

“One of the advantages of a CSS4 approach is that it signals two things. First, that there’s a significant bundle of new CSS features that have been developed after CSS3 and which are ready for use and second, that they are ready for use. Not experimental or implemented by Chrome but no one else, but ready for broad adoption.”

— Rick Gregory

The fact that browser support comes up so frequently in this discussion makes me wonder if a better place to be defining this would be somewhere like MDN. MDN is already contributed to by all browser vendors, it already has support data for these features in a way that allows us to see partial implementations of things like Box Alignment. MDN is the documentation for the web platform, so we could sidestep the issue of print implementations, or any other implementations of CSS, scoping the feature set to the web alone.

I remain unconvinced that a CSS4, or whatever we choose to call a version of CSS, will actually make any difference to the perception of CSS outside of a relatively small community. Nor do I think it will help to solve the problems that web developers have in terms of convincing their bosses and clients to upgrade browsers. If Microsoft, who provides the software, is telling companies to upgrade and companies are not upgrading, I fail to see what the carrot of supporting CSS4 will do. And, I’ve been doing this a long time and know that back when we did have versions of CSS, people still didn’t upgrade their browsers. However, I think it will make it easier to talk about a particular chunk of functionality in a less abstract way, but I think that it needs to happen outside of the CSS Working Group and the specification process, and be based on what is usable as opposed to what is well specified.

“However, I must agree with several others that major marketing versions only have meaning in a compatibility situation. If we announce that CSS5 is finally here, it must mean all major browsers have full or near-full support.

Without this compatibility condition met, I think some developers will be cynical, and return to feature or module based thinking, the current status quo.”

— Ferdy Christant

What Do You Think?

I wanted to bring the discussion to Smashing Magazine as I think that many of our readers won’t have noticed this discussion. I’d be interested in what you think. Are there ways in which declaring a version of CSS would help you, that I haven’t mentioned here? Would checking to see what was in this version be something you would do, or would you be more inclined to check Can I Use, or MDN to find out what is supported? Do you think the average web developer cares about this stuff? Let us know in the comments, post to the original issue, or join the new Community Group set up to discuss this.

Smashing Editorial
(il)

Awesome Demos Roundup #14

Original Source: http://feedproxy.google.com/~r/tympanus/~3/afgBmfRBCCo/

These past few weeks we’ve collected some really nice web experiments: from Shader magic to SVG filter trickery, interactive poetry and particle madness — there’s something for every creative coder’s heart.

We hope you enjoy this collection and find it inspiring!

Stacking Cards Effect

by Claudia Romano

Bouncing Balls

by Meto Trajkovski

Starfields GLShader

by Paul J Karlik

verlet

by Kitasenju Design

Spring pagination

by Mikael Ainalem

Turbulence

by Janxalot

Flight

by Mat Sz

ThreeJS Maths of Heart

by TheFrost

Calm Spikes

by Anna the Scavenger

Editable Neumorphic Text

by Adam Kuhn

Care Bear NEEDS Love (mousedown/touchstart)

by Jhey Tompkins

Curl Simulation

by Daniel Velasquez

Banksy – Valentine’s Day

by David Fitzgibbon

Wavy Color Cube

by Ryan Mulligan

intimacy

by Thibaud Goiffon

What’s behind ?

by Kevin Levron

threejs-nuxt-sample

by Misaki Nakano

The Three Graces (React App)

by Paul Henschel

Wind field – How To

by Louis Hoebregts

Pure CSS Claw Crane

by Jon Kantner

void-merge-2048

by Arthur

Corgo’s with Jason

by Mandy Michael

Pixel Dust

by Paul Neave

Pure CSS Responsive Browser Template

by Adam Marsden

Random, Cos and Sin

by Kevin Levron

Diagonal Layouts in 2020

by Nils Binder

r3f cannon instanced physics

by Paul Henschel

Liquid Grid

by by Kevin Levron

Memphis Beauty

by Anna the Scavenger

Tower Time

by Adrian Rampy

shader moire

by masuwa

Isometric City w/ Airplane

by Adam Kuhn

Awesome Demos Roundup #14 was written by Mary Lou and published on Codrops.

How to Design for Screen Readers with Adobe XD CC

Original Source: https://www.sitepoint.com/how-to-design-for-screen-readers-with-adobe-xd-cc/?utm_source=rss

Designing for Screen Readers with the Help of Adobe XD CC

When it comes to accessibility, designers tend to focus on colors (i.e. contrast) and UX copy (i.e. wording), whereas developers tend to focus on ARIA attributes (i.e. code that makes websites more accessible). This is due to the fact that, often enough, thick lines are drawn between “who does what”.

Also, because creating accessible apps and websites isn’t considered to be exciting, this line is hardly ever questioned.

Accessibility is still a black sheep, even in 2020.

So, since UX copy is the responsibility of the designer and ARIA attributes are the responsibility of the developer, exactly whose responsibility is it to cater for screen readers? Since:

Screen reader UX copy is expressed as Braille or dictation (so how do we communicate this when our UI tools are visual?)
Implementation is developer territory (so can we really shift the responsibility of writing UX copy to developers?)

As you can see, it’s a two-person job — and yet, the tools simply don’t exist to facilitate this. I mean, make no mistake, some aspects of accessibility design are one-sided (for example, UI designers can very easily take care of color contrast by themselves). However, other aspects such as designing for screen readers requires collaboration between designers and developers.

This is where Adobe XD CC’s design handoff and voice prototyping features come in handy. In this article, we’ll discuss what to consider when designing for screen readers, and we’ll also walk through how to use the features mentioned above.

What Are Screen Readers?

A screen reader is a type of assistive technology that communicates what’s happening on the screen (for those with visual impairments). Screen reader software can be used in combination with the keyboard (for example, users will tab and enter as opposed to using the mouse), but it can also be used in combination with screen reader hardware, which allows for more efficient navigation and also caters for users that use Braille.

If you’re an Apple user, for example, you’ll be somewhat aware of Apple VoiceOver, which is the native Apple dictation software that acts as a screen reader. Windows users, however, commonly use either JAWS or NVDA, since there aren’t any native screen reader tools in the Windows operating system.

Let’s dive in.

1. Use Headings

Screen readers often use headings as a way of deciphering a website’s structure, and if we think too visually we run the risk of leaving out these headings. In the example below, the omission of the “Chapters” heading causes screen readers to assume that the list of chapters is a continuation of the content on the left-hand side, which it obviously isn’t.

"Chapters" needs to be a heading

As a result, screen-reader users won’t be able to skip to “Chapters”, and they might not discover the information within.

While there are code workarounds available (such as the aria-label attribute), having a visible heading inclusively offers a clearer experience for everybody, whether disabled or not.

Of course, the section is very obviously a list of chapters, as we can infer from the context (i.e. the content). However, those using screen readers very rarely have the luxury of context. It’s like trying to find an object in storage where none of the boxes are labeled. Our designs need these labels and headings.

On the technical side, the rule is that every section (as defined by a <section> or <article> tag) should have not only a heading, but an explicit heading that conflicts with no other heading. As an example, if the highest level heading within a section is an <h2>, then there should be no other <h2> heading within that section. Otherwise, screen readers are clueless as to which heading is the label for the section.

The same heading for like sections

The post How to Design for Screen Readers with Adobe XD CC appeared first on SitePoint.

How to Build a File Upload Form with Express and DropzoneJS

Original Source: https://www.sitepoint.com/file-upload-form-express-dropzone-js/?utm_source=rss

How to Build a File Upload Form with Express and DropzoneJS

Let’s face it, nobody likes forms. Developers don’t like building them, designers don’t particularly enjoy styling them, and users certainly don’t like filling them in.

Of all the components that can make up a form, the file control could just be the most frustrating of the lot. It’s a real pain to style, it’s clunky and awkward to use, and uploading a file will slow down the submission process of any form.

That’s why a plugin to enhance them is always worth a look, and DropzoneJS is just one such option. It will make your file upload controls look better, make them more user-friendly, and by using AJAX to upload the file in the background, it will at the very least make the process seem quicker. It also makes it easier to validate files before they even reach your server, providing near-instantaneous feedback to the user.

We’re going to take a look at DropzoneJS in some detail. We’ll show how to implement it. and look at some of the ways in which it can be tweaked and customized. We’ll also implement a simple server-side upload mechanism using Node.js.

As ever, you can find the code for this tutorial on our GitHub repository.

Introducing DropzoneJS

DropzoneJS allows users to upload files using drag and drop. Whilst the usability benefits could justifiably be debated, it’s an increasingly common approach and one which is in tune with the way a lot of people work with files on their desktop. It’s also pretty well supported across major browsers.

DropzoneJS isn’t simply a drag and drop based widget, however. Clicking the widget launches the more conventional file chooser dialog approach.

Here’s an animation of the widget in action:

The DropzoneJS widget in action

Alternatively, take a look at this most minimal of examples.

You can use DropzoneJS for any type of file, though the nice little thumbnail effect makes it ideally suited to uploading images in particular.

Features

To summarize some of the plugin’s features and characteristics, DropzoneJS:

can be used with or without jQuery
has drag and drop support
generates thumbnail images
supports multiple uploads, optionally in parallel
includes a progress bar
is fully themeable
includes extensible file validation support
is available as an AMD module or RequireJS module
comes in at around 43KB when minified and 13KB when gzipped

Browser Support

Taken from the official documentation, browser support is as follows:

Chrome 7+
Firefox 4+
IE 10+
Opera 12+ (Version 12 for macOS is disabled because their API is buggy)
Safari 6+

There are a couple of ways to handle fallbacks for when the plugin isn’t fully supported, which we’ll look at later.

Getting Set Up

The simplest way to get started with DropzoneJS is to include the latest version from a CDN. At the time of writing, this is version 5.5.1.

Alternatively, you can download the latest release from the project’s GitLab page. There’s also a third-party package providing support for ReactJS.

Then, make sure you include both the main JavaScript file and the CSS styles in your page. For example:

<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<title>File Upload Example</title>
<link
rel=”stylesheet”
href=”https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.5.1/min/dropzone.min.css”>
</head>
<body>

<script src=”https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.5.1/min/dropzone.min.js”></script>
</body>
</html>

Note that the project supplies two CSS files — a basic.css file with some minimal styling, and a more extensive dropzone.css file. Minified versions of dropzone.css and dropzone.js are also available.

Basic Usage

The simplest way to implement the plugin is to attach it to a form, although you can use any HTML such as a <div>. Using a form, however, means fewer options to set — most notably the URL, which is the most important configuration property.

You can initialize it simply by adding the dropzone class. For example:

<form id=”upload-widget” method=”post” action=”/upload” class=”dropzone”></form>

Technically, that’s all you need to do, though in most cases you’ll want to set some additional options. The format for that is as follows:

Dropzone.options.WIDGET_ID = {
//
};

To derive the widget ID for setting the options, take the ID you defined in your HTML and camel-case it. For example, upload-widget becomes uploadWidget:

Dropzone.options.uploadWidget = {
//
};

You can also create an instance programmatically:

const uploader = new Dropzone(‘#upload-widget’, options);

Next up, we’ll look at some of the available configuration options.

Basic Configuration Options

The url option defines the target for the upload form, and is the only required parameter. That said, if you’re attaching it to a form element then it’ll simply use the form’s action attribute, in which case you don’t even need to specify that.

The method option sets the HTTP method and again, it will take this from the form element if you use that approach, or else it’ll simply default to POST, which should suit most scenarios.

The paramName option is used to set the name of the parameter for the uploaded file. If you’re using a file upload form element, it will match the name attribute. If you don’t include it, it defaults to file.

maxFiles sets the maximum number of files a user can upload, if it’s not set to null.

By default, the widget will show a file dialog when it’s clicked, though you can use the clickable parameter to disable this by setting it to false, or alternatively you can provide an HTML element or CSS selector to customize the clickable element.

Those are the basic options, but let’s now look at some of the more advanced options.

Enforcing Maximum File Size

The maxFilesize property determines the maximum file size in megabytes. This defaults to a size of 1000 bytes, but using the filesizeBase property, you could set it to another value — for example, 1024 bytes. You may need to tweak this to ensure that your client and server code calculate any limits in precisely the same way.

Restricting to Certain File Types

The acceptedFiles parameter can be used to restrict the type of file you want to accept. This should be in the form of a comma-separated list of MIME types, although you can also use wildcards.

For example, to only accept images:

acceptedFiles: ‘image/*’,

Modifying the Size of the Thumbnail

By default, the thumbnail is generated at 120x120px. That is, it’s square. There are a couple of ways you can modify this behavior.

The first is to use the thumbnailWidth and/or the thumbnailHeight configuration options.

If you set both thumbnailWidth and thumbnailHeight to null, the thumbnail won’t be resized at all.

If you want to completely customize the thumbnail generation behavior, you can even override the resize function.

One important point about modifying the size of the thumbnail is that the dz-image class provided by the package sets the thumbnail size in the CSS, so you’ll need to modify that accordingly as well.

Additional File Checks

The accept option allows you to provide additional checks to determine whether a file is valid before it gets uploaded. You shouldn’t use this to check the number of files (maxFiles), file type (acceptedFiles), or file size (maxFilesize), but you can write custom code to perform other sorts of validation.

You’d use the accept option like this:

accept: function(file, done) {
if (!someCheck()) {
return done(‘This is invalid!’);
}
return done();
}

As you can see, it’s asynchronous. You can call done() with no arguments and validation passes, or provide an error message and the file will be rejected, displaying the message alongside the file as a popover.

We’ll look at a more complex, real-world example later, when we look at how to enforce minimum or maximum image sizes.

Sending Additional Headers

Often you’ll need to attach additional headers to the uploader’s HTTP request.

As an example, one approach to CSRF (cross-site request forgery) protection is to output a token in the view, then have your POST/PUT/DELETE endpoints check the request headers for a valid token. Suppose you outputted your token like this:

<meta name=”csrf-token” content=”CL2tR2J4UHZXcR9BjRtSYOKzSmL8U1zTc7T8d6Jz”>

Then, you could add this to the configuration:

headers: {
‘x-csrf-token’: document.querySelector(‘meta[name=csrf-token]’).getAttributeNode(‘content’).value,
},

Alternatively, here’s the same example but using jQuery:

headers: {
‘x-csrf-token’: $(‘meta[name=”csrf-token”]’).attr(‘content’)
},

Your server should then verify the x-csrf-token header, perhaps using some middleware.

Handling Fallbacks

The simplest way to implement a fallback is to insert a <div> into your form containing input controls, setting the class name on the element to fallback. For example:

<form id=”upload-widget” method=”post” action=”/upload” class=”dropzone”>
<div class=”fallback”>
<input name=”file” type=”file” />
</div>
</form>

Alternatively, you can provide a function to be executed when the browser doesn’t support the plugin using the fallback configuration parameter.

You can force the widget to use the fallback behavior by setting forceFallback to true, which might help during development.

Handling Errors

You can customize the way the widget handles errors by providing a custom function using the error configuration parameter. The first argument is the file, the error message the second, and if the error occurred server-side, the third parameter will be an instance of XMLHttpRequest.

As always, client-side validation is only half the battle. You must also perform validation on the server. When we implement a simple server-side component later, we’ll look at the expected format of the error response, which when properly configured will be displayed in the same way as client-side errors (illustrated below).

Displaying errors with DropzoneJS

Overriding Messages and Translation

There are a number of additional configuration properties which set the various messages displayed by the widget. You can use these to customize the displayed text, or to translate them into another language.

Most notably, dictDefaultMessage is used to set the text which appears in the middle of the dropzone, prior to someone selecting a file to upload.

You’ll find a complete list of the configurable string values — all of which begin with dict — in the documentation.

Events

There are a number of events you can listen to in order to customize or enhance the plugin.

There are two ways to listen to an event. The first is to create a listener within an initialization function:

Dropzone.options.uploadWidget = {
init: function() {
this.on(‘success’, function(file, resp){

});
},

};

This is the alternative approach, which is useful if you decide to create the Dropzone instance programatically:

const uploader = new Dropzone(‘#upload-widget’);
uploader.on(‘success’, function(file, resp){

});

Perhaps the most notable aspect is the success event, which is fired when a file has been successfully uploaded. The success callback takes two arguments: the first a file object, and the second an instance of XMLHttpRequest.

Other useful events include addedfile and removedfile, for when a file has been added or removed from the upload list; thumbnail, which fires once the thumbnail has been generated; and uploadprogress, which you might use to implement your own progress meter.

There are also a bunch of events which take an event object as a parameter and which you could use to customize the behavior of the widget itself — drop, dragstart, dragend, dragenter, dragover and dragleave.

You’ll find a complete list of events in the relevant section of the documentation.

The post How to Build a File Upload Form with Express and DropzoneJS appeared first on SitePoint.

Collective #593

Original Source: http://feedproxy.google.com/~r/tympanus/~3/CRrfuNvQ0tU/

Codrops Collective Item Image

The Markup

The Markup is a nonprofit newsroom that investigates how powerful institutions are using technology to change our society.

Check it out

Codrops Collective Item Image

Our Sponsor

Become a Data Scientist, job guaranteed.

The Data Science Career Track is a 6-month, self-paced online course that equips students with the skills and hands-on experience to get hired in data science.

Apply today

Codrops Collective Item Image

Tailwind UI

Fully responsive, beautiful UI components, designed and developed by Adam Wathan and Steve Schoger, the creators of Tailwind CSS.

Check it out

Codrops Collective Item Image

Open Peeps

A mix-and-match hand-drawn illustration library by Pablo Stanley.

Check it out

Codrops Collective Item Image

How does the Virtual DOM work?

An animated explainer by Sarah Drasner on how the Virtual DOM works.

Check it out

Codrops Collective Item Image

Inconsistent user-experiences with native lazy-loading images

Daniel Aleksandersen highlights the differences of implementation of native lazy loading in browsers.

Read it

Codrops Collective Item Image

Revealing Hero Effect in CSS and JavaScript

Learn how to create a section that reveals its content when the previous element scrolls away. A tutorial by Claudia Romano.

Check it out

Codrops Collective Item Image

Heroicons

A set of free MIT-licensed high-quality SVG icons for UI development.

Check it out

Codrops Collective Item Image

What Does A Foldable Web Actually Mean?

A very interesting read on foldable devices and the ideas around a “foldable web”. By Frederick O’Brien.

Check it out

Codrops Collective Item Image

Drag–and–Drop: How to Design for Ease of Use

Learn how clear signifiers and feedback at all stages of the interaction make drag–and–drop discoverable and easy to use.

Read it

Codrops Collective Item Image

Iconset

Iconset is a free SVG icon organizer and manager app for designers, developers and teams for both, macOS and Windows.

Check it out

Codrops Collective Item Image

Booklets.io

A place that collects hundreds of booklets on design, business, freelancing and more.

Check it out

Codrops Collective Item Image

Why write vanilla JS when you can just use [insert library or framework here]?

Some good points on why writing your own vanilla JS instead of using a framework can be a better option.

Read it

Codrops Collective Item Image

Mosquito JS

A fun creation by Tim Holman: an annoying mosquito noise, generated with JavaScript.

Check it out

Codrops Collective Item Image

Buttono

A flexible Sass mixin for creating BEM-style buttons. By Hasan Aydo?du.

Check it out

Codrops Collective Item Image

Your website probably has a memory leak

Memory leaks are common in Single Page Apps and this article will show you how to find and fix them.

Read it

Codrops Collective Item Image

The Tuner

Eric Karjaluoto has a very distinct view on the role of the designer. He writes: “It’s hard to produce suitable work when you think about design as a form of expression.”

Read it

Codrops Collective Item Image

CSS Specificity calculator

Quickly calculate any CSS selector specificity score along with explanations.

Check it out

Codrops Collective Item Image

5 Common Web App Accessibility Issues And How To Fix Them

Some useful tips on how to fix common accessibility issues in web apps.

Read it

Codrops Collective Item Image

Share images to your website using the Web Share Target API

Learn how to use the Web Share Target API on the example of a grayscale converter for images. By Michael Scharnagl.

Check it out

Codrops Collective Item Image

Pure CSS Responsive Browser Template

A really nice and responsive browser template by Adam Marsden.

Check it out

Codrops Collective Item Image

From Our Blog
Animating SVG Text on a Path

A demo that shows how to animate SVG text on a path on scroll using the Intersection Observer API and SVG filters.

Check it out

Codrops Collective Item Image

From Our Blog
Audio-based Image Distortion Effects with WebGL

Some experiments that show how to use audio-based distortion effects on images with p5.js and its sound library.

Check it out

Collective #593 was written by Pedro Botelho and published on Codrops.

5 Simple Responsive Blunders (And How To Avoid Them)

Original Source: https://www.webdesignerdepot.com/2020/02/5-simple-responsive-blunders-and-how-to-avoid-them/

Nearly 49% of all the web traffic worldwide originates from mobile devices (excluding tablets). If you don’t design mobile-friendly websites, you’ll likely lose out on this massive chunk of your target audience. Additionally if you wish to improve your SEO, you can’t afford to ignore smartphones; Google gives priority to mobiles with mobile-first indexing.

All of this calls for responsive web design through which your website’s elements can adjust according to the screen dimensions. While creating your responsive design, you might end up making some common mistakes. To help you avoid them, we’ve put together some possible responsive design pitfalls and their solutions below.

1. Using Device Sizes as Breakpoints

According to OpenSignal, there were over 24,000 different Android devices in 2015; this number has increased in the past five years. As there are so many varieties device, the screen dimensions differ vastly too. To ensure that your website offers a seamless browsing experience on all devices, you need to get your breakpoints right. 

If you concentrate on just device size breakpoints in your responsive design, your website may not appear correctly on newer devices. Don’t restrict yourself to the dimensions of current devices for breakpoints. Instead, go for truly responsive designs that can adjust well on any screen size. 

If you concentrate on just device size breakpoints in your responsive design, your website may not appear correctly on newer devices

A great idea is to take up the mobile-first approach where you build your website for the smallest screens and then slowly scale it to larger screen sizes. If wearable devices are important for your website, you should start your designing with those instead. 

As you’re scaling up, your website design may start feeling strained. In such a situation, you can add media queries to it for making necessary changes. This will help your design remain comfortable at each step. You need to continue this process until you reach the largest screen sizes. Ideally, this would be up to 2800 pixels as most users have resolutions lower than this. 

Using this method, your breakpoints will be introduced only when they’re needed and not according to the device size. This can help you offer a seamless browsing experience to your visitors across all devices. You can use tools like LambdaTest or BrowserStack to check if your website renders well on new devices.

2. Not Considering File Sizes

Visual elements can make your website more attractive to users. However, you must be careful when you’re adding them to your website. They are typically larger than text files and can slow down your page loading speed. As your page loading time increases, so do your bounce rates. In fact, according to Akamai, the bounce rates increased by 6% when pages took 1.5 seconds more to load during the 2017 holiday season. 

It is thus necessary to optimize your images and videos to reduce their sizes. You could use tools like TinyPNG or  Compress JPEG to achieve this. If you’re a WordPress user, you can install the Smush plugin to get this work done for you. 

Minifying your CSS, HTML, and JavaScript files can help as well. You should also consider browser caching, which can increase page loading speed for return visitors. Lastly, remove all unnecessary 3rd party tools and JavaScript dependencies. To check your current page loading speed and find possible solutions, you can use Google PageSpeed Insights. You could also use the Mobile Site Speed Tool from Google to see how quickly your website loads on mobiles.

3. Not Using Adaptive Image Management

While the file size of an image is important, so are its dimensions. You may not worry about using images of different dimensions in conventional website design. However, when it comes to responsive design, missing out on image management can be catastrophic for your user experience. The last thing you’d want your visitors seeing is huge images on a small screen.

To avoid this pitfall, you should use adaptive image management techniques. You could go for the following methods to achieve this:

Resolution-based selection: Provide the same image with different resolutions;
Device-pixel-ratio-based selection: Make the images appear crisp and reduce perceptible artifacts based on screen sizes;
Viewport-based selection: Vary images based on devices used and their orientation;
Art direction: Change or crop the image based on the display to improve its viewing experience.

4. Hiding Content

missing out on image management can be catastrophic for your user experience

One of the biggest mistakes that you can make while creating a responsive design of your website is that of hiding content. You might do so to fit your website on a smaller screen or to increase your page loading speed. However, you must avoid it at all costs. Remember, people aren’t coming to your website just to look for a small sample. They want the same browsing experience that they get on desktops.

Your goal should be to provide them with this omnichannel experience. This is necessary because many of them may be accessing your website from multiple devices during a day. That’s why you must ensure that you maintain consistency of content in responsive design. You can, of course, prioritize the content differently across devices through progressive enhancement.

5. Keeping Consistent Navigation

Giving a consistent browsing experience to your visitors across all devices is of the utmost importance. However, absolute consistency isn’t good either. One of the biggest mistakes you can commit while trying to do this is that of keeping consistent navigation across all screen sizes. 

When your screen size reduces, a consistent navigation bar may end up occupying half the screen and might spoil the browsing experience altogether. You should consider shrinking the navigation with the screen size and could change it to a hamburger menu.

 Along with your navigation, button sizes and visual layouts should not remain consistent either. However, typefaces, links, and color treatments should be consistent. 

Final Thoughts

If you wish to reach your entire target audience, you can’t avoid responsive design. However, you must be careful while implementing it and avoid all the possible errors. Give your visitors a consistent browsing experience across all devices and don’t hide any information from them. Optimize your file sizes to improve your page loading speed. Additionally, use adaptive image management techniques to reduce or increase the image dimensions according to the screen sizes. 

Don’t keep your navigation consistent as it may spoil the browsing experience. The same rule applies to buttons and visual layouts too. Lastly, go for truly responsive designs and don’t restrict yourself to design breakpoints based on current devices. The key is to go mobile-first when you’re designing your website.

 

Featured image via Unsplash.

Source

p img {display:inline-block; margin-right:10px;}
.alignleft {float:left;}
p.showcase {clear:both;}
body#browserfriendly p, body#podcast p, div#emailbody p{margin:0;}

8 Rules To Writing Blog Titles Your Readers Can’t Resist

Original Source: http://feedproxy.google.com/~r/Designrfix/~3/Ortmv0DPJJE/8-rules-to-writing-blog-titles-your-readers-cant-resist

Do you want to entice more prospects and boost your website traffic drastically? Well, there’s something that can help. Catchy blog titles to a well-written blog can make all the difference. It’s one thing to write high-quality, well-researched content, but it’s a completely different thing to earn clicks and views — which is where the […]

The post 8 Rules To Writing Blog Titles Your Readers Can’t Resist appeared first on designrfix.com.

The Amazing Polestar Precept Concept Car

Original Source: http://feedproxy.google.com/~r/abduzeedo/~3/o2ib596A4bg/amazing-polestar-precept-concept-car

The Amazing Polestar Precept Concept Car
The Amazing Polestar Precept Concept Car

abduzeedoFeb 27, 2020

Electric cars are the future, at least that’s what it looks like from all the amazing electric car companies and models being announced. I am a fan and the desire of having a Tesla keeps coming and going. Now Polestar announces this amazing concept car, the Polestar Precept and boy it’s a thing of beauty. Tiago Aiello shared some images on his Behance profile and I was blown away. Maybe I will hold on a bit longer to see how many more car makers announce, there’s the new Hummer coming as well. As I said, it looks like the future is going to be electric.

Precet: a rule intended to inform behaviour or thought. In other words, a way of declaring how you mean to proceed. Starting as you mean to go on. Stating your intentions up top. A manifesto. It’s also the name for something that takes all of our ambitions and combines them.

Concept Car


10+ Examples of Responsive Websites That Got It Right

Original Source: http://feedproxy.google.com/~r/tympanus/~3/P-nysxxXwVI/

When designing a new website, there’s a long list of specifications and requirements you have to fulfill. It’s just the nature of web design these days. And at the top of that list sits responsive web design.

Thankfully, high-quality WordPress themes like BeTheme make it insanely easy to check off all the technical requirements you’re expected to meet — including responsive design. But why does it matter so much?

Well, for starters, more than half of all website traffic takes place on mobile according to data from StatCounter.

While desktop has put up a good fight for a couple years, mobile has prevailed as the winner. It will continue to do so, too, considering how much more convenient it is to access the web from the palm of one’s hand.

Plus, Google has made it clear that it rewards responsive web designs and mobile-friendly websites with better search rankings, so there’s no hiding from it now.

Responsive web design is a must.

Just keep in mind that following the rules for good mobile design doesn’t mean you ignore desktop users. By prioritizing the mobile experience, you can design more beautiful and efficient websites for all users.

Let’s look at some examples that demonstrate how to do this well.

Responsive web designs that encourage leaner desktop experiences

Just because you have more space to work with when designing for desktop users doesn’t mean you need to make the most of every pixel.

In fact, as Internet-enabled devices have grown smaller in size, it’s encouraged many designers to create leaner and more efficient experiences on desktop.

Take the website for designer/developer Rob Grabowski, for example.

This is how his website appears on a mobile screen:

With minimized logo and navigation out of the way, this allows the focus to remain on his photo and welcome message. Desktop visitors encounter the same thing:

This consistency in design is great because it enables visitors to seamlessly transition from viewing a website on one device to another (which happens often).

Mobile web designs that improve the decision-making process

Consumers today struggle with an overabundance of choice. It might be easier to find that thing or service they’re looking for, but that doesn’t make choosing between similar options any easier.

One of the benefits of responsive design is that it forces web designers to create websites in a modular fashion so that, as the screen size shrinks, each section falls in line beneath the others.

In turn, this makes it easier for customers to review options one-by-one. BeRepair, one of the 500+ pre-built sites from BeTheme, demonstrates this point really well:

This is one of the services offered. Notice how the responsive layout allows the visitor to really focus on the details before them and not get distracted by too much information.

This works well for other types of websites. Take, for instance, the BeRestaurant pre-built desktop site:

It’s a great-looking restaurant website. The mobile counterpart looks just as great, but minimizes the distractions so the core elements can really shine:

Rather than try to fit the menu to the right of the food images, the responsive website maintains the integrity of the original design by tucking it into the hamburger menu icon in the top-right.

Again, this is all about giving your visitors the ability to pause and really focus on the key actions you’re asking them to take. A navigation bar in full view would only distract from that.

Responsive designs that cut out the excess

Think about the last time you went to an art gallery or museum and the kinds of paintings you encountered:

The landscape murals that have a central focus but beautiful details surrounding it.The portraits with a singular focus that’s chock-full of intimate details.

What’s cool about responsive websites is that they allow us to display the same web page in both formats.

Desktop screens thereby display landscape murals and mobile screens display portraits. But it’s important to know where the excess is in the desktop view so you can trim it back enough to make the mobile experience worthwhile.

For instance, this is the desktop site for BeITService:

This is a great looking hero banner on the home page. It’s well-balanced, the colors are carefully chosen, and the message is crystal-clear.

This is a good example of how smart designers have become when it comes to choosing responsive images for websites.

Here’s that same image and banner from above, but now displayed on mobile:

The image may not appear in full, but there’s nothing lost in this translation from desktop to mobile. What’s more, the message remains front and center.

Culturally Connected does something similar:

On desktop, it shows an elaborate background graphic that enhances the overall design. On mobile, however, it turns into this:

Even with the image now reduced and placed at the bottom, it’s still a striking design that allows the message to really shine through.

Another great example is BeTutor. This is how the desktop version looks like:

Here we have the main title and some more info using smaller text. In order not to cramp the mobile view, the design omits the extra content and focuses on the primary message:

The mobile view stays uncluttered without loosing any of the important subject matter that reveals the type of service offered.

Responsive websites that leverage their space

While a small screen requires reducing content in most of the cases, some responsive web designs leverage the space and use the different ratio to their advantage.

Take 1987 Masters for example:

While the desktop version focuses on their main tagline, the mobile version makes use of the vertical space and shows more content, giving the mobile visitor an option to learn more about the company right away:

So a mobile design don’t necessarily have to show less content in order to work well.

The mobile screen ratio allows for making use of the vertical space, like it’s shown in this example of BeCosmetics. Check out the desktop view:

The mobile view has more vertical space so the introductory content can be shown along with the button that invites the user to explore all products:

Once again, these examples demonstrate that less space doesn’t need to mean less useful content for the mobile website user.

Responsive websites that enhance readability

When laying out text on a desktop website, you have to be careful about how much you show to a reader at once. Put too many words on a line or not include enough spacing between letters, and your visitors might skip reading it altogether.

It’s a tricky balance to maintain and usually requires visual elements to balance out the text. Take, for example, the BeDanceSchool site:

Thanks to the funky designs and eye-catching graphics around the text, it’s easy for visitors to focus on the content and read it all the way through.

This won’t work on mobile though, which is why it’s important to understand the strengths of each screen size. Here you can see how that same text from above should be handled on mobile:

The design is paired back immensely so that all the visitor can see is the content. But that’s okay because the text is still beautifully styled which helps keep attention.

That said, text presented to mobile visitors doesn’t always have to be so heavily styled. If you select the right font size and type, you can create something that’s readable and engaging just as Base Coat does:

Just be mindful of the vertical length of text on mobile. While it might be easy to see where it ends on desktop, it can seem daunting on mobile if it appears to go on and on.

Mobile sites that put a spotlight on visual content

Responsive web designs aren’t just useful for websites with lots of text. Because of the way content responds to smaller screen sizes, visual storytelling elements look great on mobile, too.

Here’s what visitors see on the BeBand website on desktop:

Mobile screens don’t have the ability to play with balance as in the example above, but they do have the ability to shine a spotlight on the images you’ve chosen:

Websites that contain eye-catching images like this one would certainly benefit from responsive web design.

It’s not just static images that this works with either. The Scott Resort, for example, invites first-time visitors to watch a video:

Regardless of what kind of device the visitor is on, the video automatically conforms to the width of the screen.

This is the video on desktop:

And this is the video on mobile:

With a mobile responsive design, you really allow your content to adapt to the device and experience your users want.

Mobile responsive sites that collect more leads

Although more website traffic comes from mobile devices, it’s still quite difficult to get mobile users to convert as much as they do on desktop. That’ll come with time, but we’re not there just yet.

In the meantime, your responsive site needs to be prepared to capture leads whenever it can to improve those conversion rates.

Let’s take a look at how this works.

This is the pre-built site for BeClub:

This “Newsletter” section stands out beautifully on the homepage. And because it’s so convenient (e.g. it’s light on text and requires only one field be filled out), it’s likely to get a ton of subscribers.

This is how that same subscriber form appears on mobile:

Again, it’s really well done — and the smaller, dedicated space on mobile might be an even more effective way to catch the attention of potential subscribers.

So, if you can design your responsive site to collect visitors’ email addresses, you’ll empower them to reconnect with your website from their preferred device. As a result, you can increase the number of conversions it gets.

Responsive web designs for the win

When WordPress users go looking for a theme to design their website with, they look for qualities like:

Ease of useCost efficiencyFeaturesCustomizabilityOverall design quality

It’s easy to take responsive web designs for granted because we see them everywhere, but, the truth is, not every WordPress theme is built with the mobile user in mind.

BeTheme is different. Each of its 500+ pre-built sites comes with mobile responsiveness baked in.

So, when you use BeTheme, you can spend less time stressing over how to make your website look like the responsive designs above and more time getting your new website online and in front of consumers.

10+ Examples of Responsive Websites That Got It Right was written by Bogdan Sandu and published on Codrops.