postcss-modules-local-by-default

A CSS Modules transform to make local scope the default

MIT 39 个版本
安装
npm install postcss-modules-local-by-default
yarn add postcss-modules-local-by-default
pnpm add postcss-modules-local-by-default
bun add postcss-modules-local-by-default
README

Build Status codecov npm

CSS Modules: Local by Default

Transformation examples:

Selectors (mode local, by default)::

.foo { ... } /* => */ :local(.foo) { ... }

.foo .bar { ... } /* => */ :local(.foo) :local(.bar) { ... }

/* Shorthand global selector */

:global .foo .bar { ... } /* => */ .foo .bar { ... }

.foo :global .bar { ... } /* => */ :local(.foo) .bar { ... }

/* Targeted global selector */

:global(.foo) .bar { ... } /* => */ .foo :local(.bar) { ... }

.foo:global(.bar) { ... } /* => */ :local(.foo).bar { ... }

.foo :global(.bar) .baz { ... } /* => */ :local(.foo) .bar :local(.baz) { ... }

.foo:global(.bar) .baz { ... } /* => */ :local(.foo).bar :local(.baz) { ... }

Declarations (mode local, by default):

.foo {
  animation-name: fadeInOut, global(moveLeft300px), local(bounce);
}

.bar {
  animation: rotate 1s, global(spin) 3s, local(fly) 6s;
}

/* => */ 

:local(.foo) {
  animation-name: :local(fadeInOut), moveLeft300px, :local(bounce);
}

:local(.bar) {
  animation: :local(rotate) 1s, spin 3s, :local(fly) 6s;
}

Pure Mode

In pure mode, all selectors must contain at least one local class or id selector

To ignore this rule for a specific selector, add the a /* cssmodules-pure-ignore */ comment in front of the selector:

/* cssmodules-pure-ignore */
:global(#modal-backdrop) {
  ...;
}

or by adding a /* cssmodules-pure-no-check */ comment at the top of a file to disable this check for the whole file:

/* cssmodules-pure-no-check */

:global(#modal-backdrop) {
  ...;
}

:global(#my-id) {
  ...;
}

Building

$ npm install
$ npm test
  • Build: Build Status
  • Lines: coveralls
  • Statements: codecov

Development

$ yarn test:watch

License

MIT

With thanks


Mark Dalgleish, 2015.

版本列表
4.2.0 2024-12-11
4.1.0 2024-11-11
4.0.5 2024-04-03
4.0.4 2024-01-17
4.0.3 2023-05-23
4.0.2 2023-05-22
4.0.1 2023-05-19
4.0.0-rc.4 2020-10-11
4.0.0-rc.3 2020-10-08
4.0.0-rc.2 2020-10-08
4.0.0-rc.1 2020-09-22
4.0.0-rc.0 2020-09-16
4.0.0 2020-10-13
3.0.3 2020-07-25
3.0.2 2019-06-04
3.0.1 2019-05-16
3.0.0 2019-05-07
2.0.6 2019-03-05
2.0.5 2019-02-06
2.0.4 2019-01-04
2.0.3 2018-12-21
2.0.2 2018-12-05
2.0.1 2018-11-23
2.0.0 2018-11-23
1.2.0 2017-05-21
1.1.1 2016-07-20
1.1.0 2016-06-20
1.0.2 2016-06-20
1.0.1 2015-12-22
1.0.0 2015-10-19
1.0.0-beta2 2015-10-19
1.0.0-beta1 2015-09-22
0.0.12 2015-08-21
0.0.11 2015-07-19
0.0.10 2015-06-16
0.0.9 2015-06-12
0.0.8 2015-06-10
0.0.7 2015-05-30
0.0.6 2015-05-27