From 66aa000808d9e17c929ae04e7a7e36e188bb7a2e Mon Sep 17 00:00:00 2001 From: hirakei1203 Date: Sun, 16 Oct 2022 23:06:02 +0900 Subject: [PATCH] feature/add_tooltip_component --- .node-version | 1 + docs/.vitepress/config.ts | 2 +- .../tooltip/examples/TooltipExample.vue | 32 ++- .../tooltip/examples/TooltipStyleExample.vue | 34 +++ .../examples/TooltipTriggerExample.vue | 36 +++ docs/components/tooltip/tooltip.md | 254 +++++++++++++++++- package.json | 7 +- src/components/Tooltip/Tooltip.vue | 53 +++- src/components/Tooltip/types.ts | 2 + 9 files changed, 402 insertions(+), 19 deletions(-) create mode 100644 .node-version create mode 100644 docs/components/tooltip/examples/TooltipStyleExample.vue create mode 100644 docs/components/tooltip/examples/TooltipTriggerExample.vue create mode 100644 src/components/Tooltip/types.ts diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..357607e --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +16.6.2 diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 6ec6c3a..476dfae 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -47,6 +47,7 @@ function getComponents() { { text: 'ListGroup', link: 'components/listGroup/listGroup.md' }, { text: 'Toast', link: 'components/toast/toast.md' }, { text: 'Modal', link: 'components/modal/modal.md' }, + { text: 'Tooltip', link: 'components/tooltip/tooltip.md' }, { text: '- Accordion', link: 'components/accordion/accordion.md' }, { text: '- Carousel', link: 'components/carousel/carousel.md' }, @@ -58,7 +59,6 @@ function getComponents() { { text: '- Sidebar', link: 'components/sidebar/sidebar.md' }, { text: '- Table', link: 'components/table/table.md' }, { text: '- Timeline', link: 'components/timeline/timeline.md' }, - { text: '- Tooltip', link: 'components/tooltip/tooltip.md' }, ] } diff --git a/docs/components/tooltip/examples/TooltipExample.vue b/docs/components/tooltip/examples/TooltipExample.vue index 76b75c3..ab2fbe4 100644 --- a/docs/components/tooltip/examples/TooltipExample.vue +++ b/docs/components/tooltip/examples/TooltipExample.vue @@ -1,8 +1,32 @@ - diff --git a/docs/components/tooltip/examples/TooltipStyleExample.vue b/docs/components/tooltip/examples/TooltipStyleExample.vue new file mode 100644 index 0000000..fdaf066 --- /dev/null +++ b/docs/components/tooltip/examples/TooltipStyleExample.vue @@ -0,0 +1,34 @@ + + + diff --git a/docs/components/tooltip/examples/TooltipTriggerExample.vue b/docs/components/tooltip/examples/TooltipTriggerExample.vue new file mode 100644 index 0000000..1edbcf7 --- /dev/null +++ b/docs/components/tooltip/examples/TooltipTriggerExample.vue @@ -0,0 +1,36 @@ + + + diff --git a/docs/components/tooltip/tooltip.md b/docs/components/tooltip/tooltip.md index 608372b..a733135 100644 --- a/docs/components/tooltip/tooltip.md +++ b/docs/components/tooltip/tooltip.md @@ -1,15 +1,265 @@ # Vue Tooltip Component - Flowbite +## Demo + + + + + + ```vue + ``` - +## Placement + +The positioning of the tooltip element relative to the triggering element (eg. button, link) can be set using placement attribute with `top`, `top-start` , `top-end`, `bottom`, `bottom-start`, `bottom-end`, `right`, `right-start`, `right-end`, `left`, `left-start`, `left-end`, `auto`, `auto-start`, `auto-end`. +The default value is: `top` + +
+ + + + + + + + + + + + + + + + + + + + +
+ +```vue + + + +``` + +## Tooltip styles + +You can use choose between dark and light version styles for the tooltip component by changing the utility classes from Tailwind CSS and by applying the `tooltip-light` or `tooltip-dark` attribute. + +
+ + + + + + + + + +
+ +```vue + + + + + + + + + + + + + + + +``` + +## triggerType + +You can choose the triggering event by using the `hover` or `click` attributes to choose whether you want to show the tooltip when hovering or clicking on the element. By default this option is set to `click`. + +
+ + + + + + + + + +
+ + +```vue + + + + + + + +``` diff --git a/package.json b/package.json index d125f2d..33d7f11 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,8 @@ "typecheck": "vue-tsc --noEmit" }, "peerDependencies": { - "vue": "^3", - "tailwindcss": "^3" + "tailwindcss": "^3", + "vue": "^3" }, "devDependencies": { "@types/lodash": "^4.14.182", @@ -65,6 +65,7 @@ }, "dependencies": { "@vueuse/core": "^8.9.1", - "vitepress": "^1.0.0-alpha.4" + "vitepress": "^1.0.0-alpha.4", + "vue3-popper": "^1.5.0" } } diff --git a/src/components/Tooltip/Tooltip.vue b/src/components/Tooltip/Tooltip.vue index 1f24255..7fd86a7 100644 --- a/src/components/Tooltip/Tooltip.vue +++ b/src/components/Tooltip/Tooltip.vue @@ -1,15 +1,50 @@ + + + diff --git a/src/components/Tooltip/types.ts b/src/components/Tooltip/types.ts new file mode 100644 index 0000000..849702d --- /dev/null +++ b/src/components/Tooltip/types.ts @@ -0,0 +1,2 @@ +export type TooltipPlacement = "auto" | "auto-start" | "auto-end" | "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "right" | "right-start" | "right-end" | "left" | "left-start" | "left-end" | undefined; +export type TooltipStyle = "tooltip-dark" | "tooltip-light"; \ No newline at end of file