@department-of-veterans-affairs/css-library 0.12.0 → 0.12.1
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.
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@import "./formation-overrides/variables";
|
|
2
|
+
@import "./override-function";
|
|
3
|
+
@charset "UTF-8";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// Spacing Units
|
|
7
|
+
@function units($unit) {
|
|
8
|
+
//$name: nth($flex-names, $i);
|
|
9
|
+
|
|
10
|
+
@if not map-has-key($units, $unit) {
|
|
11
|
+
@error '`#{$unit}` is not a valid spacing unit token. '
|
|
12
|
+
+ 'Valid spacing unit tokens: '
|
|
13
|
+
+ '#{map-keys($units)}';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
$val: map-get($units, $unit) ;
|
|
17
|
+
$remVal: $val + rem;
|
|
18
|
+
@return scale-rem($remVal);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@function units-px($unit) {
|
|
22
|
+
//$name: nth($flex-names, $i);
|
|
23
|
+
|
|
24
|
+
@if not map-has-key($units, $unit) {
|
|
25
|
+
@error '`#{$unit}` is not a valid spacing unit token. '
|
|
26
|
+
+ 'Valid spacing unit tokens: '
|
|
27
|
+
+ '#{map-keys($units)}';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
$val: map-get($units, $unit) ;
|
|
31
|
+
@return ($val * 10) + px;
|
|
32
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// Removing sass math for now because it doesn't play nicely with vets-website
|
|
2
|
+
// @use 'sass:math';
|
|
3
|
+
|
|
4
|
+
$uswds-base: 16px; // USWDS base
|
|
5
|
+
$formation-base: 10px; // Formation base
|
|
6
|
+
|
|
7
|
+
$f2u-coeff: $formation-base / $uswds-base; // Formation to USDWS conversion coeffient
|
|
8
|
+
$u2f-coeff: $uswds-base / $formation-base; // USDWS to Formation conversion coeffient
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
$unit-types: (
|
|
12
|
+
"px": 1px,
|
|
13
|
+
"cm": 1cm,
|
|
14
|
+
"mm": 1mm,
|
|
15
|
+
"%": 1%,
|
|
16
|
+
"ch": 1ch,
|
|
17
|
+
"in": 1in,
|
|
18
|
+
"em": 1em,
|
|
19
|
+
"rem": 1rem,
|
|
20
|
+
"pt": 1pt,
|
|
21
|
+
"pc": 1pc,
|
|
22
|
+
"ex": 1ex,
|
|
23
|
+
"vw": 1vw,
|
|
24
|
+
"vh": 1vh,
|
|
25
|
+
"vmin": 1vmin,
|
|
26
|
+
"vmax": 1vmax,
|
|
27
|
+
"deg": 1deg,
|
|
28
|
+
"turn": 1turn,
|
|
29
|
+
"rad": 1rad,
|
|
30
|
+
"grad": 1grad,
|
|
31
|
+
"s": 1s,
|
|
32
|
+
"ms": 1ms,
|
|
33
|
+
"Hz": 1Hz,
|
|
34
|
+
"kHz": 1kHz,
|
|
35
|
+
"dppx": 1dppx,
|
|
36
|
+
"dpcm": 1dpcm,
|
|
37
|
+
"dpi": 1dpi,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@function split-value-unit($string) {
|
|
42
|
+
// takes a string, returns a map of
|
|
43
|
+
// number: number || null
|
|
44
|
+
// unit: a unit || or null
|
|
45
|
+
// joint: the number+ its unit
|
|
46
|
+
@if(type-of($string) == number){
|
|
47
|
+
@return(
|
|
48
|
+
number: if(map-has-key($unit-types, unit($string)),
|
|
49
|
+
$string / map-get($unit-types, unit($string))
|
|
50
|
+
,$string),
|
|
51
|
+
unit: unit($string),
|
|
52
|
+
joint: $string
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
@if(type-of($string) == color){
|
|
56
|
+
@return(
|
|
57
|
+
number: $string,
|
|
58
|
+
unit: color,
|
|
59
|
+
joint: $string
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
@if(type-of($string) != string){
|
|
63
|
+
@return(
|
|
64
|
+
number: null,
|
|
65
|
+
unit: null,
|
|
66
|
+
joint: $string
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
$length: str-length($string);
|
|
70
|
+
$numeric-value: "";
|
|
71
|
+
$unit: "";
|
|
72
|
+
$digits: ( "0":0, "1":1, "2":2, "3":3, "4":4, "5":5, "6":6, "7":7, "8":8, "9":9);
|
|
73
|
+
$sign : 1;
|
|
74
|
+
$decimal: 1;
|
|
75
|
+
$magnitude: 10;
|
|
76
|
+
$past: false;
|
|
77
|
+
@for $i from 1 through $length {
|
|
78
|
+
$char: str-slice($string, $i, $i);
|
|
79
|
+
@if($char == "-") {
|
|
80
|
+
$sign : -1;
|
|
81
|
+
}
|
|
82
|
+
@else if($char == "." and $past == false) {
|
|
83
|
+
$decimal : 10;
|
|
84
|
+
$magnitude : 1;
|
|
85
|
+
}
|
|
86
|
+
@else if( map-get($digits,$char) and $past == false){
|
|
87
|
+
@if ($numeric-value == ""){
|
|
88
|
+
$numeric-value : 0;
|
|
89
|
+
}
|
|
90
|
+
$numeric-value: ($numeric-value * $magnitude) + (map-get($digits,$char)/$decimal);
|
|
91
|
+
@if ($decimal > 1){
|
|
92
|
+
$decimal : $decimal * 10;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
@else {
|
|
96
|
+
$unit: $unit + $char;
|
|
97
|
+
$past: true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
$numeric-result: if( $numeric-value == "" , null, $sign * $numeric-value);
|
|
101
|
+
@return (
|
|
102
|
+
number: $numeric-result,
|
|
103
|
+
unit: unquote($unit),
|
|
104
|
+
joint: if($numeric-result != null, #{$numeric-result} + unquote($unit), $string)
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@function str-split($string, $separator: " ") {
|
|
109
|
+
$split-list: ();
|
|
110
|
+
$index: str-index($string, $separator);
|
|
111
|
+
|
|
112
|
+
@while $index != null {
|
|
113
|
+
$item: str-slice($string, 1, $index - 1);
|
|
114
|
+
$split-list: append($split-list, $item);
|
|
115
|
+
$string: str-slice($string, $index + 1);
|
|
116
|
+
$index: str-index($string, $separator);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@return append($split-list, $string);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@function scale-rem($value, $coeff: $f2u-coeff, $separator: space) {
|
|
123
|
+
// converts any singular SCSS value with rem units
|
|
124
|
+
// to its scaled equivalent
|
|
125
|
+
// otherwise returns the orginal value
|
|
126
|
+
@if (type-of($value) == number and unit($value) == rem) {
|
|
127
|
+
@return ($value * $coeff) ;
|
|
128
|
+
}
|
|
129
|
+
@if (type-of($value) == string ) {
|
|
130
|
+
$inner-sep: if($separator == comma , ",", " ");
|
|
131
|
+
$value-set: str-split($value, $inner-sep);
|
|
132
|
+
$scaled-values: ();
|
|
133
|
+
|
|
134
|
+
@each $val in $value-set{
|
|
135
|
+
$val-parts : split-value-unit($val);
|
|
136
|
+
@if (map-get($val-parts, unit) == rem) {
|
|
137
|
+
$rem-number: str-slice($val, 0, -4);
|
|
138
|
+
$scaled-rem: map-get($val-parts, number) * $coeff ;
|
|
139
|
+
$scaled-values: append($scaled-values, $scaled-rem + rem);
|
|
140
|
+
} @else {
|
|
141
|
+
$scaled-values: append($scaled-values,
|
|
142
|
+
map-get($val-parts, joint), $separator);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
@return $scaled-values;
|
|
146
|
+
}
|
|
147
|
+
@else {
|
|
148
|
+
@return $value;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@function scale-rule($rule, $separator: space, $coeff: $f2u-coeff ) {
|
|
153
|
+
// converts any plural SCSS value with rem units
|
|
154
|
+
$scaled: ();
|
|
155
|
+
@each $value in $rule {
|
|
156
|
+
$scaled-value: scale-rem($value, $coeff, $separator);
|
|
157
|
+
$scaled: append($scaled, $scaled-value, $separator);
|
|
158
|
+
}
|
|
159
|
+
@return $scaled;
|
|
160
|
+
}
|