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

postcss-retina

v1.2.0

Published

Automatically transform your border in retina without change anything.

Downloads

1

Readme

PostCSS Retina

Build Status Coverage Status npm

PostCSS plugin for transform retina border by scale-box on mobile.

  • Automatically transform your border in retina without change anything.
  • support border-radius and color.
  • it's easy to remove it to use other way such as lib-flexible

How It Works

use a ::before element to create a scale border and replace the origin.

Example

a simple page to show the document structure

before:

.foo {
  color: white;
  border: 1px solid red;
}

after:

.foo {
  color: white;
  /* in v1.2.0+ `position` will add/update at origin  */
  position: relative; 
}

.foo::before {
  border: 1px solid red;
}

.foo::before {
  content: ' ';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  box-sizing: border-box;
  font-size: 100px;
}

/* dpr is 2 */

@media only screen and (-webkit-min-device-pixel-ratio: 2), 
only screen and (min-device-pixel-ratio: 2) {
  .foo::before {
    transform: scale(0.5);
    transform-origin: 0 0;
    width: 200%;
    height: 200%;
    font-size: 200px;
  }
}

/* dpr is 3 */

@media only screen and (-webkit-min-device-pixel-ratio: 3), 
only screen and (min-device-pixel-ratio: 3) {
  .foo::before {
    transform: scale(0.333333);
    transform-origin: 0 0;
    width: 300%;
    height: 300%;
    font-size: 300px;
  }
}

Install

npm install --save-dev postcss-retina

Usage

postcss([ require('postcss-retina') ])

Notice

  • make sure your box is not a pseudo-class.
/* WILL NOT to be transformed */
.wrong::before {
  border: 1em;
}
/* WILL NOT to be transformed */
.wrong::after {
  border: 1em;
}
  • make sure your border and border-radius use px unit.
/* WILL be transformed */
.right {
  border: 1px;
}
/* WILL NOT be transformed */
.wrong {
  border: 1em;
}
  • border-radius will not be transformed if there is not a border declare in same rule.
.foo {
  border: 1px solid red;
}
.bar {
  /* radius WILL NOT to be transformed */
  border-radius: 2px;
}
.foo {
  border: 1px solid red;
  /* radius WILL to be transformed */
  border-radius: 2px;
}

In v1.1.0+ you can comment /*retina*/ to mark it need to be transformed.

<div class="foo bar1"><div>
<div class="foo bar2"><div>
.foo {
  border: 1px solid red;
}
.bar1 {
  border-radius: 2px; /*retina*/
}
.bar2 {
  border-radius: 4px; /*retina*/
}
  • if your don't need transform any border, try to do like:
.foo {  
  border: 1px solid red; /*no*/ 
}

See PostCSS docs for examples for your environment.