|
| 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 AstroFlex from '@components/Flex/Flex.astro' |
| 7 | +import SvelteFlex from '@components/Flex/Flex.svelte' |
| 8 | +import ReactFlex from '@components/Flex/Flex.tsx' |
| 9 | +
|
| 10 | +import { getSections } from '@helpers' |
| 11 | +
|
| 12 | +import type { Gap, Responsive } from '@utils/getLayoutClasses' |
| 13 | +
|
| 14 | +const sections = getSections({ |
| 15 | + title: 'flex items', |
| 16 | + components: [AstroFlex, SvelteFlex, ReactFlex] |
| 17 | +}) |
| 18 | +
|
| 19 | +const gap = { |
| 20 | + xs: 'xs', |
| 21 | + sm: 'sm', |
| 22 | + md: 'md', |
| 23 | + lg: 'default' |
| 24 | +} as Responsive<Gap> |
| 25 | +--- |
| 26 | + |
| 27 | +<Layout> |
| 28 | + <h1>Flex</h1> |
| 29 | + <div class="grid md-2 lg-3"> |
| 30 | + <ComponentWrapper type="Astro"> |
| 31 | + <AstroFlex gap={gap}> |
| 32 | + <Box>1</Box> |
| 33 | + <Box>2</Box> |
| 34 | + <Box>3</Box> |
| 35 | + </AstroFlex> |
| 36 | + </ComponentWrapper> |
| 37 | + |
| 38 | + <ComponentWrapper type="Svelte"> |
| 39 | + <SvelteFlex gap={gap}> |
| 40 | + <Box>1</Box> |
| 41 | + <Box>2</Box> |
| 42 | + <Box>3</Box> |
| 43 | + </SvelteFlex> |
| 44 | + </ComponentWrapper> |
| 45 | + |
| 46 | + <ComponentWrapper type="React"> |
| 47 | + <ReactFlex gap={gap}> |
| 48 | + <Box>1</Box> |
| 49 | + <Box>2</Box> |
| 50 | + <Box>3</Box> |
| 51 | + </ReactFlex> |
| 52 | + </ComponentWrapper> |
| 53 | + </div> |
| 54 | + |
| 55 | + {sections.map(section => ( |
| 56 | + <h1>{section.title}</h1> |
| 57 | + <Fragment> |
| 58 | + {section.subTitle && <h2 set:html={section.subTitle} />} |
| 59 | + </Fragment> |
| 60 | + <div class="grid md-2 lg-3"> |
| 61 | + <ComponentWrapper title="Default"> |
| 62 | + <section.component> |
| 63 | + <Box>1</Box> |
| 64 | + <Box>2</Box> |
| 65 | + <Box>3</Box> |
| 66 | + </section.component> |
| 67 | + </ComponentWrapper> |
| 68 | + |
| 69 | + <ComponentWrapper title="Custom gap"> |
| 70 | + <section.component gap="xs"> |
| 71 | + <Box>1</Box> |
| 72 | + <Box>2</Box> |
| 73 | + <Box>3</Box> |
| 74 | + </section.component> |
| 75 | + </ComponentWrapper> |
| 76 | + |
| 77 | + <ComponentWrapper title="Custom direction"> |
| 78 | + <section.component direction="column"> |
| 79 | + <Box>1</Box> |
| 80 | + <Box>2</Box> |
| 81 | + <Box>3</Box> |
| 82 | + </section.component> |
| 83 | + </ComponentWrapper> |
| 84 | + |
| 85 | + <ComponentWrapper title="Row reverse"> |
| 86 | + <section.component direction="row-reverse"> |
| 87 | + <Box>1</Box> |
| 88 | + <Box>2</Box> |
| 89 | + <Box>3</Box> |
| 90 | + </section.component> |
| 91 | + </ComponentWrapper> |
| 92 | + |
| 93 | + <ComponentWrapper title="Column reverse"> |
| 94 | + <section.component direction="column-reverse"> |
| 95 | + <Box>1</Box> |
| 96 | + <Box>2</Box> |
| 97 | + <Box>3</Box> |
| 98 | + </section.component> |
| 99 | + </ComponentWrapper> |
| 100 | + |
| 101 | + <ComponentWrapper title="Horizontal alignment"> |
| 102 | + <section.component alignment={{ horizontal: 'center' }}> |
| 103 | + <Box>1</Box> |
| 104 | + <Box>2</Box> |
| 105 | + <Box>3</Box> |
| 106 | + </section.component> |
| 107 | + </ComponentWrapper> |
| 108 | + |
| 109 | + <ComponentWrapper title="Vertical alignment"> |
| 110 | + <section.component alignment={{ vertical: 'center' }} direction="column"> |
| 111 | + <Box>1</Box> |
| 112 | + <Box>2</Box> |
| 113 | + <Box>3</Box> |
| 114 | + </section.component> |
| 115 | + </ComponentWrapper> |
| 116 | + |
| 117 | + <ComponentWrapper title="Wrapping"> |
| 118 | + <section.component wrap="wrap"> |
| 119 | + <Box>1</Box> |
| 120 | + <Box>2</Box> |
| 121 | + <Box>3</Box> |
| 122 | + <Box>4</Box> |
| 123 | + <Box>5</Box> |
| 124 | + <Box>6</Box> |
| 125 | + </section.component> |
| 126 | + </ComponentWrapper> |
| 127 | + |
| 128 | + <ComponentWrapper title="Multiple properties"> |
| 129 | + <section.component |
| 130 | + gap="sm" |
| 131 | + wrap="wrap" |
| 132 | + alignment={{ horizontal: 'center', vertical: 'center' }} |
| 133 | + direction="row-reverse" |
| 134 | + > |
| 135 | + <Box>1</Box> |
| 136 | + <Box>2</Box> |
| 137 | + <Box>3</Box> |
| 138 | + <Box>4</Box> |
| 139 | + <Box>5</Box> |
| 140 | + <Box>6</Box> |
| 141 | + </section.component> |
| 142 | + </ComponentWrapper> |
| 143 | + </div> |
| 144 | + ))} |
| 145 | +</Layout> |
0 commit comments