Files
webapp/app/components/catalog/PriceSparkline.vue
Ruslan Bakiev 2b6cccdead
All checks were successful
Build Docker Image / build (push) Successful in 5m8s
Fix all TypeScript errors and remove Storybook
- Remove all Storybook files and configuration
- Add type declarations for @vueuse/core, @formkit/core, vue3-apexcharts
- Fix TypeScript configuration (typeRoots, include paths)
- Fix Sentry config - move settings to plugin
- Fix nullable prop assignments with ?? operator
- Fix type narrowing issues with explicit type assertions
- Fix Card component linkable computed properties
- Update codegen with operationResultSuffix
- Fix GraphQL operation type definitions
2026-01-26 00:32:36 +07:00

62 lines
1.3 KiB
Vue

<template>
<div class="w-20 h-10">
<Line :data="chartData" :options="chartOptions" />
</div>
</template>
<script setup lang="ts">
import { Line } from 'vue-chartjs'
import {
Chart as ChartJS,
LineElement,
PointElement,
LinearScale,
CategoryScale,
Filler
} from 'chart.js'
ChartJS.register(LineElement, PointElement, LinearScale, CategoryScale, Filler)
const props = defineProps<{
data: number[]
}>()
const isUptrend = computed(() => {
if (props.data.length < 2) return true
const last = props.data[props.data.length - 1]
const first = props.data[0]
return (last ?? 0) >= (first ?? 0)
})
const lineColor = computed(() => isUptrend.value ? '#22c55e' : '#ef4444')
const chartData = computed(() => ({
labels: props.data.map((_, i) => i.toString()),
datasets: [{
data: props.data,
borderColor: lineColor.value,
backgroundColor: `${lineColor.value}20`,
borderWidth: 1.5,
fill: true,
tension: 0.3,
pointRadius: 0
}]
}))
const chartOptions = {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { display: false },
tooltip: { enabled: false }
},
scales: {
x: { display: false },
y: { display: false }
},
elements: {
line: { borderCapStyle: 'round' as const }
}
}
</script>