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

fix(core): resolving design values [ALT-1222] #744

Merged
merged 4 commits into from
Sep 11, 2024
Merged
Changes from 1 commit
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
11 changes: 9 additions & 2 deletions packages/core/src/utils/breakpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export const getValueForBreakpoint = (
breakpoints: Breakpoint[],
activeBreakpointIndex: number,
variableName: string,
resolveDesignTokens = true,
) => {
const eventuallyResolveDesignTokens = (value: PrimitiveValue) => {
// For some built-in design propertier, we support design tokens
Expand All @@ -116,14 +117,20 @@ export const getValueForBreakpoint = (
const breakpointId = breakpoints[index]?.id;
if (isValidBreakpointValue(valuesByBreakpoint[breakpointId])) {
// If the value is defined, we use it and stop the breakpoints cascade
return eventuallyResolveDesignTokens(valuesByBreakpoint[breakpointId]);
if (resolveDesignTokens) {
return eventuallyResolveDesignTokens(valuesByBreakpoint[breakpointId]);
}
return valuesByBreakpoint[breakpointId];
}
}
// If no breakpoint matched, we search and apply the fallback breakpoint
const fallbackBreakpointIndex = getFallbackBreakpointIndex(breakpoints);
const fallbackBreakpointId = breakpoints[fallbackBreakpointIndex]?.id;
if (isValidBreakpointValue(valuesByBreakpoint[fallbackBreakpointId])) {
return eventuallyResolveDesignTokens(valuesByBreakpoint[fallbackBreakpointId]);
if (resolveDesignTokens) {
return eventuallyResolveDesignTokens(valuesByBreakpoint[fallbackBreakpointId]);
}
return valuesByBreakpoint[fallbackBreakpointId];
}
} else {
// Old design properties did not support breakpoints, keep for backward compatibility
Expand Down
Loading