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

pixel-perfect

v2.0.26

Published

A pixel perfect SCSS stylesheet. Spiced with themeable mixins, custom CSS variables and other cool stuff you can handpick from.

Downloads

12

Readme

Pixel Perfect

Version Downloads

pixel-perfect

A pixel perfect SCSS stylesheet (demo: https://pixel-perfect-39e99.firebaseapp.com/). Spiced with themeable mixins, custom CSS variables and other cool stuff you can handpick from.

Pixel perfect definition:

Each pixel is intentionally being used to the fullest for the sharpest, cleanest look.

How to use

👍 Step 1: Install Pixel Perfect

$ npm i pixel-perfect --save

🙌 Step 2: Import the library

@import "~pixel-perfect/pixel-perfect.scss";

👏 Step 3: Include the layout

You can include everything from the layout.

@include pp-layout();

Or you can handpick the styles you want. Let's say you only want the grid and the typography.

@include pp-grid();
@include pp-typography();

👌 Step 4: Create a theme for your app

Create a theme (or multiple themes) for your app.

@mixin light-theme() {
  @include css-vars(pp-palette("primary", $pp-yellow));
  @include css-vars(pp-palette("accent", $pp-orange));
  @include css-vars(pp-palette("warn", $pp-red));
  @include css-vars(pp-palette("error", $pp-orange));
  @include css-vars(pp-palette("success", $pp-black-dirty));
  @include css-vars((
    --navbar-color: white,
    --navbar-bg: map-get($pp-yellow, 500),
    --app-text: black,
    --app-bg: white
  ));
}

Include the mixins in your stylesheet. You could for example scope the themes in classes to quickly switch between themes on runtime.

.theme-light {
  @include light-theme();
}

.theme-dark {
  @include dark-theme();
}

You might be wondering what variables the css-vars(pp-palette(...)) spits out. The palette function spits out all the nessesary key-value pairs for the palette. Look below what variables we are talking about.

$pp-blue: (
  500: #4581F6,
  400: light-color(#4581F6),
  600: dark-color(#4581F6),
  contrast: (
    500: $white-87-opacity,
    400: $white-87-opacity,
    600: $white-87-opacity
  )
);

@include css-vars(pp-palette("primary", $pp-blue), $root: true);

:root {
  --primary-default: pp-map-get($colors, $default)
  --primary-lighter: pp-map-get($colors, $lighter),
  --primary-darker: pp-map-get($colors, $darker),
  --primary-default-contrast: pp-contrast($colors, $default),
  --primary-lighter-contrast: pp-contrast($colors, $lighter),
  --primary-darker-contrast: pp-contrast($colors, $darker)
  
  --primary-500: pp-map-get($colors, 500),
  --primary-500-contrast: pp-contrast($colors, 500)
  
  --primary-600: pp-map-get($colors, 600),
  --primary-600-contrast: pp-contrast($colors, 600)
  
  --primary-400: pp-map-get($colors, 400),
  --primary-400-contrast: pp-contrast($colors, 400)
}

🤘 Step 5: Decide whether you want custom CSS variables or SASS variables.

The variables can be used in your stylesheets by using the var(args...) function. If you want the primary default color you could grab it by using var(--primary-default). The theming in pixel-perfect uses custom CSS variables out of the box. Unfortunately, not all browsers support custom CSS variables yet (See current state). Therefore you can set the flag $css-vars-use-native: false; to tell pixel-perfect to use SASS variables instead. We recommend that you use custom CSS variables to get all the sweet benefits and either serve a seperate stylesheet for browsers without custom CSS variables or use polyfills.

If you want to deactivate you can do the following by extracting all of your theme related sass into one mixin that you can reuse with different variables:

// Deactive custom CSS variables :,(
$css-vars-use-native: false;

.theme-light {
  @include light-theme();
  @include demo-theme();
}

.theme-dark {
  @include dark-theme();
  @include demo-theme();
}

💪 Step 6: Customize the variables (optional)

Its possible to customize most of the variables used in pixel-perfect.

@import "~pixel-perfect/pixel-perfect.scss";

$font-size-h1: 20rem;
$font-size-h2: 17rem;

$space-s: 5rem;
$space-m: 10rem;
$space-l: 15rem;
...

👊 Step 7: Create your app-theme

Here is an example of what your theme could look like.

@mixin demo-theme() {
  body {
    color: var(--app-text);
    background: var(--app-bg);
  }
}

🔥 SCSS naming

Go from general to concrete in the naming. Examples could be "property-element" or "property-state".

$font-size-base-screen-l:   17px !default;

$font-size-l:   px-to-rem(18) !default;
$font-size-m:   px-to-rem(15) !default; 

$font-size-h1:  px-to-rem(50) !default;
$font-size-h2:  px-to-rem(32) !default;

$font-weight-h1:  $font-weight-bold !default;
$font-weight-h2:  $font-weight-thin !default;

$space-screen-s: px-to-rem(20) !default;

Its fine to use the module name (eg. "button") as prefix.

$button-border: none !default;
$button-border-radius: px-to-rem(6) !default;

$button-font-size: $font-size-h4 !default;
$button-line-height: 100% !default;
$button-transition: all 200ms ease !default;

🚀 Mixin overview

Heres an overview of some of the sweet mixins that can generate classes for you.

@include pp-normalize();
@include pp-color-classes();
@include pp-elevation-classes();

@mixin pp-layout() {
	@include pp-normalize();
	@include pp-global();
	@include pp-typography();
	@include pp-grid();
}

@mixin pp-layout-helpers() {
  @include pp-layout-helpers-padding();
  @include pp-layout-helpers-margin();
  @include pp-layout-helpers-display();
  @include pp-layout-helpers-alignment();
}

🌈 License

MIT