Skip to content

Commit

Permalink
Merge pull request #90 from webpilot-ai/dev
Browse files Browse the repository at this point in the history
Dev to Main
  • Loading branch information
CocoSgt committed Nov 6, 2023
2 parents 0874189 + dd145d5 commit 64bc001
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/components/FloatControlButtons.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<template>
<ul :class="$style.control">
<li v-show="!showBack" :class="$style.box">
<Popper hover offset-distance="14" offset-skid="-4" placement="right">
<Popper hover offset-distance="2" offset-skid="-4" placement="right">
<InteractiveIcon :class="$style.btn" type="close" @click="popupClose" />
<template #content>
<span :class="$style.popover">{{ $gettext('Close') }}</span>
</template>
</Popper>
</li>
<li v-show="showBack" :class="$style.box">
<Popper hover offset-distance="14" offset-skid="-4" placement="right">
<Popper hover offset-distance="2" offset-skid="-4" placement="right">
<InteractiveIcon :class="$style.btn" type="previous" @click="popupBack" />
<template #content>
<span :class="$style.popover">{{ $gettext('Back') }}</span>
</template>
</Popper>
</li>
<li v-show="showSetting" :class="$style.box">
<Popper hover offset-distance="14" offset-skid="-4" placement="right">
<Popper hover offset-distance="2" offset-skid="-4" placement="right">
<InteractiveIcon :class="$style.btn" type="setting" @click="openSettingPage" />
<template #content>
<span :class="$style.popover">{{ $gettext('Settings') }}</span>
</template>
</Popper>
</li>
<li v-show="showCopy" :class="$style.box">
<Popper hover offset-distance="14" offset-skid="-4" placement="right">
<Popper hover offset-distance="2" offset-skid="-4" placement="right">
<InteractiveIcon :class="$style.btn" type="copy" @click="handleCopy" />
<template #content>
<span :class="$style.popover">{{ $gettext('Copy') }}</span>
Expand Down
1 change: 1 addition & 0 deletions src/components/PromptEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ref="textareaRef"
v-model="command"
:class="$style.content__textarea"
maxlength="2048"
:placeholder="prompt.command || $gettext('Set a prompt here')"
/>
<article :class="$style.content__back">
Expand Down
8 changes: 4 additions & 4 deletions src/components/PromptMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ const handleEditPrompt = index => {
height: 20px;
margin: 0 6px;
padding: 0 6px;
color: var(--webpilot-theme-main-text-color, #292929);
color: var(--webpilot-theme-main-text-color, #292929) !important;
font-weight: 600;
font-size: 12px;
font-size: 12px !important;
line-height: 20px;
border: 1px solid var(--webpilot-theme-stoke-and-hover-status, #dcdee1);
border-radius: 10px;
Expand All @@ -148,8 +148,8 @@ const handleEditPrompt = index => {
flex: 1;
margin: 0;
padding: 8px 0;
color: var(--webpilot-theme-main-text-color, #292929);
font-size: 14px;
color: var(--webpilot-theme-main-text-color, #292929) !important;
font-size: 14px !important;
line-height: 22px;
text-align: left;
}
Expand Down
12 changes: 12 additions & 0 deletions src/components/image/IconDraggingDark.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/components/image/IconDraggingLight.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 33 additions & 6 deletions src/csui/Index/TheEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
}"
>
<ThePopupBox id="webpilot_popup" :is-ask-page="isAskPage" @close-popup="handleClosePopup" />
<section ref="refDragHandle" :class="$style.dragHandle"></section>
<section
ref="refDragHandle"
:class="[$style.draggingBody, {[$style.draggingHand]: isDragging}]"
/>
</section>
</template>

Expand Down Expand Up @@ -110,7 +113,12 @@ const updateTextAndPosition = textAndPosition => {
useSelectedText(updateTextAndPosition)
const {offsetY: tailScrollYOffset, resetScroll} = useScroll(refTail, targetElementRef)
const {offsetX: dragOffsetX, offsetY: dragOffsetY, resetDrag} = useDraggable(refDragHandle)
const {
offsetX: dragOffsetX,
offsetY: dragOffsetY,
resetDrag,
isDragging,
} = useDraggable(refDragHandle)
// keyboard
const keys = useMagicKeys()
Expand Down Expand Up @@ -277,13 +285,32 @@ const shortcutText = computed(() => {
background-color: #fff;
}
.dragHandle {
.draggingBody {
position: absolute;
top: 0;
top: -10px;
left: 0;
width: 612px;
height: 8px;
cursor: move;
height: 18px;
background: var(--webpilot-theme-content-background-color, #fff) center / 14px no-repeat;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
cursor: grab;
user-select: none;
/* stylelint-disable */
&.draggingHand {
cursor: grabbing;
}
/* stylelint-enable */
&:hover {
background-image: url('data-base64:~src/components/image/IconDraggingLight.svg');
}
}
@media (prefers-color-scheme: dark) {
.draggingBody:hover {
background-image: url('data-base64:~src/components/image/IconDraggingDark.svg');
}
}
</style>
2 changes: 1 addition & 1 deletion src/csui/Index/ThePopupBox/ThePopupBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ const handleCommandChange = () => {
}
const handleInputFocus = () => {
if (showPrompts.value && !showResult.value) inputCommand.value = ''
// if (showPrompts.value && !showResult.value) inputCommand.value = ''
if (!showPrompts.value && showResult.value) handleShowMenu()
}
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/useDraggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default function useDraggable(element) {
const lastOffset = {x: 0, y: 0}
const offsetX = ref(0)
const offsetY = ref(0)
const isDragging = ref(false)

const handleMousemove = e => {
const {clientX: x, clientY: y} = e
Expand All @@ -20,10 +21,12 @@ export default function useDraggable(element) {
originPosition.y = e.clientY

document.addEventListener('mousemove', handleMousemove)
isDragging.value = true
document.addEventListener('mouseup', () => {
lastOffset.x = offsetX.value
lastOffset.y = offsetY.value
document.removeEventListener('mousemove', handleMousemove)
isDragging.value = false
})
}

Expand All @@ -37,6 +40,7 @@ export default function useDraggable(element) {

onUnmounted(() => {
element.value.removeEventListener('mousedown', startListenMove)
isDragging.value = false
})

const resetDrag = () => {
Expand All @@ -48,5 +52,5 @@ export default function useDraggable(element) {
offsetY.value = 0
}

return {offsetX, offsetY, resetDrag}
return {offsetX, offsetY, resetDrag, isDragging}
}

0 comments on commit 64bc001

Please sign in to comment.