|
| 1 | +import { Masonry } from '@local/lib'; |
| 2 | +import { useState } from 'react'; |
| 3 | +import { Button } from './ui/Button'; |
| 4 | + |
| 5 | +const items = [ |
| 6 | + { height: 600, color: '#D32F2F', id: 1 }, // Extra Tall - Darker Red |
| 7 | + { height: 200, color: '#00796B', id: 2 }, // Short - Darker Teal |
| 8 | + { height: 400, color: '#1976D2', id: 3 }, // Tall - Darker Blue |
| 9 | + { height: 300, color: '#2E7D32', id: 4 }, // Medium - Darker Green |
| 10 | + { height: 500, color: '#F57F17', id: 5 }, // Very Tall - Darker Yellow |
| 11 | + { height: 250, color: '#C2185B', id: 6 }, // Medium-Short - Darker Pink |
| 12 | + { height: 450, color: '#4527A0', id: 7 }, // Tall - Darker Purple |
| 13 | + { height: 200, color: '#1565C0', id: 8 }, // Short - Darker Blue |
| 14 | + { height: 350, color: '#D84315', id: 9 }, // Medium-Tall - Darker Orange |
| 15 | + { height: 550, color: '#1B5E20', id: 10 }, // Very Tall - Darker Green |
| 16 | + { height: 150, color: '#B71C1C', id: 11 }, // Very Short - Darker Red |
| 17 | + { height: 400, color: '#311B92', id: 12 }, // Tall - Darker Purple |
| 18 | + { height: 300, color: '#00695C', id: 13 }, // Medium - Darker Turquoise |
| 19 | + { height: 250, color: '#E65100', id: 14 }, // Medium-Short - Darker Orange |
| 20 | + { height: 500, color: '#880E4F', id: 15 }, // Very Tall - Darker Pink |
| 21 | + { height: 200, color: '#0D47A1', id: 16 }, // Short - Darker Blue |
| 22 | + { height: 450, color: '#3E2723', id: 17 }, // Tall - Darker Brown |
| 23 | + { height: 350, color: '#4A148C', id: 18 }, // Medium-Tall - Darker Purple |
| 24 | + { height: 500, color: '#01579B', id: 19 }, // Medium - Darker Blue |
| 25 | + { height: 400, color: '#AD1457', id: 20 }, // Tall - Darker Pink |
| 26 | + { height: 300, color: '#E65100', id: 21 }, // Medium-Short - Darker Orange |
| 27 | +]; |
| 28 | + |
| 29 | +export function ReactPlock() { |
| 30 | + const [isBalanced, setIsBalanced] = useState(false); |
| 31 | + |
| 32 | + return ( |
| 33 | + <div style={{ padding: '16px', fontFamily: 'system-ui' }}> |
| 34 | + <fieldset style={{ padding: 16 }}> |
| 35 | + <legend>Settings</legend> |
| 36 | + |
| 37 | + <Button onClick={() => setIsBalanced(!isBalanced)}> |
| 38 | + {isBalanced ? 'Balanced Layout' : 'Default Layout'} |
| 39 | + </Button> |
| 40 | + </fieldset> |
| 41 | + |
| 42 | + <div style={{ paddingTop: '16px' }} /> |
| 43 | + |
| 44 | + <Masonry |
| 45 | + items={items} |
| 46 | + config={{ |
| 47 | + columns: [1, 2, 3], |
| 48 | + gap: [24, 12, 6], |
| 49 | + media: [640, 1024, 1280], |
| 50 | + useBalancedLayout: isBalanced, |
| 51 | + }} |
| 52 | + render={(item) => ( |
| 53 | + <div |
| 54 | + style={{ |
| 55 | + height: item.height, |
| 56 | + backgroundColor: item.color, |
| 57 | + width: '100%', |
| 58 | + display: 'flex', |
| 59 | + alignItems: 'center', |
| 60 | + justifyContent: 'center', |
| 61 | + color: '#FFF', |
| 62 | + fontSize: '22px', |
| 63 | + fontWeight: 'bold', |
| 64 | + }} |
| 65 | + > |
| 66 | + {`${item.height}px - #${item.id}`} |
| 67 | + </div> |
| 68 | + )} |
| 69 | + /> |
| 70 | + </div> |
| 71 | + ); |
| 72 | +} |
0 commit comments