generated from arvinxx/npm-template
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
103 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { ClassNamesArg } from '@emotion/css/create-instance'; | ||
import { CSSInterpolation, SerializedStyles } from '@emotion/serialize'; | ||
import { ThemeConfig } from 'antd/es/config-provider/context'; | ||
|
||
import { ThemeAppearance } from './appearance'; | ||
import type { AntdStylish, AntdToken, AppearanceState, FullToken } from './theme'; | ||
|
||
export interface EmotionReactCss { | ||
(template: TemplateStringsArray, ...args: Array<CSSInterpolation>): SerializedStyles; | ||
(...args: Array<CSSInterpolation>): SerializedStyles; | ||
} | ||
export type EmotionCX = (...classNames: ClassNamesArg[]) => string; | ||
|
||
export interface CommonStyleUtils { | ||
cx: EmotionCX; | ||
css: EmotionReactCss; | ||
} | ||
|
||
/** | ||
* 获取 antd theme 配置 | ||
*/ | ||
export type GetAntdThemeConfig = (appearance: ThemeAppearance) => ThemeConfig | undefined; | ||
|
||
export interface AntdStylishParams extends AppearanceState { | ||
token: AntdToken; | ||
css: EmotionReactCss; | ||
} | ||
|
||
/** | ||
* 创建 antd stylish 配置 | ||
*/ | ||
export type GetAntdStylish = (theme: AntdStylishParams) => { | ||
[T in keyof AntdStylish]: SerializedStyles; | ||
}; | ||
|
||
export interface CustomTokenParams extends AppearanceState { | ||
token: AntdToken; | ||
} | ||
|
||
/** | ||
* 创建 自定义 token | ||
*/ | ||
export type GetCustomToken<T> = (theme: CustomTokenParams) => T; | ||
|
||
export interface CustomStylishParams extends AppearanceState { | ||
token: FullToken; | ||
stylish: AntdStylish; | ||
css: EmotionReactCss; | ||
} | ||
|
||
/** | ||
* 创建 自定义 stylish | ||
*/ | ||
export type GetCustomStylish<S> = (theme: CustomStylishParams) => { | ||
[T in keyof S]: SerializedStyles; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from './appearance'; | ||
export * from './css'; | ||
export * from './function'; | ||
export * from './genericUtils'; | ||
export * from './styled'; | ||
export * from './theme'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* 判断是否是 ReactCss 的编译产物 | ||
* @param params | ||
*/ | ||
export const isReactCssResult = (params: any) => { | ||
return ( | ||
typeof params === 'object' && | ||
'styles' in params && | ||
'name' in params && | ||
'map' in params && | ||
'next' in params && | ||
'toString' in params | ||
); | ||
}; |