UNPKG

@gravity-ui/uikit

Version:

Gravity UI base styling and components

33 lines (32 loc) 1.16 kB
"use strict"; 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 ? { theme: matchingColorStopItem.theme, color: matchingColorStopItem.color, } : { theme: theme }; } return { theme: theme, }; } //# sourceMappingURL=utils.js.map