Skip to content

Commit

Permalink
组件+
Browse files Browse the repository at this point in the history
  • Loading branch information
hyl committed May 13, 2024
1 parent b203747 commit 6dbfdd5
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 47 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"preview": "vitepress preview docs",
"type-check": "vue-tsc --build --force",
"release": "vite build --config release.config.ts",
"test": "vitest"
"test": "vitest",
"dev-web": "vite"
},
"dependencies": {
"@floating-ui/vue": "^1.0.6",
Expand Down
4 changes: 3 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<template>
<div />
<div>
<e-tooltip content="11111"><e-button>111</e-button></e-tooltip>
</div>
</template>

<script setup lang="ts">
Expand Down
13 changes: 6 additions & 7 deletions src/components/Dropdown/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
</template>

<script setup lang="ts">
import type { Options, Placement, Trigger } from '@/components/common'
import type { Options, TooltipProps } from '@/components/common'
withDefaults(
defineProps<{
placement?: Placement
content?: string
trigger?: Trigger
options?: Options
}>(),
defineProps<
TooltipProps & {
options?: Options
}
>(),
{ options: [] as any, trigger: 'click' }
)
Expand Down
13 changes: 3 additions & 10 deletions src/components/Popover/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,9 @@
<script setup lang="ts">
import { inject } from 'vue'
import { $config, $configInit } from '@/config'
import type { Placement, Trigger } from '@/components/common'
import type { TooltipProps } from '@/components/common'
withDefaults(
defineProps<{
placement?: Placement
content?: string
trigger?: Trigger
}>(),
{ placement: 'bottom' }
)
withDefaults(defineProps<TooltipProps>(), { placement: 'bottom' })
const { ns } = inject($config, $configInit)!
const { ns } = inject($config, $configInit)
</script>
17 changes: 5 additions & 12 deletions src/components/Tooltip/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,16 @@ import { inject, ref, watch, nextTick, onMounted, onUnmounted, computed } from '
import { $config, $configInit } from '@/config'
import { computePosition, flip, offset, shift, useFloating } from '@floating-ui/vue'
import { debounce } from 'lodash'
import type { Placement, Trigger } from '@/components/common'
import type { TooltipProps } from '@/components/common'
defineOptions({
inheritAttrs: false
})
const props = withDefaults(
defineProps<{
placement?: Placement
content?: string
trigger?: Trigger
}>(),
{
placement: 'top',
trigger: 'hover'
}
)
const props = withDefaults(defineProps<TooltipProps>(), {
placement: 'top',
trigger: 'hover'
})
const { ns } = inject($config, $configInit)!
Expand Down
32 changes: 17 additions & 15 deletions src/components/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ export type Options = { label: string; value: string }[]

export type Direction = 'vertical' | 'horizontal'

export type Trigger = 'hover' | 'click'

export type Placement =
| 'top'
| 'top-start'
| 'top-end'
| 'bottom'
| 'bottom-start'
| 'bottom-end'
| 'left'
| 'left-start'
| 'left-end'
| 'right'
| 'right-start'
| 'right-end'
export interface TooltipProps {
placement?:
| 'top'
| 'top-start'
| 'top-end'
| 'bottom'
| 'bottom-start'
| 'bottom-end'
| 'left'
| 'left-start'
| 'left-end'
| 'right'
| 'right-start'
| 'right-end'
content?: string
trigger?: 'hover' | 'click'
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue", "src/**/*.ts","docs/**/*.vue"],
"include": ["env.d.ts", "src/**/*", "src/**/*.vue", "src/**/*.ts","docs/**/*.vue","docs/**/*.ts"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
Expand Down

0 comments on commit 6dbfdd5

Please sign in to comment.