Skip to content

Commit

Permalink
feat(tab): add prop scrollable
Browse files Browse the repository at this point in the history
  • Loading branch information
tiny-dust committed Mar 21, 2023
1 parent 7e56950 commit 26ccf6a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/varlet-ui/src/tabs/Tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default defineComponent({
}
const watchScrollable = () => {
scrollable.value = tabList.length >= 5
scrollable.value = props.scrollable === 'always' || tabList.length >= 5
}
const moveIndicator = ({ element }: TabProvider) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/varlet-ui/src/tabs/docs/en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ const active = ref(0)
| `sticky-z-index` | Sticky layouts z-index | _number_ | `10` |
| `safe-area` | Whether to enable bottom safe area adaptation | _boolean_ | `false` |
| `offset-top` | Distance offset top | _string \| number_ | `0` |

| `scrollable` | Whether to enable scrollable, optional value of `auto` `always` | _string_ | `auto` |
#### Tab Props

| Prop | Description | Type | Default |
Expand Down
1 change: 1 addition & 0 deletions packages/varlet-ui/src/tabs/docs/zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ const active = ref(0)
| `sticky-z-index` | 粘性布局的层级 | _number_ | `10` |
| `safe-area` | 是否开启底部安全区适配 | _boolean_ | `false` |
| `offset-top` | 吸顶距离 | _string \| number_ | `0` |
| `scrollable` | 是否开启滚动,可选值为 `auto` `always` | _string_ | `auto` |

#### Tab Props

Expand Down
9 changes: 9 additions & 0 deletions packages/varlet-ui/src/tabs/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ function directionValidator(direction: string) {
return ['horizontal', 'vertical'].includes(direction)
}

function scrollableValidator(scrollable: string) {
return ['auto', 'always'].includes(scrollable)
}

export const props = {
active: {
type: [String, Number],
Expand Down Expand Up @@ -58,6 +62,11 @@ export const props = {
type: Boolean,
default: false,
},
scrollable: {
type: String as PropType<'auto' | 'always'>,
default: 'auto',
validator: scrollableValidator,
},
onClick: defineListenerProp<(active: string | number) => void>(),
onChange: defineListenerProp<(active: string | number) => void>(),
'onUpdate:active': defineListenerProp<(active: string | number) => void>(),
Expand Down

0 comments on commit 26ccf6a

Please sign in to comment.