Skip to content

Commit

Permalink
Version - 0.0.61, popper arrow
Browse files Browse the repository at this point in the history
  • Loading branch information
ManukMinasyan committed Apr 3, 2024
1 parent 5011a7a commit 21cd88b
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 108 deletions.
5 changes: 5 additions & 0 deletions docs/overlays/demo/Tooltip/PopperArrow.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<STooltip text="Tooltip example" :shortcuts="['', 'O']" :popper="{ arrow: true }">
<SButton color="gray" label="Hover me" />
</STooltip>
</template>
19 changes: 18 additions & 1 deletion docs/overlays/tooltip.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
outline: deep
---

<script setup>
import Basic from './demo/Tooltip/Basic.vue';
import PopperArrow from './demo/Tooltip/PopperArrow.vue';
</script>

# Tooltip
Expand All @@ -12,4 +17,16 @@ Display content that appears on hover next to an element.
<Basic/>
</DemoContainer>

<<< @/overlays/demo/Tooltip/Basic.vue
<<< @/overlays/demo/Tooltip/Basic.vue

## Popper

Use the `popper` prop to customize the popper instance.

### Arrow

<DemoContainer>
<PopperArrow/>
</DemoContainer>

<<< @/overlays/demo/Tooltip/PopperArrow.vue
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stellar-ui",
"version": "0.0.60",
"version": "0.0.61",
"license": "MIT",
"scripts": {
"build": "rimraf dist && run-p build:stellar build:helpers",
Expand All @@ -15,7 +15,7 @@
},
"devDependencies": {
"@rollup/plugin-alias": "^5.1.0",
"@types/node": "^20.11.30",
"@types/node": "^20.12.3",
"@vitejs/plugin-vue": "^5.0.4",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-import": "^2.29.1",
Expand All @@ -24,8 +24,8 @@
"sass": "^1.72.0",
"tailwindcss": "^3.4.3",
"typescript": "latest",
"vite": "^5.2.6",
"vitepress": "^1.0.1",
"vite": "^5.2.8",
"vitepress": "^1.0.2",
"vue-tsc": "^2.0.7"
},
"files": [
Expand Down Expand Up @@ -87,7 +87,7 @@
"defu": "^6.1.4",
"fast-glob": "^3.3.2",
"fuse.js": "^7.0.0",
"joi": "^17.12.2",
"joi": "^17.12.3",
"lodash-es": "^4.17.21",
"mark.js": "^8.11.1",
"minisearch": "^6.3.0",
Expand Down
84 changes: 42 additions & 42 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions src/composables/usePopper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
popperOffsets,
applyStyles,
preventOverflow,
computeStyles
computeStyles,
arrow
} from '@popperjs/core'

import type {Instance} from '@popperjs/core'
Expand All @@ -19,7 +20,7 @@ import {MaybeElement, unrefElement} from '@vueuse/core'
import type {PopperOptions} from '../types'

export const createPopper = popperGenerator({
defaultModifiers: [popperOffsets, applyStyles, offset, flip, preventOverflow, computeStyles, eventListeners]
defaultModifiers: [popperOffsets, applyStyles, offset, flip, preventOverflow, computeStyles, eventListeners, arrow]
})

export function usePopper({
Expand Down Expand Up @@ -86,7 +87,12 @@ export function usePopper({
scroll,
resize
}
}]
},
{
name: 'arrow',
enabled: arrow
}
]
}, isUndefined))

onInvalidate(instance.value.destroy)
Expand Down
2 changes: 2 additions & 0 deletions src/types/popper.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Placement, PositioningStrategy } from '@popperjs/core'

export interface PopperOptions {
// Workaround for weak types: https://mariusschulz.com/blog/weak-type-detection-in-typescript#workarounds-for-weak-types
[key: string]: unknown
locked?: boolean
overflowPadding?: number
offsetDistance?: number
Expand Down
3 changes: 2 additions & 1 deletion src/ui.config/popper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export const arrow = {
rounded: 'before:rounded-sm',
background: 'before:bg-gray-200 dark:before:bg-gray-800',
shadow: 'before:shadow',
placement: 'group-data-[popper-placement*="right"]:-left-1 group-data-[popper-placement*="left"]:-right-1 group-data-[popper-placement*="top"]:-bottom-1 group-data-[popper-placement*="bottom"]:-top-1'
// eslint-disable-next-line quotes
placement: `group-data-[popper-placement*='right']:-left-1 group-data-[popper-placement*='left']:-right-1 group-data-[popper-placement*='top']:-bottom-1 group-data-[popper-placement*='bottom']:-top-1`
}
Loading

0 comments on commit 21cd88b

Please sign in to comment.