Skip to content

Commit

Permalink
feat: ellipsis新增定制Tooltip功能 (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanchun committed Mar 30, 2022
1 parent cf26ffa commit 0a70dab
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
6 changes: 3 additions & 3 deletions components/ellipsis/ellipsis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export default defineComponent({
.filter(Boolean)
);
const styleRef = computed(() => {
const _style = props.style;
const _style : CSSProperties = props.style;
if (props.line > 1) {
_style['-webkit-line-clamp'] = props.line;
_style['-webkit-line-clamp'] = Number(props.line);
}
return _style;
});
Expand Down Expand Up @@ -92,7 +92,7 @@ export default defineComponent({
placement="top"
{...toolTipPropsRef.value}
v-slots={{
content: slots.default,
content: slots.tooltip ?? slots.default,
}}
>
{renderTrigger()}
Expand Down
8 changes: 3 additions & 5 deletions docs/.vitepress/components/ellipsis/common.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<template>
<Space>
<FEllipsis style="max-width: 240px">
住在我心里孤独的 孤独的海怪 痛苦之王 开始厌倦 深海的光 停滞的海浪
</FEllipsis>
</Space>
<FEllipsis style="max-width: 240px">
住在我心里孤独的 孤独的海怪 痛苦之王 开始厌倦 深海的光 停滞的海浪
</FEllipsis>
</template>
6 changes: 4 additions & 2 deletions docs/.vitepress/components/ellipsis/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ app.use(FEllipsis);

### 基础用法


--COMMON

### 最大行数


--LINE

### 定制 Tooltip 内容

--TOOLTIP

--CODE

<style scoped>
Expand Down
10 changes: 4 additions & 6 deletions docs/.vitepress/components/ellipsis/line.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<template>
<Space>
<FEllipsis :line="2">
电灯熄灭 物换星移 泥牛入海<br />黑暗好像 一颗巨石 按在胸口<br />独脚大盗
百万富翁 摸爬滚打<br />黑暗好像 一颗巨石 按在胸口
</FEllipsis>
</Space>
<FEllipsis :line="2">
电灯熄灭 物换星移 泥牛入海<br />黑暗好像 一颗巨石 按在胸口<br />独脚大盗
百万富翁 摸爬滚打<br />黑暗好像 一颗巨石 按在胸口
</FEllipsis>
</template>
13 changes: 13 additions & 0 deletions docs/.vitepress/components/ellipsis/tooltip.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>
<FEllipsis :line="2">
电灯熄灭 物换星移 泥牛入海<br />黑暗好像 一颗巨石 按在胸口<br />独脚大盗
百万富翁 摸爬滚打<br />黑暗好像 一颗巨石 按在胸口
<template #tooltip>
<div style="width: 200px; text-align: center">
<h>《静夜思》</h>
<p>床前明月光,疑是地上霜。</p>
<p>举头望明月,低头思故乡。</p>
</div>
</template>
</FEllipsis>
</template>

0 comments on commit 0a70dab

Please sign in to comment.