Archive

Archive for November, 2020

Copyediting with Semantic HTML

November 17th, 2020 No comments
Side-by-side screenshots of how Pages, Google Docs and WordPress display tracked changes.

Tracking changes is a quintessential copyediting feature for comparing versions of content. While we’re used to tracking changes in a word processing document, we actually have HTML elements capable of that. There are a lot of elements that we can use for this process. The main ones we’ll look at are , and . But, as we’ll see, pairing them with other elements — including ,

Categories: Designing, Others Tags:

Jetpack Backup

November 17th, 2020 No comments

It’s no secret that CSS-Tricks is a WordPress site. And as such, we like to keep things WordPress-y, like enabling the block editor and creating some custom blocks. We also rely on Jetpack for a number of things, which if you haven’t tried, is definitely worth your time as it’s become a linchpin of this site for everything from search and security scans to social integrations and it’s own set of awesome blocks, like the slideshow block.

But one powerful feature we haven’t talked much about is Jetpack Backup and whoo-boy is it awesome. Sure, code is pretty easy to back up — we’ve got GitHub for that. But what about your assets, like images and other files? Or, gosh, what about the database? These things are super important and losing them would be, well, devastating!

Enter Jetpack Backup. It copies all that stuff, offering two plans, including one for daily backups and the other for real-time backups. Most sites can probably get away with daily backups, but it’s nice to know there’s a real-time option, especially if you’re running an active site, like forums where updates happen regularly, or some eCommerce shop where restoring lost orders would be crucial.

Another thing that makes Jetpack Backup great: it’s sold à la carte. So if backups are all you want from Jetpack, then you can get just that and that alone. But if you need additional features, like all the ones we use around here, then they’re easily accessible and enabled with a few clicks.

You even get a little activity log which is nice to not just see what’s happening on your site, but because it’s another way to pinpoint where things might have gone wrong.

Ugh, Geoff screwing everything up as per usual. ?

So, yeah, check it out! If you want a deep dive into how it all works, here’s Chris walking through our setup.


The post Jetpack Backup appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

A Complete Guide to CSS Gradients

November 16th, 2020 No comments

The background-size property in CSS is one of the most useful — and most complex — of the background properties. There are many variations and different syntaxes you can use for this property, all of which have different use cases. Here’s a basic example:

html {
  background: url(greatimage.jpg);
  background-size: 300px 100px; 
}

That’s an example of the two-value syntax for background size. There are four different syntaxes you can use with this property: the keyword syntax, the one-value syntax, the two-value syntax, and the multiple background syntax.

Keywords

In addition to the default value (auto), there are two keywords you can use with background-size: cover and contain

The difference

cover tells the browser to make sure the image always covers the entire container, even if it has to stretch the image or cut a little bit off one of the edges. contain, on the other hand, says to always show the whole image, even if that leaves a little space to the sides or bottom.

The default keyword — auto — tells the browser to automatically calculate the size based on the actual size of the image and the aspect ratio.

One Value

If you only provide one value (e.g. background-size: 400px) it counts for the width, and the height is set to auto. You can use any CSS size units you like, including pixels, percentages, ems, viewport units, etc.

Two Values

If you provide two values, the first sets the background image’s width and the second sets the height. Like the single value syntax, you can use whatever measurement units you like.

Multiple Images

You can also combine any of the above methods and apply them to multiple images, simply by adding commas between each syntax. Example:

html {
  background: url(greatimage.jpg), url(wonderfulimage.jpg);
  background-size: 300px 100px, cover;
  /* first image is 300x100, second image covers the whole area */
}

Keep background image stacking order in mind when using multiple images.

Demo

This demo shows examples of cover, contain, and multiple background images with a mix of pixel and keyword values.

See the Pen background-size by CSS-Tricks (@css-tricks) on CodePen.

Related

More Resources

Browser Support

Chrome Safari Firefox Opera IE Android iOS
3+ 4.1+ 3.6+ 10+ 9+ 2.3+ 4.0+

The post A Complete Guide to CSS Gradients appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

CSS Background Patterns

November 16th, 2020 No comments

Nice little tool from Jim Raptis: CSS Background Patterns. A bunch of easy-to-customize and copy-and-paste backgrounds that use hard stop CSS gradients to make classy patterns. Not quite as flexible as SVG backgrounds, but just as lightweight.

Like this:

CodePen Embed Fallback

Speaking of cool background gradient tricks, check out our Complete Guide to CSS Gradients that just went out today!

Direct Link to ArticlePermalink


The post CSS Background Patterns appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

Logical layout enhancements with flow-relative shorthands

November 16th, 2020 No comments

Admission: I’ve never worked on a website that was in anything other than English. I have worked on websites that were translated by other teams, but I didn’t have much to do with it. I do, however, spend a lot of time thinking in terms of block-level and inline-level elements. It’s been a couple of years now since logical properties have started to drop, and they have definitely started to invade my CSS muscle memory.

If you work in top-to-bottom, left-to-right languages like English as I do, you just map top and bottom to block in your head (you probably already do) and left and right as inline. So instead of height, you think block-size. Instead of border-right, you think border-inline-end. Instead of padding: 0 1em, you think padding-inline: 1em. And instead of margin-top, you think margin-block-start.

I mapped out that stuff in another post.

One trouble is that browser support is a little weird. Like margin-block-end is gonna work anywhere that any logical properties at all work, but if you’re like, “I’d like to set both the start and the end (like margin: 1rem 0), so I’ll use just margin-block,” well, that doesn’t work in some browsers (yet). That makes a certain sense, because there is no “direct mapping” of margin-block to any ex-logical CSS property. There are enough other little caveats like that, making me a just a smidge squeamish about using them everywhere.

Still, I’m probably going to start using them a lot more, as even if I still mostly only work on English sites, I like the idea that if I use them consistently, it makes translating any site I work on to languages that aren’t left-to-right and top-to-bottom a lot easier. Not to mention, I just like the mental model of thinking of things as block and inline.

I’m trying to link to Adam Argyle and Oriol Brufau’s article here, so let me just end with a quote from it, putting a point on why using non-logical properties only makes sense for one “language style”:

In English, letters and words flow left to right while paragraphs are stacked top to bottom. In traditional Chinese, letters and words are top to bottom while paragraphs are stacked right to left. In just these 2 cases, if we write CSS that puts “margin top” on a paragraph, we’re only appropriately spacing 1 language style. If the page is translated into traditional Chinese from English, the margin may well not make sense in the new vertical writing mode.

Direct Link to ArticlePermalink


The post Logical layout enhancements with flow-relative shorthands appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

Mixing Colors in Pure CSS

November 16th, 2020 No comments

Red + Blue = Purple… right?

Is there some way to express that in CSS? Well, not easily. There is a proposal draft for a color-mix function and some degree of interest from Chrome, but it doesn’t seem right around the corner. It would be nice to have native CSS color mixing, as it would give designers greater flexibility when working with colors. One example is to create tinted variants of a single base color to form a design palette.

But this is CSS-Tricks so let’s do some CSS tricks.

We have a calc() function in CSS for manipulating numbers. But we have very few ways to operate directly on colors, even though some color formats (e.g. hsl() and rgb()) are based on numeric values.

Mixing colors with animation

We can transition from one color to another in CSS. This works:

div {
  background: blue;
  transition: 0.2s;
}
div:hover {
  background: red; 
}

And here’s that with animations:

div {
  background: blue;
  transition: 0.2s;
}
div:hover {
  animation: change-color 0.2s forwards;
}


@keyframes change-color {
  to {
    background: red;
  }
}

This is an keyframe animation that runs infinitely, where you can see the color moving between red and blue. Open the console and click the page — you can see that even JavaScript can tell you the current color at any exact point in the animation.

CodePen Embed Fallback

So what if we pause the animation somewhere in the middle? Color mixing works! Here is a paused animation that is 0.5s through it’s 1s duration, so exactly halfway through:

CodePen Embed Fallback

We accomplished that by setting an animation-delay of -0.5s. And what color is halfway between red and blue? Purple. We can adjust that animation-delay to specify the percentage of two colors.

CodePen Embed Fallback

This works for Chromium core browsers and Firefox. In Safari, you must change animation-name to force browser to recalculate the animation progress.

Getting the mixed color to a CSS custom property

This is a neat trick so far, but it’s not very practical to apply an animation on any element you need to use a mixed color on, and then have to set all the properties you want to change within the @keyframes.

We can improve on this a smidge if we add in a couple more CSS features:

  1. Use a @property typed CSS custom property, so it can be created as a proper color, and thus animated as a color.
  2. Use a Sass @function to easily call keyframes at a particular point.
CodePen Embed Fallback

Now we still need to call animation, but the result is that a custom property is altered that we can use on any other property.


The post Mixing Colors in Pure CSS appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

Categories: Designing, Others Tags:

Exciting New Tools for Designers, November 2020

November 16th, 2020 No comments

In the spirit of fall feasts, this month’s collection of tools and resources is a smorgasbord of sorts. You’ll find everything from web tools to icon libraries to animation tools to great free fonts. Let’s dig in.

Here’s what new for designers this month.

The Good Line-Height

The Good Line-Height is the tool you won’t be able to live without after using it a few times. The tool calculates the ideal line-height for every text size in a typographic scale so that everything always fits the baseline grid. Set the font size, multiplier, and grid row height to get started.

Link-to-QR

Link-to-QR makes creating quick codes a breeze. Paste in your link and the tool creates an immediate QR code that you can download or share. Pick a color and transparency, plus size, and you are done.

Quarkly

Quarkly allows you to create websites and web apps both using a mouse and typing code – you get all the pros of responsive editing, but can also open the code editor at any time and manually edit anything and it all synchronizes. The tool is built for design control and is in beta.

UnSpam.email

Unspam.email is an online spam tester tool for emails. Improve deliverability with the free email tester. The service analyzes the main aspects of an email and returns a spam score and predicts results with a heat map of your email newsletter.

Filmstrip

Filmstrip allows you to create or import keyframe animations, make adjustments, and export them for web playback. It’s a quick and easy tool for modern web animation.

CSS Background Patterns

CSS Background Patterns is packed with groovy designs that you can adjust and turn into just the right background for your web project. Set the colors, opacity, and spacing; then pick a pattern; preview it right on the screen; and then snag the CSS. You can also submit your own patterns.

Neonpad

Neonpad is a simple – but fun – plain text editor in neon colors. Switch hues for a different writing experience. Use it small or expand to full browser size.

Link Hover Animation

Link Hover Animation is a nifty twist on a hover state. The animation draws a circle around the link!

Tint and Shade Generator

Tint and Shade Generator helps you make the most of any hex color. Start with a base color palette and use it to generate complementary colors for gradients, borders, backgrounds, or shadows.

Pure CSS Product Card

Pure CSS Product Card by Adam Kuhn is a lovely example of an e-commerce design that you can learn from. The card is appealing and functional.

Free Favicon Maker

Free Favicon Maker allows you to create a simple SVG or PNG favicon in a few clicks. You can set a style that includes a letter or emoji, font and size, color, and edge type and you are ready to snag the HTML or download the SVG or PNG file.

Ultimate Free iOS Icon Pack

The Ultimate Free iOS Icon Pack is a collection of 100 minimal icons in an Apple style. With black and white version of each icon and original PSD files, you can create sleek icons for your iPhone screen in minutes. And it’s completely free! No email address or registration required.

Phosphor Icon Family

Phosphor is a flexible icon family for all the things you need icons for including diagrams and presentations. There are plenty of arrows, chats, circles, clocks, office elements, lists, business logos, and more. Everything is in a line style, filled, or with duotone color. Everything is free but donations are accepted.

3,000 Hands

3,000 Hands is a kit of hands that includes plenty of gestures and style in six skin tones and with 10 angles of every gesture. They have a 3D-ish shape and are in an easy to use PNG format. This kit has everything you need from a set of hand icons.

Radix Icons

Radix Icons is a set of 15px by 15px icons for tiny spaces. They are in a line style and are available in a variety of formats including Figma, Sketch, iconJar, SVG, npm installation, or GitHub.

Deepnote

Deepnote is a new kind of data science notebook. It is Jupyter-compatible with real-time collaboration and running in the cloud and designed for data science teams.

ZzFXM Tiny JavaScript Music Generator

ZzFXM is a tiny JavaScript function that generates stereo music tracks from patterns of note and instrument data. Instrument samples are created using a modified version of the super-tiny ZzFX sound generator by Frank Force. It is designed for size-limited productions.

Image Tiles Scroll Animation

Image Tiles Scroll Animation is a different type of scrolling pattern using Locomotive Scroll. The grid creates a smooth animation in a fun and modern style.

Bubbles

Bubbles is a Chrome extension that allows you to collaborate by clicking anywhere on your screen and then dropping a comment to start a conversation with anyone. This is a nice option for work from home teams.

Tyrus

Tyrus is a toolkit from the design team at Airbnb to help illustrators make the most out of their design businesses. It is broken into sections to help you with design briefs, originality, deadlines, and feedback.

PatchGirl

PatchGirl is an automated QA tool for developers. You can combine SQL and HTTP queries to build any possible state of your database.

Apparel

Apparel is a beautiful premium typeface family with plenty of versatility in a modern serif style. It is a contemporary, classy, and fresh serif typeface with a laid-back. Its medium-large x-height makes it ideal for headlines and brand identity design.

Christmas Story

Christmas Story is a nice solution if you are already starting to think ahead to holiday projects or cards. The long swashes and tails are elaborate and fun.

Nafta

Nafta is a fun handwriting style font that has a marker-style stroke. It’s a modern take on the popular Sharpie font. It includes all uppercase letters.

Safira

Safira is a wide and modern sans with ligatures and a stylish feel. The rounded ball terminals are especially elegant.

Shine Brighter Sans

Shine Brighter Sans is a super-thin sans-serif with a light attitude. The limited character set combined with its light weight is best for display use.

Source

Categories: Designing, Others Tags:

Popular Design News of the Week: November 9, 2020 – November 15, 2020

November 15th, 2020 No comments

Every week users submit a lot of interesting stuff on our sister site Webdesigner News, highlighting great content from around the web that can be of interest to web designers.

The best way to keep track of all the great stories and news being posted is simply to check out the Webdesigner News site, however, in case you missed some here’s a quick and useful compilation of the most popular designer news that we curated from the past week.

Quarkly – Design Tool for Creating Websites and Web Apps

Create your Personal Branding Strategy in 4 Simple Steps

How to Design a Landing Page

No Code MBA – Learn to Build Real Apps and Websites Without Code

Your Computer Isn’t Yours

Swatches – Generate Colors for Every Purpose

Markabaly – Cross-platform Markdown Editor

12+ Bootstrap Hero Image Examples

The UX of Among Us: The Importance of Colorblind-friendly Design

No, your Clean Code won’t Save the Planet

My Side Project Rocks – Share and Discover Side Projects

How to Test Content like a Pro: A Step-by-step Guide

MacOS Big Sur is Here

Free Fonts for Prototyping and Wireframing

Gamification: The Broken Way of Carrot and Stick

Everything You were Wondering About Apple’s New M1 Chip

Please Unsubscribe – Fwd Emails to Unsubscribe from Marketing

The Fonts in Popular Things Identified Vol. 2

How to Become a Self-taught Graphic Designer

Using PowerPoint’s Animated GIF Function

Scribbble.io – A Blogging Platform for Developers

How to Work with WordPress Block Patterns

The Power of Happiness: Being Safe, Free, and Supported

How to Handle Scope Creep in Web Design

Building Products

Want more? No problem! Keep track of top design news from around the web with Webdesigner News.

Source

Categories: Designing, Others Tags:

Parsing Markdown into an Automated Table of Contents

November 13th, 2020 No comments

A table of contents is a list of links that allows you to quickly jump to specific sections of content on the same page. It benefits long-form content because it shows the user a handy overview of what content there is with a convenient way to get there.

This tutorial will show you how to parse long Markdown text to HTML and then generate a list of links from the headings. After that, we will make use of the Intersection Observer API to find out which section is currently active, add a scrolling animation when a link is clicked, and finally, learn how Vue’s allow us to create a nice animated list depending on which section is currently active.

Parsing Markdown

On the web, text content is often delivered in the form of Markdown. If you haven’t used it, there are lots of reasons why Markdown is an excellent choice for text content. We are going to use a markdown parser called marked, but any other parser is also good.

We will fetch our content from a Markdown file on GitHub. After we loaded our Markdown file, all we need to do is call the marked(, ) function to parse the Markdown to HTML.

async function fetchAndParseMarkdown() {
  const url = 'https://gist.githubusercontent.com/lisilinhart/e9dcf5298adff7c2c2a4da9ce2a3db3f/raw/2f1a0d47eba64756c22460b5d2919d45d8118d42/red_panda.md'
  const response = await fetch(url)
  const data = await response.text()
  const htmlFromMarkdown = marked(data, { sanitize: true });
  return htmlFromMarkdown
}

After we fetch and parse our data, we will pass the parsed HTML to our DOM by replacing the content with innerHTML.

async function init() {
  const $main = document.querySelector('#app');
  const htmlContent = await fetchAndParseMarkdown();
  $main.innerHTML = htmlContent
}


init();
CodePen Embed Fallback

Generating a list of heading links

Now that we’ve generated the HTML, we need to transform our headings into a clickable list of links. To find the headings, we will use the DOM function querySelectorAll('h1, h2'), which selects all

and

elements within our markdown container. Then we’ll run through the headings and extract the information we need: the text inside the tags, the depth (which is 1 or 2), and the element ID we can use to link to each respective heading.

function generateLinkMarkup($contentElement) {
  const headings = [...$contentElement.querySelectorAll('h1, h2')]
  const parsedHeadings = headings.map(heading => {
    return {
      title: heading.innerText,
      depth: heading.nodeName.replace(/D/g,''),
      id: heading.getAttribute('id')
    }
  })
  console.log(parsedHeadings)
}

This snippet results in an array of elements that looks like this:

[
  {title: "The Red Panda", depth: "1", id: "the-red-panda"},
  {title: "About", depth: "2", id: "about"},
  // ... 
]

After getting the information we need from the heading elements, we can use ES6 template literals to generate the HTML elements we need for the table of contents.

First, we loop through all the headings and create

  • elements. If we’re working with an

    with depth: 2, we will add an additional padding class, .pl-4, to indent them. That way, we can display

    elements as indented subheadings within the list of links.

    Finally, we join the array of

  • snippets and wrap it inside a
      element.

      function generateLinkMarkup($contentElement) {
        // ...
        const htmlMarkup = parsedHeadings.map(h => `
        <li class="${h.depth > 1 ? 'pl-4' : ''}">
          <a href="#${h.id}">${h.title}</a>
        </li>
        `)
        const finalMarkup = `<ul>${htmlMarkup.join('')}</ul>`
        return finalMarkup
      }

      That’s all we need to generate our link list. Now, we will add the generated HTML to the DOM.

      async function init() {
        const $main = document.querySelector('#content');
        const $aside = document.querySelector('#aside');
        const htmlContent = await fetchAndParseMarkdown();
        $main.innerHTML = htmlContent
        const linkHtml = generateLinkMarkup($main);
        $aside.innerHTML = linkHtml        
      }
      CodePen Embed Fallback

      Adding an Intersection Observer

      Next, we need to find out which part of the content we’re currently reading. Intersection Observers are the perfect choice for this. MDN defines Intersection Observer as follows:

      The Intersection Observer API provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document’s viewport.

      So, basically, they allow us to observe the intersection of an element with the viewport or one of its parent’s elements. To create one, we can call a new IntersectionObserver(), which creates a new observer instance. Whenever we create a new observer, we need to pass it a callback function that is called when the observer has observed an intersection of an element. Travis Almand has a thorough explanation of the Intersection Observer you can read, but what we need for now is a callback function as the first parameter and an options object as the second parameter.

      function createObserver() {
        const options = {
          rootMargin: "0px 0px -200px 0px",
          threshold: 1
        }
        const callback = () => { console.log("observed something") }
        return new IntersectionObserver(callback, options)
      }

      The observer is created, but nothing is being observed at the moment. We will need to observe the heading elements in our Markdown, so let’s loop over them and add them to the observer with the observe() function.

      const observer = createObserver()
      $headings.map(heading => observer.observe(heading))

      Since we want to update our list of links, we will pass it to the observer function as a $links parameter, because we don’t want to re-read the DOM on every update for performance reasons. In the handleObserver function, we find out whether a heading is intersecting with the viewport, then obtain its id and pass it to a function called updateLinks which handles updating the class of the links in our table of contents.

      function handleObserver(entries, observer, $links) {
        entries.forEach((entry)=> {
          const { target, isIntersecting, intersectionRatio } = entry
          if (isIntersecting && intersectionRatio >= 1) {
            const visibleId = `#${target.getAttribute('id')}`
            updateLinks(visibleId, $links)
          }
        })
      }

      Let’s write the function to update the list of links. We need to loop through all links, remove the .is-active class if it exists, and add it only to the element that’s actually active.

      function updateLinks(visibleId, $links) {
        $links.map(link => {
          let href = link.getAttribute('href')
          link.classList.remove('is-active')
          if(href === visibleId) link.classList.add('is-active')
        })
      }

      The end of our init() function creates an observer, observes all the headings, and updates the links list so the active link is highlights when the observer notices a change.

      async function init() {
        // Parsing Markdown
        const $aside = document.querySelector('#aside');
      

        // Generating a list of heading links
        const $headings = [...$main.querySelectorAll('h1, h2')];
      

        // Adding an Intersection Observer
        const $links = [...$aside.querySelectorAll('a')]
        const observer = createObserver($links)
        $headings.map(heading => observer.observe(heading))
      }
      CodePen Embed Fallback

      Scroll to section animation

      The next part is to create a scrolling animation so that, when a link in the table of contents is clicked, the user is scrolled to the heading position rather abruptly jumping there. This is often called smooth scrolling.

      Scrolling animations can be harmful if a user prefers reduced motion, so we should only animate this scrolling behavior if the user hasn’t specified otherwise. With window.matchMedia('(prefers-reduced-motion)'), we can read the user preference and adapt our animation accordingly. That means we need a click event listener on each link. Since we need to scroll to the headings, we will also pass our list of $headings and the motionQuery.

      const motionQuery = window.matchMedia('(prefers-reduced-motion)');
      

      $links.map(link => {
        link.addEventListener("click", 
          (evt) => handleLinkClick(evt, $headings, motionQuery)
        )
      })

      Let’s write our handleLinkClick function, which is called whenever a link is clicked. First, we need to prevent the default behavior of links, which would be to jump directly to the section. Then we’ll read the href attribute of the clicked link and find the heading with the corresponding id attribute. With a tabindex value of -1 and focus(), we can focus our heading to make the users aware of where they jumped to. Finally, we add the scrolling animation by calling scroll() on our window.

      Here is where our motionQuery comes in. If the user prefers reduced motion, the behavior will be instant; otherwise, it will be smooth. The top option adds a bit of scroll margin to the top of the headings to prevent them from sticking to the very top of the window.

      function handleLinkClick(evt, $headings, motionQuery) {
        evt.preventDefault()
        let id = evt.target.getAttribute("href").replace('#', '')
        let section = $headings.find(heading => heading.getAttribute('id') === id)
        section.setAttribute('tabindex', -1)
        section.focus()
      

        window.scroll({
          behavior: motionQuery.matches ? 'instant' : 'smooth',
          top: section.offsetTop - 20
        })
      }
      CodePen Embed Fallback

      Animate the list of links

      For the last part, we will make use of Vue’s , which is very useful for list transitions. Here is Sarah Drasner’s excellent intro to Vue transitions if you’ve never worked with them before. They are especially great because they provide us with animation lifecycle hooks with easy access to CSS animations.

      Vue automatically attaches CSS classes for us when an element is added (v-enter) or removed (v-leave) from a list, and also with classes for when the animation is active (v-enter-active and v-leave-active). This is perfect for our case because we can vary the animation when subheadings are added or removed from our list. To use them, we will need wrap our

    • elements in our table of contents with an element. The name attribute of the defines how the CSS animations will be called, the tag attribute should be our parent
        element.

        <transition-group name="list" tag="ul">
          <li v-for="(item, index) in activeHeadings" v-bind:key="item.id">
            <a :href="item.id">
              {{ item.text }}
            </a>
          </li>
        </transition-group>

        Now we need to add the actual CSS transitions. Whenever an element is entering or leaving it, should animate from not visible (opacity: 0) and moved a bit to the bottom (transform: translateY(10px)).

        .list-enter, .list-leave-to {
          opacity: 0;
          transform: translateY(10px);
        }

        Then we define what CSS property we want to animate. For performance reasons, we only want to animate the transform and the opacity properties. CSS allows us to chain the transitions with different timings: the transform should take 0.8 seconds and the fading only 0.4s.

        .list-leave-active, .list-move {
          transition: transform 0.8s, opacity 0.4s;
        }

        Then we want to add a bit of a delay when a new element is added, so the subheadings fade in after the parent heading moved up or down. We can make use of the v-enter-active hook to do that:

        .list-enter-active { 
          transition: transform 0.8s ease 0.4s, opacity 0.4s ease 0.4s;
        }

        Finally, we can add absolute positioning to the elements that are leaving to avoid sudden jumps when the other elements are animating:

        .list-leave-active {
          position: absolute;
        }

        Since the scrolling interaction is fading elements out and in, it’s advisable to debounce the scrolling interaction in case someone is scrolling very quickly. By debouncing the interaction we can avoid unfinished animations overlapping other animations. You can either write your own debouncing function or simply use the lodash debounce function. For our example the simplest way to avoid unfinished animation updates is to wrap the Intersection Observer callback function with a debounce function and pass the debounced function to the observer.

        const debouncedFunction = _.debounce(this.handleObserver)
        this.observer = new IntersectionObserver(debouncedFunction,options)

        Here’s the final demo

        CodePen Embed Fallback

        Again, a table of contents is a great addition to any long-form content. It helps make clear what content is covered and provides quick access to specific content. Using the Intersection Observer and Vue’s list animations on top of it can help to make a table of contents even more interactive and even allow it to serve as an indication of reading progress. But even if you only add a list of links, it will already be a great feature for the user reading your content.


        The post Parsing Markdown into an Automated Table of Contents appeared first on CSS-Tricks.

        You can support CSS-Tricks by being an MVP Supporter.

  • Categories: Designing, Others Tags:

    Print Is Not Dead: 5 Graphic Design Magazines You Should Subscribe Today

    November 13th, 2020 No comments
    Juxtapoz Magazine layout

    Living in a digital world makes everything easier including finding graphic design inspiration. Holding a magazine and leafing through the pages may seem a little obsolete in 2020 but gaining inspiration from digital sources can not top the feeling of the traditional, physical experiences.

    The amount of online resources you can find is exciting. Also, we can’t argue that online resources have become our main source of inspiration and information in every aspect imaginable. Yet still, there is something special about waiting for the monthly subscription of your favorite magazine to arrive or discovering new resources in your neighborhood bookstore.

    After all, the print is not dead. Graphic design magazines full of value-rich content and inspiration are still available. In light of this unbeatable pleasure, we curated our top graphic designer magazine picks around the world.

    Top 5 Graphic Design Magazines for Print Lovers

    1. Disegno

    Disegno graphic design magazine cover

    Disegno has a unique view on graphic design and can be counted among one of the world’s leading design magazines. Disegno’s colorful content not only covers graphic design but also touches on fields like architecture, technology, and fashion. The magazine features in-depth independent reporting, critical writing on design as well as academic analysis, reviews, and interviews.

    disegno graphic design magazine layout

    Even skimming through the pages of Disegno is a satisfying experience with its text over remarkable photography. This quarterly London-based magazine is internationally available both in printed and digital versions in April, June, September, and November.

    Disegno Magazine Issue 13 layout

    2. form

    form graphic design magazine cover

    Founded in 1957, form offers a holistic coverage of industrial, graphic, and hybrid designs. The magazine is divided into three sections: Filter, Focus, and Files. The Filter mainly consists of the latest design trends and information about design-related events and conventions.

    graphic design magazine layout

    The Focus covers a comprehensive analysis of that individual issue’s key topic. The Files is a combination of international discussions and reviews. Its high-quality content is mainly geared towards designers, students, and architects. form is published every two months both in printed and digital versions. The magazine is available in German and English languages and offers an annual subscription plan along with a subscription gift as well as individual back issues.

    form graphic design magazine layout

    3. Juxtapoz

    JUXTAPOZ graphic design magazine cover

    It’s not a big surprise that this one is one of the best selling magazines in the United States. Juxtapoz can be considered one of the most exciting design magazines on our list with its psychedelic, underground approach.

    Juxtapoz graphic design magazine layout

    It was first published in 1994 with the mission of celebrating urban alternative and underground contemporary art by combining diverse genres together such as street art and conceptual art. Juxtapoz covers diverse mediums including photography, painting, fashion, and installations. Each issue is published with two different cover images, newsstand and subscribers only versions.

    Juxtapoz graphic design magazine art

    4. Eye

    Published since 1990, Eye magazine is a goldmine for professional designers and design enthusiasts aspiring to read about the international design scene, design history, and new media with its informative critical writings.

    eye graphic design magazine cover

    Being full of inspiration and visual culture makes Eye one of the most popular design magazines available. Published quarterly, this London-based magazine not only inspires its readers but also educates them with its in-depth articles and analysis of design history.

    Eye graphic design magazine layout
    eye graphic design magazine layout

    Wrap

    Wrap graphic design magazine layout

    Wrap puts the spotlight on some of the best up-and-coming artists, illustrators, and designers, giving them a chance to showcase their work.

    Wrap graphic design magazine layout

    Published biannually, Wrap also features design tips, interviews with creatives, and a glimpse into the lives of artists.

    wrap graphic design magazine layout

    It comes with five double-sided wrapping paper for each issue and also offers products like greeting cards, and scented candles made in collaboration with favorite artists.

    Wrap graphic design magazine scented candle

    Whether they are in a printed or digital format, digging through graphic design magazines is a great way to gain inspiration and knowledge. If you prefer print over digital, we hope our graphic design magazine selection will help you pick at least one to subscribe to.

    If you are looking for more in-depth resources other than magazines to inspire you and learn more about graphic design be sure to check out our “Graphic Design Books Every Designer Should Read in 2020article full of great suggestions.

    What are your favorite graphic design magazines that you love to read the most? Share your thoughts in the comments section!

    Categories: Others Tags: