@gravity-ui/uikit
Version:
Gravity UI base styling and components
21 lines (20 loc) • 847 B
JavaScript
export function getOffset(value) {
return value < 100 ? value - 100 : 0;
}
export function getValueFromStack(stack) {
return stack.reduce((sum, { value }) => sum + value, 0);
}
export function getTheme(props) {
const { theme, colorStops, colorStopsValue, value } = props;
if (colorStops) {
const matchingColorStopItem = colorStops.find((item, index) => {
const currentValue = typeof colorStopsValue === 'number' ? colorStopsValue : value;
const minValue = index > 1 ? colorStops[index - 1].stop : 0;
const maxValue = index < colorStops.length - 1 ? item.stop : 100;
return currentValue >= minValue && currentValue <= maxValue;
});
return matchingColorStopItem ? matchingColorStopItem.theme : theme;
}
return theme;
}
//# sourceMappingURL=utils.js.map