Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: ts strict fixes for ui theme #3400

Merged
merged 3 commits into from
Feb 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tidy-fans-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@aws-amplify/ui": patch
---

chore: ts strict fixes for createTheme
26 changes: 26 additions & 0 deletions packages/ui/src/theme/types/style-dictionary.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions packages/ui/src/theme/utils.ts
Original file line number Diff line number Diff line change
@@ -33,12 +33,12 @@ export function cssValue(token: BaseDesignToken): string | number {
return referenceValue(value);
}

if (isShadowToken(value)) {
if (isShadowTokenObject(value)) {
return SHADOW_PROPERTIES.map((property) => {
return referenceValue(
// lookup property against `token` first for custom non-nested value, then lookup
// property against `value` for design token value
isShadowToken(token) ? token[property] : value[property]
isShadowTokenObject(token) ? token[property] : value[property]
);
}).join(' ');
}
@@ -65,7 +65,9 @@ export function isDesignToken(value: unknown): value is WebDesignToken {
return isObject(value) && has(value, 'value');
}

export function isShadowToken(value: unknown): value is ShadowValue {
export function isShadowTokenObject(
value: unknown
): value is ShadowValue & object {
return isObject(value) && has(value, 'offsetX');
}