pineafan | 15b813d | 2022-02-13 10:06:09 +0000 | [diff] [blame] | 1 | import react, { Component, cloneElement } from "react"; |
| 2 | import Styles from '../styles/tilerow.module.css'; |
| 3 | |
| 4 | class TileRow extends Component { |
| 5 | constructor(props) { |
| 6 | super(props); |
| 7 | } |
| 8 | render() { |
| 9 | return ( |
| 10 | <div className={Styles.container}> |
| 11 | { |
| 12 | react.Children.toArray(this.props.children).map((item, index) => { |
| 13 | if (this.props.divless !== false) { // Intentional comparison to false, initially had a default of false, now has a default of true |
| 14 | const className = (item.props.className ? item.props.className + " " : "") + Styles.item |
| 15 | |
| 16 | const key = index; |
| 17 | |
| 18 | const props = { |
| 19 | className, |
| 20 | key |
| 21 | } |
| 22 | |
| 23 | return cloneElement(item, props); |
| 24 | } else { |
| 25 | return <div className={Styles.item + " " + Styles.fitItemWidth} key={index}>{item}</div>; |
| 26 | } |
| 27 | }) |
| 28 | } |
| 29 | </div> |
| 30 | ) |
| 31 | } |
| 32 | } |
| 33 | export default TileRow; |