postcss-modules-scope

WebJar for postcss-modules-scope

License

License

ISC
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

postcss-modules-scope
Last Version

Last Version

3.0.0-rc.2
Release Date

Release Date

Type

Type

jar
Description

Description

postcss-modules-scope
WebJar for postcss-modules-scope
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/css-modules/postcss-modules-scope

Download postcss-modules-scope

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/postcss-modules-scope/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>postcss-modules-scope</artifactId>
    <version>3.0.0-rc.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/postcss-modules-scope/
implementation 'org.webjars.npm:postcss-modules-scope:3.0.0-rc.2'
// https://jarcasting.com/artifacts/org.webjars.npm/postcss-modules-scope/
implementation ("org.webjars.npm:postcss-modules-scope:3.0.0-rc.2")
'org.webjars.npm:postcss-modules-scope:jar:3.0.0-rc.2'
<dependency org="org.webjars.npm" name="postcss-modules-scope" rev="3.0.0-rc.2">
  <artifact name="postcss-modules-scope" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='postcss-modules-scope', version='3.0.0-rc.2')
)
libraryDependencies += "org.webjars.npm" % "postcss-modules-scope" % "3.0.0-rc.2"
[org.webjars.npm/postcss-modules-scope "3.0.0-rc.2"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : postcss-selector-parser jar [6.0.4,7)

Project Modules

There are no modules declared in this project.

CSS Modules: Scope Locals & Extend

Build Status

Transforms:

:local(.continueButton) {
  color: green;
}

into:

:export {
  continueButton: __buttons_continueButton_djd347adcxz9;
}
.__buttons_continueButton_djd347adcxz9 {
  color: green;
}

so it doesn't pollute CSS global scope and can be simply used in JS like so:

import styles from "./buttons.css";
elem.innerHTML = `<button class="${styles.continueButton}">Continue</button>`;

Composition

Since we're exporting class names, there's no reason to export only one. This can give us some really useful reuse of styles:

.globalButtonStyle {
  background: white;
  border: 1px solid;
  border-radius: 0.25rem;
}
.globalButtonStyle:hover {
  box-shadow: 0 0 4px -2px;
}
:local(.continueButton) {
  compose-with: globalButtonStyle;
  color: green;
}

becomes:

.globalButtonStyle {
  background: white;
  border: 1px solid;
  border-radius: 0.25rem;
}
.globalButtonStyle:hover {
  box-shadow: 0 0 4px -2px;
}
:local(.continueButton) {
  compose-with: globalButtonStyle;
  color: green;
}

Note: you can also use composes as a shorthand for compose-with

Local-by-default & reuse across files

You're looking for CSS Modules. It uses this plugin as well as a few others, and it's amazing.

Building

npm install
npm test
  • Status: Build Status
  • Lines: Coverage Status
  • Statements: codecov.io

Development

  • npm test:watch will watch src and test for changes and run the tests

License

ISC

With thanks

  • Mark Dalgleish
  • Tobias Koppers
  • Guy Bedford

Glen Maddern, 2015.

org.webjars.npm

Versions

Version
3.0.0-rc.2
2.1.0
2.0.1
1.1.0
1.0.0