|
1 | 1 | <script lang="ts">
|
2 | 2 | import { classNames } from '$lib/utils/classnames';
|
| 3 | + import AnimatedLogo from './animated-logo.svelte'; |
3 | 4 |
|
4 | 5 | type Props = {
|
5 | 6 | title?: string;
|
|
69 | 70 | {
|
70 | 71 | src: '/images/logos/trusted-by/nestle.svg',
|
71 | 72 | alt: 'Nestle',
|
72 |
| - width: 119, |
| 73 | + width: 150, |
73 | 74 | height: 34
|
74 | 75 | },
|
75 | 76 | {
|
|
86 | 87 | }
|
87 | 88 | ];
|
88 | 89 |
|
89 |
| - let currentIndex = $state<number>(0); |
90 |
| - let itemCount = 4; |
| 90 | + let baseDelay = 2.9; |
91 | 91 |
|
92 |
| - const currentLogos = $derived(logos.slice(currentIndex, currentIndex + itemCount)); |
93 |
| -
|
94 |
| - $effect(() => { |
95 |
| - const interval = setInterval(() => { |
96 |
| - currentIndex = currentIndex + itemCount >= logos.length ? 0 : currentIndex + itemCount; |
97 |
| - }, 5000); |
98 |
| -
|
99 |
| - return () => { |
100 |
| - clearInterval(interval); |
101 |
| - }; |
102 |
| - }); |
| 92 | + const logoGroups = logos.reduce( |
| 93 | + (groups, logo, index) => { |
| 94 | + const groupIndex = Math.floor(index / 3); |
| 95 | + if (!groups[groupIndex]) { |
| 96 | + groups[groupIndex] = []; |
| 97 | + } |
| 98 | + groups[groupIndex].push(logo); |
| 99 | + return groups; |
| 100 | + }, |
| 101 | + [] as Array<typeof logos> |
| 102 | + ); |
103 | 103 | </script>
|
104 | 104 |
|
105 |
| -<div class={classNames('py-32', className)}> |
106 |
| - <div class="container"> |
107 |
| - <h2 class="font-aeonik-pro text-greyscale-100 text-label mx-auto max-w-md text-center"> |
| 105 | +<div class={classNames('py-12', className)}> |
| 106 | + <div class="mx-auto max-w-4xl"> |
| 107 | + <h2 |
| 108 | + class="font-aeonik-pro text-greyscale-100 text-description mx-auto max-w-[312px] text-center text-pretty" |
| 109 | + > |
108 | 110 | {title}
|
109 | 111 | </h2>
|
110 |
| - <ul |
111 |
| - class="grid gap-10 pt-10 text-center" |
112 |
| - style:grid-template-columns={`repeat(${itemCount}, minmax(150px, 1fr))`} |
113 |
| - > |
114 |
| - {#each currentLogos as { src, alt, width, height }} |
115 |
| - <li class="grid place-content-center"> |
116 |
| - <img {src} {alt} {width} {height} /> |
117 |
| - </li> |
| 112 | + <div class="relative grid grid-cols-2 gap-4 py-10 md:grid-cols-4"> |
| 113 | + {#each logoGroups as group, i} |
| 114 | + <div class="relative flex aspect-[8/2] flex-col items-center justify-center"> |
| 115 | + {#each group as { src, alt, width, height }, index} |
| 116 | + <AnimatedLogo |
| 117 | + repeatDelay={baseDelay * 2} |
| 118 | + delay={index * baseDelay + i * 0.1} |
| 119 | + class="absolute" |
| 120 | + > |
| 121 | + <img {src} {alt} {width} {height} /> |
| 122 | + </AnimatedLogo> |
| 123 | + {/each} |
| 124 | + </div> |
118 | 125 | {/each}
|
119 |
| - </ul> |
| 126 | + </div> |
120 | 127 | </div>
|
121 | 128 | </div>
|
0 commit comments