-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
480 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<template> | ||
<div | ||
class="pdf-object__addon" | ||
:class="classNames"> | ||
<slot /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { | ||
computed, | ||
defineComponent, | ||
PropType, | ||
} from 'vue-demi' | ||
import { AddonPositionVariant } from '.' | ||
export default defineComponent({ | ||
props: { | ||
position: { | ||
type : String as PropType<AddonPositionVariant>, | ||
default: 'right', | ||
}, | ||
}, | ||
setup (props) { | ||
const classNames = computed(() => { | ||
const result: string[] = [] | ||
if (props.position) | ||
result.push(`pdf-object__addon--${props.position}`) | ||
return result | ||
}) | ||
return { classNames } | ||
}, | ||
}) | ||
</script> | ||
|
||
<style lang="postcss"> | ||
.pdf-object { | ||
&__addon { | ||
@apply absolute; | ||
&--right { | ||
@apply top-0 left-full pl-2; | ||
} | ||
&--left { | ||
@apply top-0 right-full pr-2; | ||
} | ||
&--top { | ||
@apply bottom-full left-0 pb-2; | ||
} | ||
&--bottom { | ||
@apply top-full left-0 pt-2; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<template> | ||
<div | ||
ref="target" | ||
class="pdf-object__debugger"> | ||
<pre>x: {{ x }}</pre> | ||
<pre>y: {{ y }}</pre> | ||
<pre>page: {{ page }}</pre> | ||
<pre>width: {{ width }}</pre> | ||
<pre>height: {{ height }}</pre> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { | ||
autoPlacement, | ||
autoUpdate, | ||
computePosition, | ||
offset, | ||
} from '@floating-ui/dom' | ||
import { templateRef } from '@vueuse/core' | ||
import { | ||
defineComponent, | ||
inject, | ||
watchEffect, | ||
} from 'vue-demi' | ||
import { PDF_OBJECT_CONTEXT } from '.' | ||
export default defineComponent({ | ||
setup () { | ||
const { | ||
x, | ||
y, | ||
page, | ||
width, | ||
height, | ||
} = inject(PDF_OBJECT_CONTEXT) | ||
const target = templateRef<HTMLDivElement>('target') | ||
watchEffect((onCleanup) => { | ||
if (target.value) { | ||
const cleanup = autoUpdate(target.value.parentElement, target.value, () => { | ||
computePosition(target.value.parentElement, target.value, { | ||
strategy : 'absolute', | ||
middleware: [autoPlacement(), offset(12)], | ||
}).then(({ x, y }) => { | ||
if (target.value) { | ||
target.value.style.left = `${x || 0}px` | ||
target.value.style.top = `${y || 0}px` | ||
} | ||
}) | ||
}) | ||
onCleanup(cleanup) | ||
} | ||
}, { flush: 'post' }) | ||
return { | ||
x, | ||
y, | ||
page, | ||
width, | ||
height, | ||
} | ||
}, | ||
}) | ||
</script> | ||
|
||
<style lang="postcss"> | ||
.pdf-object { | ||
&__debugger { | ||
@apply grid grid-cols-1 p-4 bg-emphasis text-on-emphasis absolute rounded w-[198px]; | ||
> pre { | ||
@apply truncate; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.