Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
652cfe6
refactor(clerk-js): Update color logic utils
alexcarpenter Jun 24, 2025
8198e12
checkpoint
alexcarpenter Jun 24, 2025
283f322
refactor color utilities
alexcarpenter Jun 24, 2025
33a32dd
remove eslint-disable usage
alexcarpenter Jun 24, 2025
7cb8d8a
Enhance sandbox styles and color utilities
alexcarpenter Jun 24, 2025
5898f2b
Update colorOptionToHslaScale.ts
alexcarpenter Jun 24, 2025
7db3449
creat unified colors interface to manage modern and legacy support
alexcarpenter Jun 24, 2025
719ee2a
reorganize colors folder
alexcarpenter Jun 24, 2025
c1a3174
extract constants and cache
alexcarpenter Jun 25, 2025
df764fc
add tests
alexcarpenter Jun 25, 2025
87419bd
Delete performance.ts
alexcarpenter Jun 25, 2025
6f1d280
Update app.ts
alexcarpenter Jun 25, 2025
18f15aa
revert sandbox changes
alexcarpenter Jun 25, 2025
b7dcccc
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter Jun 25, 2025
8ea0357
add temp changelog
alexcarpenter Jun 25, 2025
3d22bb9
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter Jun 26, 2025
417d0e5
fix missing import
alexcarpenter Jun 26, 2025
ca6e8e4
refactor: use unknown vs any
alexcarpenter Jun 26, 2025
cf99453
refactor prefixAndStringifyScale types
alexcarpenter Jun 26, 2025
8d60397
Update packages/clerk-js/src/ui/utils/colors/README.md
alexcarpenter Jun 26, 2025
f56fbd4
remove features list
alexcarpenter Jun 26, 2025
ccba2f5
Merge branch 'alexcarpenter/user-2201-add-color-mix-utilities' of git…
alexcarpenter Jun 26, 2025
96a1456
remove perf benefits
alexcarpenter Jun 26, 2025
5273a82
🔪 README
alexcarpenter Jun 26, 2025
da7235b
remove getCacheStats
alexcarpenter Jun 26, 2025
9834559
remove duplicate file
alexcarpenter Jun 26, 2025
abd06ce
remove relative color support for makeTransparent as color-mix handle…
alexcarpenter Jun 26, 2025
41299da
update description
alexcarpenter Jun 26, 2025
0c7e07b
improve description
alexcarpenter Jun 26, 2025
6e7c566
remove comment
alexcarpenter Jun 26, 2025
107c583
cleanup
alexcarpenter Jun 26, 2025
5fcf1ee
remove export
alexcarpenter Jun 26, 2025
facce98
make consistent
alexcarpenter Jun 26, 2025
e51268c
refactor toHSLA and toTransparent usage
alexcarpenter Jun 26, 2025
8d581a9
remove
alexcarpenter Jun 26, 2025
a3ef27b
bring back getCacheStats
alexcarpenter Jun 26, 2025
488f2b9
refactor cache and hasModernColorSupport
alexcarpenter Jun 26, 2025
3189c48
use hasModernColorSupport
alexcarpenter Jun 26, 2025
91a9800
use constants
alexcarpenter Jun 26, 2025
b31b45b
handle feedback
alexcarpenter Jun 26, 2025
9b86c9e
refactor
alexcarpenter Jun 26, 2025
1ae5c97
add legacy tests
alexcarpenter Jun 26, 2025
f200029
rename and consolidate scale generation
alexcarpenter Jun 26, 2025
065445c
feedback
alexcarpenter Jun 26, 2025
79ccc92
rename
alexcarpenter Jun 26, 2025
d21c353
extract color generation functions
alexcarpenter Jun 26, 2025
441a41c
remove memoization
alexcarpenter Jun 26, 2025
2a0bdd2
rename and add js doc comments
alexcarpenter Jun 26, 2025
0ab897c
reduce lookups
alexcarpenter Jun 27, 2025
0a6be7f
reduce lookups
alexcarpenter Jun 27, 2025
7522f71
revert
alexcarpenter Jun 27, 2025
ad7bf32
fix adjustForLightness usage
alexcarpenter Jun 27, 2025
d081f27
add resolveCssVariable funtionality
alexcarpenter Jun 27, 2025
20900a1
fix legacy scale generation
alexcarpenter Jun 27, 2025
50eb9a1
feedback
alexcarpenter Jun 27, 2025
4c1dcce
remove css var from error
alexcarpenter Jun 27, 2025
1a735d2
add docs
alexcarpenter Jun 27, 2025
59f007e
revert
alexcarpenter Jun 27, 2025
d2f01e8
refactor to support composite feature checks
alexcarpenter Jun 27, 2025
fe8b6de
fix spec
alexcarpenter Jun 27, 2025
cde9e6b
Update bundlewatch.config.json
alexcarpenter Jun 27, 2025
88414a2
Update bundlewatch.config.json
alexcarpenter Jun 27, 2025
8a667ad
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter Jun 27, 2025
aff50d2
Update packages/clerk-js/src/ui/utils/colors/README.md
alexcarpenter Jun 27, 2025
9feee93
Update packages/clerk-js/src/ui/utils/colors/README.md
alexcarpenter Jun 27, 2025
7faf80a
Update packages/clerk-js/src/ui/utils/colors/index.ts
alexcarpenter Jun 27, 2025
709a9f7
Update packages/clerk-js/src/ui/utils/colors/modern.ts
alexcarpenter Jun 27, 2025
7741bec
Update packages/clerk-js/src/ui/utils/colors/modern.ts
alexcarpenter Jun 27, 2025
c1af115
Update packages/clerk-js/src/ui/utils/colors/index.ts
alexcarpenter Jun 27, 2025
7081c7b
handle feedback
alexcarpenter Jun 27, 2025
619f2ff
fix css supports usage
alexcarpenter Jun 27, 2025
97e6456
fix adjustForLightness usage
alexcarpenter Jun 27, 2025
ecee31a
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter Jun 27, 2025
6fad410
extract CSS variable utilities
alexcarpenter Jun 30, 2025
e6cc63c
fix colorTextSecondary color
alexcarpenter Jun 30, 2025
9ab7299
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter Jun 30, 2025
5598627
refactor(clerk-js): Introduce `resolveComputedCSSProperty` to pass al…
alexcarpenter Jul 2, 2025
c7b82a4
feat(clerk-js): Remove CSS variables when modern color isn't supporte…
dstaley Jul 2, 2025
66c5d1f
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter Jul 2, 2025
1f7e79e
Update bundlewatch.config.json
alexcarpenter Jul 2, 2025
c2c7bf1
Update chubby-parts-try.md
alexcarpenter Jul 2, 2025
be92ca6
Update bundlewatch.config.json
alexcarpenter Jul 2, 2025
d41acfe
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter Jul 2, 2025
3d73abd
handle negative margins
alexcarpenter Jul 2, 2025
c41b4e5
bring back 500 shade error
alexcarpenter Jul 2, 2025
6fcf437
add test case
alexcarpenter Jul 2, 2025
120ba37
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter Jul 3, 2025
b697754
Update bundlewatch.config.json
alexcarpenter Jul 3, 2025
0138f04
Merge branch 'alexcarpenter/user-2201-add-color-mix-utilities' of git…
alexcarpenter Jul 3, 2025
79c05ca
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter Jul 7, 2025
82bd682
resolve stripe appearance
alexcarpenter Jul 7, 2025
f691fe5
fix stripe appearance
alexcarpenter Jul 7, 2025
b5484a5
Merge branch 'main' into alexcarpenter/user-2201-add-color-mix-utilities
alexcarpenter Jul 7, 2025
ef6acaf
negative margin
alexcarpenter Jul 7, 2025
e15a0ab
Update bundlewatch.config.json
alexcarpenter Jul 7, 2025
11e7dff
fix scales test
alexcarpenter Jul 7, 2025
315070d
Update bundlewatch.config.json
alexcarpenter Jul 7, 2025
a84db2d
Update chubby-parts-try.md
alexcarpenter Jul 7, 2025
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
7 changes: 7 additions & 0 deletions .changeset/chubby-parts-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@clerk/clerk-js': minor
---

Add CSS variable support to the `appearance.variables` object, enabling use of CSS custom properties. For example, you can now use `colorPrimary: 'var(--brand-color)'` to reference CSS variables defined in your stylesheets.

This feature includes automatic fallback support for browsers that don't support modern CSS color manipulation features.
4 changes: 2 additions & 2 deletions packages/clerk-js/bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{ "path": "./dist/clerk.legacy.browser.js", "maxSize": "115KB" },
{ "path": "./dist/clerk.headless*.js", "maxSize": "55KB" },
{ "path": "./dist/ui-common*.js", "maxSize": "111.8KB" },
{ "path": "./dist/ui-common*.legacy.*.js", "maxSize": "112.1KB" },
{ "path": "./dist/ui-common*.legacy.*.js", "maxSize": "113.67KB" },
{ "path": "./dist/vendors*.js", "maxSize": "40.2KB" },
{ "path": "./dist/coinbase*.js", "maxSize": "38KB" },
{ "path": "./dist/stripe-vendors*.js", "maxSize": "1KB" },
Expand All @@ -23,7 +23,7 @@
{ "path": "./dist/waitlist*.js", "maxSize": "1.5KB" },
{ "path": "./dist/keylessPrompt*.js", "maxSize": "6.5KB" },
{ "path": "./dist/pricingTable*.js", "maxSize": "4.02KB" },
{ "path": "./dist/checkout*.js", "maxSize": "8.34KB" },
{ "path": "./dist/checkout*.js", "maxSize": "8.4KB" },
{ "path": "./dist/up-billing-page*.js", "maxSize": "3.0KB" },
{ "path": "./dist/op-billing-page*.js", "maxSize": "3.0KB" },
{ "path": "./dist/up-plans-page*.js", "maxSize": "1.0KB" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ const NotificationCountBadgeSwitcherTrigger = () => {
<NotificationCountBadge
containerSx={t => ({
position: 'absolute',
top: `-${t.space.$2}`,
right: `-${t.space.$2}`,
top: `calc(${t.space.$2} * -1)`,
right: `calc(${t.space.$2} * -1)`,
})}
notificationCount={notificationCount}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,40 @@ import { useCardState } from '@/ui/elements/contexts';
import { Form } from '@/ui/elements/Form';
import { FormButtons } from '@/ui/elements/FormButtons';
import { FormContainer } from '@/ui/elements/FormContainer';
import { resolveComputedCSSColor, resolveComputedCSSProperty } from '@/ui/utils/cssVariables';
import { handleError } from '@/ui/utils/errorHandler';
import { normalizeColorString } from '@/ui/utils/normalizeColorString';

import { useSubscriberTypeContext, useSubscriberTypeLocalizationRoot } from '../../contexts';
import { descriptors, Flex, localizationKeys, Spinner, useAppearance, useLocalizations } from '../../customizables';
import type { LocalizationKey } from '../../localization';

const useStripeAppearance = () => {
const useStripeAppearance = (node: HTMLElement | null) => {
const theme = useAppearance().parsedInternalTheme;

return useMemo(() => {
if (!node) {
return undefined;
}
const { colors, fontWeights, fontSizes, radii, space } = theme;
return {
colorPrimary: normalizeColorString(colors.$primary500),
colorBackground: normalizeColorString(colors.$colorInputBackground),
colorText: normalizeColorString(colors.$colorText),
colorTextSecondary: normalizeColorString(colors.$colorTextSecondary),
colorSuccess: normalizeColorString(colors.$success500),
colorDanger: normalizeColorString(colors.$danger500),
colorWarning: normalizeColorString(colors.$warning500),
fontWeightNormal: fontWeights.$normal.toString(),
fontWeightMedium: fontWeights.$medium.toString(),
fontWeightBold: fontWeights.$bold.toString(),
fontSizeXl: fontSizes.$xl,
fontSizeLg: fontSizes.$lg,
fontSizeSm: fontSizes.$md,
fontSizeXs: fontSizes.$sm,
borderRadius: radii.$md,
spacingUnit: space.$1,
colorPrimary: resolveComputedCSSColor(node, colors.$primary500, colors.$colorBackground),
colorBackground: resolveComputedCSSColor(node, colors.$colorInputBackground, colors.$colorBackground),
colorText: resolveComputedCSSColor(node, colors.$colorText, colors.$colorBackground),
colorTextSecondary: resolveComputedCSSColor(node, colors.$colorTextSecondary, colors.$colorBackground),
colorSuccess: resolveComputedCSSColor(node, colors.$success500, colors.$colorBackground),
colorDanger: resolveComputedCSSColor(node, colors.$danger500, colors.$colorBackground),
colorWarning: resolveComputedCSSColor(node, colors.$warning500, colors.$colorBackground),
fontWeightNormal: resolveComputedCSSProperty(node, 'font-weight', fontWeights.$normal.toString()),
fontWeightMedium: resolveComputedCSSProperty(node, 'font-weight', fontWeights.$medium.toString()),
fontWeightBold: resolveComputedCSSProperty(node, 'font-weight', fontWeights.$bold.toString()),
fontSizeXl: resolveComputedCSSProperty(node, 'font-size', fontSizes.$xl),
fontSizeLg: resolveComputedCSSProperty(node, 'font-size', fontSizes.$lg),
fontSizeSm: resolveComputedCSSProperty(node, 'font-size', fontSizes.$md),
fontSizeXs: resolveComputedCSSProperty(node, 'font-size', fontSizes.$sm),
borderRadius: resolveComputedCSSProperty(node, 'border-radius', radii.$lg),
spacingUnit: resolveComputedCSSProperty(node, 'padding', space.$1),
};
}, [theme]);
}, [theme, node]);
};

type AddPaymentSourceProps = {
Expand All @@ -66,11 +69,12 @@ const [AddPaymentSourceContext, useAddPaymentSourceContext] = createContextAndHo

const AddPaymentSourceRoot = ({ children, checkout, ...rest }: PropsWithChildren<AddPaymentSourceProps>) => {
const subscriberType = useSubscriberTypeContext();
const stripeAppearanceNode = useRef<HTMLDivElement | null>(null);
const { t } = useLocalizations();
const [headerTitle, setHeaderTitle] = useState<LocalizationKey | undefined>(undefined);
const [headerSubtitle, setHeaderSubtitle] = useState<LocalizationKey | undefined>(undefined);
const [submitLabel, setSubmitLabel] = useState<LocalizationKey | undefined>(undefined);
const stripeAppearance = useStripeAppearance();
const stripeAppearance = useStripeAppearance(stripeAppearanceNode.current);

return (
<AddPaymentSourceContext.Provider
Expand All @@ -87,6 +91,10 @@ const AddPaymentSourceRoot = ({ children, checkout, ...rest }: PropsWithChildren
},
}}
>
<div
ref={stripeAppearanceNode}
style={{ display: 'none' }}
/>
<PaymentElementProvider
checkout={checkout}
for={subscriberType}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';

// Mock cssSupports
vi.mock('../../utils/cssSupports', () => ({
cssSupports: {
modernColor: vi.fn(),
},
}));

import { cssSupports } from '@/ui/utils/cssSupports';

import { removeInvalidValues } from '../parseVariables';

const mockModernColorSupport = vi.mocked(cssSupports.modernColor);

describe('removeInvalidValues', () => {
beforeEach(() => {
vi.clearAllMocks();
mockModernColorSupport.mockReturnValue(false);
});

it('should return the variables as-is if modern color support is present', () => {
mockModernColorSupport.mockReturnValue(true);
const variables = {
colorPrimary: 'var(--color-primary)',
};

const result = removeInvalidValues(variables);
expect(result).toEqual({ colorPrimary: 'var(--color-primary)' });
});

it('should remove invalid string values if modern color support is not present', () => {
mockModernColorSupport.mockReturnValue(false);
const variables = {
colorPrimary: 'var(--color-primary)',
colorDanger: '#ff0000',
};

const result = removeInvalidValues(variables);
expect(result).toEqual({ colorDanger: '#ff0000' });
});

it('should remove invalid object values if modern color support is not present', () => {
mockModernColorSupport.mockReturnValue(false);
const variables = {
colorPrimary: {
400: 'var(--color-primary-500)',
500: '#fff',
},
colorDanger: {
500: '#ff0000',
},
};

const result = removeInvalidValues(variables);
expect(result).toEqual({ colorDanger: { 500: '#ff0000' } });
});
});
116 changes: 75 additions & 41 deletions packages/clerk-js/src/ui/customizables/parseVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,89 @@ import type { Theme } from '@clerk/types';

import { spaceScaleKeys } from '../foundations/sizes';
import type { fontSizes, fontWeights } from '../foundations/typography';
import { colorOptionToHslaAlphaScale, colorOptionToHslaLightnessScale } from '../utils/colorOptionToHslaScale';
import { colors } from '../utils/colors';
import { colorOptionToThemedAlphaScale, colorOptionToThemedLightnessScale } from '../utils/colors/scales';
import { cssSupports } from '../utils/cssSupports';
import { fromEntries } from '../utils/fromEntries';
import { removeUndefinedProps } from '../utils/removeUndefinedProps';

export const createColorScales = (theme: Theme) => {
const variables = theme.variables || {};
const variables = removeInvalidValues(theme.variables || {});

const primaryScale = colorOptionToHslaLightnessScale(variables.colorPrimary, 'primary');
const primaryAlphaScale = colorOptionToHslaAlphaScale(primaryScale?.primary500, 'primaryAlpha');
const dangerScale = colorOptionToHslaLightnessScale(variables.colorDanger, 'danger');
const dangerAlphaScale = colorOptionToHslaAlphaScale(dangerScale?.danger500, 'dangerAlpha');
const successScale = colorOptionToHslaLightnessScale(variables.colorSuccess, 'success');
const successAlphaScale = colorOptionToHslaAlphaScale(successScale?.success500, 'successAlpha');
const warningScale = colorOptionToHslaLightnessScale(variables.colorWarning, 'warning');
const warningAlphaScale = colorOptionToHslaAlphaScale(warningScale?.warning500, 'warningAlpha');
const dangerScale = colorOptionToThemedLightnessScale(variables.colorDanger, 'danger');
const primaryScale = colorOptionToThemedLightnessScale(variables.colorPrimary, 'primary');
const successScale = colorOptionToThemedLightnessScale(variables.colorSuccess, 'success');
const warningScale = colorOptionToThemedLightnessScale(variables.colorWarning, 'warning');

const dangerAlphaScale = colorOptionToThemedAlphaScale(dangerScale?.danger500, 'dangerAlpha');
const neutralAlphaScale = colorOptionToThemedAlphaScale(variables.colorNeutral, 'neutralAlpha');
const primaryAlphaScale = colorOptionToThemedAlphaScale(primaryScale?.primary500, 'primaryAlpha');
const successAlphaScale = colorOptionToThemedAlphaScale(successScale?.success500, 'successAlpha');
const warningAlphaScale = colorOptionToThemedAlphaScale(warningScale?.warning500, 'warningAlpha');

return removeUndefinedProps({
...primaryScale,
...primaryAlphaScale,
...dangerScale,
...dangerAlphaScale,
...primaryScale,
...successScale,
...successAlphaScale,
...warningScale,
...dangerAlphaScale,
...neutralAlphaScale,
...primaryAlphaScale,
...successAlphaScale,
...warningAlphaScale,
...colorOptionToHslaAlphaScale(variables.colorNeutral, 'neutralAlpha'),
primaryHover: colors.adjustForLightness(primaryScale?.primary500),
colorTextOnPrimaryBackground: toHSLA(variables.colorTextOnPrimaryBackground),
colorText: toHSLA(variables.colorText),
colorTextSecondary: toHSLA(variables.colorTextSecondary) || colors.makeTransparent(variables.colorText, 0.35),
colorInputText: toHSLA(variables.colorInputText),
colorBackground: toHSLA(variables.colorBackground),
colorInputBackground: toHSLA(variables.colorInputBackground),
colorShimmer: toHSLA(variables.colorShimmer),
colorTextOnPrimaryBackground: colors.toHslaString(variables.colorTextOnPrimaryBackground),
colorText: colors.toHslaString(variables.colorText),
colorTextSecondary:
colors.toHslaString(variables.colorTextSecondary) || colors.makeTransparent(variables.colorText, 0.35),
colorInputText: colors.toHslaString(variables.colorInputText),
colorBackground: colors.toHslaString(variables.colorBackground),
colorInputBackground: colors.toHslaString(variables.colorInputBackground),
colorShimmer: colors.toHslaString(variables.colorShimmer),
});
};

export const toHSLA = (str: string | undefined) => {
return str ? colors.toHslaString(str) : undefined;
export const removeInvalidValues = (variables: NonNullable<Theme['variables']>): NonNullable<Theme['variables']> => {
// Check for modern color support. If present, we can simply return the variables as-is since we support everything
// CSS supports.
if (cssSupports.modernColor()) {
return variables;
}

// If not, we need to remove any values that are specified with CSS variables, as our color scale generation only
// supports CSS variables using modern CSS functionality.
const validVariables: Theme['variables'] = Object.fromEntries(
Object.entries(variables).filter(([key, value]) => {
if (typeof value === 'string') {
const isValid = !value.startsWith('var(');
if (!isValid) {
console.warn(
`Invalid color value: ${value} for key: ${key}, using default value instead. Using CSS variables is not supported in this browser.`,
);
}
return isValid;
}

if (typeof value === 'object') {
return Object.entries(value).every(([key, value]) => {
if (typeof value !== 'string') return true;

const isValid = !value.startsWith('var(');
if (!isValid) {
console.warn(
`Invalid color value: ${value} for key: ${key}, using default value instead. Using CSS variables is not supported in this browser.`,
);
}

return isValid;
});
}

return false;
}),
);

return validVariables;
};

export const createRadiiUnits = (theme: Theme) => {
Expand All @@ -51,12 +94,11 @@ export const createRadiiUnits = (theme: Theme) => {
}

const md = borderRadius === 'none' ? '0' : borderRadius;
const { numericValue, unit = 'rem' } = splitCssUnit(md);
return {
sm: (numericValue * 0.66).toString() + unit,
sm: `calc(${md} * 0.66)`,
md,
lg: (numericValue * 1.33).toString() + unit,
xl: (numericValue * 2).toString() + unit,
lg: `calc(${md} * 1.33)`,
xl: `calc(${md} * 2)`,
};
};

Expand All @@ -65,12 +107,11 @@ export const createSpaceScale = (theme: Theme) => {
if (spacingUnit === undefined) {
return;
}
const { numericValue, unit } = splitCssUnit(spacingUnit);
return fromEntries(
spaceScaleKeys.map(k => {
const num = Number.parseFloat(k.replace('x', '.'));
const percentage = (num / 0.5) * 0.125;
return [k, `${numericValue * percentage}${unit}`];
return [k, `calc(${spacingUnit} * ${percentage})`];
}),
);
};
Expand All @@ -83,13 +124,12 @@ export const createFontSizeScale = (theme: Theme): Record<keyof typeof fontSizes
if (fontSize === undefined) {
return;
}
const { numericValue, unit = 'rem' } = splitCssUnit(fontSize);
return {
xs: (numericValue * 0.8).toString() + unit,
sm: (numericValue * 0.9).toString() + unit,
xs: `calc(${fontSize} * 0.8)`,
sm: `calc(${fontSize} * 0.9)`,
md: fontSize,
lg: (numericValue * 1.3).toString() + unit,
xl: (numericValue * 1.85).toString() + unit,
lg: `calc(${fontSize} * 1.3)`,
xl: `calc(${fontSize} * 1.85)`,
};
};

Expand All @@ -102,9 +142,3 @@ export const createFonts = (theme: Theme) => {
const { fontFamily, fontFamilyButtons } = theme.variables || {};
return removeUndefinedProps({ main: fontFamily, buttons: fontFamilyButtons });
};

const splitCssUnit = (str: string) => {
const numericValue = Number.parseFloat(str);
const unit = str.replace(numericValue.toString(), '') || undefined;
return { numericValue, unit };
};
2 changes: 1 addition & 1 deletion packages/clerk-js/src/ui/elements/Card/CardFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const CardFooter = React.forwardRef<HTMLDivElement, CardFooterProps>((pro
elementDescriptor={descriptors.footer}
sx={[
t => ({
marginTop: `-${t.space.$2}`,
marginTop: `calc(${t.space.$2} * -1)`,
paddingTop: t.space.$2,
background: common.mergedColorsBackground(
colors.setAlpha(t.colors.$colorBackground, 1),
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/ui/elements/CodeControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export const OTPCodeControl = React.forwardRef<{ reset: any }>((_, ref) => {
hasError={feedbackType === 'error'}
elementDescriptor={descriptors.otpCodeFieldInputs}
gap={2}
sx={t => ({ direction: 'ltr', padding: t.space.$1, marginLeft: `-${t.space.$1}`, ...centerSx })}
sx={t => ({ direction: 'ltr', padding: t.space.$1, marginLeft: `calc(${t.space.$1} * -1)`, ...centerSx })}
role='group'
aria-label='Verification code input'
>
Expand Down
4 changes: 2 additions & 2 deletions packages/clerk-js/src/ui/elements/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const NavbarContainer = (
t.colors.$neutralAlpha50,
),
padding: `${t.space.$6} ${t.space.$5} ${t.space.$4} ${t.space.$3}`,
marginRight: `-${t.space.$2}`,
marginRight: `calc(${t.space.$2} * -1)`,
color: t.colors.$colorText,
justifyContent: 'space-between',
})}
Expand Down Expand Up @@ -332,7 +332,7 @@ export const NavbarMenuButtonRow = ({ navbarTitleLocalizationKey, ...props }: Na
t.colors.$neutralAlpha50,
),
padding: `${t.space.$2} ${t.space.$3} ${t.space.$4} ${t.space.$3}`,
marginBottom: `-${t.space.$2}`,
marginBottom: `calc(${t.space.$2} * -1)`,
[mqu.md]: {
display: 'flex',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/ui/elements/PopoverCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const PopoverCardFooter = (props: PropsOfComponent<typeof Flex>) => {
colors.setAlpha(t.colors.$colorBackground, 1),
t.colors.$neutralAlpha50,
),
marginTop: `-${t.space.$2}`,
marginTop: `calc(${t.space.$2} * -1)`,
paddingTop: t.space.$2,
'&:empty': {
padding: 0,
Expand Down
Loading
Loading