@fkui/font-default 6.23.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/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2021 Försäkringskassan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # @fkui/font-default
2
+
3
+ Innehåller den standardfont och konfiguration som Försäkringskassan använder ([Inter][inter]).
4
+
5
+ [inter]: https://rsms.me/inter/
6
+
7
+ ## Användning
8
+
9
+ För att använda standardfonten importera `@fkui/default-font` efter tema (exempelvis `@fkui/theme-default`):
10
+
11
+ ```diff
12
+ @use "@fkui/theme-default";
13
+ +@use "@fkui/font-default";
14
+ ```
15
+
16
+ För att applicera CSS på en egen selector sätter du `$global: false` och använder den som en mixin istället:
17
+
18
+ ```scss
19
+ @use "@fkui/font-default" with (
20
+ $global: false
21
+ );
22
+
23
+ .awesome-selector {
24
+ @include font-default.font;
25
+ }
26
+ ```
27
+
28
+ Om du inte använder Vite behöver du:
29
+
30
+ 1. Manuellt kopiera över filer till den katalog som innehåller dina kompilerade css-filer.
31
+ 2. Sätta `$asset-path` till en relativ sökväg från den byggda css-filen till katalogen som innehåller filerna.
32
+
33
+ ```diff
34
+ @use "@fkui/theme-default";
35
+ +@use "@fkui/font-default" with (
36
+ + $asset-path: "./fonts"
37
+ +);
38
+ ```
39
+
40
+ ## Metadata
41
+
42
+ Paketet levererar metadata i `@fkui/font-default/metadata.json` med följande format:
43
+
44
+ ```ts
45
+ export interface Asset {
46
+ filename: string;
47
+ }
48
+
49
+ export declare const assets: Asset[];
50
+ ```
51
+
52
+ Kan med fördel användas för att kopiera över samtliga fontfiler.
package/metadata.json ADDED
@@ -0,0 +1,7 @@
1
+ [
2
+ { "filename": "Inter-Bold.woff2" },
3
+ { "filename": "Inter-Light.woff2" },
4
+ { "filename": "Inter-Medium.woff2" },
5
+ { "filename": "Inter-Regular.woff2" },
6
+ { "filename": "Inter-SemiBold.woff2" }
7
+ ]
@@ -0,0 +1,8 @@
1
+ export interface Asset {
2
+ filename: string;
3
+ description: string;
4
+ }
5
+
6
+ declare const assets: Asset[];
7
+
8
+ export default assets;
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@fkui/font-default",
3
+ "version": "6.23.0",
4
+ "description": "Försäkringskassan standardfont",
5
+ "keywords": [
6
+ "fkui",
7
+ "designsystem",
8
+ "css"
9
+ ],
10
+ "homepage": "https://designsystem.forsakringskassan.se/",
11
+ "bugs": "https://github.com/Forsakringskassan/designsystem/issues",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/Forsakringskassan/designsystem.git",
15
+ "directory": "packages/font-default"
16
+ },
17
+ "license": "MIT",
18
+ "author": "Försäkringskassan",
19
+ "sideEffects": [
20
+ "./src/**/*.scss"
21
+ ],
22
+ "main": "./src/font.scss",
23
+ "files": [
24
+ "assets",
25
+ "metadata.json",
26
+ "metadata.json.d.ts",
27
+ "src"
28
+ ],
29
+ "scripts": {
30
+ "build": "node build.mjs",
31
+ "prepack": "release-prepack --bundle --retain-scripts",
32
+ "postpack": "release-postpack",
33
+ "prepublishOnly": "release-prepublish --bundle --retain-scripts",
34
+ "test": "node --test"
35
+ },
36
+ "engines": {
37
+ "node": ">= 20",
38
+ "npm": ">= 7"
39
+ },
40
+ "sass": "./src/font.scss",
41
+ "gitHead": "fa6f480d4762eb6f01607c7fc9d9de58e2d946c0"
42
+ }
package/src/font.scss ADDED
@@ -0,0 +1,84 @@
1
+ $global: true !default;
2
+ $asset-path: "" !default;
3
+
4
+ @mixin font-face {
5
+ @if $asset-path == "" {
6
+ @font-face {
7
+ font-family: Inter;
8
+ font-weight: 300;
9
+ src: url("../fonts/Inter-Light.woff2") format("woff2");
10
+ }
11
+
12
+ @font-face {
13
+ font-family: Inter;
14
+ font-weight: 400;
15
+ src: url("../fonts/Inter-Regular.woff2") format("woff2");
16
+ }
17
+
18
+ @font-face {
19
+ font-family: Inter;
20
+ font-weight: 500;
21
+ src: url("../fonts/Inter-Medium.woff2") format("woff2");
22
+ }
23
+
24
+ @font-face {
25
+ font-family: Inter;
26
+ font-weight: 600;
27
+ src: url("../fonts/Inter-SemiBold.woff2") format("woff2");
28
+ }
29
+
30
+ @font-face {
31
+ font-family: Inter;
32
+ font-weight: 700;
33
+ src: url("../fonts/Inter-Bold.woff2") format("woff2");
34
+ }
35
+ } @else {
36
+ @font-face {
37
+ font-family: Inter;
38
+ font-weight: 300;
39
+ src: url("#{$asset-path}/Inter-Light.woff2") format("woff2");
40
+ }
41
+
42
+ @font-face {
43
+ font-family: Inter;
44
+ font-weight: 400;
45
+ src: url("#{$asset-path}/Inter-Regular.woff2") format("woff2");
46
+ }
47
+
48
+ @font-face {
49
+ font-family: Inter;
50
+ font-weight: 500;
51
+ src: url("#{$asset-path}/Inter-Medium.woff2") format("woff2");
52
+ }
53
+
54
+ @font-face {
55
+ font-family: Inter;
56
+ font-weight: 600;
57
+ src: url("#{$asset-path}/Inter-SemiBold.woff2") format("woff2");
58
+ }
59
+
60
+ @font-face {
61
+ font-family: Inter;
62
+ font-weight: 700;
63
+ src: url("#{$asset-path}/Inter-Bold.woff2") format("woff2");
64
+ }
65
+ }
66
+ }
67
+
68
+ @mixin font-family {
69
+ --f-font-family: "Inter", arial, "Helvetica Neue", sans-serif;
70
+ --f-font-weight-normal: 400;
71
+ --f-font-weight-medium: 500;
72
+ --f-font-weight-bold: 700;
73
+ }
74
+
75
+ @mixin font {
76
+ @include font-face;
77
+ @include font-family;
78
+ }
79
+
80
+ @if $global {
81
+ :root {
82
+ @include font;
83
+ }
84
+ }
@@ -0,0 +1,34 @@
1
+ import { it, snapshot } from "node:test";
2
+ import { compileString } from "sass";
3
+
4
+ snapshot.setDefaultSnapshotSerializers([(value) => value]);
5
+
6
+ it("should compile global as default", (t) => {
7
+ const source = `@use "font";`;
8
+ const result = compileString(source, { url: import.meta.url });
9
+ t.assert.snapshot(result.css);
10
+ });
11
+
12
+ it("should not include any styling if global is disabled", (t) => {
13
+ const source = `@use "font" with ($global: false);`;
14
+ const result = compileString(source, { url: import.meta.url });
15
+ t.assert.snapshot(result.css);
16
+ });
17
+
18
+ it("should support compile with custom selector", (t) => {
19
+ const source = [
20
+ `@use "font" with ($global: false);`,
21
+ ``,
22
+ `.awesome-selector {`,
23
+ ` @include font.font`,
24
+ `}`,
25
+ ].join("\n");
26
+ const result = compileString(source, { url: import.meta.url });
27
+ t.assert.snapshot(result.css);
28
+ });
29
+
30
+ it("should support compile with custom asset path", (t) => {
31
+ const source = `@use "font" with ($asset-path: "awesome-fonts");`;
32
+ const result = compileString(source, { url: import.meta.url });
33
+ t.assert.snapshot(result.css);
34
+ });
@@ -0,0 +1,105 @@
1
+ exports[`should compile global as default 1`] = `
2
+ @font-face {
3
+ font-family: Inter;
4
+ font-weight: 300;
5
+ src: url("../fonts/Inter-Light.woff2") format("woff2");
6
+ }
7
+ @font-face {
8
+ font-family: Inter;
9
+ font-weight: 400;
10
+ src: url("../fonts/Inter-Regular.woff2") format("woff2");
11
+ }
12
+ @font-face {
13
+ font-family: Inter;
14
+ font-weight: 500;
15
+ src: url("../fonts/Inter-Medium.woff2") format("woff2");
16
+ }
17
+ @font-face {
18
+ font-family: Inter;
19
+ font-weight: 600;
20
+ src: url("../fonts/Inter-SemiBold.woff2") format("woff2");
21
+ }
22
+ @font-face {
23
+ font-family: Inter;
24
+ font-weight: 700;
25
+ src: url("../fonts/Inter-Bold.woff2") format("woff2");
26
+ }
27
+ :root {
28
+ --f-font-family: "Inter", arial, "Helvetica Neue", sans-serif;
29
+ --f-font-weight-normal: 400;
30
+ --f-font-weight-medium: 500;
31
+ --f-font-weight-bold: 700;
32
+ }
33
+ `;
34
+
35
+ exports[`should not include any styling if global is disabled 1`] = `
36
+
37
+ `;
38
+
39
+ exports[`should support compile with custom asset path 1`] = `
40
+ @font-face {
41
+ font-family: Inter;
42
+ font-weight: 300;
43
+ src: url("awesome-fonts/Inter-Light.woff2") format("woff2");
44
+ }
45
+ @font-face {
46
+ font-family: Inter;
47
+ font-weight: 400;
48
+ src: url("awesome-fonts/Inter-Regular.woff2") format("woff2");
49
+ }
50
+ @font-face {
51
+ font-family: Inter;
52
+ font-weight: 500;
53
+ src: url("awesome-fonts/Inter-Medium.woff2") format("woff2");
54
+ }
55
+ @font-face {
56
+ font-family: Inter;
57
+ font-weight: 600;
58
+ src: url("awesome-fonts/Inter-SemiBold.woff2") format("woff2");
59
+ }
60
+ @font-face {
61
+ font-family: Inter;
62
+ font-weight: 700;
63
+ src: url("awesome-fonts/Inter-Bold.woff2") format("woff2");
64
+ }
65
+ :root {
66
+ --f-font-family: "Inter", arial, "Helvetica Neue", sans-serif;
67
+ --f-font-weight-normal: 400;
68
+ --f-font-weight-medium: 500;
69
+ --f-font-weight-bold: 700;
70
+ }
71
+ `;
72
+
73
+ exports[`should support compile with custom selector 1`] = `
74
+ @font-face {
75
+ font-family: Inter;
76
+ font-weight: 300;
77
+ src: url("../fonts/Inter-Light.woff2") format("woff2");
78
+ }
79
+ @font-face {
80
+ font-family: Inter;
81
+ font-weight: 400;
82
+ src: url("../fonts/Inter-Regular.woff2") format("woff2");
83
+ }
84
+ @font-face {
85
+ font-family: Inter;
86
+ font-weight: 500;
87
+ src: url("../fonts/Inter-Medium.woff2") format("woff2");
88
+ }
89
+ @font-face {
90
+ font-family: Inter;
91
+ font-weight: 600;
92
+ src: url("../fonts/Inter-SemiBold.woff2") format("woff2");
93
+ }
94
+ @font-face {
95
+ font-family: Inter;
96
+ font-weight: 700;
97
+ src: url("../fonts/Inter-Bold.woff2") format("woff2");
98
+ }
99
+ .awesome-selector {
100
+ --f-font-family: "Inter", arial, "Helvetica Neue", sans-serif;
101
+ --f-font-weight-normal: 400;
102
+ --f-font-weight-medium: 500;
103
+ --f-font-weight-bold: 700;
104
+ }
105
+ `;