Skip to content

Commit 94d516c

Browse files
committed
feat(range): 调整 demo
1 parent fbd01ea commit 94d516c

File tree

13 files changed

+186
-129
lines changed

13 files changed

+186
-129
lines changed

src/packages/range/demos/taro/demo1.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@ import React, { useMemo, useState } from 'react'
22
import { View } from '@tarojs/components'
33
import { Range, Cell /* , Toast */ } from '@nutui/nutui-react-taro'
44
import pxTransform from '@/utils/px-transform'
5+
import { harmonyAndRn } from '@/utils/platform-taro'
56

67
const Demo1 = () => {
7-
const cellStyle = useMemo(
8-
() => ({
9-
paddingTop: pxTransform(40),
10-
paddingBottom: pxTransform(40),
11-
paddingLeft: pxTransform(18),
12-
paddingRight: pxTransform(18),
13-
}),
14-
[]
15-
)
8+
const cellStyle = useMemo(() => {
9+
return harmonyAndRn()
10+
? {
11+
paddingTop: pxTransform(40),
12+
paddingBottom: pxTransform(40),
13+
paddingLeft: pxTransform(18),
14+
paddingRight: pxTransform(18),
15+
}
16+
: {
17+
padding: '40px 18px',
18+
}
19+
}, [])
1620
const [show, setShow] = useState(false)
1721
const [msg, setMsg] = useState('')
1822
const showToast = (msg: string) => {

src/packages/range/demos/taro/demo10.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import React, { useMemo } from 'react'
22
import { Range, ConfigProvider, Cell } from '@nutui/nutui-react-taro'
33
import pxTransform from '@/utils/px-transform'
4+
import { harmonyAndRn } from '@/utils/platform-taro'
45

56
const Demo10 = () => {
6-
const cellStyle = useMemo(
7-
() => ({
8-
paddingTop: pxTransform(40),
9-
paddingBottom: pxTransform(40),
10-
paddingLeft: pxTransform(18),
11-
paddingRight: pxTransform(18),
12-
}),
13-
[]
14-
)
7+
const cellStyle = useMemo(() => {
8+
return harmonyAndRn()
9+
? {
10+
paddingTop: pxTransform(40),
11+
paddingBottom: pxTransform(40),
12+
paddingLeft: pxTransform(18),
13+
paddingRight: pxTransform(18),
14+
}
15+
: {
16+
padding: '40px 18px',
17+
}
18+
}, [])
1519

1620
return (
1721
<Cell

src/packages/range/demos/taro/demo11.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
import React, { useMemo, useState } from 'react'
22
import { View, Text } from '@tarojs/components'
33
import { Range, Cell /* , Toast */ } from '@nutui/nutui-react-taro'
4-
import { rn, harmony } from '@/utils/platform-taro'
4+
import { rn, harmony, harmonyAndRn } from '@/utils/platform-taro'
55
import pxTransform from '@/utils/px-transform'
66

77
const Demo11 = () => {
8-
const cellStyle = useMemo(
9-
() => ({
10-
paddingTop: pxTransform(40),
11-
paddingBottom: pxTransform(40),
12-
paddingLeft: pxTransform(18),
13-
paddingRight: pxTransform(18),
14-
}),
15-
[]
16-
)
8+
const cellStyle = useMemo(() => {
9+
return harmonyAndRn()
10+
? {
11+
paddingTop: pxTransform(40),
12+
paddingBottom: pxTransform(40),
13+
paddingLeft: pxTransform(18),
14+
paddingRight: pxTransform(18),
15+
}
16+
: {
17+
padding: '40px 18px',
18+
}
19+
}, [])
1720

1821
const buttonNativeStyle = useMemo(() => {
1922
if (rn()) {
@@ -49,6 +52,7 @@ const Demo11 = () => {
4952
justifyContent: 'center',
5053
top: '50%',
5154
left: '50%',
55+
// @ts-ignore
5256
transform: 'translate(-50%, -50%)',
5357
...buttonNativeStyle,
5458
}}

src/packages/range/demos/taro/demo12.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@ import React, { useMemo, useState } from 'react'
22
import { View } from '@tarojs/components'
33
import { Range, Cell /* , Toast */ } from '@nutui/nutui-react-taro'
44
import pxTransform from '@/utils/px-transform'
5+
import { harmonyAndRn } from '@/utils/platform-taro'
56

67
const Demo12 = () => {
7-
const verticalStyle = useMemo(
8-
() => ({
9-
height: pxTransform(180),
10-
paddingTop: pxTransform(10),
11-
paddingBottom: pxTransform(10),
12-
paddingLeft: pxTransform(10),
13-
paddingRight: pxTransform(10),
14-
}),
15-
[]
16-
)
8+
const verticalStyle = useMemo(() => {
9+
return harmonyAndRn()
10+
? {
11+
height: pxTransform(180),
12+
paddingTop: pxTransform(10),
13+
paddingBottom: pxTransform(10),
14+
paddingLeft: pxTransform(10),
15+
paddingRight: pxTransform(10),
16+
}
17+
: {
18+
height: '180px',
19+
padding: '10px',
20+
}
21+
}, [])
1722
const viewStyle = useMemo(
1823
() => ({ width: pxTransform(150), height: '100%' }),
1924
[]

src/packages/range/demos/taro/demo13.tsx

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,35 @@ import React, { useMemo, useState } from 'react'
22
import { View } from '@tarojs/components'
33
import { Range, Cell /* , Toast */ } from '@nutui/nutui-react-taro'
44
import pxTransform from '@/utils/px-transform'
5+
import { harmonyAndRn } from '@/utils/platform-taro'
56

67
const Demo13 = () => {
7-
const cellStyle = useMemo(
8-
() => ({
9-
paddingTop: pxTransform(40),
10-
paddingBottom: pxTransform(40),
11-
paddingLeft: pxTransform(18),
12-
paddingRight: pxTransform(18),
13-
}),
14-
[]
15-
)
16-
const verticalStyle = useMemo(
17-
() => ({
18-
height: pxTransform(180),
19-
paddingTop: pxTransform(10),
20-
paddingBottom: pxTransform(10),
21-
paddingLeft: pxTransform(10),
22-
paddingRight: pxTransform(10),
23-
}),
24-
[]
25-
)
8+
const cellStyle = useMemo(() => {
9+
return harmonyAndRn()
10+
? {
11+
paddingTop: pxTransform(40),
12+
paddingBottom: pxTransform(40),
13+
paddingLeft: pxTransform(18),
14+
paddingRight: pxTransform(18),
15+
}
16+
: {
17+
padding: '40px 18px',
18+
}
19+
}, [])
20+
const verticalStyle = useMemo(() => {
21+
return harmonyAndRn()
22+
? {
23+
height: pxTransform(180),
24+
paddingTop: pxTransform(10),
25+
paddingBottom: pxTransform(10),
26+
paddingLeft: pxTransform(10),
27+
paddingRight: pxTransform(10),
28+
}
29+
: {
30+
height: '180px',
31+
padding: '10px',
32+
}
33+
}, [])
2634
const [marks] = useState({
2735
0: 'Start',
2836
20: 20,

src/packages/range/demos/taro/demo2.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import React, { useMemo, useState } from 'react'
22
import { Range, Cell } from '@nutui/nutui-react-taro'
33
import pxTransform from '@/utils/px-transform'
4+
import { harmonyAndRn } from '@/utils/platform-taro'
45

56
const Demo2 = () => {
6-
const cellStyle = useMemo(
7-
() => ({
8-
paddingTop: pxTransform(40),
9-
paddingBottom: pxTransform(40),
10-
paddingLeft: pxTransform(18),
11-
paddingRight: pxTransform(18),
12-
}),
13-
[]
14-
)
7+
const cellStyle = useMemo(() => {
8+
return harmonyAndRn()
9+
? {
10+
paddingTop: pxTransform(40),
11+
paddingBottom: pxTransform(40),
12+
paddingLeft: pxTransform(18),
13+
paddingRight: pxTransform(18),
14+
}
15+
: {
16+
padding: '40px 18px',
17+
}
18+
}, [])
1519
const [value, setValue] = useState(40)
1620
return (
1721
<Cell style={cellStyle}>

src/packages/range/demos/taro/demo3.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@ import React, { useMemo, useState } from 'react'
22
import { View } from '@tarojs/components'
33
import { Range, Cell /* , Toast */ } from '@nutui/nutui-react-taro'
44
import pxTransform from '@/utils/px-transform'
5+
import { harmonyAndRn } from '@/utils/platform-taro'
56

67
const Demo3 = () => {
7-
const cellStyle = useMemo(
8-
() => ({
9-
paddingTop: pxTransform(40),
10-
paddingBottom: pxTransform(40),
11-
paddingLeft: pxTransform(18),
12-
paddingRight: pxTransform(18),
13-
}),
14-
[]
15-
)
8+
const cellStyle = useMemo(() => {
9+
return harmonyAndRn()
10+
? {
11+
paddingTop: pxTransform(40),
12+
paddingBottom: pxTransform(40),
13+
paddingLeft: pxTransform(18),
14+
paddingRight: pxTransform(18),
15+
}
16+
: {
17+
padding: '40px 18px',
18+
}
19+
}, [])
1620
const [show, setShow] = useState(false)
1721
const [msg, setMsg] = useState('')
1822
const showToast = (msg: string) => {

src/packages/range/demos/taro/demo4.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@ import React, { useState, useMemo } from 'react'
22
import { View } from '@tarojs/components'
33
import { Range, Cell /* , Toast */ } from '@nutui/nutui-react-taro'
44
import pxTransform from '@/utils/px-transform'
5+
import { harmonyAndRn } from '@/utils/platform-taro'
56

67
const Demo4 = () => {
7-
const cellStyle = useMemo(
8-
() => ({
9-
paddingTop: pxTransform(40),
10-
paddingBottom: pxTransform(40),
11-
paddingLeft: pxTransform(18),
12-
paddingRight: pxTransform(18),
13-
}),
14-
[]
15-
)
8+
const cellStyle = useMemo(() => {
9+
return harmonyAndRn()
10+
? {
11+
paddingTop: pxTransform(40),
12+
paddingBottom: pxTransform(40),
13+
paddingLeft: pxTransform(18),
14+
paddingRight: pxTransform(18),
15+
}
16+
: {
17+
padding: '40px 18px',
18+
}
19+
}, [])
1620
const [show, setShow] = useState(false)
1721
const [msg, setMsg] = useState('')
1822
const showToast = (msg: string) => {

src/packages/range/demos/taro/demo5.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@ import React, { useMemo, useState } from 'react'
22
import { View } from '@tarojs/components'
33
import { Range, Cell /* , Toast */ } from '@nutui/nutui-react-taro'
44
import pxTransform from '@/utils/px-transform'
5+
import { harmonyAndRn } from '@/utils/platform-taro'
56

67
const Demo5 = () => {
7-
const cellStyle = useMemo(
8-
() => ({
9-
paddingTop: pxTransform(40),
10-
paddingBottom: pxTransform(40),
11-
paddingLeft: pxTransform(18),
12-
paddingRight: pxTransform(18),
13-
}),
14-
[]
15-
)
8+
const cellStyle = useMemo(() => {
9+
return harmonyAndRn()
10+
? {
11+
paddingTop: pxTransform(40),
12+
paddingBottom: pxTransform(40),
13+
paddingLeft: pxTransform(18),
14+
paddingRight: pxTransform(18),
15+
}
16+
: {
17+
padding: '40px 18px',
18+
}
19+
}, [])
1620
const [show, setShow] = useState(false)
1721
const [msg, setMsg] = useState('')
1822
const showToast = (msg: string) => {

src/packages/range/demos/taro/demo6.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@ import React, { useMemo, useState } from 'react'
22
import { View } from '@tarojs/components'
33
import { Range, Cell /* , Toast */ } from '@nutui/nutui-react-taro'
44
import pxTransform from '@/utils/px-transform'
5+
import { harmonyAndRn } from '@/utils/platform-taro'
56

67
const Demo6 = () => {
7-
const cellStyle = useMemo(
8-
() => ({
9-
paddingTop: pxTransform(40),
10-
paddingBottom: pxTransform(40),
11-
paddingLeft: pxTransform(18),
12-
paddingRight: pxTransform(18),
13-
}),
14-
[]
15-
)
8+
const cellStyle = useMemo(() => {
9+
return harmonyAndRn()
10+
? {
11+
paddingTop: pxTransform(40),
12+
paddingBottom: pxTransform(40),
13+
paddingLeft: pxTransform(18),
14+
paddingRight: pxTransform(18),
15+
}
16+
: {
17+
padding: '40px 18px',
18+
}
19+
}, [])
1620
const [show, setShow] = useState(false)
1721
const [msg, setMsg] = useState('')
1822
const showToast = (msg: string) => {

0 commit comments

Comments
 (0)