Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
42 changes: 17 additions & 25 deletions src/packages/backtop/demo.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import Taro from '@tarojs/taro'
import { ScrollView, View } from '@tarojs/components'
import { Cell } from '@nutui/nutui-react-taro'
import { useTranslate } from '@/sites/assets/locale/taro'
import Header from '@/sites/components/header'
import Demo1 from './demos/taro/demo1'
Expand All @@ -21,39 +20,32 @@ const BackTopDemo = () => {
},
})
const demoStyle = {
height: '100%',
height: 'auto',
minHeight: 'auto',
}

return (
<View
style={{
position: 'relative',
}}
>
<Header />
<>
{harmonyAndRn() ? (
<Demo5>
<View
<>
<View style={{ position: 'relative' }}>
<Header />
<Demo5 />
</View>
</>
) : (
<>
<Header />
<ScrollView
className={`demo ${Taro.getEnv() === 'WEB' ? 'web' : ''}`}
style={{ height: 'auto' }}
style={demoStyle}
>
<View className="h2">{translated.title}</View>
{new Array(24).fill(0).map((_, index) => {
return <Cell key={index}>我是测试数据{index}</Cell>
})}
</View>
</Demo5>
) : (
<ScrollView
className={`demo ${Taro.getEnv() === 'WEB' ? 'web' : ''}`}
style={demoStyle}
>
<View className="h2">{translated.title}</View>
<Demo1 />
</ScrollView>
<Demo1 />
</ScrollView>
</>
)}
</View>
</>
)
}

Expand Down
8 changes: 3 additions & 5 deletions src/packages/backtop/demos/taro/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react'
import { View, Icon } from '@tarojs/components'
import { View } from '@tarojs/components'
import { BackTop, Cell } from '@nutui/nutui-react-taro'
// @TODO 暂不支持
// import { Top } from '@nutui/icons-react-taro'
import { Top } from '@nutui/icons-react-taro'

const Demo1 = () => {
return (
Expand All @@ -24,8 +23,7 @@ const Demo1 = () => {
alignItems: 'center',
}}
>
<Icon size={12} type="search" />
{/* <Top size={12} /> */}
<Top size={12} />
<View style={{ fontSize: '12px' }}>顶部</View>
</View>
</BackTop>
Expand Down
22 changes: 11 additions & 11 deletions src/packages/backtop/demos/taro/demo5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
* JDRN 端最佳实践
*/
import React, { useRef, useState } from 'react'
import { ScrollView, View, Icon } from '@tarojs/components'
import { BackTop } from '@nutui/nutui-react-taro'
import Taro from '@tarojs/taro'
import { ScrollView, View } from '@tarojs/components'
import { BackTop, Cell } from '@nutui/nutui-react-taro'
import { Top } from '@nutui/icons-react-taro'
import pxTransform from '@/utils/px-transform'
import { harmony, rn } from '@/utils/platform-taro'
import { BasicComponent } from '@/utils/typings'
// @TODO 暂不支持
// import { Top } from '@nutui/icons-react-taro'

const Demo5 = (props: BasicComponent) => {
const { children } = props
const Demo5 = () => {
const [scrollRes, setScrollRes] = useState<any>(null)
const sv = useRef<any>(null)

Expand All @@ -31,9 +29,13 @@ const Demo5 = (props: BasicComponent) => {
ref={sv}
// @TODO RN 端暂不支持
// trapScroll={true}
className={`demo ${Taro.getEnv() === 'WEB' ? 'web' : ''}`}
style={{ height: 'auto' }}
>
{children}
<View className="h2">基础用法</View>
{new Array(24).fill(0).map((_, index) => {
return <Cell key={index}>我是测试数据{index}</Cell>
})}
</ScrollView>
<BackTop
threshold={200}
Expand All @@ -57,9 +59,7 @@ const Demo5 = (props: BasicComponent) => {
alignItems: 'center',
}}
>
<Icon size={12} type="search" />
{/* <Top size={12} /> */}
<View style={{ fontSize: pxTransform(12) }}>顶部</View>
<Top size={12} />
</View>
</BackTop>
</View>
Expand Down
Loading