Skip to content

Commit

Permalink
✨ feat: createStyles 入参支持 appearance 和 injectGlobal
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Jan 10, 2023
1 parent d318382 commit 0b1d947
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/functions/createStyles.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import { css, cx, type CSSObject } from '@emotion/css';
import { css, cx, injectGlobal, type CSSObject } from '@emotion/css';
import type { Emotion } from '@emotion/css/create-instance';
import { useMemo } from 'react';

import { useTheme } from '@/hooks';
import { AntdStylish, FullToken, ReturnStyleToUse, StyleDefinition, Theme } from '@/types';
import {
AntdStylish,
FullToken,
ReturnStyleToUse,
StyleDefinition,
Theme,
ThemeAppearance,
} from '@/types';

export interface CreateStylesTheme {
token: FullToken;
stylish: AntdStylish;
appearance: ThemeAppearance;
cx: Emotion['cx'];
css: Emotion['css'];
injectGlobal: Emotion['injectGlobal'];
}

/**
Expand Down Expand Up @@ -50,9 +59,9 @@ export const createStyles: CreateStylesFn =
let styles;

if (styleOrGetStyleFn instanceof Function) {
const { stylish, ...token } = theme;
const { stylish, appearance, ...token } = theme;

styles = styleOrGetStyleFn({ token, stylish, cx, css }, props);
styles = styleOrGetStyleFn({ token, stylish, appearance, cx, css, injectGlobal }, props);
} else {
styles = styleOrGetStyleFn;
}
Expand Down

0 comments on commit 0b1d947

Please sign in to comment.