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

Commit 4380dee

Browse files
committed
feat: create toolip
1 parent 563b9f3 commit 4380dee

11 files changed

+87
-10
lines changed

packages/c-tooltip/examples/simple-c-tooltip.vue

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script setup lang="ts">
2+
import { CTooltip, CTooltipTrigger, CTooltipContent } from "../src"
3+
import { CTag } from "../../vue/src"
4+
</script>
5+
6+
<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>
13+
</template>

packages/c-tooltip/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"dev": "tsup --watch"
3535
},
3636
"dependencies": {
37+
"@chakra-ui/c-tooltip": "workspace:*",
3738
"@chakra-ui/vue-composables": "workspace:*",
3839
"@chakra-ui/vue-system": "workspace:*",
3940
"@chakra-ui/vue-utils": "workspace:*",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { computed, defineComponent, watchEffect } from "vue"
1+
import { computed, defineComponent } from "vue"
22
import { useTooltipContext } from "./tooltip.context"
33
import { HTMLChakraProps, chakra } from "@chakra-ui/vue-system"
44

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { computed, defineComponent, mergeProps } from "vue"
2+
import { useTooltipContext } from "./tooltip.context"
3+
import {
4+
HTMLChakraProps,
5+
ThemingProps,
6+
chakra,
7+
useStyleConfig,
8+
} from "@chakra-ui/vue-system"
9+
import { CTooltipPositioner } from "./c-tooltip-positioner"
10+
import { filterUndefined } from "@chakra-ui/utils"
11+
import { vueThemingProps } from "@chakra-ui/vue-utils"
12+
13+
export type CTooltipContentProps = HTMLChakraProps<"div">
14+
export const CTooltipContent = defineComponent({
15+
name: "CTooltipContent",
16+
props: vueThemingProps,
17+
setup(props, { slots, attrs }) {
18+
const api = useTooltipContext()
19+
20+
const mergedProps = computed(() => mergeProps(props, attrs))
21+
const themingProps = computed<ThemingProps>(() =>
22+
filterUndefined({
23+
colorScheme: mergedProps.value.colorScheme,
24+
variant: mergedProps.value.variant,
25+
size: mergedProps.value.size,
26+
styleConfig: mergedProps.value.styleConfig,
27+
})
28+
)
29+
console.log("styles", themingProps.value)
30+
const styles = useStyleConfig("Tooltip", themingProps.value)
31+
32+
return () => (
33+
<CTooltipPositioner>
34+
<chakra.div __css={styles.value} {...api.value.contentProps} {...attrs}>
35+
{slots.default?.()}
36+
</chakra.div>
37+
</CTooltipPositioner>
38+
)
39+
},
40+
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { computed, defineComponent, watchEffect } from "vue"
1+
import { computed, defineComponent } from "vue"
22
import { useTooltipContext } from "./tooltip.context"
33
import { HTMLChakraProps, chakra } from "@chakra-ui/vue-system"
44

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { computed, defineComponent } from "vue"
2+
import { useTooltipContext } from "./tooltip.context"
3+
import { withSingleton } from "@chakra-ui/vue-utils"
4+
5+
export const CTooltipTrigger = defineComponent({
6+
name: "CTooltipTrigger",
7+
setup(_, { slots, attrs }) {
8+
const api = useTooltipContext()
9+
return () =>
10+
withSingleton(slots, "CPopoverTrigger", {
11+
...api.value.triggerProps,
12+
...attrs,
13+
})
14+
},
15+
})

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010

1111
import { computed, defineComponent, h, Fragment, PropType } from "vue"
12-
import { chakra, DOMElements } from "@chakra-ui/vue-system"
1312
import { TooltipProvider } from "./tooltip.context"
1413
import { useTooltip, UseTooltipProps } from "./use-tooltip"
1514
import type * as PP from "@zag-js/popper"

packages/c-tooltip/src/index.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
11
export { CTooltip, type CTooltipProps } from "./c-tooltip"
2+
export { CTooltipArrow, type CTooltipArrowProps } from "./c-tooltip-arrow"
3+
export {
4+
CTooltipPositioner,
5+
type CTooltipPositionerProps,
6+
} from "./c-tooltip-positioner"
7+
export { tooltipAnatomy } from "./tooltip.anatomy"
8+
export {
9+
useTooltip,
10+
type UseTooltipProps,
11+
type UseTooltipReturn,
12+
} from "./use-tooltip"
13+
export { CTooltipContent, type CTooltipContentProps } from "./c-tooltip-content"
14+
export { CTooltipTrigger } from "./c-tooltip-trigger"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { anatomy as tooltipAnatomy } from "@zag-js/tooltip"

0 commit comments

Comments
 (0)