Skip to content
Closed
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions .changeset/busy-impalas-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@clerk/clerk-js': minor
'@clerk/themes': minor
'@clerk/types': minor
---

TODO
2 changes: 1 addition & 1 deletion packages/clerk-js/bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{ "path": "./dist/clerk.headless*.js", "maxSize": "55.2KB" },
{ "path": "./dist/ui-common*.js", "maxSize": "113KB" },
{ "path": "./dist/ui-common*.legacy.*.js", "maxSize": "118KB" },
{ "path": "./dist/vendors*.js", "maxSize": "40.2KB" },
{ "path": "./dist/vendors*.js", "maxSize": "40.6KB" },
{ "path": "./dist/coinbase*.js", "maxSize": "38KB" },
{ "path": "./dist/stripe-vendors*.js", "maxSize": "1KB" },
{ "path": "./dist/createorganization*.js", "maxSize": "5KB" },
Expand Down
32 changes: 31 additions & 1 deletion packages/clerk-js/src/ui/customizables/AppearanceContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { createContextAndHook, useDeepEqualMemo } from '@clerk/shared/react';
import type { BaseTheme, BaseThemeTaggedType } from '@clerk/types';
// eslint-disable-next-line no-restricted-imports
import { css, Global } from '@emotion/react';
import React from 'react';

import type { AppearanceCascade, ParsedAppearance } from './parseAppearance';
Expand All @@ -17,7 +20,34 @@ const AppearanceProvider = (props: AppearanceProviderProps) => {
return { value };
}, [props.appearance, props.globalAppearance]);

return <AppearanceContext.Provider value={ctxValue}>{props.children}</AppearanceContext.Provider>;
// Extract global CSS from theme if it exists
const getGlobalCss = (theme: BaseTheme | BaseTheme[] | undefined) => {
if (
typeof theme === 'object' &&
!Array.isArray(theme) &&
'__type' in theme &&
theme.__type === 'prebuilt_appearance'
) {
// Cast to the specific type that includes __internal_globalCss
return (theme as BaseThemeTaggedType & { __internal_globalCss?: string }).__internal_globalCss;
}
return null;
};

const globalCss = getGlobalCss(props.appearance?.theme) || getGlobalCss(props.globalAppearance?.theme);

return (
<AppearanceContext.Provider value={ctxValue}>
{globalCss && (
<Global
styles={css`
${globalCss}
`}
/>
)}
{props.children}
</AppearanceContext.Provider>
);
};

export { AppearanceProvider, useAppearance };
7 changes: 5 additions & 2 deletions packages/themes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --exclude-entrypoints shadcn.css --profile node16"
"lint:attw": "attw --pack . --exclude-entrypoints shadcn.css --profile node16",
"test": "vitest run",
"test:watch": "vitest"
},
"dependencies": {
"@clerk/types": "workspace:^",
"tslib": "catalog:repo"
},
"devDependencies": {
"tsup": "catalog:repo"
"tsup": "catalog:repo",
"vitest": "catalog:repo"
},
"engines": {
"node": ">=18.17.0"
Expand Down
Loading
Loading