@transfermarkt/global-styles 1.0.4 → 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/README.md CHANGED
@@ -1 +1,117 @@
1
- # Global Styles for tm
1
+ # Global Styles for Transfermarkt projects
2
+
3
+ ## Install
4
+
5
+ ```
6
+ npm i @transfermarkt/global-styles
7
+ ```
8
+
9
+ ## Import
10
+
11
+ To import the styles you have 2 options:
12
+
13
+ 1. Import all SCSS files at once (not recommended)
14
+ ```
15
+ @use '@transfermarkt/global-styles
16
+ ```
17
+ 2. Include parts of global-styles
18
+ ```
19
+ @use '@transfermarkt/global-styles/scss/functions' as *;
20
+ ```
21
+
22
+ Maybe you have to specify the path with the node_modules folder
23
+
24
+ ```
25
+ @use 'path-to-node_modules-folder/@transfermarkt/global-styles/scss/functions' as *;
26
+ ```
27
+
28
+ ## Functions
29
+
30
+ 1. ### rem-calc
31
+ #### Description
32
+ Converts one or more pixel values into matching rem values.
33
+ One or more values to convert. Be sure to separate them with spaces and not commas.
34
+ Based on 16px.
35
+ #### Usage
36
+
37
+ ```
38
+ .class {
39
+ font-size: rem-calc(12);
40
+ }
41
+ ```
42
+
43
+ #### Functionality
44
+ Returns a list of converted values.
45
+
46
+ 2. ### strip-unit
47
+
48
+ #### Description
49
+ The `strip-unit` function in SCSS is designed to remove the unit from a numerical value, returning just the numeric
50
+ part. This is particularly useful when you need to perform calculations or operations that require unitless numbers.
51
+
52
+ #### Functionality
53
+ Checks if the provided value is a number with a unit. If so, it strips off the unit by dividing the number by 1,
54
+ effectively retaining only the numeric value. If the input is already a unitless number or not a number, it returns
55
+ the value as is.
56
+
57
+ #### Use Case
58
+ Ideal for responsive designs and calculations where units (like px, em, rem) need to be removed from measurements to
59
+ perform arithmetic or logical operations.
60
+
61
+ 3. ### tm-color
62
+ #### Description & Functionality
63
+ Returns the HEX value of a specific color.
64
+
65
+ #### Usage
66
+ ```
67
+ .class {
68
+ color: tm-color(gun-powder);
69
+ }
70
+ ```
71
+ 4. ### tm-font
72
+ #### Description
73
+ Returns a font set of the given name -> see font variables for available sets.
74
+ #### Usage
75
+ ```
76
+ .class {
77
+ font-family: tm-font(primary);
78
+ }
79
+ ```
80
+
81
+ 5. ### zf-to-rem
82
+ #### Description
83
+ Converts a pixel value to matching rem value. *Any* value passed, regardless of unit, is assumed to be a pixel
84
+ value. By default, the base pixel value used to calculate the rem value is taken from the `$global-font-size`
85
+ variable.
86
+
87
+ ## Mixins
88
+
89
+ `breakpoint`
90
+
91
+ ### Description
92
+
93
+ Generates a media query for the given breakpoint.
94
+
95
+ ### Usage
96
+
97
+ ```
98
+ .class {
99
+ @include breakpoint(desktop) {
100
+ width: 200px;
101
+ }
102
+ ```
103
+
104
+ ## Variables
105
+
106
+ 1. ### Colors
107
+ #### Description
108
+ Color palette of the colors currently used in the Transfermarkt projects.
109
+ [Here](scss/variables/_colors.scss) you can find the available colors.
110
+ #### Usage
111
+ Should only be used via the `tm-color` function.
112
+ 2. ### Fonts
113
+ #### Description
114
+ Collection of font sets currently in use in the Transfermarkt projects.
115
+ [Here](scss/variables/_fonts.scss) are the available font sets.
116
+ #### Usage
117
+ Should only be used via the `tm-font` function.
package/package.json CHANGED
@@ -1,10 +1,16 @@
1
1
  {
2
2
  "name": "@transfermarkt/global-styles",
3
- "version": "1.0.4",
4
- "description": "Global stylings, colors and fonts for the transfermarkt web and apps.",
3
+ "version": "1.1.0",
4
+ "description": "Shared styles of the Transfermarkt projects",
5
5
  "author": "Transfermarkt",
6
6
  "license": "MIT",
7
- "scripts": {},
7
+ "main": "scss/index.scss",
8
+ "style": "scss/index.scss",
9
+ "scripts": {
10
+ "lint": "stylelint 'scss/**/*.{css,scss}'",
11
+ "prepare": "husky install",
12
+ "test": "echo \"Error: no test specified\" && exit 1"
13
+ },
8
14
  "volta": {
9
15
  "node": "20.11.0"
10
16
  },
@@ -13,6 +19,26 @@
13
19
  "tag": "latest",
14
20
  "access": "public"
15
21
  },
22
+ "devDependencies": {
23
+ "@transfermarkt/prettier-config": "^1.3.0",
24
+ "@transfermarkt/semantic-release-config": "1.1.13",
25
+ "@transfermarkt/stylelint-config": "^2.0.0",
26
+ "husky": "^9.0.10",
27
+ "lint-staged": "^15.2.0"
28
+ },
29
+ "peerDependencies": {
30
+ "sass-map-get-next-prev": "^1.0.0"
31
+ },
32
+ "stylelint": {
33
+ "extends": "@transfermarkt/stylelint-config",
34
+ "customSyntax": "postcss-scss"
35
+ },
36
+ "prettier": "@transfermarkt/prettier-config",
37
+ "lint-staged": {
38
+ "*.scss": [
39
+ "prettier --parser scss --write"
40
+ ]
41
+ },
16
42
  "release": {
17
43
  "extends": "@transfermarkt/semantic-release-config",
18
44
  "plugins": [
@@ -23,8 +49,5 @@
23
49
  }
24
50
  ]
25
51
  ]
26
- },
27
- "devDependencies": {
28
- "@transfermarkt/semantic-release-config": "1.1.13"
29
52
  }
30
53
  }
@@ -0,0 +1,3 @@
1
+ @forward 'tm-color';
2
+ @forward 'tm-font';
3
+ @forward 'rem-calc';
@@ -0,0 +1,16 @@
1
+ @function map-get-next($map, $key) {
2
+ $next: null;
3
+ $found: false;
4
+
5
+ @each $k, $v in $map {
6
+ @if $k == $key {
7
+ $found: true;
8
+ } @else if $found {
9
+ $next: $v;
10
+
11
+ @return $next;
12
+ }
13
+ }
14
+
15
+ @return $next;
16
+ }
@@ -0,0 +1,47 @@
1
+ @use 'sass:list';
2
+ @use 'strip-unit' as *;
3
+ @use 'zf-to-rem' as *;
4
+
5
+ // Example usage: font-size: rem-calc(2px); padding: rem-calc(10px 5px 0)
6
+ /* stylelint-disable */
7
+ $global-font-size: 16px;
8
+
9
+ /// Converts one or more pixel values into matching rem values.
10
+ /// @param {Number|List} $values - One or more values to convert. Be sure to separate them with spaces and not commas.
11
+ // If you need to convert a comma-separated list, wrap the list in parentheses.
12
+ /// @param {Number} $base [null] - The base value to use when calculating the `rem`. If you're using Foundation out of
13
+ // the box, this is 16px. If this parameter is `null`, the function will reference the `$global-font-size` variable as
14
+ // the base.
15
+ /// @returns {List} A list of converted values.
16
+ @function rem-calc($values, $base: null) {
17
+ $rem-values: ();
18
+ $count: list.length($values);
19
+
20
+ // If no base is defined, defer to the global font size
21
+ @if not $base {
22
+ $base: $global-font-size;
23
+ }
24
+
25
+ // If the base font size is a %, then multiply it by 16px
26
+ // This is because 100% font size = 16px in most all browsers
27
+ @if unit($base) == '%' {
28
+ $base: ($base / 100%) * 16px;
29
+ }
30
+
31
+ // Using rem as base allows correct scaling
32
+ @if unit($base) == 'rem' {
33
+ $base: strip-unit($base) * 16px;
34
+ }
35
+
36
+ @if $count == 1 {
37
+ @return -zf-to-rem($values, $base);
38
+ }
39
+
40
+ @for $i from 1 through $count {
41
+ $rem-values: list.append($rem-values, -zf-to-rem(list.nth($values, $i), $base));
42
+ }
43
+
44
+ @return $rem-values;
45
+ }
46
+
47
+ /* stylelint-enable */
@@ -0,0 +1,9 @@
1
+ @use 'sass:math';
2
+
3
+ @function strip-unit($number) {
4
+ @if type-of($number) == 'number' and not unitless($number) {
5
+ @return math.div($number, $number * 0 + 1);
6
+ }
7
+
8
+ @return $number;
9
+ }
@@ -0,0 +1,12 @@
1
+ @use 'sass:map';
2
+ @use '../variables';
3
+
4
+ @function tm-color($color-name) {
5
+ $color-value: map.get(variables.$tm-colors, #{$color-name});
6
+
7
+ @if not $color-value {
8
+ @error 'Color #{$color-name} does not exist in color map.';
9
+ }
10
+
11
+ @return #{$color-value};
12
+ }
@@ -0,0 +1,12 @@
1
+ @use 'sass:map';
2
+ @use '../variables';
3
+
4
+ @function tm-font($font-name) {
5
+ $font-value: map.get(variables.$tm-fonts, #{$font-name});
6
+
7
+ @if not $font-value {
8
+ @error 'Font #{$font-name} does not exist in font map.';
9
+ }
10
+
11
+ @return #{$font-value};
12
+ }
@@ -0,0 +1,35 @@
1
+ @use 'sass:math';
2
+ @use 'strip-unit' as *;
3
+
4
+ /// Converts a pixel value to matching rem value. *Any* value passed, regardless of unit, is assumed to be a pixel
5
+ // value. By default, the base pixel value used to calculate the rem value is taken from the `$global-font-size`
6
+ // variable.
7
+ /// @access private
8
+ /// @param {Number} $value - Pixel value to convert.
9
+ /// @param {Number} $base [null] - Base for pixel conversion.
10
+ /// @returns {Number} A number in rems, calculated based on the given value and the base pixel value. rem values are
11
+ // passed through as is.
12
+ @function -zf-to-rem($value, $base: null) {
13
+ // 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.';
16
+ @return $value;
17
+ }
18
+
19
+ // Transform em into rem if someone hands over 'em's
20
+ @if unit($value) == 'em' {
21
+ $value: strip-unit($value) * 1rem;
22
+ }
23
+
24
+ // Calculate rem if units for $value is not rem or em
25
+ @if unit($value) != 'rem' {
26
+ $value: math.div(strip-unit($value), strip-unit($base)) * 1rem;
27
+ }
28
+
29
+ // Turn 0rem into 0
30
+ @if $value == '0rem' {
31
+ $value: 0;
32
+ }
33
+
34
+ @return $value;
35
+ }
@@ -0,0 +1,3 @@
1
+ @forward 'functions';
2
+ @forward 'mixins';
3
+ @forward 'variables';
@@ -0,0 +1,53 @@
1
+ // Source: https://rimdev.io/making-media-query-mixins-with-sass/
2
+
3
+ @use 'sass:map';
4
+ @use '../functions/map-get-next' as *;
5
+ @use '../variables/breakpoints' as *;
6
+
7
+ /* stylelint-disable */
8
+
9
+ @mixin breakpoint($breakpoint, $mode: min) {
10
+ @if map-has-key($breakpoints, $breakpoint) {
11
+ // Get the breakpoint value.
12
+ $breakpoint-value: map.get($breakpoints, $breakpoint);
13
+ $breakpoint-next-value: map-get-next($breakpoints, $breakpoint);
14
+
15
+ @if $mode == range {
16
+ @media (min-width: $breakpoint-value) and (max-width: map-get-next($breakpoints, $breakpoint) - 1) {
17
+ @content;
18
+ }
19
+ }
20
+
21
+ @if $mode == max {
22
+ @media (max-width: ($breakpoint-value - 1)) {
23
+ @content;
24
+ }
25
+ } @else if $mode == min {
26
+ @media (min-width: $breakpoint-value) {
27
+ @content;
28
+ }
29
+ } @else {
30
+ @media ($mode: $breakpoint-value) {
31
+ @content;
32
+ }
33
+ }
34
+
35
+ // If the breakpoint doesn't exist in the map.
36
+ } @else {
37
+ @if $mode == max {
38
+ @media (max-width: $breakpoint) {
39
+ @content;
40
+ }
41
+ } @else if $mode == min {
42
+ @media (min-width: $breakpoint) {
43
+ @content;
44
+ }
45
+ } @else {
46
+ @media ($mode: $breakpoint) {
47
+ @content;
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ /* stylelint-enable */
@@ -0,0 +1 @@
1
+ @forward 'breakpoint';
@@ -0,0 +1,14 @@
1
+ // BREAKPOINTS
2
+
3
+ /* stylelint-disable */
4
+ $breakpoints: (
5
+ base: 0,
6
+ phone: 400px,
7
+ tablet: 600px,
8
+ laptop: 769px,
9
+ desktop: 1024px,
10
+ desktoplg: 1280px,
11
+ desktopxlg: 1440px
12
+ );
13
+
14
+ /* stylelint-enable */
@@ -0,0 +1,124 @@
1
+ $tm-colors: (
2
+ 'white': #fff,
3
+ 'black': #000,
4
+ // blues
5
+ 'admiral': #00193f,
6
+ 'azure': #007aff,
7
+ // old value of tm-azure is now tm-medium-blue
8
+ 'blue': #06183d,
9
+ 'cadet-blue': #6da0bc,
10
+ 'cobalt': #00449e,
11
+ 'cyan': #5ca6ff,
12
+ 'dark-blue': #1a3151,
13
+ 'denim': #374457,
14
+ 'foggy-sky': #d2e3ed,
15
+ 'kashmir-blue': #596a81,
16
+ 'lighest-sky-blue': #bdd9ef,
17
+ 'light-blue': #1d75a3,
18
+ 'light-midnight': #16273e,
19
+ 'lightest-blue': #00aded,
20
+ 'medium-blue': #314f77,
21
+ 'midnight': #17283e,
22
+ 'navy': #001942,
23
+ 'pacific-blue': #0a96d6,
24
+ // $$carolinablue
25
+ 'prussian-blue': #003555,
26
+ 'royal': #09224d,
27
+ // #0d2051 see below
28
+ 'sapphire': #1274a5,
29
+ // old tm-sapphire is now tm-royal
30
+ 'seagull': #8ebad1,
31
+ 'sky-blue': #0ebce6,
32
+ 'sky-blue-transparent': #3fa6fc0d,
33
+ 'tiffany': #21babf,
34
+ 'turquoise': #02ced1,
35
+ // $tiffanyblue
36
+ // greens
37
+ 'caper': #b9cf8b,
38
+ 'dark-green': #008000,
39
+ 'dealdone': #0cd97a,
40
+ 'forest-green': #35652f,
41
+ // old name -> $wahretabelleDark
42
+ 'green': #749f18,
43
+ 'lightest-green': #e3ecd1,
44
+ 'limeade': #55a826,
45
+ 'olivine': #a5c169,
46
+ 'pastel-green': #00bc4b,
47
+ 'pear': #7ac142,
48
+ 'pickle': #739f17,
49
+ 'reef': #ceddae,
50
+ // greys
51
+ 'abalone': #d5d5d5,
52
+ 'alice-blue': #eef6ff,
53
+ 'border-grey': #ccc,
54
+ 'cool-grey': #ececec,
55
+ 'dark-dim': #666,
56
+ // new $stealgrey
57
+ 'dark-grey': #333,
58
+ // $darkgrey $anthracite
59
+ 'dark-whisper': #e6e6e6,
60
+ 'dim-grey': #6c6c6c,
61
+ 'gainsboro': #e5e6e7,
62
+ 'grey': #ddd,
63
+ 'grey-blue': #8b8f9b,
64
+ 'gun-powder': #585859,
65
+ // $$flaggenrahmen
66
+ 'hawkes-blue': #d4d8de,
67
+ 'light-grey': #e4e4e4,
68
+ 'light-purplish-grey': #bbb,
69
+ 'lightest-grey': #f2f2f2,
70
+ 'lightest-grey-blue': #d5e4ec,
71
+ 'lunar-rock': #c5c5c5,
72
+ 'middle-grey': #57585a,
73
+ 'middle-light-grey': #999,
74
+ 'silver': #bbb,
75
+ 'slate-grey': #728094,
76
+ 'smoke': #f3f3f3,
77
+ // the new tm-ultralight-grey
78
+ 'whisper': #e9e9e9,
79
+ // the new $rivergrey
80
+ 'white-smoke': #f0f0f0,
81
+ // reds
82
+ 'red': #8f1a29,
83
+ 'danger': #d10414,
84
+ // maybe another name?
85
+ 'dark-red': #bd2e2b,
86
+ 'chili': #9c002d,
87
+ 'vermilion': #d9020d,
88
+ 'crimson': #a91b39,
89
+ 'venetian-red': #b80718,
90
+ 'peachpuff': #f8cfcd,
91
+ 'light-red': #c03,
92
+ 'raspberry-ripple': #c8102e,
93
+ 'pure-red': #f00,
94
+ 'pale-chestnut': #e6a8ae,
95
+ // yellows
96
+ 'yellow': #efa93b,
97
+ 'sunflower': #e6b40a,
98
+ 'bird-flower': #d8c206,
99
+ 'lightest-yellow': #fff6db,
100
+ 'pure-yellow': #ff0,
101
+ 'kournikova': #ffd24a,
102
+ 'oasis': #ffeebd,
103
+ 'paris-daisy': #ffea47,
104
+ // variations
105
+ 'brown': #1c0e05,
106
+ 'fuchsia': #d047d1,
107
+ 'gold': #dcb24e,
108
+ 'goldenrod': #d4c06a,
109
+ 'indigo': #400080,
110
+ 'magenta': #e20074,
111
+ 'mustard': #a88040,
112
+ 'orange': #ff9f05,
113
+ 'petrol': #16738f,
114
+ 'purple': #8d5ba1,
115
+ // brands
116
+ 'brand-facebook': #37589a,
117
+ 'brand-snapchat': #fffd00,
118
+ 'brand-twitter': #0ea8e2,
119
+ 'brand-whatsapp': #20b300,
120
+ 'brand-youtube': #f2342c,
121
+ 'brand-rss': #f60,
122
+ 'brand-community': #1d75a3,
123
+ 'brand-wahretabelle': #429535
124
+ );
@@ -0,0 +1,9 @@
1
+ $tm-fonts: (
2
+ 'primary': "'Source Sans Pro', 'Source Sans Pro-fallback', sans-serif",
3
+ 'secondary': "'Oswald-VF', 'Oswald-fallback', sans-serif",
4
+ 'tertiary': "'OSB', 'OSB-fallback', sans-serif",
5
+ 'quaternary': "'OSL', 'OSL-fallback', sans-serif",
6
+ 'quinary': "'Arial', sans-serif",
7
+ 'senary': "'Times New Roman', sans-serif",
8
+ 'septenary': "'SourceSansPro-VF', sans-serif"
9
+ );
@@ -0,0 +1,3 @@
1
+ @forward 'colors';
2
+ @forward 'fonts';
3
+ @forward 'breakpoints';