|
2 | 2 | <TabbedLayout>
|
3 | 3 | <template #preview>
|
4 | 4 | <div class="demo-container">
|
5 |
| - <MagnetLines :rows="10" :columns="12" container-size="40vmin" line-width="2px" line-height="30px" /> |
| 5 | + <MagnetLines |
| 6 | + :rows="rows" |
| 7 | + :columns="columns" |
| 8 | + container-size="500px" |
| 9 | + :line-width="lineWidthPx" |
| 10 | + :line-height="lineHeightPx" |
| 11 | + :line-color="lineColor" |
| 12 | + :base-angle="baseAngle" |
| 13 | + /> |
6 | 14 | </div>
|
7 | 15 |
|
| 16 | + <Customize> |
| 17 | + <PreviewColor title="Line Color" v-model="lineColor" /> |
| 18 | + |
| 19 | + <PreviewSlider title="Rows" v-model="rows" :min="5" :max="maxRows" :step="1" /> |
| 20 | + |
| 21 | + <PreviewSlider title="Columns" v-model="columns" :min="5" :max="15" :step="1" /> |
| 22 | + |
| 23 | + <PreviewSlider title="Line Height (px)" v-model="lineHeight" :min="10" :max="50" :step="5" /> |
| 24 | + |
| 25 | + <PreviewSlider title="Line Width (px)" v-model="lineWidth" :min="1" :max="5" :step="1" /> |
| 26 | + |
| 27 | + <PreviewSlider title="Base Angle (°)" v-model="baseAngle" :min="-45" :max="45" :step="1" /> |
| 28 | + </Customize> |
| 29 | + |
8 | 30 | <PropTable :data="propData" />
|
9 | 31 | </template>
|
10 | 32 |
|
|
19 | 41 | </template>
|
20 | 42 |
|
21 | 43 | <script setup lang="ts">
|
| 44 | +import { computed, nextTick, ref, watch } from 'vue'; |
22 | 45 | import TabbedLayout from '../../components/common/TabbedLayout.vue';
|
23 | 46 | import PropTable from '../../components/common/PropTable.vue';
|
24 | 47 | import CliInstallation from '../../components/code/CliInstallation.vue';
|
25 | 48 | import CodeExample from '../../components/code/CodeExample.vue';
|
| 49 | +import Customize from '../../components/common/Customize.vue'; |
| 50 | +import PreviewSlider from '../../components/common/PreviewSlider.vue'; |
| 51 | +import PreviewColor from '../../components/common/PreviewColor.vue'; |
26 | 52 | import MagnetLines from '../../content/Animations/MagnetLines/MagnetLines.vue';
|
27 | 53 | import { magnetLines } from '@/constants/code/Animations/magnetLinesCode';
|
28 | 54 |
|
| 55 | +const lineHeight = ref(30); |
| 56 | +const lineWidth = ref(2); |
| 57 | +const lineColor = ref('#efefef'); |
| 58 | +const baseAngle = ref(-10); |
| 59 | +const columns = ref(12); |
| 60 | +
|
| 61 | +const lineWidthPx = computed(() => `${lineWidth.value}px`); |
| 62 | +const lineHeightPx = computed(() => `${lineHeight.value}px`); |
| 63 | +
|
| 64 | +const maxRows = computed(() => { |
| 65 | + const containerHeight = 500; |
| 66 | + return Math.floor(containerHeight / lineHeight.value); |
| 67 | +}); |
| 68 | +
|
| 69 | +const rows = ref(Math.min(10, maxRows.value)); |
| 70 | +
|
| 71 | +watch(lineHeight, () => { |
| 72 | + nextTick(() => { |
| 73 | + rows.value = Math.min(rows.value, maxRows.value); |
| 74 | + }); |
| 75 | +}); |
| 76 | +
|
29 | 77 | const propData = [
|
30 | 78 | {
|
31 | 79 | name: 'rows',
|
|
0 commit comments