-
Notifications
You must be signed in to change notification settings - Fork 160
/
index.ts
65 lines (57 loc) · 2.37 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { ThemeBuilder } from '@cloudscape-design/theming-build';
import {
createAlertContext,
createCompactTableContext,
createFlashbarContext,
createFlashbarWarningContext,
createHeaderContext,
createTopNavigationContext,
} from '../utils/contexts';
import { createColorMode, createDensityMode, createMotionMode } from '../utils/modes';
import alertHeaderContextTokens from './contexts/header-alert';
const modes = [
createColorMode('.awsui-dark-mode'),
createDensityMode('.awsui-compact-mode'),
createMotionMode('.awsui-motion-disabled'),
];
const tokenCategories = [
require('./color-palette'),
require('./color-charts'),
require('./color-severity'),
require('./colors'),
require('./typography'),
require('./borders'),
require('./motion'),
require('./sizes'),
require('./spacing'),
require('./shadows'),
];
export function buildVisualRefresh(builder: ThemeBuilder) {
tokenCategories.forEach(({ tokens, mode: modeId }) => {
const mode = modes.find(mode => mode.id === modeId);
builder.addTokens(tokens, mode);
});
// eslint-disable-next-line @typescript-eslint/no-var-requires
builder.addContext(createCompactTableContext(require('./contexts/compact-table').tokens));
// eslint-disable-next-line @typescript-eslint/no-var-requires
builder.addContext(createTopNavigationContext(require('./contexts/top-navigation').tokens));
// eslint-disable-next-line @typescript-eslint/no-var-requires
builder.addContext(createHeaderContext(require('./contexts/header').tokens));
// eslint-disable-next-line @typescript-eslint/no-var-requires
builder.addContext(createFlashbarContext(require('./contexts/flashbar').tokens));
// eslint-disable-next-line @typescript-eslint/no-var-requires
builder.addContext(createFlashbarWarningContext(require('./contexts/flashbar-warning').tokens));
// eslint-disable-next-line @typescript-eslint/no-var-requires
builder.addContext(createAlertContext(require('./contexts/alert').tokens));
builder.addContext({
id: 'alert-header',
selector: '.awsui-context-content-header .awsui-context-alert',
tokens: alertHeaderContextTokens,
});
return builder.build();
}
const builder = new ThemeBuilder('visual-refresh', ':root', modes);
const theme = buildVisualRefresh(builder);
export default theme;