Skip to content

Commit 8b47b40

Browse files
authored
Merge pull request #66 from Gazoon007/feat/magnet-lines-demo-customize-component
feat(MagnetLinesDemo): integrate customize component
2 parents bd3ad94 + 8456b34 commit 8b47b40

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

src/demo/Animations/MagnetLinesDemo.vue

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,31 @@
22
<TabbedLayout>
33
<template #preview>
44
<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+
/>
614
</div>
715

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+
830
<PropTable :data="propData" />
931
</template>
1032

@@ -19,13 +41,39 @@
1941
</template>
2042

2143
<script setup lang="ts">
44+
import { computed, nextTick, ref, watch } from 'vue';
2245
import TabbedLayout from '../../components/common/TabbedLayout.vue';
2346
import PropTable from '../../components/common/PropTable.vue';
2447
import CliInstallation from '../../components/code/CliInstallation.vue';
2548
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';
2652
import MagnetLines from '../../content/Animations/MagnetLines/MagnetLines.vue';
2753
import { magnetLines } from '@/constants/code/Animations/magnetLinesCode';
2854
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+
2977
const propData = [
3078
{
3179
name: 'rows',

0 commit comments

Comments
 (0)