Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 3125586

Browse files
committed
feat: positioning examples
1 parent 4380dee commit 3125586

File tree

2 files changed

+46
-14
lines changed

2 files changed

+46
-14
lines changed
Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
11
<script setup lang="ts">
22
import { CTooltip, CTooltipTrigger, CTooltipContent } from "../src"
3-
import { CTag } from "../../vue/src"
3+
import { CButton, CSimpleGrid } from "../../vue/src"
4+
5+
const placements = [
6+
"top",
7+
"top-start",
8+
"top-end",
9+
"bottom",
10+
"bottom-start",
11+
"bottom-end",
12+
"left",
13+
"left-start",
14+
"left-end",
15+
"right",
16+
"right-start",
17+
"right-end",
18+
]
419
</script>
520

621
<template>
7-
<c-tooltip>
8-
<c-tooltip-trigger>
9-
<c-tag> Hover me </c-tag>
10-
</c-tooltip-trigger>
11-
<c-tooltip-content>Tooltip content</c-tooltip-content>
12-
</c-tooltip>
22+
<c-simple-grid
23+
gap="16"
24+
template-columns="repeat(3, auto)"
25+
grid-auto-flow="row"
26+
>
27+
<c-tooltip
28+
v-for="placement in placements"
29+
:key="placement"
30+
:positioning="{
31+
placement: placement as any,
32+
}"
33+
>
34+
<c-tooltip-trigger>
35+
<c-button> {{ placement }} </c-button>
36+
</c-tooltip-trigger>
37+
<c-tooltip-content>Tooltip content {{ placement }}</c-tooltip-content>
38+
</c-tooltip>
39+
</c-simple-grid>
1340
</template>

packages/c-tooltip/src/c-tooltip-content.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { computed, defineComponent, mergeProps } from "vue"
1+
import { Teleport, computed, defineComponent, mergeProps } from "vue"
22
import { useTooltipContext } from "./tooltip.context"
33
import {
44
HTMLChakraProps,
@@ -26,15 +26,20 @@ export const CTooltipContent = defineComponent({
2626
styleConfig: mergedProps.value.styleConfig,
2727
})
2828
)
29-
console.log("styles", themingProps.value)
3029
const styles = useStyleConfig("Tooltip", themingProps.value)
3130

3231
return () => (
33-
<CTooltipPositioner>
34-
<chakra.div __css={styles.value} {...api.value.contentProps} {...attrs}>
35-
{slots.default?.()}
36-
</chakra.div>
37-
</CTooltipPositioner>
32+
<Teleport to="body">
33+
<CTooltipPositioner>
34+
<chakra.div
35+
__css={styles.value}
36+
{...api.value.contentProps}
37+
{...attrs}
38+
>
39+
{slots.default?.()}
40+
</chakra.div>
41+
</CTooltipPositioner>
42+
</Teleport>
3843
)
3944
},
4045
})

0 commit comments

Comments
 (0)