~bigbes/lethe

ref: c01a501a4fb0fe47f94c8f36c9e18f73d9571619 lethe/web/src/primitives/Spark.tsx -rw-r--r-- 613 bytes
c01a501a — Eugene Blikh web: PKCE machinery + Authorization-header attachment in apiFetch 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>
  )
}