scope-css

WebJar for scope-css

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

scope-css
Последняя версия

Последняя версия

1.2.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

scope-css
WebJar for scope-css
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/dy/scope-css

Скачать scope-css

Как подключить последнюю версию

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

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
org.webjars.npm : escaper jar [2.5.3,3)
org.webjars.npm : slugify jar [1.3.1,2)
org.webjars.npm : strip-css-comments jar [3.0.0,4)

Модули Проекта

Данный проект не имеет модулей.

scope-css unstable Build Status

Prefix or nest each style selector in a css string. Useful to create namespaced css for components, themes, applications, modular css etc. Also it is tiny.

Usage

npm install scope-css

const scope = require('scope-css');

scope(`
.my-component {}
.my-component-element {}
`, '.parent');

/*
`
.parent .my-component {}
.parent .my-component-element {}
`
*/

API

css = scope(css, parent, options?)

Return css string with each rule prefixed with the parent selector. Note that parent selector itself will be ignored. Also each :host keyword will be replaced with parent value. Example:

scope(`
	.panel {}
	:host {}
	:host .my-element {}
	.panel .my-element {}
	.my-element {}
`, '.panel');

/*
`
	.panel {}
	.panel {}
	.panel .my-element {}
	.panel .my-element {}
	.panel .my-element {}
`
*/

Options can scope keyframes via { keyframes: bool|prefixStr } option, eg.

scope(`
	.panel {
		animation: infinite loading 4s;
	}
	@keyframes loading {
		from { top: 0; }
		to { top: 100px; }
	}
`, '.panel', { keyframes: true })

/*
`
.panel {
	animation: infinite panel-loading 4s;
}
@keyframes panel-loading {
	from { top: 0; }
	to { top: 100px; }
`)
*/

css = scope.replace(css, 'replacement $1$2')

Apply replace to css, where $1 is matched selectors and $2 is rules for the selectors. It does not do any self/host detection, so use it for more flexible replacements.

scope.replace(`
	.my-component, .my-other-component {
		padding: 0;
	}
`, '$1');

// `.my-component, .my-other-component`

See also

Credits

Based on this question.

Версии библиотеки

Версия
1.2.1