@unsass/selector 1.0.0-beta.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +26 -0
- package/package.json +15 -12
- package/src/_functions.scss +28 -26
- package/src/_mixins.scss +8 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.1.0](https://github.com/unsass/selector/compare/v1.0.0...v1.1.0) (2023-03-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* use `@unsass/string` instead of specific function ([af2dd21](https://github.com/unsass/selector/commit/af2dd217a4acea2e2734037749b010f2d73f02ff))
|
|
11
|
+
|
|
12
|
+
## 1.0.0 (2022-08-31)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* add `media` mixin ([2ce8316](https://github.com/unsass/selector/commit/2ce8316b44004a38f3c77c663b536510bf435983))
|
|
18
|
+
* add mixins and functions ([729e708](https://github.com/unsass/selector/commit/729e70868e8688656b89ec2ff9bf3b5fe598510b))
|
|
19
|
+
|
|
5
20
|
## [1.0.0-beta.2](https://github.com/unsass/selector/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2022-08-27)
|
|
6
21
|
|
|
7
22
|
|
package/README.md
CHANGED
|
@@ -13,3 +13,29 @@ Sass functions and mixins to manage CSS selectors.
|
|
|
13
13
|
```shell
|
|
14
14
|
npm install @unsass/selector
|
|
15
15
|
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```scss
|
|
20
|
+
@use "@unsass/selector";
|
|
21
|
+
|
|
22
|
+
@include selector.create("foo") {
|
|
23
|
+
color: darkcyan;
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Result
|
|
28
|
+
|
|
29
|
+
```css
|
|
30
|
+
.foo {
|
|
31
|
+
color: darkcyan;
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
### Sass mixins
|
|
38
|
+
|
|
39
|
+
| Mixin | Description |
|
|
40
|
+
|----------------------------------------------------------------------------------|------------------------------------------------------------|
|
|
41
|
+
| `create($selector, $scope, $separator, $suffix, $pseudo-class, $pseudo-element)` | Sets new CSS selector with class scope and pseudo options. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unsass/selector",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Sass functions and mixins to manage CSS selectors.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint:css": "stylelint --fix \"**/*.scss\"",
|
|
@@ -10,26 +10,29 @@
|
|
|
10
10
|
"release": "semantic-release"
|
|
11
11
|
},
|
|
12
12
|
"engines": {
|
|
13
|
-
"node": ">=
|
|
13
|
+
"node": ">=16.0.0",
|
|
14
14
|
"npm": ">=8.0.0"
|
|
15
15
|
},
|
|
16
16
|
"sass": "index.scss",
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@commitlint/cli": "^17.
|
|
19
|
-
"@commitlint/config-conventional": "^17.
|
|
20
|
-
"@semantic-release/changelog": "^6.0.
|
|
18
|
+
"@commitlint/cli": "^17.4.4",
|
|
19
|
+
"@commitlint/config-conventional": "^17.4.4",
|
|
20
|
+
"@semantic-release/changelog": "^6.0.2",
|
|
21
21
|
"@semantic-release/git": "^10.0.1",
|
|
22
22
|
"glob": "^7.2.0",
|
|
23
|
-
"husky": "^8.0.
|
|
24
|
-
"jest": "^
|
|
23
|
+
"husky": "^8.0.3",
|
|
24
|
+
"jest": "^29.5.0",
|
|
25
|
+
"jest-environment-node-single-context": "^29.0.0",
|
|
26
|
+
"jest-junit": "^15.0.0",
|
|
25
27
|
"npm-run-all": "^4.1.5",
|
|
26
|
-
"sass-true": "^
|
|
27
|
-
"semantic-release": "^
|
|
28
|
-
"stylelint": "^
|
|
29
|
-
"stylelint-config-unsass": "^1.0.
|
|
28
|
+
"sass-true": "^7.0.0",
|
|
29
|
+
"semantic-release": "^20.1.3",
|
|
30
|
+
"stylelint": "^15.3.0",
|
|
31
|
+
"stylelint-config-unsass": "^1.0.1"
|
|
30
32
|
},
|
|
31
33
|
"dependencies": {
|
|
32
|
-
"@unsass/
|
|
34
|
+
"@unsass/string": "^1.4.2",
|
|
35
|
+
"@unsass/types": "^1.0.2",
|
|
33
36
|
"sass": "^1.53.0"
|
|
34
37
|
},
|
|
35
38
|
"keywords": [
|
package/src/_functions.scss
CHANGED
|
@@ -16,44 +16,46 @@
|
|
|
16
16
|
// Public functions
|
|
17
17
|
// ------------------------------------------------------------------------- //
|
|
18
18
|
|
|
19
|
+
///
|
|
20
|
+
/// @example - scss
|
|
21
|
+
/// $selector: pseudo-class(".foo", "hover");
|
|
22
|
+
/// // ".foo:hover"
|
|
23
|
+
///
|
|
24
|
+
/// @access public
|
|
25
|
+
///
|
|
19
26
|
@function pseudo-class($selector, $pseudo-class) {
|
|
20
27
|
@return selector.append($selector, ":#{$pseudo-class}");
|
|
21
28
|
}
|
|
22
29
|
|
|
30
|
+
///
|
|
31
|
+
/// @example - scss
|
|
32
|
+
/// $selector: pseudo-class(".foo", "before");
|
|
33
|
+
/// // ".foo::before"
|
|
34
|
+
//
|
|
35
|
+
/// @access public
|
|
36
|
+
///
|
|
23
37
|
@function pseudo-element($selector, $pseudo-element) {
|
|
24
38
|
@return selector.append($selector, "::#{$pseudo-element}");
|
|
25
39
|
}
|
|
26
40
|
|
|
41
|
+
///
|
|
42
|
+
/// @example - scss
|
|
43
|
+
/// $selector: to-id("foo");
|
|
44
|
+
/// // "#foo"
|
|
45
|
+
//
|
|
46
|
+
/// @access public
|
|
47
|
+
///
|
|
27
48
|
@function to-id($selector) {
|
|
28
49
|
@return "##{$selector}";
|
|
29
50
|
}
|
|
30
51
|
|
|
52
|
+
///
|
|
53
|
+
/// @example - scss
|
|
54
|
+
/// $selector: to-class("foo");
|
|
55
|
+
/// // ".foo"
|
|
56
|
+
///
|
|
57
|
+
/// @access public
|
|
58
|
+
///
|
|
31
59
|
@function to-class($selector) {
|
|
32
60
|
@return ".#{$selector}";
|
|
33
61
|
}
|
|
34
|
-
|
|
35
|
-
///
|
|
36
|
-
/// Number.
|
|
37
|
-
///
|
|
38
|
-
@function number($value) {
|
|
39
|
-
@if meta.type-of($value) == "number" {
|
|
40
|
-
@return $value;
|
|
41
|
-
} @else if meta.type-of($value) != "string" {
|
|
42
|
-
@error "Invalid string type for `#{$value}` value. Use string type instead.";
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
$numbers: (
|
|
46
|
-
"0": 0,
|
|
47
|
-
"1": 1,
|
|
48
|
-
"2": 2,
|
|
49
|
-
"3": 3,
|
|
50
|
-
"4": 4,
|
|
51
|
-
"5": 5,
|
|
52
|
-
"6": 6,
|
|
53
|
-
"7": 7,
|
|
54
|
-
"8": 8,
|
|
55
|
-
"9": 9
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
@return map.get($numbers, $value);
|
|
59
|
-
}
|
package/src/_mixins.scss
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
@use "sass:meta";
|
|
6
6
|
@use "sass:selector";
|
|
7
|
-
@use "
|
|
8
|
-
@use "@unsass/
|
|
7
|
+
@use "@unsass/string";
|
|
8
|
+
@use "@unsass/types" as type;
|
|
9
9
|
@use "./functions";
|
|
10
10
|
|
|
11
11
|
///
|
|
12
12
|
/// @example - scss
|
|
13
|
-
/// @include create("foo") {
|
|
13
|
+
/// @include selector.create("foo") {
|
|
14
14
|
/// color: darkcyan;
|
|
15
15
|
/// }
|
|
16
16
|
///
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
/// }
|
|
21
21
|
///
|
|
22
22
|
/// @example - scss
|
|
23
|
-
/// @include create("foo", "md") {
|
|
23
|
+
/// @include selector.create("foo", "md") {
|
|
24
24
|
/// color: darkcyan;
|
|
25
25
|
/// }
|
|
26
26
|
///
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
/// }
|
|
31
31
|
///
|
|
32
32
|
/// @example - scss
|
|
33
|
-
/// @include create("foo", $pseudo-class: "hover") {
|
|
33
|
+
/// @include selector.create("foo", $pseudo-class: "hover") {
|
|
34
34
|
/// color: darkcyan;
|
|
35
35
|
/// }
|
|
36
36
|
///
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
/// }
|
|
41
41
|
///
|
|
42
42
|
/// @example - scss
|
|
43
|
-
/// @include create("foo", $pseudo-element: "before") {
|
|
43
|
+
/// @include selector.create("foo", $pseudo-element: "before") {
|
|
44
44
|
/// color: darkcyan;
|
|
45
45
|
/// }
|
|
46
46
|
///
|
|
@@ -58,8 +58,6 @@
|
|
|
58
58
|
///
|
|
59
59
|
/// @see {function} functions.pseudo-class
|
|
60
60
|
/// @see {function} functions.pseudo-element
|
|
61
|
-
/// @see {function} functions.number
|
|
62
|
-
/// @see {function} utilities.string-replace
|
|
63
61
|
///
|
|
64
62
|
/// @access public
|
|
65
63
|
///
|
|
@@ -91,8 +89,8 @@
|
|
|
91
89
|
///
|
|
92
90
|
|
|
93
91
|
@if $scope and not $suffix {
|
|
94
|
-
@if
|
|
95
|
-
$scope:
|
|
92
|
+
@if type.is-number(string.to-number(string.slice($scope, 1, $end-at: 1))) {
|
|
93
|
+
$scope: string.replace(\3 #{string.unquote($scope)}, " ");
|
|
96
94
|
}
|
|
97
95
|
|
|
98
96
|
$selector: selector.append("#{$scope}\\#{$separator}", $selector);
|