Skip to content

Commit ef84a39

Browse files
committed
fix: clean up code formatting and improve hover effect styling
1 parent 6b73cc4 commit ef84a39

File tree

6 files changed

+59
-66
lines changed

6 files changed

+59
-66
lines changed

src/constants/code/TextAnimations/variableProximityCode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ export const variableProximity = createCodeObject(code, 'TextAnimations/Variable
2323
2424
const containerRef = ref<HTMLElement | null>(null);
2525
</script>`
26-
});
26+
});

src/content/Components/BounceCards/BounceCards.vue

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@
1010
v-for="(src, idx) in images"
1111
:key="idx"
1212
ref="cardRefs"
13-
class="absolute w-[200px] aspect-square border-[5px] border-white rounded-[25px] overflow-hidden shadow-[0_4px_10px_rgba(0,0,0,0.2)] bg-[#f8f9fa] opacity-0"
13+
class="absolute w-[200px] aspect-square border-[5px] border-white rounded-[25px] overflow-hidden shadow-[0_4px_10px_rgba(0,0,0,0.2)] bg-[#0b0b0b] opacity-0"
1414
:style="{ transform: transformStyles[idx] ?? 'none' }"
1515
@mouseenter="() => pushSiblings(idx)"
1616
@mouseleave="resetSiblings"
1717
>
18-
<div v-if="!imageLoaded[idx]" class="absolute inset-0 z-[1] flex items-center justify-center bg-black/80">
19-
<div class="w-[75px] h-[75px] border-[3px] border-gray-400 border-t-[#27FF64] rounded-full animate-spin"></div>
20-
</div>
18+
<div v-if="!imageLoaded[idx]" class="absolute inset-0 z-[1] bg-[#0b0b0b] overflow-hidden shimmer-container"></div>
2119

2220
<img
23-
class="absolute inset-0 w-full h-full object-cover transition-opacity duration-300 ease-in-out z-[2]"
21+
class="absolute inset-0 w-full h-full object-cover z-[2] transition-opacity duration-700 ease-out"
2422
:src="src"
2523
:alt="`card-${idx}`"
2624
:style="{ opacity: imageLoaded[idx] ? 1 : 0 }"
@@ -165,13 +163,34 @@ const playEntranceAnimation = () => {
165163
};
166164
167165
onMounted(playEntranceAnimation);
168-
watch(() => props.images, async () => {
169-
await nextTick();
170-
gsap.set(cardRefs.value, { opacity: 0, scale: 0 });
171-
playEntranceAnimation();
172-
});
166+
watch(
167+
() => props.images,
168+
async () => {
169+
await nextTick();
170+
gsap.set(cardRefs.value, { opacity: 0, scale: 0 });
171+
playEntranceAnimation();
172+
}
173+
);
173174
174175
onUnmounted(() => {
175176
gsap.killTweensOf(cardRefs.value);
176177
});
177178
</script>
179+
180+
<style scoped>
181+
.shimmer-container {
182+
background: linear-gradient(110deg, transparent 40%, rgba(255, 255, 255, 0.1) 50%, transparent 60%);
183+
background-size: 600% 600%;
184+
background-position: -600% 0;
185+
animation: shimmer-sweep 6s infinite;
186+
}
187+
188+
@keyframes shimmer-sweep {
189+
0% {
190+
background-position: -600% 0;
191+
}
192+
100% {
193+
background-position: 200% 0;
194+
}
195+
}
196+
</style>

src/content/Components/MagicBento/MagicBento.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ const ParticleCard = defineComponent({
378378
const GlobalSpotlight = defineComponent({
379379
name: 'GlobalSpotlight',
380380
props: {
381-
gridRef: {type: [Object, null] as PropType<HTMLDivElement | null>, required: true},
381+
gridRef: { type: [Object, null] as PropType<HTMLDivElement | null>, required: true },
382382
disableAnimations: { type: Boolean, default: false },
383383
enabled: { type: Boolean, default: true },
384384
spotlightRadius: { type: Number, default: DEFAULT_SPOTLIGHT_RADIUS },

src/content/TextAnimations/VariableProximity/VariableProximity.vue

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@
2626
>
2727
{{ letter }}
2828
</span>
29-
<span
30-
v-if="wordIndex < words.length - 1"
31-
class="inline-block"
32-
>&nbsp;</span>
29+
<span v-if="wordIndex < words.length - 1" class="inline-block">&nbsp;</span>
30+
</span>
31+
<span class="absolute w-px h-px p-0 -m-px overflow-hidden whitespace-nowrap clip-rect-0 border-0">
32+
{{ props.label }}
3333
</span>
34-
<span class="absolute w-px h-px p-0 -m-px overflow-hidden whitespace-nowrap clip-rect-0 border-0">{{ props.label }}</span>
3534
</span>
3635
</template>
3736

@@ -57,7 +56,7 @@ const props = withDefaults(defineProps<VariableProximityProps>(), {
5756
falloff: 'linear',
5857
className: '',
5958
style: () => ({}),
60-
onClick: undefined,
59+
onClick: undefined
6160
});
6261
6362
const rootRef = ref<HTMLElement | null>(null);
@@ -90,7 +89,7 @@ const parsedSettings = computed(() => {
9089
return Array.from(fromSettings.entries()).map(([axis, fromValue]) => ({
9190
axis,
9291
fromValue,
93-
toValue: toSettings.get(axis) ?? fromValue,
92+
toValue: toSettings.get(axis) ?? fromValue
9493
}));
9594
});
9695
@@ -100,15 +99,17 @@ const calculateDistance = (x1: number, y1: number, x2: number, y2: number) =>
10099
const calculateFalloff = (distance: number) => {
101100
const norm = Math.min(Math.max(1 - distance / props.radius, 0), 1);
102101
switch (props.falloff) {
103-
case 'exponential': return norm ** 2;
104-
case 'gaussian': return Math.exp(-((distance / (props.radius / 2)) ** 2) / 2);
102+
case 'exponential':
103+
return norm ** 2;
104+
case 'gaussian':
105+
return Math.exp(-((distance / (props.radius / 2)) ** 2) / 2);
105106
case 'linear':
106-
default: return norm;
107+
default:
108+
return norm;
107109
}
108110
};
109111
110-
const getLetterKey = (wordIndex: number, letterIndex: number) =>
111-
`${wordIndex}-${letterIndex}`;
112+
const getLetterKey = (wordIndex: number, letterIndex: number) => `${wordIndex}-${letterIndex}`;
112113
113114
const getGlobalLetterIndex = (wordIndex: number, letterIndex: number) => {
114115
let globalIndex = 0;
@@ -175,12 +176,7 @@ const animationLoop = () => {
175176
const letterCenterX = rect.left + rect.width / 2 - containerRect.left;
176177
const letterCenterY = rect.top + rect.height / 2 - containerRect.top;
177178
178-
const distance = calculateDistance(
179-
mousePosition.value.x,
180-
mousePosition.value.y,
181-
letterCenterX,
182-
letterCenterY
183-
);
179+
const distance = calculateDistance(mousePosition.value.x, mousePosition.value.y, letterCenterX, letterCenterY);
184180
185181
if (distance >= props.radius) {
186182
return;

src/demo/Components/BounceCardsDemo.vue

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<template>
32
<TabbedLayout>
43
<template #preview>
@@ -18,26 +17,11 @@
1817
</div>
1918

2019
<Customize>
21-
<PreviewSwitch
22-
title="Enable Hover Effect"
23-
v-model="enableHover"
24-
/>
20+
<PreviewSwitch title="Enable Hover Effect" v-model="enableHover" />
2521

26-
<PreviewSlider
27-
title="Animation Delay"
28-
v-model="animationDelay"
29-
:min="0.1"
30-
:max="2"
31-
:step="0.1"
32-
/>
22+
<PreviewSlider title="Animation Delay" v-model="animationDelay" :min="0.1" :max="2" :step="0.1" />
3323

34-
<PreviewSlider
35-
title="Animation Stagger"
36-
v-model="animationStagger"
37-
:min="0"
38-
:max="0.3"
39-
:step="0.01"
40-
/>
24+
<PreviewSlider title="Animation Stagger" v-model="animationStagger" :min="0" :max="0.3" :step="0.01" />
4125
</Customize>
4226

4327
<PropTable :data="propData" />
@@ -76,11 +60,11 @@ const animationStagger = ref(0.08);
7660
const { rerenderKey, forceRerender } = useForceRerender();
7761
7862
const images = ref([
79-
'https://picsum.photos/400/400?grayscale',
80-
'https://picsum.photos/500/500?grayscale',
81-
'https://picsum.photos/600/600?grayscale',
82-
'https://picsum.photos/700/700?grayscale',
83-
'https://picsum.photos/300/300?grayscale'
63+
'https://picsum.photos/id/287/300/300?grayscale',
64+
'https://picsum.photos/id/1001/300/300?grayscale',
65+
'https://picsum.photos/id/1027/300/300?grayscale',
66+
'https://picsum.photos/id/1025/300/300?grayscale',
67+
'https://picsum.photos/id/1026/300/300?grayscale'
8468
]);
8569
8670
const transformStyles = ref([
@@ -126,7 +110,7 @@ const propData = [
126110
name: 'animationStagger',
127111
type: 'number',
128112
default: '-',
129-
description: 'Time (in seconds) between each card\'s animation.'
113+
description: "Time (in seconds) between each card's animation."
130114
},
131115
{
132116
name: 'easeType',
@@ -144,7 +128,7 @@ const propData = [
144128
name: 'enableHover',
145129
type: 'boolean',
146130
default: 'false',
147-
description: 'If true, hovering pushes siblings aside and flattens the hovered card\'s rotation.'
131+
description: "If true, hovering pushes siblings aside and flattens the hovered card's rotation."
148132
}
149133
];
150134
</script>

src/demo/TextAnimations/VariableProximityDemo.vue

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@
1717
</div>
1818

1919
<Customize>
20-
<PreviewSlider
21-
title="Radius"
22-
v-model="radius"
23-
:min="50"
24-
:max="300"
25-
:step="10"
26-
/>
20+
<PreviewSlider title="Radius" v-model="radius" :min="50" :max="300" :step="10" />
2721

2822
<div class="flex gap-2 flex-wrap">
2923
<button
@@ -80,13 +74,13 @@ const propData = [
8074
{
8175
name: 'fromFontVariationSettings',
8276
type: 'string',
83-
default: '"\'wght\' 400, \'opsz\' 9"',
77+
default: "\"'wght' 400, 'opsz' 9\"",
8478
description: 'The starting variation settings.'
8579
},
8680
{
8781
name: 'toFontVariationSettings',
8882
type: 'string',
89-
default: '"\'wght\' 800, \'opsz\' 40"',
83+
default: "\"'wght' 800, 'opsz' 40\"",
9084
description: 'The variation settings to reach at cursor proximity.'
9185
},
9286
{
@@ -128,5 +122,5 @@ const propData = [
128122
];
129123
</script>
130124
<style scoped>
131-
@import url("https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap");
125+
@import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap');
132126
</style>

0 commit comments

Comments
 (0)