Overview
The Openlane UI library provides a collection of utility functions for common tasks including class name merging, chart color management, and window event handling.Styling Utilities
cn
Merges Tailwind CSS class names with support for conditional classes. Location:packages/ui/lib/utils.ts:4
inputs- Variable number of class values (strings, objects, arrays)
Chart Utilities
chartColors
Predefined color palette for charts with support for background, stroke, fill, and text utilities. Location:packages/ui/lib/chartUtils.tsx:3
blue- Primary blue colorsaffron- Yellow/saffron colorjade- Green/jade colorpink- Pink colorpurple- Purple colorred- Red colorgrey- Gray color
constructCategoryColors
Maps categories to chart colors in a round-robin fashion. Location:packages/ui/lib/chartUtils.tsx:56
categories- Array of category namescolors- Array of color keys to use
getColorClassName
Retrieves the Tailwind class name for a specific color and utility type. Location:packages/ui/lib/chartUtils.tsx:64
color- The color key (e.g., ‘blue’, ‘saffron’)type- The utility type: ‘bg’ | ‘stroke’ | ‘fill’ | ‘text’
getYAxisDomain
Calculates the Y-axis domain for charts with support for auto-scaling. Location:packages/ui/lib/chartUtils.tsx:74
autoMinValue- Whether to auto-calculate minimum valueminValue- Optional explicit minimum valuemaxValue- Optional explicit maximum value
hasOnlyOneValueForKey
Checks if all objects in an array have the same value for a specific key. Location:packages/ui/lib/chartUtils.tsx:80
array- Array of objects to checkkeyToCheck- The key to compare across objects
true if all objects have the same value for the key
Example:
Error Handling Utilities
getErrorMessage
Extracts user-friendly error messages from various error types. Location:packages/ui/hooks/use-upload-file.ts:95
err- Error of any type (ZodError, Error, or unknown)
showErrorToast
Displays an error message in a toast notification. Location:packages/ui/hooks/use-upload-file.ts:111
err- Error of any type
Stream Processing Utilities
markdownJoinerTransform
Transform stream for processing markdown chunks in AI-generated content. Location:packages/ui/lib/markdown-joiner-transform.ts:9
MarkdownJoiner
Class for buffering and joining markdown syntax elements. Location:packages/ui/lib/markdown-joiner-transform.ts:72
processText(text)- Process text chunk and return complete markdown elementsflush()- Flush remaining buffer contents