Skip to content

Commit 5426326

Browse files
committed
feat(Tooltip): 支持多个展开方向
1 parent e4ac2fb commit 5426326

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

packages/devui-vue/devui/tooltip/src/tooltip-types.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
import type { ComputedRef, ExtractPropTypes, PropType, Ref } from 'vue';
22

3-
export type BasePlacement = 'top' | 'right' | 'bottom' | 'left';
3+
export type Alignment = 'start' | 'end';
4+
export type BasePlacement =
5+
| 'top'
6+
| 'right'
7+
| 'bottom'
8+
| 'left'
9+
| 'top-start'
10+
| 'top-end'
11+
| 'right-start'
12+
| 'right-end'
13+
| 'bottom-start'
14+
| 'bottom-end'
15+
| 'left-start'
16+
| 'left-end';
417

518
export const tooltipProps = {
619
content: {
@@ -11,6 +24,10 @@ export const tooltipProps = {
1124
type: [String, Array] as PropType<BasePlacement | Array<BasePlacement>>,
1225
default: 'top',
1326
},
27+
align: {
28+
type: String as PropType<Alignment> | null,
29+
default: null,
30+
},
1431
showAnimation: {
1532
type: Boolean,
1633
default: true,
@@ -34,7 +51,7 @@ export const tooltipProps = {
3451
hideAfter: {
3552
type: Number,
3653
default: 0,
37-
}
54+
},
3855
};
3956

4057
export type TooltipProps = ExtractPropTypes<typeof tooltipProps>;

packages/devui-vue/devui/tooltip/src/tooltip.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default defineComponent({
1111
name: 'DTooltip',
1212
props: tooltipProps,
1313
setup(props: TooltipProps, { slots }) {
14-
const { showAnimation, content } = toRefs(props);
14+
const { showAnimation, content, align } = toRefs(props);
1515
const origin = ref<HTMLElement>();
1616
const tooltipRef = ref<HTMLElement>();
1717
const { visible, placement, positionArr, overlayStyles, onPositionChange, onMouseleave, onMouseenterOverlay } = useTooltip(
@@ -37,6 +37,7 @@ export default defineComponent({
3737
class={className.value}
3838
origin={origin.value}
3939
position={positionArr.value}
40+
align={align.value}
4041
offset={6}
4142
show-arrow
4243
style={overlayStyles.value}

0 commit comments

Comments
 (0)