Skip to content

Commit be26349

Browse files
authored
Fix CSS variable name + test to prevent failures. (#8120)
1 parent e74ee03 commit be26349

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

pkg/web_css/lib/src/_site_header.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233
bottom: 0;
234234
left: 0;
235235
width: 80%;
236-
background: var(pub-site_header_popup-background-color);
236+
background: var(--pub-site_header_popup-background-color);
237237
transform: translateX(-100%);
238238
transition: transform 0.3s ease;
239239
z-index: $z-index-nav-mask + 1;

pkg/web_css/test/variables_test.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,28 @@ void main() {
7575

7676
expect(unused, isEmpty);
7777
});
78+
79+
test('all variables used have definition', () async {
80+
final files = await Directory('lib')
81+
.list(recursive: true)
82+
.where((f) => f is File && f.path.endsWith('.scss'))
83+
.cast<File>()
84+
.toList();
85+
final varRegExp = RegExp(r'var\((.*?)\)');
86+
for (final file in files) {
87+
final content = await file.readAsString();
88+
for (final m in varRegExp.allMatches(content)) {
89+
final name = m.group(1)!.trim();
90+
if (!variables.contains(name)) {
91+
// exempt Material Design variables
92+
if (name.startsWith('--mdc-')) {
93+
continue;
94+
}
95+
96+
fail('${file.path} references `$name` without definition.');
97+
}
98+
}
99+
}
100+
});
78101
});
79102
}

0 commit comments

Comments
 (0)