|
| 1 | +--- |
| 2 | +import ComponentWrapper from '@static/ComponentWrapper.astro' |
| 3 | +import Layout from '@static/Layout.astro' |
| 4 | +
|
| 5 | +import AstroAspectRatio from '@components/AspectRatio/AspectRatio.astro' |
| 6 | +import SvelteAspectRatio from '@components/AspectRatio/AspectRatio.svelte' |
| 7 | +import ReactAspectRatio from '@components/AspectRatio/AspectRatio.tsx' |
| 8 | +
|
| 9 | +import { getSections } from '@helpers' |
| 10 | +
|
| 11 | +const sections = getSections({ |
| 12 | + title: 'aspect ratios', |
| 13 | + components: [AstroAspectRatio, SvelteAspectRatio, ReactAspectRatio] |
| 14 | +}) |
| 15 | +--- |
| 16 | + |
| 17 | +<Layout> |
| 18 | + <h1>AspectRatio</h1> |
| 19 | + <div class="grid md-2 lg-3"> |
| 20 | + <ComponentWrapper type="Astro"> |
| 21 | + <AstroAspectRatio ratio="16/9"> |
| 22 | + <img src="../img/placeholder1.png" /> |
| 23 | + </AstroAspectRatio> |
| 24 | + </ComponentWrapper> |
| 25 | + |
| 26 | + <ComponentWrapper type="Svelte"> |
| 27 | + <SvelteAspectRatio ratio="16/9"> |
| 28 | + <img src="../img/placeholder2.png" /> |
| 29 | + </SvelteAspectRatio> |
| 30 | + </ComponentWrapper> |
| 31 | + |
| 32 | + <ComponentWrapper type="React"> |
| 33 | + <ReactAspectRatio ratio="16/9"> |
| 34 | + <img src="../img/placeholder3.png" /> |
| 35 | + </ReactAspectRatio> |
| 36 | + </ComponentWrapper> |
| 37 | + </div> |
| 38 | + |
| 39 | + {sections.map(section => ( |
| 40 | + <h1>{section.title}</h1> |
| 41 | + <Fragment> |
| 42 | + {section.subTitle && <h2 set:html={section.subTitle} />} |
| 43 | + </Fragment> |
| 44 | + <div class="grid md-2 lg-3"> |
| 45 | + <ComponentWrapper title="Default"> |
| 46 | + <section.component ratio="16/9"> |
| 47 | + <img src="../img/placeholder1.png" /> |
| 48 | + </section.component> |
| 49 | + </ComponentWrapper> |
| 50 | + |
| 51 | + <ComponentWrapper title="Alternate syntax"> |
| 52 | + <section.component ratio="16:9"> |
| 53 | + <img src="../img/placeholder2.png" /> |
| 54 | + </section.component> |
| 55 | + </ComponentWrapper> |
| 56 | + |
| 57 | + <ComponentWrapper title="Custom styles"> |
| 58 | + <section.component ratio="16:9" className="ratio"> |
| 59 | + <img src="../img/placeholder3.png" /> |
| 60 | + </section.component> |
| 61 | + </ComponentWrapper> |
| 62 | + |
| 63 | + <ComponentWrapper title="1:1"> |
| 64 | + <section.component ratio="1"> |
| 65 | + <img src="../img/placeholder1.png" /> |
| 66 | + </section.component> |
| 67 | + </ComponentWrapper> |
| 68 | + |
| 69 | + <ComponentWrapper title="4:3"> |
| 70 | + <section.component ratio="4/3"> |
| 71 | + <img src="../img/placeholder2.png" /> |
| 72 | + </section.component> |
| 73 | + </ComponentWrapper> |
| 74 | + |
| 75 | + <ComponentWrapper title="21:9"> |
| 76 | + <section.component ratio="21/9"> |
| 77 | + <img src="../img/placeholder3.png" /> |
| 78 | + </section.component> |
| 79 | + </ComponentWrapper> |
| 80 | + </div> |
| 81 | + ))} |
| 82 | +</Layout> |
| 83 | + |
| 84 | +<style lang="scss" is:global> |
| 85 | + @import '../../scss/config.scss'; |
| 86 | + |
| 87 | + .ratio { |
| 88 | + @include background(primary-50); |
| 89 | + |
| 90 | + img { |
| 91 | + object-fit: contain; |
| 92 | + } |
| 93 | + } |
| 94 | +</style> |
0 commit comments