@cloudscape-design/theming-runtime
Advanced tools
Comparing version 1.0.14 to 1.0.15
@@ -5,2 +5,3 @@ import { ThemePreset, Override } from '../shared/theme'; | ||
preset: ThemePreset; | ||
baseThemeId?: string; | ||
} | ||
@@ -7,0 +8,0 @@ export interface ApplyThemeResult { |
@@ -7,8 +7,9 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
import { createMultiThemeCustomizer } from '../shared/declaration/customizer'; | ||
import { getContexts } from '../shared/theme/validate'; | ||
import { getContexts, getThemeFromPreset } from '../shared/theme/validate'; | ||
export function applyTheme(params) { | ||
var override = params.override, preset = params.preset; | ||
var override = params.override, preset = params.preset, baseThemeId = params.baseThemeId; | ||
var availableContexts = getContexts(preset); | ||
var validated = validateOverride(override, preset.themeable, availableContexts); | ||
var content = createOverrideDeclarations(preset.theme, validated, preset.propertiesMap, createMultiThemeCustomizer(preset.theme.selector)); | ||
var theme = getThemeFromPreset(preset, baseThemeId); | ||
var content = createOverrideDeclarations(theme, validated, preset.propertiesMap, createMultiThemeCustomizer(theme.selector)); | ||
var nonce = getNonce(); | ||
@@ -15,0 +16,0 @@ var styleNode = createStyleNode(content, nonce); |
{ | ||
"commit": "23c08c719c113e94d47aa266d33bc29cf1f8c399" | ||
"commit": "08d2634ece93560254be57d7145e54c8964b305d" | ||
} |
{ | ||
"version": "1.0.14", | ||
"version": "1.0.15", | ||
"name": "@cloudscape-design/theming-runtime", | ||
@@ -4,0 +4,0 @@ "main": "./browser/index.js", |
@@ -1,2 +0,2 @@ | ||
import { Override, ThemePreset, Token } from './interfaces'; | ||
import { Override, Theme, ThemePreset, Token } from './interfaces'; | ||
/** | ||
@@ -12,1 +12,2 @@ * This function compares the theme override against the list of tokens that are allowed | ||
export declare function getContexts(preset: ThemePreset): string[]; | ||
export declare function getThemeFromPreset(preset: ThemePreset, baseThemeId?: string): Theme; |
@@ -76,1 +76,17 @@ import { __assign, __spreadArray } from "tslib"; | ||
} | ||
export function getThemeFromPreset(preset, baseThemeId) { | ||
var _a; | ||
if (!baseThemeId) { | ||
return preset.theme; | ||
} | ||
var themesMap = __spreadArray([preset.theme], ((_a = preset.secondary) !== null && _a !== void 0 ? _a : []), true).reduce(function (accThemesMap, currentTheme) { | ||
accThemesMap[currentTheme.id] = currentTheme; | ||
return accThemesMap; | ||
}, {}); | ||
if (!themesMap[baseThemeId]) { | ||
throw new Error("Specified baseThemeId '".concat(baseThemeId, "' is not available. Available values are ").concat(Object.keys(themesMap) | ||
.map(function (value) { return "'".concat(value, "'"); }) | ||
.join(', '), ".")); | ||
} | ||
return themesMap[baseThemeId]; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69560
1328