// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { CardDeck } from 'reactstrap';
import { CardItem } from './CardItem';
export class CardGrid extends Component {
static DEFAULT_CARD_PER_ROW = 3;
copyStyleWithFixedWidth = (existingStyle, width) => {
return {
...existingStyle,
flex: `0 0 ${width}px`
}
}
render() {
let gridContent = null;
const {cards, cardPerRow, cardWidth, ...rest} = this.props;
if(cardPerRow && cardWidth){
console.error('You can specify only cardPerRow or cardWidth. Default to rendering cardWidth only');
}
if(cardWidth) {
let cardItems = [];
cards.forEach((card, index) => {
let cardClassName = card.className || '';
cardClassName += ' mb-4';
const cardStyle = this.copyStyleWithFixedWidth(card.style, cardWidth);
cardItems.push(