Last change
on this file since 5528b99 was e6c2521, checked in by darsov2 <62809499+darsov2@…>, 9 months ago |
images upload/download impl, other fixes
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Rev | Line | |
---|
[e6c2521] | 1 | import React, {useState} from "react";
|
---|
| 2 | import {Col, Container, Row, Carousel} from "react-bootstrap";
|
---|
| 3 | import MenuItem from "./MenuItem";
|
---|
| 4 |
|
---|
| 5 | const Menu = (props) => {
|
---|
| 6 | const menu = props.menu
|
---|
| 7 |
|
---|
| 8 | console.log(menu)
|
---|
| 9 | const partitionBy3 = (arr) => {
|
---|
| 10 | const rowPartitions = Array.from({length: Math.ceil(arr.length / 5)}, (v, i) =>
|
---|
| 11 | arr.slice(i * 5, i * 5 + 5)
|
---|
| 12 | );
|
---|
| 13 | return Array.from({length: Math.ceil(rowPartitions.length / 2)}, (v, i) =>
|
---|
| 14 | rowPartitions.slice(i * 2, i * 2 + 2)
|
---|
| 15 | );
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | const [ind, setIndex] = useState(0);
|
---|
| 19 |
|
---|
| 20 | const handleSelect = (selectedIndex) => {
|
---|
| 21 | setIndex(selectedIndex);
|
---|
| 22 | };
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 | return (<>
|
---|
| 26 | <Carousel activeIndex={ind} onSelect={handleSelect} indicators={false}>
|
---|
| 27 | {partitionBy3(menu).map((slides, index) => {
|
---|
| 28 | return (
|
---|
| 29 | <Carousel.Item key={index}>
|
---|
| 30 | {slides.map((row) => {
|
---|
| 31 | return (
|
---|
| 32 | <Row>
|
---|
| 33 | {row.map((menuItem) => {
|
---|
| 34 | return (
|
---|
| 35 | <Col>
|
---|
| 36 | <MenuItem data={menuItem}/>
|
---|
| 37 | </Col>
|
---|
| 38 | )
|
---|
| 39 | })}
|
---|
| 40 | </Row>
|
---|
| 41 | )
|
---|
| 42 | })}
|
---|
| 43 | </Carousel.Item>)
|
---|
| 44 | })}
|
---|
| 45 | </Carousel>
|
---|
| 46 | </>)
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | export default Menu; |
---|
Note:
See
TracBrowser
for help on using the repository browser.