npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-cli-plugin-scss-base

v0.2.2

Published

An opinionated Vue CLI plugin to include base SCSS structure and files such as variables, mixins and reset

Downloads

902

Readme

vue-cli-plugin-scss-base

SCSS Base is an opinionated plugin that includes globally used SCSS files to your project. This includes CSS reset, mixins, variables, base styling, animation and utility classes.

All the files are added under src/scss in your view project.

The structure is as follows:

  • scss
    • animation
    • base
    • mixins
    • utilities
    • variables

The main file settings.scss is automatically included in your project using the following config in your vue.config.js or the "vue" section of your package.json. This file includes all the variables and mixins.

vue: {
  css: {
    loaderOptions: {
      sass: {
        data: '@import "@/scss/settings.scss";'
      }
    }
  }
}

All the basic CSS files such as reset, animation etc are added to App.vue with the line @import '@/scss/base.scss';

Once you install this plugin you can immediately use your SCSS files such as variables and mixins within your project.

<template>
  <a class="link" :href="href">
    <slot></slot>
  </a>
</template>

<script>
export default {
  props: {
    href: String
  }
}
</script>

<style lang="scss">
  .link {
    background: $white;
    color: $black;
  }
</style>

Notes

Using REM

The plugin sets the <html> font-size to 62.5% and <body> font-size to 1.6rem. This enables you to use rem unit with easy math so 1rem will equal to 10px. You can still use pixels or em as you normally would. For more information on rem you can refer to this article

Media Queries

We recommend taking a mobile first approach in writing your media queries. That means to favour min-width over max-width. here is an article on benefits of this approach. There's a useful mixin called breakpoints already included in this plugin which makes writing media queries less verbos. Here's an example:

<style lang="scss">
  .promo {
    width: 100%;

    // $medium refers to px values of the min-width and
    // can be set in scss/varaibles/breakpoints
    @include breakpoint($medium) {
      width: 50%;
    }

    @include breakpoint($large) {
      width: 25%;
    }
  }
</style>

the above code is equivalent to this:

<style lang="scss">
  .promo {
    width: 100%;

    @media screen and (min-width: $medium) {
      width: 50%;
    }

    @media screen and (min-width: $large) {
      width: 50%;
    }
  }
</style>

Utility Classes

Sometime you need share styling within your components and you don't want to repeat the the code. This where utility classes come in. You can write your own utility classes scss/utilities folder. Once you have include in the scss/utilities/_utilities.scss file and you can use it throughout your project. You can either use @extend or add it directly to your template

<style lang="scss">
  .promo {
    background: url('@/assets/bg.jpg');

    .label {
      // Only visible to screen readers && search bots
      @extend .u-visually-hidden;
    }
  }
</style>

or

<template>
  <div class="promo">
    <span class="label u-visually-hidden">This text is only for screen readers</span>
  </div>
</template>

LICENSE

MIT