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-1px

v0.2.1

Published

Automatically transform your border in retina without change anything.

Downloads

9

Readme

PostCSS Retina 1px

[PostCSS] plugin for transform 1px 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

before:

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

after:

.foo {
  color: white;
  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;
    border-radius: 12px;
  }
}

/* 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;
    border-radius: 18px;
  }
}

Install

npm install --save-dev postcss-retina-1px

Usage

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

Default Options:

{
  radiusUnit: 'px' /*border-radius unit(only deal with this unit)*/
}

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 use 1px
/* 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;
}
  • 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.