@gravity-ui/uikit
Version:
Gravity UI base styling and components
26 lines (25 loc) • 1.01 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getOffset = getOffset;
exports.getValueFromStack = getValueFromStack;
exports.getTheme = getTheme;
function getOffset(value) {
return value < 100 ? value - 100 : 0;
}
function getValueFromStack(stack) {
return stack.reduce((sum, { value }) => sum + value, 0);
}
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
;