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

styled-modern-normalize

v0.2.0

Published

modern-normalize.css for styled-components

Downloads

250

Readme

A common import method for modern-normalize.css is to use unnamed imports which works fine for projects with vanilla CSS or pre-processors workflows like Sass/Less and a bundler like webpack, but it doesn't make use of the advantages of CSS-in-JS libraries like styled-components, e.g. auto-prefixing and CSS optimizing.

styled-modern-normalize is a proxy package of modern-normalize.css for styled-components to provide the CSS as template literal with interpolation by using styled-component's css API function. This allows to import and use it via injectGlobal or any other styled component.

The package is based on and compatible with modern-normalize.css version 0.5.0. The provided styles are compatible with styled-components v2, v3 and v4.

Getting Started

Installation

Add the package as dependency to your project:

npm install --save styled-modern-normalize

Run npm install from within the project root to bootstrap the project and install the development- and runtime dependencies. Note that this will not install the required styled-components package which is defined as peer dependency and must be installed separately as described in the peer dependencies section below.

Peer Dependencies

This package uses styled-components API functions that return React components.

Therefore this package depends on the styled-components and react packages defined as peer dependencies.

Linux & macOS users can easily install all peer dependencies by using the npx which comes prebundled with npm 5 or higher:

npx install-peerdeps styled-modern-normalize

When using npm < 5 the npx tool is not prebundled, but users can either simply install it globally and then run the above command or install the install-peerdeps package locally/globally to let it handle the installation of all peer dependencies.

# Via local installation…
npm install install-peerdeps
./node_modules/.bin/install-peerdeps styled-modern-normalize

# …or globally.
npm install -g install-peerdeps
install-peerdeps styled-modern-normalize

Manually

All peer dependencies can also be installed manually (e.g. for users running a Microsoft Windows based system) by installing the correct version of each package:

npm info "styled-modern-normalize@latest" peerDependencies

Usage

styled-modern-normalize can be used by importing the default or named export modernNormalize.

// With default export…
import modernNormalize from "styled-modern-normalize";

// …or via named export.
import { modernNormalize } from "styled-modern-normalize";

To inject the styles when using styled-components v4 the createGlobalStyle API function can be used that generates a StyledComponent Reach component:

// Usage with the latest "styled-components" v4.
import { createGlobalStyle } from "styled-components";

const ModernNormalize = createGlobalStyle`
  ${modernNormalize}
  /* ... */
`;

// Use the generated component in your rendering logic to inject the styles.
/* ... */
<React.Fragment>
  <ModernNormalize />
</React.Fragment>;
/* ... */

When using styled-components v2 or v3 the styles can be injected using the injectGlobal API:

// Usage with "styled-components" v2 or v3.
import { injectGlobal } from "styled-components";

const cssBaseline = injectGlobal`
  ${modernNormalize}
  /* ... */
`;

The version of modern-normalize.css this package is currently based is exported as MODERN_NORMALIZE_VERSION:

import { MODERN_NORMALIZE_VERSION } from "styled-modern-normalize";

// Example:
console.log(MODERN_NORMALIZE_VERSION); // "0.5.0"

Development Workflow

Run npm install from within the project root to bootstrap the project and install the development- and runtime dependencies. To start the development with automatic recompilation on any source file change in the src/ directory run

npm run dev

The project is also configured for the opinionated code formatter Prettier which provides integration support for many editors to e.g. automatically format the source file on save.

Building

A distribution build can be created by running

npm run dist

Continuous integration builds are running at Circle CI and Travis CI.

Testing

Linting

JavaScript sources are linted with ESLint using the arcticicestudio-base configuration which can be run with

npm run lint:js

Markdown sources are linted with remark-lint using the arcticicestudio preset which can be run with

npm run lint:md

All linting tasks can be run with

npm run lint

Contributing

Read the contributing guide to learn about the development process and how to propose enhancement suggestions and report bugs, how to submit pull requests and the project's styleguides, branch organization and versioning model.

The guide also includes information about minimal, complete, and verifiable examples and other ways to contribute to the project like improving existing issues and giving feedback on issues and pull requests.