forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: merge preset colors (ant-design#39742)
* style: remove redundant code * feat(style): add preset colour style generation method (cherry picked from commit 1266e42) * feat: uniform preset colour generation css selector method (cherry picked from commit 5af87e8) * chore: merge preset colors (cherry picked from commit 05040df) * chore: update (cherry picked from commit 241b40a) * chore: remove Badge preset inverse colors * chore: remove fix 删除的这部分其实一个 Bug,但是为了给 PR 减负(尽可能单一, 后面新开一个 PR 来修复这个问题 * suggestions accepted Update components/style/presetColor.tsx Co-authored-by: MadCcc <1075746765@qq.com> Co-authored-by: MadCcc <1075746765@qq.com>
- Loading branch information
Showing
14 changed files
with
130 additions
and
126 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
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 was deleted.
Oops, something went wrong.
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,35 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
import type { CSSObject } from '@ant-design/cssinjs'; | ||
import type { AliasToken, PresetColorKey } from '../theme/internal'; | ||
import { PresetColors } from '../theme/internal'; | ||
import type { TokenWithCommonCls } from '../theme/util/genComponentStyleHook'; | ||
|
||
interface CalcColor { | ||
/** token[`${colorKey}-1`] */ | ||
lightColor: string; | ||
/** token[`${colorKey}-3`] */ | ||
lightBorderColor: string; | ||
/** token[`${colorKey}-6`] */ | ||
darkColor: string; | ||
/** token[`${colorKey}-7`] */ | ||
textColor: string; | ||
} | ||
|
||
type GenCSS = (colorKey: PresetColorKey, calcColor: CalcColor) => CSSObject; | ||
|
||
export function genPresetColor<Token extends TokenWithCommonCls<AliasToken>>( | ||
token: Token, | ||
genCss: GenCSS, | ||
): CSSObject { | ||
return PresetColors.reduce((prev: CSSObject, colorKey: PresetColorKey) => { | ||
const lightColor = token[`${colorKey}-1`]; | ||
const lightBorderColor = token[`${colorKey}-3`]; | ||
const darkColor = token[`${colorKey}-6`]; | ||
const textColor = token[`${colorKey}-7`]; | ||
|
||
return { | ||
...prev, | ||
...genCss(colorKey, { lightColor, lightBorderColor, darkColor, textColor }), | ||
}; | ||
}, {} as CSSObject); | ||
} |
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
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
Oops, something went wrong.