lumina-sass 2.5.0 → 2.6.2
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/package.json
CHANGED
package/src/mix/_typography.sass
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
@use 'sass:map'
|
|
3
3
|
@use 'sass:list'
|
|
4
|
+
@use 'sass:meta'
|
|
5
|
+
@use 'sass:string'
|
|
4
6
|
@use '../map/fonts' as fonts
|
|
5
7
|
|
|
6
8
|
@mixin text-wrap-safe($inline: 0)
|
|
@@ -14,8 +16,18 @@
|
|
|
14
16
|
@mixin font-style($font, $family: null, $line-height: null, $variant: null)
|
|
15
17
|
$detected-family: font-family-of($font)
|
|
16
18
|
|
|
17
|
-
@if $
|
|
19
|
+
@if is-known-font($font)
|
|
18
20
|
$family: $detected-family
|
|
21
|
+
|
|
22
|
+
@else if $family == null
|
|
23
|
+
$family: $detected-family
|
|
24
|
+
@if $font != null
|
|
25
|
+
@warn "Font '#{$font}' not found in configuration map. Defaulting to stack: '#{$font}', #{$family}."
|
|
26
|
+
|
|
27
|
+
@if meta.type-of($font) == 'list'
|
|
28
|
+
$last: list.nth($font, list.length($font))
|
|
29
|
+
@if $last == $family
|
|
30
|
+
$family: null
|
|
19
31
|
|
|
20
32
|
@if $line-height != null
|
|
21
33
|
line-height: $line-height
|
|
@@ -23,11 +35,13 @@
|
|
|
23
35
|
@if $variant != null
|
|
24
36
|
font-variant: $variant
|
|
25
37
|
|
|
26
|
-
|
|
38
|
+
@if $font != null
|
|
39
|
+
font-family: $font, $family
|
|
40
|
+
@else
|
|
41
|
+
font-family: $family
|
|
27
42
|
|
|
28
43
|
@mixin font( $font:null, $size: 1rem, $family: null, $style: null, $weight: null, $line-height: null, $variant: null)
|
|
29
|
-
@
|
|
30
|
-
@include font-style($font, $family, $line-height, $variant)
|
|
44
|
+
@include font-style($font, $family, $line-height, $variant)
|
|
31
45
|
|
|
32
46
|
@if $size != null
|
|
33
47
|
font-size: $size
|
|
@@ -41,17 +55,46 @@
|
|
|
41
55
|
@if $variant != null
|
|
42
56
|
font-variant: $variant
|
|
43
57
|
|
|
44
|
-
@
|
|
58
|
+
@function get-default-stack($category)
|
|
59
|
+
@if not map.has-key(fonts.$fonts, $category)
|
|
60
|
+
@return null
|
|
61
|
+
$map: map.get(fonts.$fonts, $category)
|
|
62
|
+
$keys: map.keys($map)
|
|
63
|
+
$generic: $category
|
|
64
|
+
@if $category == 'mono'
|
|
65
|
+
$generic: monospace
|
|
66
|
+
@return list.append($keys, $generic)
|
|
67
|
+
|
|
68
|
+
@mixin sans-serif($font: null, $size: 1rem, $weight: null, $style: null)
|
|
69
|
+
@if $font == null
|
|
70
|
+
$font: get-default-stack('sans-serif')
|
|
45
71
|
@include font($font, $size, sans-serif, $style, $weight)
|
|
46
72
|
|
|
47
|
-
@mixin serif($font, $size: 1rem, $weight: null, $style: null)
|
|
73
|
+
@mixin serif($font: null, $size: 1rem, $weight: null, $style: null)
|
|
74
|
+
@if $font == null
|
|
75
|
+
$font: get-default-stack('serif')
|
|
48
76
|
@include font($font, $size, serif, $style, $weight)
|
|
49
77
|
|
|
50
|
-
@mixin monospace($font, $size: 1rem, $weight: null, $style: null)
|
|
78
|
+
@mixin monospace($font: null, $size: 1rem, $weight: null, $style: null)
|
|
79
|
+
@if $font == null
|
|
80
|
+
$font: get-default-stack('mono')
|
|
51
81
|
@include font($font, $size, monospace, $style, $weight)
|
|
52
82
|
|
|
83
|
+
@function is-known-font($font)
|
|
84
|
+
@if $font == null
|
|
85
|
+
@return false
|
|
86
|
+
@if map.has-key(fonts.$fonts, $font)
|
|
87
|
+
@return true
|
|
88
|
+
@each $category, $map in fonts.$fonts
|
|
89
|
+
@if map.has-key($map, $font)
|
|
90
|
+
@return true
|
|
91
|
+
@return false
|
|
92
|
+
|
|
53
93
|
// Helper: return the generic family for a given font name using the fonts map.
|
|
54
94
|
@function font-family-of($font)
|
|
95
|
+
@if $font == null
|
|
96
|
+
@return ('Nunito', Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif)
|
|
97
|
+
|
|
55
98
|
@if map.has-key(fonts.$fonts, $font)
|
|
56
99
|
@if $font == 'mono'
|
|
57
100
|
@return monospace
|
|
@@ -60,7 +103,9 @@
|
|
|
60
103
|
@each $category, $map in fonts.$fonts
|
|
61
104
|
@if map.has-key($map, $font)
|
|
62
105
|
@return map.get($map, $font)
|
|
63
|
-
|
|
106
|
+
|
|
107
|
+
// Default fallback stack when font is not found
|
|
108
|
+
@return ('Nunito', Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif)
|
|
64
109
|
|
|
65
110
|
@mixin text-adjustments($alignment: null, $decoration: null)
|
|
66
111
|
@if $alignment != null
|
|
@@ -142,6 +142,69 @@
|
|
|
142
142
|
@include true.assert-equal(typo.font-family-of('mono'), monospace)
|
|
143
143
|
@include true.assert-equal(typo.font-family-of('serif'), serif)
|
|
144
144
|
|
|
145
|
+
@include true.test('Provides fallbacks for unknown fonts in font-family-of')
|
|
146
|
+
@include true.assert-equal(typo.font-family-of('MyCustomFont'), ('Nunito', Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif))
|
|
147
|
+
|
|
148
|
+
@include true.test('Generates fallback for unknown font')
|
|
149
|
+
@include true.assert
|
|
150
|
+
@include true.output
|
|
151
|
+
@include typo.font('MyCustomFont')
|
|
152
|
+
|
|
153
|
+
@include true.expect
|
|
154
|
+
font-family: "MyCustomFont", "Nunito", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif
|
|
155
|
+
|
|
156
|
+
@include true.test('Generates fallback for unknown font')
|
|
157
|
+
@include true.assert
|
|
158
|
+
@include true.output
|
|
159
|
+
@include typo.font()
|
|
160
|
+
|
|
161
|
+
@include true.expect
|
|
162
|
+
font-family: "Nunito", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif
|
|
163
|
+
|
|
164
|
+
@include true.test('Does not overwrite explicit fallback override for unknown font')
|
|
165
|
+
@include true.assert
|
|
166
|
+
@include true.output
|
|
167
|
+
@include typo.font('MyCustomFont', $family: serif)
|
|
168
|
+
|
|
169
|
+
@include true.expect
|
|
170
|
+
font-family: "MyCustomFont", serif
|
|
171
|
+
|
|
172
|
+
@include true.test('Generates default fallback stack when no font is provided')
|
|
173
|
+
@include true.assert
|
|
174
|
+
@include true.output
|
|
175
|
+
@include typo.font()
|
|
176
|
+
|
|
177
|
+
@include true.expect
|
|
178
|
+
font-family: "Nunito", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif
|
|
179
|
+
font-size: 1rem
|
|
180
|
+
|
|
181
|
+
@include true.test('Generates default system sans-serif stack when no font is provided')
|
|
182
|
+
@include true.assert
|
|
183
|
+
@include true.output
|
|
184
|
+
@include typo.sans-serif()
|
|
185
|
+
|
|
186
|
+
@include true.expect
|
|
187
|
+
font-family: "Roboto", "Helvetica", "Arial", "Work Sans", "Nunito", "Open Sans", "Lato", "Montserrat", "Source Sans Pro", "Inter", "Tahoma", "Verdana", "Gill Sans", "Futura", "Ubuntu", "Noto Sans", "Noto Sans KR", "Noto Sans JP", "Noto Sans SC", "Noto Sans Arabic", "Noto Sans Hebrew", sans-serif
|
|
188
|
+
font-size: 1rem
|
|
189
|
+
|
|
190
|
+
@include true.test('Generates default system serif stack when no font is provided')
|
|
191
|
+
@include true.assert
|
|
192
|
+
@include true.output
|
|
193
|
+
@include typo.serif()
|
|
194
|
+
|
|
195
|
+
@include true.expect
|
|
196
|
+
font-family: "Georgia", "Times New Roman", "Palatino", "Libre Baskerville", "Merriweather", "PT Serif", "Noto Serif", "Noto Serif KR", "Noto Serif JP", "Noto Serif SC", serif
|
|
197
|
+
font-size: 1rem
|
|
198
|
+
|
|
199
|
+
@include true.test('Generates default system monospace stack when no font is provided')
|
|
200
|
+
@include true.assert
|
|
201
|
+
@include true.output
|
|
202
|
+
@include typo.monospace()
|
|
203
|
+
|
|
204
|
+
@include true.expect
|
|
205
|
+
font-family: "Courier New", "Consolas", "Ubuntu Mono", "Source Code Pro", "Fira Code", "Inconsolata", "Menlo", "Monaco", "Noto Mono", monospace
|
|
206
|
+
font-size: 1rem
|
|
207
|
+
|
|
145
208
|
@include true.test-module('Styling (Native)')
|
|
146
209
|
@include true.test('Applies typography font styling to figcaption')
|
|
147
210
|
@include true.assert
|