mirror of
https://github.com/DavidHDev/vue-bits.git
synced 2026-03-07 22:49:31 -07:00
Added defineModel support for PreviewColor component. Updated watch in TrueFocus component.
This commit is contained in:
@@ -1,24 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="preview-color">
|
<div class="preview-color">
|
||||||
<span class="color-label">{{ title }}</span>
|
<span class="color-label">{{ title }}</span>
|
||||||
<input :value="modelValue" @input="handleColorChange" type="color" :disabled="disabled" class="color-input" />
|
<input :value="color" @input="handleColorChange" type="color" :disabled="props.disabled" class="color-input" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
defineProps<{
|
const props = defineProps<{ title: string; disabled?: boolean }>();
|
||||||
title: string;
|
const color = defineModel<string>();
|
||||||
modelValue: string;
|
|
||||||
disabled?: boolean;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
'update:modelValue': [value: string];
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const handleColorChange = (event: Event) => {
|
const handleColorChange = (event: Event) => {
|
||||||
const target = event.target as HTMLInputElement;
|
color.value = (event.target as HTMLInputElement).value;
|
||||||
emit('update:modelValue', target.value);
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const focusRect = ref({ x: 0, y: 0, width: 0, height: 0 });
|
|||||||
let interval: number | null = null;
|
let interval: number | null = null;
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => props.manualMode, () => props.animationDuration, () => props.pauseBetweenAnimations, words],
|
[() => props.manualMode, () => props.animationDuration, () => props.pauseBetweenAnimations, () => words.value],
|
||||||
() => {
|
() => {
|
||||||
if (interval) {
|
if (interval) {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
@@ -52,7 +52,7 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[currentIndex, words.value.length],
|
[currentIndex, () => words.value.length],
|
||||||
async () => {
|
async () => {
|
||||||
if (currentIndex.value === null || currentIndex.value === -1) return;
|
if (currentIndex.value === null || currentIndex.value === -1) return;
|
||||||
if (!wordRefs.value[currentIndex.value] || !containerRef.value) return;
|
if (!wordRefs.value[currentIndex.value] || !containerRef.value) return;
|
||||||
|
|||||||
@@ -33,9 +33,9 @@
|
|||||||
<span class="ml-1 text-gray-400">{{ blobType }}</span>
|
<span class="ml-1 text-gray-400">{{ blobType }}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<PreviewColor title="Fill Color" v-model="fillColor" @update:model-value="forceRerender" />
|
<PreviewColor title="Fill Color" v-model="fillColor" />
|
||||||
<PreviewColor title="Inner Color" v-model="innerColor" @update:model-value="forceRerender" />
|
<PreviewColor title="Inner Color" v-model="innerColor" />
|
||||||
<PreviewColor title="Shadow Color" v-model="shadowColor" @update:model-value="forceRerender" />
|
<PreviewColor title="Shadow Color" v-model="shadowColor" />
|
||||||
|
|
||||||
<PreviewSlider
|
<PreviewSlider
|
||||||
title="Trail Count"
|
title="Trail Count"
|
||||||
@@ -214,9 +214,6 @@ import Customize from '../../components/common/Customize.vue';
|
|||||||
import PreviewSlider from '../../components/common/PreviewSlider.vue';
|
import PreviewSlider from '../../components/common/PreviewSlider.vue';
|
||||||
import PreviewColor from '../../components/common/PreviewColor.vue';
|
import PreviewColor from '../../components/common/PreviewColor.vue';
|
||||||
import BlobCursor from '../../content/Animations/BlobCursor/BlobCursor.vue';
|
import BlobCursor from '../../content/Animations/BlobCursor/BlobCursor.vue';
|
||||||
import { useForceRerender } from '@/composables/useForceRerender';
|
|
||||||
|
|
||||||
const { forceRerender } = useForceRerender();
|
|
||||||
|
|
||||||
const blobType = ref<'circle' | 'square'>('circle');
|
const blobType = ref<'circle' | 'square'>('circle');
|
||||||
const fillColor = ref<string>('#27FF64');
|
const fillColor = ref<string>('#27FF64');
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Customize>
|
<Customize>
|
||||||
<PreviewColor title="Spark Color" v-model="sparkColor" @update:model-value="forceRerender" />
|
<PreviewColor title="Spark Color" v-model="sparkColor" />
|
||||||
|
|
||||||
<PreviewSlider
|
<PreviewSlider
|
||||||
title="Spark Size"
|
title="Spark Size"
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Customize>
|
<Customize>
|
||||||
<PreviewColor title="Color" v-model="color" @update:model-value="forceRerender" />
|
<PreviewColor title="Color" v-model="color" />
|
||||||
|
|
||||||
<PreviewSlider
|
<PreviewSlider
|
||||||
title="Ball Count"
|
title="Ball Count"
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
width="200"
|
width="200"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PreviewColor title="Pixel Color" v-model="pixelColor" @update:model-value="forceRerender" />
|
<PreviewColor title="Pixel Color" v-model="pixelColor" />
|
||||||
</Customize>
|
</Customize>
|
||||||
|
|
||||||
<PropTable :data="propData" />
|
<PropTable :data="propData" />
|
||||||
|
|||||||
@@ -22,8 +22,7 @@
|
|||||||
v-for="(color, index) in colorStops"
|
v-for="(color, index) in colorStops"
|
||||||
:key="index"
|
:key="index"
|
||||||
:title="`Color ${index + 1}`"
|
:title="`Color ${index + 1}`"
|
||||||
:model-value="color"
|
v-model="colorStops[index]"
|
||||||
@update:model-value="value => updateColorStop(index, value)"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -100,10 +99,6 @@ const blend = ref(0.5);
|
|||||||
const speed = ref(1.0);
|
const speed = ref(1.0);
|
||||||
const intensity = ref(1.0);
|
const intensity = ref(1.0);
|
||||||
|
|
||||||
const updateColorStop = (index: number, color: string) => {
|
|
||||||
colorStops.value[index] = color;
|
|
||||||
};
|
|
||||||
|
|
||||||
const propData = [
|
const propData = [
|
||||||
{
|
{
|
||||||
name: 'colorStops',
|
name: 'colorStops',
|
||||||
|
|||||||
@@ -16,11 +16,10 @@
|
|||||||
<Customize>
|
<Customize>
|
||||||
<div class="flex gap-4">
|
<div class="flex gap-4">
|
||||||
<PreviewColor
|
<PreviewColor
|
||||||
v-for="(color, index) in colorStops"
|
v-for="(_, index) in colorStops"
|
||||||
:key="index"
|
:key="index"
|
||||||
:title="`Color ${index + 1}`"
|
:title="`Color ${index + 1}`"
|
||||||
:model-value="color"
|
v-model="colorStops[index]"
|
||||||
@update:model-value="value => updateColorStop(index, value)"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -64,10 +63,6 @@ const pixelation = ref(745);
|
|||||||
const mouseInteractionEnabled = ref(true);
|
const mouseInteractionEnabled = ref(true);
|
||||||
const rotate = ref(false);
|
const rotate = ref(false);
|
||||||
|
|
||||||
const updateColorStop = (index: number, color: string) => {
|
|
||||||
colorStops.value[index] = color;
|
|
||||||
};
|
|
||||||
|
|
||||||
const propData = [
|
const propData = [
|
||||||
{
|
{
|
||||||
name: 'spinRotation',
|
name: 'spinRotation',
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Customize>
|
<Customize>
|
||||||
<PreviewColor title="Color" :model-value="lightColor" @update:model-value="lightColor = $event" />
|
<PreviewColor title="Color" v-model="lightColor" />
|
||||||
|
|
||||||
<PreviewSlider
|
<PreviewSlider
|
||||||
title="Beam Width"
|
title="Beam Width"
|
||||||
|
|||||||
@@ -22,9 +22,9 @@
|
|||||||
|
|
||||||
<Customize>
|
<Customize>
|
||||||
<div class="color-controls">
|
<div class="color-controls">
|
||||||
<PreviewColor title="Base Color" v-model="baseColor" @update:model-value="forceRerender" />
|
<PreviewColor title="Base Color" v-model="baseColor" />
|
||||||
|
|
||||||
<PreviewColor title="Active Color" v-model="activeColor" @update:model-value="forceRerender" />
|
<PreviewColor title="Active Color" v-model="activeColor" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PreviewSlider
|
<PreviewSlider
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<Customize>
|
<Customize>
|
||||||
<div class="flex gap-4 items-center">
|
<div class="flex gap-4 items-center">
|
||||||
<PreviewColor title="Color" :model-value="color" @update:model-value="updateColor" />
|
<PreviewColor title="Color" v-model="color" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PreviewSlider
|
<PreviewSlider
|
||||||
@@ -117,12 +117,7 @@ const moveParticlesOnHover = ref(true);
|
|||||||
const alphaParticles = ref(false);
|
const alphaParticles = ref(false);
|
||||||
const disableRotation = ref(false);
|
const disableRotation = ref(false);
|
||||||
|
|
||||||
const { rerenderKey, forceRerender } = useForceRerender();
|
const { rerenderKey } = useForceRerender();
|
||||||
|
|
||||||
const updateColor = (value: string) => {
|
|
||||||
color.value = value;
|
|
||||||
forceRerender();
|
|
||||||
};
|
|
||||||
|
|
||||||
const propData = [
|
const propData = [
|
||||||
{ name: 'particleCount', type: 'number', default: '200', description: 'The number of particles to generate.' },
|
{ name: 'particleCount', type: 'number', default: '200', description: 'The number of particles to generate.' },
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
:step="0.1"
|
:step="0.1"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PreviewColor title="Color" :model-value="color" @update:model-value="color = $event" />
|
<PreviewColor title="Color" v-model="color" />
|
||||||
</Customize>
|
</Customize>
|
||||||
|
|
||||||
<PropTable :data="propData" />
|
<PropTable :data="propData" />
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="flex gap-4 items-center">
|
<div class="flex gap-4 items-center">
|
||||||
<PreviewColor title="Waves Color" :model-value="color" @update:model-value="color = $event" />
|
<PreviewColor title="Waves Color" v-model="color" />
|
||||||
</div>
|
</div>
|
||||||
</Customize>
|
</Customize>
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
@update:model-value="forceRerender"
|
@update:model-value="forceRerender"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PreviewColor title="Text Color" v-model="textColor" @update:model-value="forceRerender" />
|
<PreviewColor title="Text Color" v-model="textColor" />
|
||||||
|
|
||||||
<PreviewSelect title="Font" v-model="font" :options="fontOptions" @update:model-value="forceRerender" />
|
<PreviewSelect title="Font" v-model="font" :options="fontOptions" @update:model-value="forceRerender" />
|
||||||
</Customize>
|
</Customize>
|
||||||
|
|||||||
@@ -31,9 +31,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="color-controls">
|
<div class="color-controls">
|
||||||
<PreviewColor title="Text Color" v-model="textColor" @update:model-value="forceRerender" />
|
<PreviewColor title="Text Color" v-model="textColor" />
|
||||||
|
|
||||||
<PreviewColor title="Stroke Color" v-model="strokeColor" @update:model-value="forceRerender" />
|
<PreviewColor title="Stroke Color" v-model="strokeColor" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="mt-6 text-[#999] text-sm">Animation Settings</p>
|
<p class="mt-6 text-[#999] text-sm">Animation Settings</p>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Customize>
|
<Customize>
|
||||||
<PreviewColor title="Corners Color" v-model="borderColor" @update:model-value="forceRerender" />
|
<PreviewColor title="Corners Color" v-model="borderColor" />
|
||||||
|
|
||||||
<PreviewSwitch title="Hover Mode" v-model="manualMode" @update:model-value="forceRerender" />
|
<PreviewSwitch title="Hover Mode" v-model="manualMode" @update:model-value="forceRerender" />
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user