blob: ed0bf0b33709a740b964e1f585b04d3e52b81cb8 [file] [log] [blame]
Skyler Turnerf5361212021-09-14 20:33:58 +01001import react, { Component, cloneElement } from "react";
Samuel Shuert604e31d2021-09-02 16:06:20 -05002import Styles from '../styles/tilerow.module.css';
Samuel Shuert8aac6012021-09-02 13:21:30 -05003
pineafanaed30242021-09-04 09:33:40 +01004class TileRow extends Component {
Skyler Turnerf5361212021-09-14 20:33:58 +01005 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) => {
Skyler Turner58e7da42021-09-14 20:41:21 +010013 if (this.props.divless !== false) { // Intentional comparison to false, initially had a default of false, now has a default of true
Skyler Turnerf5361212021-09-14 20:33:58 +010014 const className = (item.props.className ? item.props.className + " " : "") + Styles.item
Samuel Shuert8aac6012021-09-02 13:21:30 -050015
Skyler Turnerf5361212021-09-14 20:33:58 +010016 const key = index;
Samuel Shuert8aac6012021-09-02 13:21:30 -050017
Skyler Turnerf5361212021-09-14 20:33:58 +010018 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 }
Samuel Shuert8aac6012021-09-02 13:21:30 -050032}
Skyler Turnerf5361212021-09-14 20:33:58 +010033export default TileRow;