Skip to content

Commit

Permalink
feat(trendarrow): 多端适配 (#2540)
Browse files Browse the repository at this point in the history
* chore: save

* chore: update

* feat: icon占位

* fix: build

* chore: delete useless

* fix: arrow

* chore: cr

* chore: cr
  • Loading branch information
Alex-huxiyang authored Nov 8, 2024
1 parent 9160682 commit 16b173e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@
"author": "zhaoqian16"
},
{
"version": "2.0.0",
"version": "3.0.0",
"name": "TrendArrow",
"type": "component",
"cName": "趋势箭头",
Expand Down
5 changes: 3 additions & 2 deletions src/packages/trendarrow/trendarrow.harmony.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.nut-trendarrow {
display: inline-flex;
display: flex;
flex-direction: row;
align-items: center;
color: #1A1A1A;
color: #1a1a1a;
font-size: 14px;
}
.nut-trendarrow-icon-before {
Expand Down
3 changes: 2 additions & 1 deletion src/packages/trendarrow/trendarrow.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.nut-trendarrow {
display: inline-flex;
display: flex;
flex-direction: row;
align-items: center;
color: $color-title;
font-size: $trendarrow-font-size;
Expand Down
18 changes: 12 additions & 6 deletions src/packages/trendarrow/trendarrow.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { FunctionComponent, useRef } from 'react'
import { TriangleDown, TriangleUp } from '@nutui/icons-react-taro'
import { View, Text } from '@tarojs/components'
import { BasicComponent, ComponentDefaults } from '@/utils/typings'
import { harmony } from '@/utils/platform-taro'

export interface TrendArrowProps extends BasicComponent {
value: number
Expand All @@ -24,8 +26,8 @@ const defaultProps = {
left: false,
sync: true,
color: '#333',
riseColor: 'var(--nutui-brand-6)',
dropColor: 'var(--nutui-secondary-1)',
riseColor: harmony() ? '#ff0f23' : 'var(--nutui-brand-6)',
dropColor: harmony() ? '#14cc33' : 'var(--nutui-secondary-1)',
riseIcon: null,
dropIcon: null,
} as TrendArrowProps
Expand Down Expand Up @@ -96,16 +98,20 @@ export const TrendArrow: FunctionComponent<
const renderContent = (left: boolean) => {
const classNameSuffix = !left ? 'icon-after' : 'icon-before'
return (
<span
<Text
className={`${classPrefix}-${classNameSuffix} ${classPrefix}-value`}
style={calcStyle}
>
{calcRate}
</span>
</Text>
)
}
return (
<div className={`${classPrefix} ${className}`} style={style} {...rest}>
<View
className={`${classPrefix} ${className}`}
style={style}
{...(rest as any)}
>
{!left && renderContent(!left)}
{Number(value) !== 0 && (
<>
Expand All @@ -117,7 +123,7 @@ export const TrendArrow: FunctionComponent<
</>
)}
{left && renderContent(!left)}
</div>
</View>
)
}

Expand Down

0 comments on commit 16b173e

Please sign in to comment.