Skip to content

Commit fd8eb3d

Browse files
authored
chore: Detect and report missing css styles (#3591)
1 parent 4a00c08 commit fd8eb3d

File tree

15 files changed

+232
-8
lines changed

15 files changed

+232
-8
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ src/index.ts
99
src/test-utils/dom/index.ts
1010
src/test-utils/selectors
1111
src/icon/generated
12-
src/internal/generated/custom-css-properties/index.*
12+
src/internal/generated/custom-css-properties
1313
vendor/generated-*.txt
1414
# IDEs
1515
.vscode
1616
# System
17-
.DS_Store
17+
.DS_Store

build-tools/tasks/clean.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = task('clean', () => {
1414
`${workspace.targetPath}/**`,
1515
`${workspace.staticSitePath}/**`,
1616
`${workspace.generatedTestUtils}/**`,
17+
`${workspace.generatedPath}/custom-css-properties/**`,
1718
`node_modules/.cache`,
1819
],
1920
{ glob: true }

build-tools/tasks/generate-custom-css-properties.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
const customCssPropertiesList = require('../../src/internal/generated/custom-css-properties/list');
43
const path = require('path');
5-
const { writeFile } = require('../utils/files');
64
const { getHashDigest } = require('loader-utils');
5+
const customCssPropertiesList = require('../utils/custom-css-properties');
6+
const { writeFile } = require('../utils/files');
7+
const workspace = require('../utils/workspace');
78

8-
const outputBasePath = path.join(__dirname, '../../src/internal/generated/custom-css-properties');
9+
const outputBasePath = path.join(workspace.generatedPath, 'custom-css-properties');
910
const hash = getHashDigest(Buffer.from(JSON.stringify(customCssPropertiesList)), 'md5', 'base36', 6);
1011

1112
const getHashedProperty = property => {
@@ -32,6 +33,9 @@ function writeSassFile() {
3233
writeFile(
3334
filepath,
3435
`
36+
// Build environment
37+
$awsui-commit-hash: ${workspace.gitCommitVersion};
38+
// Manually managed CSS-variables
3539
${customCssPropertiesList.map(property => `$${property}: ${getHashedProperty(property)};`).join('\n')}
3640
`
3741
);

build-tools/tasks/generate-environment.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function writeEnvironmentFile(theme) {
1010
const values = {
1111
PACKAGE_SOURCE: workspace.packageSource,
1212
PACKAGE_VERSION: workspace.packageVersion,
13+
GIT_SHA: workspace.gitCommitVersion,
1314
THEME: theme.name,
1415
ALWAYS_VISUAL_REFRESH: !!theme.alwaysVisualRefresh,
1516
};

build-tools/utils/workspace.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
isProd: process.env.NODE_ENV === 'production',
1212
packageSource,
1313
packageVersion,
14+
gitCommitVersion,
1415
sourcePath: 'src',
1516
generatedPath: 'src/internal/generated',
1617
generatedTestUtils: 'src/test-utils/selectors',

src/__integ__/__snapshots__/themes.test.ts.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
exports[`CSS Custom Properties match previous snapshot for mode "compact" 1`] = `
44
{
5+
"awsui-version-info": "true",
56
"border-active-width": "2px",
67
"border-code-editor-status-divider-width": "0px",
78
"border-container-sticky-width": "1px",
@@ -679,6 +680,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "compact" 1`] =
679680

680681
exports[`CSS Custom Properties match previous snapshot for mode "dark" 1`] = `
681682
{
683+
"awsui-version-info": "true",
682684
"border-active-width": "2px",
683685
"border-code-editor-status-divider-width": "0px",
684686
"border-container-sticky-width": "1px",
@@ -1356,6 +1358,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "dark" 1`] = `
13561358

13571359
exports[`CSS Custom Properties match previous snapshot for mode "light" 1`] = `
13581360
{
1361+
"awsui-version-info": "true",
13591362
"border-active-width": "2px",
13601363
"border-code-editor-status-divider-width": "0px",
13611364
"border-container-sticky-width": "1px",
@@ -2033,6 +2036,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "light" 1`] = `
20332036

20342037
exports[`CSS Custom Properties match previous snapshot for mode "reduced-motion" 1`] = `
20352038
{
2039+
"awsui-version-info": "true",
20362040
"border-active-width": "2px",
20372041
"border-code-editor-status-divider-width": "0px",
20382042
"border-container-sticky-width": "1px",
@@ -2710,6 +2714,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "reduced-motion"
27102714

27112715
exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh" 1`] = `
27122716
{
2717+
"awsui-version-info": "true",
27132718
"border-active-width": "4px",
27142719
"border-code-editor-status-divider-width": "1px",
27152720
"border-container-sticky-width": "0px",
@@ -3387,6 +3392,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh"
33873392

33883393
exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh-compact" 1`] = `
33893394
{
3395+
"awsui-version-info": "true",
33903396
"border-active-width": "4px",
33913397
"border-code-editor-status-divider-width": "1px",
33923398
"border-container-sticky-width": "0px",
@@ -4064,6 +4070,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh-
40644070

40654071
exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh-content-header" 1`] = `
40664072
{
4073+
"awsui-version-info": "true",
40674074
"border-active-width": "4px",
40684075
"border-code-editor-status-divider-width": "1px",
40694076
"border-container-sticky-width": "0px",
@@ -4741,6 +4748,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh-
47414748

47424749
exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh-dark" 1`] = `
47434750
{
4751+
"awsui-version-info": "true",
47444752
"border-active-width": "4px",
47454753
"border-code-editor-status-divider-width": "1px",
47464754
"border-container-sticky-width": "0px",

src/__integ__/themes.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CustomPropertyPageObject extends BasePageObject {
2323
for (const [prop, value] of (element as any).computedStyleMap()) {
2424
// Custom Property
2525
if (prop.startsWith('--')) {
26-
const valueWithoutPostfix = prop.substring(2, prop.length - 7);
26+
const valueWithoutPostfix = prop.replace(/^--/, '').replace(/-[\d\w]+$/, '');
2727
result[valueWithoutPostfix] = value[0][0];
2828
}
2929
}

src/internal/base-component/styles.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@
99
*/
1010
@use 'awsui:globals';
1111
@use '../styles/global.scss';
12+
@use '../generated/custom-css-properties' as custom-styles;
13+
14+
:root {
15+
--awsui-version-info-#{custom-styles.$awsui-commit-hash}: true;
16+
}

src/internal/environment.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
export const THEME: string;
66
export const PACKAGE_SOURCE: string;
77
export const PACKAGE_VERSION: string;
8+
export const GIT_SHA: string;
89
/** Indicates that the current theme is always in visual refresh mode. */
910
export const ALWAYS_VISUAL_REFRESH: boolean;

0 commit comments

Comments
 (0)