Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(splitter): 修复 collasped api 不起作用的问题、添加英文文档 #40

Merged
merged 3 commits into from
Dec 21, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
feat(splitter): 添加展开和收起提示文字
  • Loading branch information
jecyu committed Dec 19, 2021
commit 47a262b866976d1fe0fe2a504f9e90fe92fb8d1f
48 changes: 30 additions & 18 deletions packages/devui-vue/devui/splitter/src/splitter-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@ import {
defineComponent,
ref,
watch,
nextTick,
reactive,
computed,
withDirectives,
onMounted,
inject,
} from 'vue'
import type { SplitterStore } from './splitter-store'

import DToolTip from '../../tooltip/src/tooltip'
import { setStyle } from '../../shared/util/set-style'
import type { SplitterStore } from './splitter-store'
import { addClass, removeClass } from '../../shared/util/class'
import dresize, { ResizeDirectiveProp } from './util/d-resize-directive'
import './splitter-bar.scss'
import { splitterBarProps, SplitterBarProps } from './splitter-bar-type'
import './splitter-bar.scss'

export default defineComponent({
name: 'DSplitterBar',
props: splitterBarProps,
components: {
DToolTip,
},
setup(props: SplitterBarProps) {
const store: SplitterStore = inject('splitterStore')
const state = reactive({
Expand Down Expand Up @@ -109,8 +113,6 @@ export default defineComponent({
// 计算前面板收起操作样式
const prevClass = computed(() => {
const { pane, nearPane } = queryPanes(props.index, props.index + 1)
// TODO 提示文字

// 第一个面板或者其它面板折叠方向不是向后的, 显示操作按钮
const showIcon =
pane?.component?.props?.collapseDirection !== 'after' ||
Expand All @@ -121,8 +123,6 @@ export default defineComponent({
// 计算相邻面板收起操作样式
const nextClass = computed(() => {
const { pane, nearPane } = queryPanes(props.index + 1, props.index)
// TODO 提示文字

// 最后一个面板或者其它面板折叠方向不是向前的显示操作按钮
const showIcon =
pane?.component?.props?.collapseDirection !== 'before' ||
Expand Down Expand Up @@ -157,28 +157,40 @@ export default defineComponent({
handleCollapsePrePane(true)
handleCollapseNextPane(true)
}

onMounted(() => {
initialCollapseStatus()
})

const renderCollapsedTip = () => {
const { pane, nearPane } = queryPanes(props.index, props.index + 1)
const isCollapsed =
pane?.component?.props?.collapsed ||
nearPane?.component?.props?.collapsed
return isCollapsed ? '展开' : '收起'
}

return () => {
return withDirectives(
<div class={state.wrapperClass} ref={domRef}>
{props.showCollapseButton && (
<div
class={['prev', prevClass.value]}
onClick={() => {
handleCollapsePrePane()
}}
></div>
<DToolTip content={renderCollapsedTip()}>
<div
class={['prev', prevClass.value]}
onClick={() => {
handleCollapsePrePane()
}}
></div>
</DToolTip>
)}
<div class="devui-resize-handle"></div>
{props.showCollapseButton && (
<div
class={['next', nextClass.value]}
onClick={() => handleCollapseNextPane()}
></div>
<DToolTip content={renderCollapsedTip()}>
<div
class={['next', nextClass.value]}
onClick={() => handleCollapseNextPane()}
></div>
</DToolTip>
)}
</div>,
[[dresize, resizeProp]]
Expand Down