~bigbes/lethe

ref: 717e25b528bcecf9364e792de85b8b467a137ef4 lethe/web/src/primitives/Spark.tsx -rw-r--r-- 613 bytes
717e25b5 — Eugene Blikh config: add auth.oidc.dev_stub block (disabled by default) a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import type React from 'react'

interface SparkProps {
  points: number[]
  w?: number
  h?: number
  accent?: boolean
}

export function Spark({ points, w = 60, h = 16, accent = false }: SparkProps): React.JSX.Element {
  const ptStr = points
    .map((v, i) => `${((i / Math.max(points.length - 1, 1)) * w).toFixed(1)},${v.toFixed(1)}`)
    .join(' ')

  return (
    <svg
      width={w}
      height={h}
      viewBox={`0 0 ${w} ${h}`}
      preserveAspectRatio="none"
      style={{ display: 'block' }}
    >
      <polyline points={ptStr} className={'spark' + (accent ? ' accent' : '')} />
    </svg>
  )
}