Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(trendarrow): 多端适配 #2540

Merged
merged 16 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/nutui-taro-demo/bin/ts-node
1 change: 1 addition & 0 deletions packages/nutui-taro-demo/bin/ts-node-cwd
1 change: 1 addition & 0 deletions packages/nutui-taro-demo/bin/ts-node-esm
1 change: 1 addition & 0 deletions packages/nutui-taro-demo/bin/ts-node-script
1 change: 1 addition & 0 deletions packages/nutui-taro-demo/bin/ts-node-transpile-only
1 change: 1 addition & 0 deletions packages/nutui-taro-demo/bin/ts-script
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
9 changes: 7 additions & 2 deletions src/packages/trendarrow/demo.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Demo5 from './demos/taro/demo5'
import Demo6 from './demos/taro/demo6'
import Demo7 from './demos/taro/demo7'
import Demo8 from './demos/taro/demo8'
import { harmonyAndRn } from '@/utils/platform-taro'

const TrendArrowDemo = () => {
const [translated] = useTranslate({
Expand Down Expand Up @@ -64,8 +65,12 @@ const TrendArrowDemo = () => {
<Demo6 />
<View className="h2">{translated.title7}</View>
<Demo7 />
<View className="h2">{translated.title8}</View>
<Demo8 />
{!harmonyAndRn() && (
<>
<View className="h2">{translated.title8}</View>
<Demo8 />
</>
)}
</ScrollView>
</>
)
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
32 changes: 24 additions & 8 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 { harmonyAndRn } 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: '#ff0f23',
dropColor: '#14cc33',
Alex-huxiyang marked this conversation as resolved.
Show resolved Hide resolved
riseIcon: null,
dropIcon: null,
} as TrendArrowProps
Expand Down Expand Up @@ -96,28 +98,42 @@ 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}>
{!left && renderContent(!left)}
{Number(value) !== 0 && (
<>
{rateTrend.current ? (
<>{riseIcon || <TriangleUp color={calcIconProps.color} />}</>
<>
{riseIcon ||
(harmonyAndRn() ? (
<Text>⬆️</Text>
Alex-huxiyang marked this conversation as resolved.
Show resolved Hide resolved
) : (
<TriangleUp color={calcIconProps.color} />
))}
</>
) : (
<>{dropIcon || <TriangleDown color={calcIconProps.color} />}</>
<>
{dropIcon ||
(harmonyAndRn() ? (
<Text>⬇️</Text>
) : (
<TriangleDown color={calcIconProps.color} />
))}
</>
)}
</>
)}
{left && renderContent(!left)}
</div>
</View>
)
}

Expand Down