@awsui/components-react
Version:
AWS UI is a collection of [React](https://reactjs.org/) components that help create intuitive, responsive, and accessible user experiences for web applications. It is developed by Amazon Web Services (AWS). This work is available under the terms of the [A
26 lines (25 loc) • 769 B
JavaScript
var WIDTHS = [1920, 1400, 1200, 992, 768];
var defaultCardsPerRow = WIDTHS.map(function (value, index, widths) { return ({
minWidth: value,
cards: widths.length + 1 - index
}); });
export var getCardsPerRow = function (width, config) {
if (config.length === 0) {
config = defaultCardsPerRow;
}
var cardsPerRow = 1;
var sortedConfig = config
.slice()
.map(function (value) { return ({
minWidth: value.minWidth || 0,
cards: value.cards
}); })
.sort(function (a, b) { return b.minWidth - a.minWidth; });
sortedConfig.some(function (layout) {
if (width >= layout.minWidth) {
cardsPerRow = layout.cards;
return true;
}
});
return cardsPerRow;
};