Skip to content

Commit

Permalink
fix: example components
Browse files Browse the repository at this point in the history
  • Loading branch information
selemondev committed Oct 6, 2024
1 parent 7dff6ee commit 83dca08
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 46 deletions.
6 changes: 3 additions & 3 deletions docs/src/components/spark-ui/animatedBeam/AnimatedList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ function getLeave() {
</script>

<template>
<div :class="cn('border w-[600px] h-[370px] overflow-auto rounded-lg', $props.class)">
<transition-group name="animated-beam" tag="div" class="flex flex-col-reverse items-center p-2" move-class="move">
<div :class="cn('border w-[600px] h-[370px] shadow-lg overflow-auto rounded-lg', $props.class)">
<transition-group name="animatedBeam" tag="div" class="flex flex-col-reverse items-center p-2" move-class="move">
<div
v-for="(item, idx) in itemsToShow" :key="idx" v-motion :initial="getInitial(idx)"
:enter="getEnter(idx)" :leave="getLeave()" :class="cn('mx-auto w-full mb-4')"
:enter="getEnter(idx)" :leave="getLeave()" :class="cn('mx-auto w-full')"
>
<component :is="item" />
</div>
Expand Down
12 changes: 6 additions & 6 deletions docs/src/components/spark-ui/animatedBeam/Notification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { cn } from '../../../lib/utils'
const props = defineProps(['name', 'description', 'icon', 'color', 'time'])
const className = cn(
'relative mx-auto min-h-fit w-full max-w-[400px] cursor-pointer overflow-hidden rounded-2xl p-2',
'relative mx-auto min-h-fit w-full max-w-[400px] cursor-pointer overflow-hidden rounded-2xl p-3',
// animation styles
'transition-all duration-200 ease-in-out hover:scale-[103%]',
// light styles
Expand All @@ -16,17 +16,17 @@ const className = cn(

<template>
<figure :class="className">
<div class="flex flex-row border rounded-xl items-center px-2 gap-4">
<div class="flex flex-row bg-white border rounded-xl shadow-md py-2 items-center px-2 gap-4">
<div class="flex size-10 items-center justify-center rounded-2xl" :style="{ backgroundColor: props.color }">
<span class="text-lg">{{ props.icon }}</span>
</div>
<div class="flex flex-col space-y-1 overflow-hidden">
<div class="flex flex-col overflow-hidden">
<div class="flex flex-row items-center whitespace-pre text-lg font-medium ">
<span class="text-sm text-black dark:text-white font-semibold sm:text-lg">{{ props.name }}</span>
<span class="text-sm text-black sm:text-lg">{{ props.name }}</span>
<span class="mx-1">·</span>
<span class="text-xs text-gray-500 dark:text-gray-200">{{ props.time }}</span>
<span class="text-xs text-gray-500">{{ props.time }}</span>
</div>
<p class="text-sm font-normal dark:text-white">
<p class="text-sm font-normal">
{{ props.description }}
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,9 @@ const className = cn(
<template>
<div :class="className">
<div
class="absolute animate-gradient inset-0 block h-full w-full bg-gradient-to-r from-[#ffaa40]/50 via-[#9c40ff]/50 to-[#ffaa40]/50 bg-[length:var(--bg-size)_100%] p-[1px] ![mask-composite:subtract] [border-radius:inherit] [mask:linear-gradient(#fff_0_0)_content-box,linear-gradient(#fff_0_0)]"
class="absolute inset-0 block h-full w-full bg-gradient-to-r from-[#ffaa40]/50 via-[#9c40ff]/50 to-[#ffaa40]/50 bg-[length:var(--bg-size)_100%] p-[1px] ![mask-composite:subtract] [border-radius:inherit] [mask:linear-gradient(#fff_0_0)_content-box,linear-gradient(#fff_0_0)]"
/>

<slot />
</div>
</template>

<style>
@keyframes gradientAnimation {
0% {
background-position: var(--bg-size) 0;
}
50% {
background-position: 0 0;
}
100% {
background-position: var(--bg-size) 0;
}
}
.animate-gradient {
background-size: var(--bg-size);
animation: gradientAnimation 8s ease infinite;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const items = [
<div v-for="item in items" :key="item.id">
<div
:key="item.id"
class="flex cursor-pointer w-72 p-6 items-center space-x-2 rounded-md border border-gray-100 px-5 shadow-md transition-all hover:-translate-y-1 hover:translate-x-1 hover:scale-[1.025] hover:shadow-xl "
class="flex cursor-pointer w-72 p-6 items-center space-x-2 rounded-md border border-gray-100 dark:border-gray-800 px-5 shadow-md transition-all hover:-translate-y-1 hover:translate-x-1 hover:scale-[1.025] hover:shadow-xl "
>
<svg
xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
Expand Down
8 changes: 8 additions & 0 deletions docs/src/composables/useTheme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useLocalStorage } from '@vueuse/core'

export function useTheme() {
const theme = useLocalStorage('vitepress-theme-appearance', () => '')
return {
theme,
}
}
93 changes: 93 additions & 0 deletions docs/src/example/animatedBeamDemo/AnimatedList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<script lang="ts" setup>
import { computed, onMounted, ref, useSlots } from 'vue'
import { cn } from '../../lib/utils'
const props = defineProps({
class: {
type: String,
default: '',
},
delay: {
type: Number,
default: 1000,
},
})
const slots = useSlots()
const index = ref(0)
const slotsArray = ref<any>([])
onMounted(loadComponents)
const itemsToShow = computed(() => {
return slotsArray.value.slice(0, index.value)
})
async function loadComponents() {
slotsArray.value = slots.default ? slots.default()[0]?.children : []
while (index.value < slotsArray.value.length) {
index.value++
await delay(props.delay)
}
}
async function delay(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms))
}
function getInitial(idx: number) {
return idx === index.value - 1
? {
scale: 0,
opacity: 0,
}
: undefined
}
function getEnter(idx: number) {
return idx === index.value - 1
? {
scale: 1,
opacity: 1,
y: 0,
transition: {
type: 'spring',
stiffness: 250,
damping: 40,
},
}
: undefined
}
function getLeave() {
return {
scale: 0,
opacity: 0,
y: 0,
transition: {
type: 'spring',
stiffness: 350,
damping: 40,
},
}
}
</script>

<template>
<div :class="cn('border w-[600px] h-[370px] overflow-auto rounded-lg', $props.class)">
<transition-group name="animated-beam" tag="div" class="flex flex-col-reverse items-center p-2" move-class="move">
<div
v-for="(item, idx) in itemsToShow" :key="idx" v-motion :initial="getInitial(idx)"
:enter="getEnter(idx)" :leave="getLeave()" :class="cn('mx-auto w-full mb-4')"
>
<component :is="item" />
</div>
</transition-group>
</div>
</template>

<style scoped>
.move {
transition: transform 0.4s ease-out;
}
</style>
4 changes: 2 additions & 2 deletions docs/src/example/animatedBeamDemo/Demo.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang='ts'>
import AnimatedList from '../../components/spark-ui/animatedBeam/AnimatedList.vue'
import Notification from '../../components/spark-ui/animatedBeam/Notification.vue'
import AnimatedList from './AnimatedList.vue'
import Notification from './Notification.vue'
let notifications = [
{
Expand Down
35 changes: 35 additions & 0 deletions docs/src/example/animatedBeamDemo/Notification.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<script setup lang='ts'>
import { cn } from '../../lib/utils'
const props = defineProps(['name', 'description', 'icon', 'color', 'time'])
const className = cn(
'relative mx-auto min-h-fit w-full max-w-[400px] cursor-pointer overflow-hidden rounded-2xl p-2',
// animation styles
'transition-all duration-200 ease-in-out hover:scale-[103%]',
// light styles
'bg-white [box-shadow:0_0_0_1px_rgba(0,0,0,.03),0_2px_4px_rgba(0,0,0,.05),0_12px_24px_rgba(0,0,0,.05)]',
// dark styles
'transform-gpu dark:bg-transparent dark:backdrop-blur-md dark:[border:1px_solid_rgba(255,255,255,.1)] dark:[box-shadow:0_-20px_80px_-20px_#ffffff1f_inset]',
)
</script>

<template>
<figure :class="className">
<div class="flex flex-row border rounded-xl items-center px-2 gap-4">
<div class="flex size-10 items-center justify-center rounded-2xl" :style="{ backgroundColor: props.color }">
<span class="text-lg">{{ props.icon }}</span>
</div>
<div class="flex flex-col space-y-1 overflow-hidden">
<div class="flex flex-row items-center whitespace-pre text-lg font-medium ">
<span class="text-sm text-black dark:text-white font-semibold sm:text-lg">{{ props.name }}</span>
<span class="mx-1">·</span>
<span class="text-xs text-gray-500 dark:text-gray-200">{{ props.time }}</span>
</div>
<p class="text-sm font-normal dark:text-white">
{{ props.description }}
</p>
</div>
</div>
</figure>
</template>
35 changes: 23 additions & 12 deletions docs/src/example/skewedInfiniteScroll/SkewedInfiniteScroll.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
<script setup lang='ts'>
import { computed } from 'vue'
import { useTheme } from '../../composables/useTheme'
const { theme } = useTheme()
const currentTheme = computed(() => theme.value === 'auto' ? '#1f2937' : theme.value === 'light' ? '#f3f4f6' : '')
const items = [
{ id: '1', text: 'Spark UI' },
{ id: '2', text: 'Another One' },
{ id: '3', text: 'Yet Another One' },
{ id: '4', text: 'Yet Another One' },
{ id: '5', text: 'Yet Another One' },
{ id: '6', text: 'Yet Another One' },
{ id: '2', text: 'Magic UI' },
{ id: '3', text: 'Spark UI' },
{ id: '4', text: 'Magic UI' },
{ id: '5', text: 'Spark UI' },
{ id: '6', text: 'Magic UI' },
{
id: '7',
text: 'Yet Another One',
text: 'Spark UI',
},
{
id: '8',
text: 'Yet Another One',
text: 'Magic UI',
},
]
</script>
Expand All @@ -35,12 +41,12 @@ const items = [
<div v-for="item in items" :key="item.id">
<div
:key="item.id"
class="flex cursor-pointer w-72 px-6 py-1 items-center space-x-2 rounded-md border border-gray-100 shadow-md transition-all hover:-translate-y-1 hover:translate-x-1 hover:scale-[1.025] hover:shadow-xl "
class="flex cursor-pointer w-72 px-6 py-1 items-center space-x-2 rounded-md border-parent shadow-md transition-all hover:-translate-y-1 hover:translate-x-1 hover:scale-[1.025] hover:shadow-xl "
>
<svg
xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
fill="currentColor" stroke="white" strokeWidth="2" strokeLinecap="round"
strokeLinejoin="round" class="h-6 w-6 flex-none text-red-500"
xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor"
stroke="white" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"
class="h-6 w-6 flex-none text-red-500"
>
<path
d="M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z"
Expand All @@ -58,7 +64,11 @@ const items = [
</div>
</template>

<style>
<style scoped>
.border-parent {
border: 1px solid v-bind(currentTheme);
}
.animate-skew-scroll {
animation: SkewScroll 20s linear infinite;
}
Expand All @@ -67,6 +77,7 @@ const items = [
0% {
transform: rotatex(20deg) rotateZ(-20deg) skewX(20deg) translateZ(0) translateY(0);
}
100% {
transform: rotatex(20deg) rotateZ(-20deg) skewX(20deg) translateZ(0) translateY(-100%);
}
Expand Down

0 comments on commit 83dca08

Please sign in to comment.