11<script setup lang="ts">
22import type { FileDiffResponse , FileChange , DiffHunk } from ' #shared/types'
33import { createDiff , insertSkipBlocks , countDiffStats } from ' #shared/utils/diff'
4+ import { onClickOutside } from ' @vueuse/core'
45import { motion } from ' motion-v'
56
67const props = defineProps <{
@@ -16,6 +17,10 @@ const maxDiffDistance = ref(30)
1617const inlineMaxCharEdits = ref (2 )
1718const wordWrap = ref (false )
1819const showOptions = ref (false )
20+ const optionsDropdownRef = useTemplateRef (' optionsDropdownRef' )
21+ onClickOutside (optionsDropdownRef , () => {
22+ showOptions .value = false
23+ })
1924const loading = ref (true )
2025const loadError = ref <Error | null >(null )
2126const diff = ref <FileDiffResponse | null >(null )
@@ -192,8 +197,8 @@ function getStepMarks(min: number, max: number, step: number): number[] {
192197 return marks
193198}
194199
195- const changeRatioMarks = computed (() => getStepMarks (0 , 1 , 0.01 ))
196- const diffDistanceMarks = computed (() => getStepMarks (1 , 60 , 1 ))
200+ const changeRatioMarks = computed (() => getStepMarks (0 , 1 , 0.1 ))
201+ const diffDistanceMarks = computed (() => getStepMarks (1 , 60 , 10 ))
197202const charEditMarks = computed (() => [] as number []) // no dots for char edits slider
198203const changeRatioPercent = computed (() => calcPercent (maxChangeRatio .value , 0 , 1 ))
199204const diffDistancePercent = computed (() => calcPercent (maxDiffDistance .value , 1 , 60 ))
@@ -260,7 +265,7 @@ function getCodeUrl(version: string): string {
260265
261266 <div class =" flex items-center gap-2 shrink-0" >
262267 <!-- Options dropdown -->
263- <div class =" relative" >
268+ <div ref = " optionsDropdownRef " class =" relative" >
264269 <button
265270 type =" button"
266271 class =" px-2 py-1 text-xs text-fg-muted hover:text-fg bg-bg-muted border border-border rounded transition-colors flex items-center gap-1.5"
@@ -278,7 +283,7 @@ function getCodeUrl(version: string): string {
278283 <!-- Dropdown menu -->
279284 <motion .div
280285 v-if =" showOptions"
281- class =" absolute right -0 top-full mt-2 z-20 p-4 bg-bg-elevated border border-border shadow-2xl overflow-auto"
286+ class =" absolute inset-ie -0 top-full mt-2 z-20 p-4 bg-bg-elevated border border-border shadow-2xl overflow-auto"
282287 :style =" {
283288 width: mergeModifiedLines
284289 ? 'min(420px, calc(100vw - 24px))'
0 commit comments