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

@classicmike/postcss-shadrem

v1.1.0

Published

This PostCSS plugin replaces standard rem units with a custom shadrem unit to enable REM-like support within Shadow DOM. It uses the font size of the shadow root as the base for shadrem measurements, ensuring consistent styling that adapts to the shadow D

Downloads

167

Readme

Shad-REM

Welcome to Shad-REM, a PostCSS plugin designed to help you work with REM units within shadow DOMs. Shad-REM allows you to use a new CSS custom unit property called --shadrem which lets you base your REM calculations on the shadow root instead of the document root node.

Table of Contents

Introduction

In web development, managing CSS units within shadow DOMs can be challenging. Traditional REM units are based on the root font size of the document, which may not always be what you want when working within shadow roots. Shad-REM solves this problem by introducing a new CSS unit, shad rem, that respects the font size of the shadow root.

Features

  • Shadow Root Aware: Converts REM units to shad rem units based on the shadow root's font size.
  • Seamless Integration: Works seamlessly with your existing PostCSS setup.
  • Flexible: Allows you to maintain consistent styling within shadow DOMs.

Installation

To install Shad-REM, you need to have PostCSS and the PostCSS CLI set up in your project. Then, you can install Shad-REM via npm:

npm install @classicmike/postcss-shadrem --save-dev

Usage

Once installed, you need to configure PostCSS to use the Shad-REM plugin. Create or update your PostCSS configuration file (e.g., postcss.config.js or postcss.config.cjs) to include Shad-REM.

// postcss.config.js
module.exports = {
  plugins: [
    require('@classicmike/postcss-shadrem'),
    // other plugins
  ]
};

Examples

Here are some examples of how Shad-REM transforms your CSS:

A note before using ShadREM.

Before using ShadREM, if you have a root font size other than what is set in your browser default, ensure your shadow root element has that font size set up. I.e:

  // What used to be in the document root element.
  :host {
    font-size: 16px;
  }

Before Shad-REM

/* Input CSS */
.my-element {
  font-size: 1.5rem;
  margin: 2rem;
}

After Shad-REM

Assuming a base font size of 16px in the shadow root, the output CSS will be:

/* Output CSS */
.my-element {
  font-size: calc(1.5 * var(--shadrem)); /* Equivalent to 24px if base font size is 16px */
  margin: calc(2 * var(--shadrem));      /* Equivalent to 32px if base font size is 16px */
}

Contributing

We welcome contributions to Shad-REM! If you find any issues or have ideas for improvements, please submit a pull request or open an issue on our GitHub repository.

License

Shad-REM is licensed under the MIT License. See the LICENSE file for more information.


Feel free to customize and extend Shad-REM to better fit your needs. Happy coding!