UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) 814 B
import{jsx as n,jsxs as g}from"react/jsx-runtime";import"./HeatmapLegend.scss";import h from"classnames";import{getColorFromGradient as f}from"../../utils/color-gradient";const _=(e,r)=>{const t=r-e;return t<=0?2:Math.min(t+1,5)},j=({min:e,max:r,palette:t,ariaLabel:c,className:d,style:m})=>{const s=_(e,r),i=Array.from({length:s},(a,o)=>{const u=o/(s-1),l=Math.round(e+(r-e)*u);return{value:l,color:f(l,e,r,t)}}),p=`linear-gradient(to right, ${i.map(a=>a.color).join(", ")})`;return g("div",{className:h("efp-heatmap-legend",d),style:m,role:"img","aria-label":c,children:[n("div",{className:"efp-heatmap-legend__colors",style:{background:p},"aria-hidden":"true"}),n("div",{className:"efp-heatmap-legend__values",children:i.map(({value:a},o)=>n("span",{"aria-hidden":"true",children:a},o))})]})};export default j;