Skip to content

Commit 34a31ac

Browse files
committed
fix: update props
1 parent 40830e7 commit 34a31ac

File tree

9 files changed

+44
-64
lines changed

9 files changed

+44
-64
lines changed

src/packages/elevator/doc.en-US.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { Elevator } from '@nutui/nutui-react'
5656

5757
| Property | Description | Type | Default |
5858
| --- | --- | --- | --- |
59+
| mode | Elevator structure display mode | `horizontal` \| `vertical` | `horizontal` |
5960
| height | Height of elevator area | `number` \| `string` | `200px` |
6061
| floorKey | Index key value | `string` | `title` |
6162
| list | Index list | `Array(item needs to contain id and name attributes, and name supports passing in html structure)` | `[{id: 0, name: ''}]` |

src/packages/elevator/doc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { Elevator } from '@nutui/nutui-react'
5656

5757
| 属性 | 说明 | 类型 | 默认值 |
5858
| --- | --- | --- | --- |
59+
| mode | 电梯结构展示模式 | `horizontal` \| `vertical` | `horizontal` |
5960
| height | 电梯区域的高度 | `number` \| `string` | `200px` |
6061
| floorKey | 索引 key 值 | `string` | `title` |
6162
| list | 索引列表 | `Array(item 需包含 id、name 属性, name 支持传入 html 结构)` | `[{id: 0, name: ''}]` |

src/packages/elevator/doc.taro.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { Elevator } from '@nutui/nutui-react-taro'
5656

5757
| 属性 | 说明 | 类型 | 默认值 |
5858
| --- | --- | --- | --- |
59+
| mode | 电梯结构展示模式 | `horizontal` \| `vertical` | `horizontal` |
5960
| height | 电梯区域的高度 | `number` \| `string` | `200px` |
6061
| floorKey | 索引 key 值 | `string` | `title` |
6162
| list | 索引列表 | `Array(item 需包含 id、name 属性, name 支持传入 html 结构)` | `[{id: 0, name: ''}]` |

src/packages/elevator/doc.zh-TW.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { Elevator } from '@nutui/nutui-react'
5656

5757
| 屬性 | 說明 | 類型 | 默認值 |
5858
| --- | --- | --- | --- |
59+
| mode | 電梯結構展示模式 | `horizontal` \| `vertical` | `horizontal` |
5960
| height | 電梯區域的高度 | `number` \| `string` | `200px` |
6061
| floorKey | 索引 key 值 | `string` | `title` |
6162
| list | 索引列表 | `Array(item 需包含 id、name 屬性, name 支持傳入 html 結構)` | `[{id: 0, name: ''}]` |
@@ -79,30 +80,23 @@ import { Elevator } from '@nutui/nutui-react'
7980
| \--nutui-elevator-list-item-padding | 樓層區域列表項內邊距 | `0 36px 0 20px` |
8081
| \--nutui-elevator-list-item-name-height | 樓層區域列表項高度 | `34px` |
8182
| \--nutui-elevator-list-item-code-font-size | 樓層區域列表項標題字體大小 | `$font-size-base` |
82-
| \--nutui-elevator-list-item-code-color | 樓層區域列表項標題顏色 | `$color-title` |
83+
| \--nutui-elevator-list-item-code-color | 樓層區域列表項標題顏色 | `$color-text-help` |
8384
| \--nutui-elevator-list-item-code-font-weight | 樓層區域列表項標題字體粗細 | `$font-weight-bold` |
84-
| \--nutui-elevator-list-item-code-height | 樓層區域列表項標題高度 | `35px` |
85-
| \--nutui-elevator-list-item-code-line-height | 樓層區域列表項標題行高 | `35px` |
85+
| \--nutui-elevator-list-item-code-height | 樓層區域列表項標題高度 | `34px` |
8686
| \--nutui-elevator-list-item-code-border-bottom | 樓層區域列表項標題下邊框寬度 | `1px solid $color-border` |
87-
| \--nutui-elevator-list-item-code-background-color | 樓層區域列表項標題背景色 | `inherit` |
88-
| \--nutui-elevator-list-item-code-current-bg-color | 電梯提示背景顏色 | `#fff` |
87+
| \--nutui-elevator-list-item-code-current-bg-color | 電梯提示背景顏色 | `$color-text-disabled` |
8988
| \--nutui-elevator-list-item-code-current-border-radius | 電梯提示圓角 | `50%` |
9089
| \--nutui-elevator-list-item-code-current-width | 電梯提示寬度 | `45px` |
9190
| \--nutui-elevator-list-item-code-current-height | 電梯提示高度 | `45px` |
92-
| \--nutui-elevator-list-item-code-current-line-height | 電梯提示行高 | `45px` |
9391
| \--nutui-elevator-list-item-code-current-right | 電梯提示定位後右邊緣位置 | `60px` |
9492
| \--nutui-elevator-list-item-code-current-top | 電梯提示定位後top邊緣位置 | `50%` |
95-
| \--nutui-elevator-list-item-code-current-text-align | 電梯提示文字對齊方式 | `center` |
96-
| \--nutui-elevator-bars-right | 電梯樓層定位後右邊緣位置 | `10px` |
93+
| \--nutui-elevator-bars-right | 電梯樓層定位後右邊緣位置 | `16px` |
9794
| \--nutui-elevator-bars-top | 電梯樓層定位後頂部邊緣位置 | `50%` |
9895
| \--nutui-elevator-bars-transform | 電梯樓層定位後滑動距離 | `translateY(-50%)` |
99-
| \--nutui-elevator-bars-padding | 電梯樓層內邊距 | `15px 0` |
100-
| \--nutui-elevator-bars-background-color | 電梯樓層背景顏色 | `#eeeff2` |
101-
| \--nutui-elevator-bars-border-radius | 電梯樓層圓角大小 | `6px` |
102-
| \--nutui-elevator-bars-active-color | 電梯樓層高亮文字顏色 | `$color-primary` |
96+
| \--nutui-elevator-bars-active-color | 電梯樓層高亮文字顏色 | `white` |
97+
| \--nutui-elevator-bars-color | 電梯樓層文字顏色 | `$color-text-help` |
10398
| \--nutui-elevator-bars-z-index | 電梯樓層層級 | `1` |
104-
| \--nutui-elevator-bars-inner-item-padding | 電梯樓層標識項內邊距 | `3px` |
105-
| \--nutui-elevator-bars-font-size | 電梯樓層標識項字體大小 | `10px` |
99+
| \--nutui-elevator-bars-font-size | 電梯樓層標識項字體大小 | `$font-size-xxs` |
106100
| \--nutui-elevator-list-fixed-color | 吸頂樓層文字顏色 | `$color-primary` |
107101
| \--nutui-elevator-list-fixed-bg-color | 吸頂樓層背景顏色 | `$white` |
108102
| \--nutui-elevator-list-fixed-box-shadow | 吸頂樓層陰影 | `0 0 10px #eee` |

src/packages/elevator/elevator.taro.tsx

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,14 @@ import React, {
99
import Taro, { nextTick, createSelectorQuery } from '@tarojs/taro'
1010
import { ScrollView, View, Text } from '@tarojs/components'
1111
import classNames from 'classnames'
12-
import { BasicComponent, ComponentDefaults } from '@/utils/typings'
12+
import { ComponentDefaults } from '@/utils/typings'
1313
import { harmony } from '@/utils/taro/platform'
1414
import { useUuid } from '@/hooks/use-uuid'
1515
import raf from '@/utils/raf'
16+
import { ElevatorItem, TaroElevatorProps } from '@/types'
1617

17-
export const elevatorContext = createContext({} as ElevatorData)
18+
export const elevatorContext = createContext({} as ElevatorItem)
1819

19-
export interface ElevatorProps extends BasicComponent {
20-
mode: 'horizontal' | 'vertical'
21-
height: number | string
22-
floorKey: string
23-
list: any[]
24-
sticky: boolean
25-
spaceHeight: number
26-
showKeys: boolean
27-
onItemClick: (key: string, item: ElevatorData) => void
28-
onIndexClick: (key: string) => void
29-
}
3020
const defaultProps = {
3121
...ComponentDefaults,
3222
mode: 'horizontal',
@@ -36,14 +26,10 @@ const defaultProps = {
3626
sticky: false,
3727
spaceHeight: 18,
3828
showKeys: true,
39-
} as ElevatorProps
40-
interface ElevatorData {
41-
name: string
42-
id: number | string
43-
[key: string]: string | number
44-
}
29+
} as TaroElevatorProps
30+
4531
export const Elevator: FunctionComponent<
46-
Partial<ElevatorProps> & React.HTMLAttributes<HTMLDivElement>
32+
Partial<TaroElevatorProps> & React.HTMLAttributes<HTMLDivElement>
4733
> & { Context: typeof elevatorContext } = (props) => {
4834
const {
4935
mode,
@@ -76,8 +62,8 @@ export const Elevator: FunctionComponent<
7662
y2: 0,
7763
})
7864

79-
const [currentData, setCurrentData] = useState<ElevatorData>(
80-
{} as ElevatorData
65+
const [currentData, setCurrentData] = useState<ElevatorItem>(
66+
{} as ElevatorItem
8167
)
8268
const [currentKey, setCurrentKey] = useState('')
8369
const [codeIndex, setCodeIndex] = useState<number>(0)
@@ -170,7 +156,7 @@ export const Elevator: FunctionComponent<
170156
scrollTo(index)
171157
}
172158

173-
const handleClickItem = (key: string, item: ElevatorData) => {
159+
const handleClickItem = (key: string, item: ElevatorItem) => {
174160
onItemClick && onItemClick(key, item)
175161
setCurrentData(item)
176162
setCurrentKey(key)
@@ -249,7 +235,7 @@ export const Elevator: FunctionComponent<
249235
{item[floorKey]}
250236
</View>
251237
<View className={`${classPrefix}-list-item-sublist`}>
252-
{item.list.map((subitem: ElevatorData) => {
238+
{item.list.map((subitem: ElevatorItem) => {
253239
return (
254240
<View
255241
className={classNames({

src/packages/elevator/elevator.tsx

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,11 @@ import React, {
88
import { useGesture } from '@use-gesture/react'
99
import { animated } from '@react-spring/web'
1010
import classNames from 'classnames'
11-
import { BasicComponent, ComponentDefaults } from '@/utils/typings'
11+
import { ComponentDefaults } from '@/utils/typings'
12+
import { ElevatorItem, WebElevatorProps } from '@/types'
1213

13-
export const elevatorContext = createContext({} as ElevatorData)
14+
export const elevatorContext = createContext({} as ElevatorItem)
1415

15-
export interface ElevatorProps extends BasicComponent {
16-
mode: 'horizontal' | 'vertical'
17-
height: number | string
18-
floorKey: string
19-
list: any[]
20-
sticky: boolean
21-
spaceHeight: number
22-
showKeys: boolean
23-
onItemClick: (key: string, item: ElevatorData) => void
24-
onIndexClick: (key: string) => void
25-
}
2616
const defaultProps = {
2717
...ComponentDefaults,
2818
mode: 'horizontal',
@@ -32,14 +22,10 @@ const defaultProps = {
3222
sticky: false,
3323
spaceHeight: 18,
3424
showKeys: true,
35-
} as ElevatorProps
36-
interface ElevatorData {
37-
name: string
38-
id: number | string
39-
[key: string]: string | number
40-
}
25+
} as WebElevatorProps
26+
4127
export const Elevator: FunctionComponent<
42-
Partial<ElevatorProps> & React.HTMLAttributes<HTMLDivElement>
28+
Partial<WebElevatorProps> & React.HTMLAttributes<HTMLDivElement>
4329
> & { Context: typeof elevatorContext } = (props) => {
4430
const {
4531
mode,
@@ -72,8 +58,8 @@ export const Elevator: FunctionComponent<
7258
y2: 0,
7359
})
7460
const [scrollY, setScrollY] = useState(0)
75-
const [currentData, setCurrentData] = useState<ElevatorData>(
76-
{} as ElevatorData
61+
const [currentData, setCurrentData] = useState<ElevatorItem>(
62+
{} as ElevatorItem
7763
)
7864
const [currentKey, setCurrentKey] = useState('')
7965
const [currentIndex, setCurrentIndex] = useState<number>(0)
@@ -148,7 +134,7 @@ export const Elevator: FunctionComponent<
148134
},
149135
})
150136

151-
const handleClickItem = (key: string, item: ElevatorData) => {
137+
const handleClickItem = (key: string, item: ElevatorItem) => {
152138
onItemClick && onItemClick(key, item)
153139
setCurrentData(item)
154140
setCurrentKey(key)
@@ -224,7 +210,7 @@ export const Elevator: FunctionComponent<
224210
{item[floorKey]}
225211
</div>
226212
<div className={`${classPrefix}-list-item-sublist`}>
227-
{item.list.map((subitem: ElevatorData) => {
213+
{item.list.map((subitem: ElevatorItem) => {
228214
return (
229215
<div
230216
className={classNames({

src/sites/sites-react/doc/docs/react/migrate-from-v2.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ plugins: [
112112

113113
### 导航组件
114114

115-
[//]: # '#### Elevator'
115+
#### Elevator
116+
117+
- 新增 `mode` 属性,可选值 `'horizontal'``'vertical'`,默认 `horizontal`
118+
- 移除 `titleHeight` 属性, 代码中未使用。
119+
116120
[//]: # '#### FixedNav'
117121

118122
#### Indicator

src/sites/sites-react/doc/docs/taro/migrate-from-v2.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ plugins: [
112112

113113
### 导航组件
114114

115-
[//]: # '#### Elevator'
115+
#### Elevator
116+
117+
- 新增 `mode` 属性,可选值 `'horizontal'``'vertical'`,默认 `horizontal`
118+
- 移除 `titleHeight` 属性, 代码中未使用。
119+
116120
[//]: # '#### FixedNav'
117121

118122
#### Indicator

src/types/spec/elevator/base.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ export type ElevatorList = {
1515
[key: ElevatorFloorKey]: string // 只允许其他属性为字符串
1616
}
1717

18+
export type ElevatorMode = 'horizontal' | 'vertical'
19+
1820
export interface BaseElevator extends BaseProps {
21+
mode: ElevatorMode
1922
height: SimpleValue
2023
floorKey: ElevatorFloorKey
2124
list: ElevatorList[]

0 commit comments

Comments
 (0)