|
| 1 | +--- |
| 2 | +import Box from '@static/Box.astro' |
| 3 | +import ComponentWrapper from '@static/ComponentWrapper.astro' |
| 4 | +import Layout from '@static/Layout.astro' |
| 5 | +
|
| 6 | +import AstroGrid from '@components/Grid/Grid.astro' |
| 7 | +import SvelteGrid from '@components/Grid/Grid.svelte' |
| 8 | +import ReactGrid from '@components/Grid/Grid.tsx' |
| 9 | +
|
| 10 | +import { getSections } from '@helpers' |
| 11 | +
|
| 12 | +import type { Gap, Responsive } from '@utils/getLayoutClasses' |
| 13 | +
|
| 14 | +const sections = getSections({ |
| 15 | + title: 'grids', |
| 16 | + components: [AstroGrid, SvelteGrid, ReactGrid] |
| 17 | +}) |
| 18 | +
|
| 19 | +const gap = { |
| 20 | + default: 'xxs', |
| 21 | + xs: 'xs', |
| 22 | + sm: 'sm', |
| 23 | + md: 'md', |
| 24 | + lg: 'default' |
| 25 | +} as Responsive<Gap> |
| 26 | +--- |
| 27 | + |
| 28 | +<Layout> |
| 29 | + <h1>Grid</h1> |
| 30 | + |
| 31 | + <p> |
| 32 | + To use this component, <code>includeUtilities</code> must not be disabled in your <code>setup</code> mixin. |
| 33 | + You can also use the <a href="/css/utilities">utility classes</a> without this component to build grid layouts. |
| 34 | + To build flexible layouts, see the <code><a href="/components/flex">Flex</a></code> component. |
| 35 | + </p> |
| 36 | + |
| 37 | + <div class="grid md-2 lg-3"> |
| 38 | + <ComponentWrapper type="Astro"> |
| 39 | + <AstroGrid gap={gap}> |
| 40 | + <Box>1</Box> |
| 41 | + <Box>2</Box> |
| 42 | + <Box>3</Box> |
| 43 | + </AstroGrid> |
| 44 | + </ComponentWrapper> |
| 45 | + |
| 46 | + <ComponentWrapper type="Svelte"> |
| 47 | + <SvelteGrid gap={gap}> |
| 48 | + <Box>1</Box> |
| 49 | + <Box>2</Box> |
| 50 | + <Box>3</Box> |
| 51 | + </SvelteGrid> |
| 52 | + </ComponentWrapper> |
| 53 | + |
| 54 | + <ComponentWrapper type="React"> |
| 55 | + <ReactGrid gap={gap}> |
| 56 | + <Box>1</Box> |
| 57 | + <Box>2</Box> |
| 58 | + <Box>3</Box> |
| 59 | + </ReactGrid> |
| 60 | + </ComponentWrapper> |
| 61 | + </div> |
| 62 | + |
| 63 | + {sections.map(section => ( |
| 64 | + <h1>{section.title}</h1> |
| 65 | + <Fragment> |
| 66 | + {section.subTitle && <h2 set:html={section.subTitle} />} |
| 67 | + </Fragment> |
| 68 | + <div class="grid md-2 lg-3"> |
| 69 | + <ComponentWrapper title="Default"> |
| 70 | + <section.component> |
| 71 | + <Box>1</Box> |
| 72 | + <Box>2</Box> |
| 73 | + <Box>3</Box> |
| 74 | + </section.component> |
| 75 | + </ComponentWrapper> |
| 76 | + |
| 77 | + <ComponentWrapper title="Custom gap"> |
| 78 | + <section.component gap="xs"> |
| 79 | + <Box>1</Box> |
| 80 | + <Box>2</Box> |
| 81 | + <Box>3</Box> |
| 82 | + </section.component> |
| 83 | + </ComponentWrapper> |
| 84 | + |
| 85 | + <ComponentWrapper title="Number of columns (Set to 3)"> |
| 86 | + <section.component column={3}> |
| 87 | + <Box>1</Box> |
| 88 | + <Box>2</Box> |
| 89 | + <Box>3</Box> |
| 90 | + </section.component> |
| 91 | + </ComponentWrapper> |
| 92 | + |
| 93 | + <ComponentWrapper title="Media-query columns"> |
| 94 | + <section.component column={{ |
| 95 | + xs: 2, |
| 96 | + sm: 3, |
| 97 | + md: 4 |
| 98 | + }}> |
| 99 | + <Box>1</Box> |
| 100 | + <Box>2</Box> |
| 101 | + <Box>3</Box> |
| 102 | + <Box>4</Box> |
| 103 | + </section.component> |
| 104 | + </ComponentWrapper> |
| 105 | + </div> |
| 106 | + ))} |
| 107 | +</Layout> |
0 commit comments