Skip to content

Commit

Permalink
[fix] Make theme optional in Pigment CSS config (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
brijeshb42 committed May 28, 2024
1 parent b84a55f commit f33d4f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/pigment-css-react/src/utils/generateCss.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { serializeStyles } from '@emotion/serialize';
import { Theme } from './extendTheme';

export function generateTokenCss(theme: Theme) {
export function generateTokenCss(theme?: Theme) {
if (!theme) {
return '';
}
// use emotion to serialize the object to css string
const { styles } = serializeStyles(theme.generateStyleSheets?.() || []);
return styles;
}

export function generateThemeTokens(theme: Theme) {
export function generateThemeTokens(theme?: Theme) {
if (!theme || typeof theme !== 'object') {
return {};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/pigment-css-vite-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface PigmentOptions extends Omit<VitePluginOptions, 'themeArgs'> {
/**
* The theme object that you want to be passed to the `styled` function
*/
theme: Theme;
theme?: Theme;
}

const VIRTUAL_CSS_FILE = `\0zero-runtime-styles.css`;
Expand Down

0 comments on commit f33d4f9

Please sign in to comment.