-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(components): optimize popup & tooltip components
- Loading branch information
Showing
16 changed files
with
341 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
title: ToolTip | ||
lang: en-US | ||
--- | ||
|
||
# ToolTip <new-badge/> | ||
|
||
Tooltip can be used to show a message when hovering over an element. | ||
|
||
|
||
## Basic | ||
|
||
Move the mouse in or click to pop up bubbles, which can operate on the elements on the floating layer, and carry complex content and operations. | ||
|
||
<demo src="../example/tooltip/basic.vue"></demo> | ||
|
||
## Theme | ||
|
||
Tooltip has two built-in themes: `Dark` and `Light`. | ||
|
||
Set `type` to modify theme, the default is `Dark`. | ||
|
||
<demo src="../example/tooltip/type.vue"></demo> | ||
|
||
|
||
## Trigger | ||
|
||
By setting `trigger`, you can specify different trigger methods. | ||
|
||
They are: `hover` | `click` | `focus` | `context-menu`. | ||
|
||
<demo src="../example/tooltip/trigger.vue"></demo> | ||
|
||
|
||
## Position | ||
|
||
`Tooltip` supports 12 different positions. They are: `top` `left` `right` `bottom` `top-left` `top-right` `bottom-left` `bottom-right` `left-top` `left-bottom` `right-top` `right-bottom`. | ||
|
||
<demo src="../example/tooltip/position.vue"></demo> | ||
|
||
## Custom Background Color | ||
|
||
Customize the background color through the `background-color` property. | ||
|
||
<demo src="../example/tooltip/bg.vue"></demo> | ||
|
||
|
||
|
||
## Tooltip Props | ||
|
||
| Name | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| popup-visible / v-model | `boolean` | `undefined` | Whether the ToolTip is visible. | | ||
| default-popup-visible | `boolean` | `false` | Whether the ToolTip is visible by default (`uncontrolled mode`). | | ||
| content | `string`|`undefined`| Content. | | ||
| type | `'Dark' \| 'Light'` | `'Dark'` | ToolTip type. | | ||
| trigger | `'hover' \| 'click' \| 'focus' \| 'contextMenu'`|`'hover'` | `'hover'` | Trigger method. | | ||
| position | `'top' \| 'top-left' \| 'top-right' \| 'bottom' \| 'bottom-left' \| 'bottom-right' \| 'left' \| 'left-top' \| 'left-bottom' \| 'right' \| 'right-top' \| 'right-bottom'`|`'top'` | ToolTip position. | | ||
| background-color | `string` | `undefined` | The backgroundColor of the ToolTip content. | | ||
| content-class | `string` | `undefined` | The class name of the ToolTip content. | | ||
| content-style | `CSSProperties` | `undefined` | The style of the ToolTip content. | | ||
| arrow-class | `string` | `undefined` | The class name of the ToolTip arrow. | | ||
| arrow-style | `CSSProperties` | `undefined` | The style of the ToolTip arrow. | | ||
| popup-container | `string \| HTMLElement \| undefined` | `undefined` | Mount container for ToolTip box. | | ||
|
||
|
||
## Tooltip Slots | ||
|
||
|
||
| Name | Parameters | Description | | ||
| --- | --- | --- | | ||
| content | `()` | Custom ToolTip content. | | ||
|
||
## Tooltip Methods | ||
|
||
| Name | Parameters | Description | | ||
| --- | --- | --- | | ||
| popup-visible-change | `(visible: boolean) => void` | Triggered when the text bubble display status changes. | | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<template> | ||
<div space-y-2> | ||
<div fscw gap-2> | ||
<o-tool-tip content="Here is the text content"> | ||
<o-button type="primary"> | ||
Hover | ||
</o-button> | ||
</o-tool-tip> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<template> | ||
<div space-y-2> | ||
<div fscw gap-2> | ||
<OToolTip content="Here is the text content" background-color="#722ED1"> | ||
<o-button type="secondary"> | ||
Custom | ||
</o-button> | ||
</OToolTip> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<template> | ||
<div grid="~ gap-3 cols-1 md:cols-2 xl:cols-3" mx-auto> | ||
<OToolTip position="top-left"> | ||
<o-button type="success"> | ||
top-left | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
<OToolTip position="top"> | ||
<o-button type="success"> | ||
top | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
<OToolTip position="top-right"> | ||
<o-button type="success"> | ||
top-right | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
<OToolTip position="bottom-left"> | ||
<o-button type="success"> | ||
bottom-left | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
<OToolTip position="bottom"> | ||
<o-button type="success"> | ||
bottom | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
<OToolTip position="bottom-right"> | ||
<o-button type="success"> | ||
bottom-right | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
<OToolTip position="left-top"> | ||
<o-button type="success"> | ||
left-top | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
<OToolTip position="left"> | ||
<o-button type="success"> | ||
left | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
<OToolTip position="left-bottom"> | ||
<o-button type="success"> | ||
left-bottom | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
<OToolTip position="right-top"> | ||
<o-button type="success"> | ||
right-top | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
<OToolTip position="right"> | ||
<o-button type="success"> | ||
right | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
<OToolTip position="right-bottom"> | ||
<o-button type="success"> | ||
right-bottom | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<script lang="ts" setup> | ||
const handleVisibleChange = (visible: boolean) => { | ||
// eslint-disable-next-line no-console | ||
console.log(visible) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div space-y-2> | ||
<div fscw gap-2> | ||
<OToolTip> | ||
<o-button type="error"> | ||
Hover | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
<OToolTip trigger="click"> | ||
<o-button type="secondary"> | ||
Click | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
<OToolTip trigger="context-menu"> | ||
<o-button type="success"> | ||
Context-menu | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
<OToolTip | ||
trigger="focus" | ||
@popup-visible-change="handleVisibleChange" | ||
> | ||
<o-button type="warning"> | ||
Focus | ||
</o-button> | ||
<template #content> | ||
Here is the text content | ||
</template> | ||
</OToolTip> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<template> | ||
<div space-y-2> | ||
<div fscw gap-2> | ||
<o-tool-tip content="Here is the text content" type="Dark"> | ||
<o-button> | ||
Dark | ||
</o-button> | ||
</o-tool-tip> | ||
<o-tool-tip content="Here is the text content" type="Light"> | ||
<o-button> | ||
Light | ||
</o-button> | ||
</o-tool-tip> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.