generated from Blazity/next-enterprise
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1376a2
commit 79e5b9c
Showing
10 changed files
with
266 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
import { getColorScale } from "components/PercentileLineChart"; | ||
const TooltipDot: React.FC<{value:number, inverted?:boolean}> = ({value, inverted}) => { | ||
const colorScale = getColorScale(inverted) | ||
const clampedValue = Math.min(100, Math.max(0, value)) | ||
const color = colorScale(clampedValue) | ||
return ( | ||
<div className="h-4 w-4 rounded-full" style={{backgroundColor: color}}></div> | ||
) | ||
} | ||
|
||
export const LeadSectionsRenderer: React.FC<{ sections: any[] }> = ({ sections }) => { | ||
return ( | ||
<div className="flex flex-row justify-between align-middle gap-2"> | ||
{sections.map((section, i) => ( | ||
<div key={i} className="text-sm flex flex-col w-24"> | ||
<div className="flex flex-row items-center gap-2"> | ||
<p className="text-3xl">{(section.formatter ? | ||
section.formatter(section.value) : section.value) || '--'}</p> | ||
{section.value !== undefined && <TooltipDot value={section.value} inverted={section.inverted} />} | ||
</div> | ||
<b className="text-xs">{section.label}</b> | ||
</div> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
|
||
export const TooltipSectionsRenderer: React.FC<{ sections: any[], children?:React.ReactNode }> = ({ sections, children }) => { | ||
const leadSections = sections.filter((section) => section.category === 'lead') | ||
const nonLeadSections = sections.filter((section) => section.category !== 'lead') | ||
return ( | ||
<> | ||
{/* flex lead sections in each row label as small text */} | ||
<LeadSectionsRenderer sections={leadSections} /> | ||
{/* flex non lead sections in each row */} | ||
{children} | ||
<p className="text-xs pt-4"> | ||
<i>Click for more info</i> | ||
</p> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export const adjustTooltipToMousePosition = (x:number, y:number, tooltipWidth: number): {left?:number, top?:number, right?:number, bottom?:number} => { | ||
const screenWidth = window.innerWidth | ||
const screenHeight = window.innerHeight | ||
// if in bottom right quadrant of screen | ||
// move tooltip to the left | ||
const quadrantX = x > screenWidth / 2 ? "right" : "left" | ||
const quadrantY = y > screenHeight / 2 ? "bottom" : "top" | ||
let cssProps: {left?:number, top?:number, right?:number, bottom?:number} = { | ||
|
||
} | ||
if (quadrantX === "right") { | ||
cssProps['right'] = screenWidth - x + 10 | ||
} else { | ||
cssProps = {left: x + 10} | ||
} | ||
if (quadrantY === "bottom") { | ||
cssProps['bottom'] = screenHeight - y + 10 | ||
} else { | ||
cssProps['top'] = y + 10 | ||
} | ||
|
||
return cssProps | ||
} |
Oops, something went wrong.