Skip to content

Commit

Permalink
refactor(comp:layout): remove onCollapse (#747)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `onCollapse` was removed
  • Loading branch information
danranVm committed Feb 9, 2022
1 parent af525d9 commit 3001bbd
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/components/divider/docs/Index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cover:
| --- | --- | --- | --- | --- | --- |
| `dashed` | 是否虚线 | `boolean` | `false` || - |
| `label` | 分割线显示文字 | `string \| #default` | - | - | `vertical` 模式下不可用 |
| `labelPlacement` | 文字显示位置 | `left \|center\| right` | `center`|| - |
| `labelPlacement` | 文字显示位置 | `'start' \| 'center' \| 'end'` | `center`|| - |
| `plain` | 文字是否显示为普通正文样式 | `boolean` | `false` || - |
| `size` | 分割线大小 | `'sm' \| 'md' \| 'lg'` | `md` || - |
| `vertical` | 是否为垂直分割线 | `boolean` | - | - | - |
12 changes: 6 additions & 6 deletions packages/components/grid/demo/Align.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<IxDivider position="left" dashed>Align top</IxDivider>
<IxRow justify="center" align="top">
<IxDivider position="left" dashed>Align start</IxDivider>
<IxRow justify="space-between" align="start">
<IxCol :span="4">
<div class="height-80">col-4</div>
</IxCol>
Expand All @@ -15,8 +15,8 @@
</IxCol>
</IxRow>

<IxDivider position="left" dashed>Align middle</IxDivider>
<IxRow justify="space-around" align="middle">
<IxDivider position="left" dashed>Align center</IxDivider>
<IxRow justify="space-between" align="center">
<IxCol :span="4">
<div class="height-80">col-4</div>
</IxCol>
Expand All @@ -31,8 +31,8 @@
</IxCol>
</IxRow>

<IxDivider position="left" dashed>Align bottom</IxDivider>
<IxRow justify="space-between" align="bottom">
<IxDivider position="left" dashed>Align end</IxDivider>
<IxRow justify="space-between" align="end">
<IxCol :span="4">
<div class="height-80">col-4</div>
</IxCol>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/header/docs/Index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ order: 0
| `description` | 标题下方的说明文字 | `string \| #description` | - | - | - |
| `disabled` | 是否禁用 | `boolean` | `false` | - | - |
| `prefix` | 标题前缀图标 | `string \| VNode \| #prefix` | - | - | - |
| `size` | 标题大小 | `xl \| lg \| md \| sm` | `md` | - | - |
| `size` | 标题大小 | `'xl' \| 'lg' \| 'md' \| 'sm'` | `'md'` | - | - |
| `showBar` | 是否显示标题前的竖条 | `boolean` | `false` | - | - |
| `subTitle` | 二级标题文字 | `string \| #subTitle` | - | - | - |
| `suffix` | 标题后缀图标 | `string \| VNode \| #suffix` | - | - | 通常用于额外操作 |
Expand Down
1 change: 0 additions & 1 deletion packages/components/layout/docs/Index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ order: 0
| --- | --- | --- | --- | --- | --- |
| `v-model:collapsed` | 是否折叠状态 | `boolean` | - | - | - |
| `breakpoint` | 触发响应式布局的断点 | `xs`, `sm`, `md`, `lg`, `xl` | - | - | - |
| `onCollapse` | 折叠状态发生变量时的回调 | `(collapsed: boolean, type: 'breakpoint \| trigger') => void` | - | - | - |
17 changes: 5 additions & 12 deletions packages/components/layout/src/LayoutSider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

import type { LayoutSiderProps } from './types'

import { WatchStopHandle, computed, defineComponent, normalizeClass, watch, watchEffect } from 'vue'
import { type WatchStopHandle, computed, defineComponent, normalizeClass, watch, watchEffect } from 'vue'

import { BREAKPOINTS_KEYS, useSharedBreakpoints } from '@idux/cdk/breakpoint'
import { callEmit, useControlledProp } from '@idux/cdk/utils'
import { useControlledProp } from '@idux/cdk/utils'
import { useGlobalConfig } from '@idux/components/config'

import { layoutSiderProps } from './types'
import { type LayoutSiderProps, layoutSiderProps } from './types'

export default defineComponent({
name: 'IxLayoutSider',
Expand All @@ -39,12 +37,7 @@ export default defineComponent({
})

const useCollapsed = (props: LayoutSiderProps) => {
const [collapsed, _setCollapsed] = useControlledProp(props, 'collapsed', false)

const changeCollapsed = (collapsed: boolean, type: 'trigger' | 'breakpoint') => {
_setCollapsed(collapsed)
callEmit(props.onCollapse, collapsed, type)
}
const [collapsed, setCollapsed] = useControlledProp(props, 'collapsed', false)

const breakpointIndex = computed(() => {
const { breakpoint } = props
Expand All @@ -62,7 +55,7 @@ const useCollapsed = (props: LayoutSiderProps) => {
const breakpoints = useSharedBreakpoints()
stopBreakpoints = watchEffect(() => {
const currBreakpointIndex = BREAKPOINTS_KEYS.findIndex(key => breakpoints[key])
changeCollapsed(currBreakpointIndex <= breakpointIndex.value, 'breakpoint')
setCollapsed(currBreakpointIndex <= breakpointIndex.value)
})
}
},
Expand Down
1 change: 0 additions & 1 deletion packages/components/layout/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export const layoutSiderProps = {

// events
'onUpdate:collapsed': IxPropTypes.emit<(collapsed: boolean) => void>(),
onCollapse: IxPropTypes.emit<(collapsed: boolean, type: 'trigger' | 'breakpoint') => void>(),
}

export type LayoutSiderProps = IxInnerPropTypes<typeof layoutSiderProps>
Expand Down

0 comments on commit 3001bbd

Please sign in to comment.