@transfermarkt/global-styles 1.4.0 → 1.5.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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Global Styles for Transfermarkt projects
1
+ # Global Styles and Stylelint global preset for Transfermarkt projects
2
2
 
3
3
  ## Install
4
4
 
@@ -6,7 +6,33 @@
6
6
  npm i @transfermarkt/global-styles
7
7
  ```
8
8
 
9
- ## Import
9
+ ## Use stylelint config
10
+
11
+ To use the stylelint config you have to edit your package.json
12
+
13
+ ### package.json
14
+ ```
15
+ "stylelint": {"extends": "./node_modules/@transfermarkt/global-styles/config/stylelint/index.js"}
16
+ ```
17
+
18
+ ### Configuration of `customSyntax`
19
+
20
+ It may be necessary to configure the `customSyntax` option in your `stylelint` configuration. This is necessary if you use a syntax that is not supported by stylelint out of the box. For example, if you use the `postcss-scss` syntax, you need to add the following to your `stylelint` configuration:
21
+
22
+ ```
23
+ "stylelint": {
24
+ "extends": "@transfermarkt/stylelint-config",
25
+ "customSyntax": "postcss-scss"
26
+ }
27
+ ```
28
+
29
+ For example a project with .scss files will need the custom syntax option with postcss-scss.
30
+
31
+ **The default value is postcss-html.**
32
+
33
+ ---
34
+
35
+ ## Import styles
10
36
 
11
37
  To import the styles you have 2 options:
12
38
 
@@ -74,9 +100,11 @@ Maybe you have to specify the path with the node_modules folder
74
100
  #### Usage
75
101
  ```
76
102
  .class {
77
- font-family: tm-font(primary);
103
+ font-family: tm-font('septenary');
78
104
  }
79
105
  ```
106
+
107
+ **Warning:** Using tm-font with 'primary' is deprecated!
80
108
 
81
109
  5. ### zf-to-rem
82
110
  #### Description
@@ -0,0 +1,50 @@
1
+ module.exports = {
2
+ extends: ['stylelint-config-standard-scss'],
3
+ plugins: ['stylelint-order', 'stylelint-selector-bem-pattern', './tm-font-primary-deprecation.mjs'],
4
+ customSyntax: 'postcss-html',
5
+ rules: {
6
+ "transfermarkt/tm-font-primary-deprecation": [
7
+ true,
8
+ {
9
+ "severity": "warning"
10
+ }
11
+ ],
12
+ "property-disallowed-list": "float",
13
+ "declaration-no-important": [
14
+ true,
15
+ {
16
+ "severity": "warning"
17
+ }
18
+ ],
19
+ "at-rule-disallowed-list": [
20
+ ["media","import"],
21
+ {severity: (atRule) => {
22
+ return atRule.includes("import") ? "error" : "warning"
23
+ }}],
24
+ 'unit-disallowed-list': ['px',
25
+ {
26
+ 'ignoreProperties': {
27
+ 'px': ['/^border/', 'top', 'bottom', 'left', 'right', "/^(min-|max-)?(width|height)$/"]
28
+ }
29
+ }
30
+ ],
31
+ 'max-nesting-depth': 2,
32
+ 'order/order': ['custom-properties', 'declarations'],
33
+ 'order/properties-alphabetical-order': true,
34
+ 'font-family-name-quotes': 'always-unless-keyword',
35
+ 'no-descending-specificity': null,
36
+ 'declaration-property-value-no-unknown': [
37
+ true,
38
+ {
39
+ ignoreProperties: {
40
+ 'font-family': ['/tm-font.+/'],
41
+ '/.+/': ['/rem-calc.+/', '/tm-color.+/', '/map.+/'],
42
+ },
43
+ },
44
+ ],
45
+ 'selector-pseudo-class-no-unknown': [
46
+ true,
47
+ { ignorePseudoClasses: 'global' },
48
+ ],
49
+ },
50
+ };
@@ -0,0 +1,45 @@
1
+ import stylelint from "stylelint";
2
+
3
+ const {
4
+ createPlugin,
5
+ utils: {report, ruleMessages, validateOptions}
6
+ } = stylelint;
7
+
8
+ const ruleName = "transfermarkt/tm-font-primary-deprecation";
9
+ const messages = ruleMessages(ruleName, {
10
+ deprecated: "Using 'primary' with 'tm-font' is deprecated. Please use 'septenary' instead."
11
+ });
12
+
13
+ /** @type {import('stylelint').Rule} */
14
+ const ruleFunction = (primaryOption, secondaryOptions, context) => {
15
+ return (root, result) => {
16
+ const validOptions = validateOptions(result, ruleName, {
17
+ actual: primaryOption,
18
+ possible: [true]
19
+ });
20
+
21
+ if (!validOptions) return;
22
+
23
+ root.walkDecls(decl => {
24
+ if (decl.prop === 'font-family') {
25
+ const css = decl.value;
26
+ const regex = /tm-font\((?:'|"|)primary(?:'|"|)\)/;
27
+
28
+ if (regex.test(css)) {
29
+ report({
30
+ result,
31
+ ruleName,
32
+ message: messages.deprecated,
33
+ node: decl,
34
+ word: "primary"
35
+ });
36
+ }
37
+ }
38
+ });
39
+ }
40
+ }
41
+
42
+ ruleFunction.ruleName = ruleName;
43
+ ruleFunction.messages = messages;
44
+
45
+ export default createPlugin(ruleName, ruleFunction);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@transfermarkt/global-styles",
3
- "version": "1.4.0",
4
- "description": "Shared styles of the Transfermarkt projects",
3
+ "version": "1.5.0",
4
+ "description": "Shared styles and Global configuration for stylelint rules of the Transfermarkt projects",
5
5
  "author": "Transfermarkt",
6
6
  "license": "MIT",
7
- "main": "scss/index.scss",
7
+ "main": "config/stylelint/index.js",
8
8
  "style": "scss/index.scss",
9
9
  "scripts": {
10
10
  "lint": "stylelint 'scss/**/*.{css,scss}'",
@@ -12,13 +12,22 @@
12
12
  "test": "echo \"Error: no test specified\" && exit 1"
13
13
  },
14
14
  "volta": {
15
- "node": "20.15.0"
15
+ "node": "20.17.0"
16
16
  },
17
17
  "publishConfig": {
18
18
  "registry": "https://registry.npmjs.org/",
19
19
  "tag": "latest",
20
20
  "access": "public"
21
21
  },
22
+ "dependencies": {
23
+ "postcss": "8.4.45",
24
+ "postcss-html": "1.7.0",
25
+ "postcss-scss": "4.0.9",
26
+ "stylelint": "16.9.0",
27
+ "stylelint-config-standard-scss": "13.1.0",
28
+ "stylelint-order": "6.0.4",
29
+ "stylelint-selector-bem-pattern": "4.0.1"
30
+ },
22
31
  "devDependencies": {
23
32
  "@transfermarkt/prettier-config": "^1.3.0",
24
33
  "@transfermarkt/semantic-release-config": "2.0.12",
@@ -30,7 +39,7 @@
30
39
  "sass-map-get-next-prev": "^1.0.0"
31
40
  },
32
41
  "stylelint": {
33
- "extends": "@transfermarkt/stylelint-config",
42
+ "extends": "./config/stylelint/index.js",
34
43
  "customSyntax": "postcss-scss"
35
44
  },
36
45
  "prettier": "@transfermarkt/prettier-config",
@@ -0,0 +1,35 @@
1
+ @font-face {
2
+ font-display: swap;
3
+ font-family: 'SourceSansPro-VF';
4
+ font-style: normal;
5
+ font-weight: normal;
6
+ src: url('https://tmsi.akamaized.net/fonts/SourceSans3VF-Roman.woff2') format('woff2');
7
+ }
8
+
9
+ @font-face {
10
+ ascent-override: 160%;
11
+ font-family: 'Oswald-fallback';
12
+ size-adjust: 81.94%;
13
+ src: local('Arial');
14
+ }
15
+
16
+ @font-face {
17
+ ascent-override: 111%;
18
+ font-family: 'Source Sans Pro-fallback';
19
+ size-adjust: 93.75%;
20
+ src: local('Arial');
21
+ }
22
+
23
+ @font-face {
24
+ ascent-override: 110%;
25
+ font-family: 'OSL-fallback';
26
+ size-adjust: 73.1%;
27
+ src: local('Arial');
28
+ }
29
+
30
+ @font-face {
31
+ ascent-override: 110%;
32
+ font-family: 'OSB-fallback';
33
+ size-adjust: 62.7%;
34
+ src: local('Arial');
35
+ }
@@ -1,7 +1,8 @@
1
1
  @use 'sass:math';
2
+ @use 'sass:meta';
2
3
 
3
4
  @function strip-unit($number) {
4
- @if type-of($number) == 'number' and not unitless($number) {
5
+ @if meta.type-of($number) == 'number' and not math.is-unitless($number) {
5
6
  @return math.div($number, $number * 0 + 1);
6
7
  }
7
8
 
@@ -1,4 +1,5 @@
1
1
  @use 'sass:map';
2
+ @use 'sass:color';
2
3
  @use '../variables';
3
4
 
4
5
  @function tm-color($color-name, $opacity: 1) {
@@ -2,6 +2,10 @@
2
2
  @use '../variables';
3
3
 
4
4
  @function tm-font($font-name) {
5
+ @if $font-name == 'primary' {
6
+ @warn "The 'primary' parameter in tm-font is deprecated and will be removed in future versions. Please use 'septenary' instead.";
7
+ }
8
+
5
9
  $font-value: map.get(variables.$tm-fonts, #{$font-name});
6
10
 
7
11
  @if not $font-value {
@@ -1,5 +1,6 @@
1
1
  @use 'sass:math';
2
2
  @use 'strip-unit' as *;
3
+ @use 'sass:meta';
3
4
 
4
5
  /// Converts a pixel value to matching rem value. *Any* value passed, regardless of unit, is assumed to be a pixel
5
6
  // value. By default, the base pixel value used to calculate the rem value is taken from the `$global-font-size`
@@ -11,18 +12,18 @@
11
12
  // passed through as is.
12
13
  @function zf-to-rem($value, $base: null) {
13
14
  // Check if the value is a number
14
- @if type-of($value) != 'number' {
15
- @warn inspect($value) + ' was passed to rem-calc(), which is not a number.';
15
+ @if meta.type-of($value) != 'number' {
16
+ @warn meta.inspect($value) + ' was passed to rem-calc(), which is not a number.';
16
17
  @return $value;
17
18
  }
18
19
 
19
20
  // Transform em into rem if someone hands over 'em's
20
- @if unit($value) == 'em' {
21
+ @if math.unit($value) == 'em' {
21
22
  $value: strip-unit($value) * 1rem;
22
23
  }
23
24
 
24
25
  // Calculate rem if units for $value is not rem or em
25
- @if unit($value) != 'rem' {
26
+ @if math.unit($value) != 'rem' {
26
27
  $value: math.div(strip-unit($value), strip-unit($base)) * 1rem;
27
28
  }
28
29
 
package/scss/index.scss CHANGED
@@ -1,3 +1,4 @@
1
+ @forward 'fonts';
1
2
  @forward 'functions';
2
3
  @forward 'mixins';
3
4
  @forward 'variables';