-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pagination): color of icon (#2769)
* fix(pagination): color of icon * fix: review * fix: ai’s review
- Loading branch information
1 parent
85a05cd
commit 5bcca3b
Showing
2 changed files
with
33 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { ReactElement, ReactNode } from 'react' | ||
import { harmony } from './platform-taro' | ||
|
||
interface ColorProps { | ||
color?: string | ||
} | ||
|
||
/** | ||
* 为支持 Harmony 的 React 元素添加颜色属性 | ||
* @param maybeElement - 要处理的 React 节点 | ||
* @param color - 要添加的颜色值(如:'#ff0000') | ||
* @returns 处理后的 React 节点 | ||
*/ | ||
function addColorForHarmony(maybeElement: ReactNode, color: string) { | ||
if (React.isValidElement(maybeElement) && harmony()) { | ||
return React.cloneElement<ColorProps>(maybeElement as ReactElement, { | ||
color, | ||
}) | ||
} | ||
return maybeElement | ||
} | ||
|
||
export default addColorForHarmony |