Files
codex-proxy-rs/frontend/src/components/AnimatedMetricValue.vue
T
f0484c4e11 chore(frontend): upgrade ESLint config to v10 and migrate formatting (#522)
* chore(deps-dev): bump @antfu/eslint-config in /frontend

Bumps [@antfu/eslint-config](https://github.com/antfu/eslint-config) from 9.5.1 to 10.0.0.
- [Release notes](https://github.com/antfu/eslint-config/releases)
- [Commits](https://github.com/antfu/eslint-config/compare/v9.5.1...v10.0.0)

---
updated-dependencies:
- dependency-name: "@antfu/eslint-config"
  dependency-version: 10.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(frontend): migrate formatting to ESLint v10

Co-authored-by: Codex <noreply@openai.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Zyy <zyycn@users.noreply.github.com>
Co-authored-by: Codex <noreply@openai.com>
2026-10-26 11:34:32 +08:00

47 lines
1.1 KiB
Vue

<script setup lang="ts">
import { TransitionPresets, usePreferredReducedMotion, useTransition } from '@vueuse/core'
import { computed } from 'vue'
type MetricValueFormatter = (value: number) => string
const props = withDefaults(
defineProps<{
value: string
rawValue?: number | null
formatter?: MetricValueFormatter
duration?: number
}>(),
{
rawValue: null,
duration: 520,
},
)
const preferredMotion = usePreferredReducedMotion()
const hasAnimatedValue = computed(
() =>
typeof props.rawValue === 'number'
&& Number.isFinite(props.rawValue)
&& Boolean(props.formatter),
)
const sourceValue = computed(() => (hasAnimatedValue.value
? (props.rawValue ?? 0)
: 0))
const disabled = computed(() => preferredMotion.value === 'reduce' || !hasAnimatedValue.value)
const animatedValue = useTransition(sourceValue, {
duration: computed(() => props.duration),
easing: TransitionPresets.easeOutCubic,
disabled,
})
const displayValue = computed(() =>
hasAnimatedValue.value && props.formatter
? props.formatter(animatedValue.value)
: props.value,
)
</script>
<template>
<span>{{ displayValue }}</span>
</template>