Skip to content

Commit

Permalink
add brand slider marquee
Browse files Browse the repository at this point in the history
  • Loading branch information
khafidprayoga committed Oct 3, 2024
1 parent aa69f8e commit 6523d53
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 10 deletions.
Binary file modified dressly/bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions dressly/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@rsbuild/core": "^1.0.1",
"@rsbuild/plugin-image-compress": "^1.0.2",
"@rsbuild/plugin-svelte": "^1.0.1",
"@selemondev/svelte-marquee": "^0.0.2",
"add": "^2.0.6",
"autoprefixer": "^10.4.20",
"eslint": "^9.10.0",
Expand All @@ -31,6 +32,7 @@
"prettier": "^3.3.3",
"svelte-check": "^4.0.1",
"tailwindcss": "^3.4.13",
"tailwindcss-animate": "^1.0.7",
"typescript": "^5.5.2",
"typescript-eslint": "^8.5.0"
},
Expand Down
40 changes: 33 additions & 7 deletions dressly/src/components/BrandSlider/BrandSlider.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
balenciaga,
louisVuitton,
} from '@brand/index';
import { Marquee } from '@selemondev/svelte-marquee';
const brands = [
{
Expand Down Expand Up @@ -34,15 +35,40 @@
image: louisVuitton,
},
];
let animateSponsor = false;
// Update the state based on window size
const updateSponsorAnimation = () => {
if (window.innerWidth < 640) { // 640px is the 'sm' breakpoint in Tailwind
animateSponsor = false;
} else {
animateSponsor = true;
}
};
</script>

<div id="brand-slider">
{#each brands as { name, image }}
<div class="brand-wrapper">
<img src={image} alt={`Brand ${name}`} class="drop-shadow-2xl" />
</div>
{/each}
</div>
<Marquee
class="gap-[3rem] [--duration:10s] [--gap:3rem] md:w-[800px] mx-auto overflow-x-hidden"
direction="left"
fade={true}
reverse={false}
pauseOnHover={true}
innerClassName="gap-[3rem]"
>
<div id="brand-slider">
{#each brands as { name, image }}
<div class="brand-wrapper">
<img
src={image}
alt={`Brand ${name}`}
class="drop-shadow-2xl select-none"
/>
</div>
{/each}
</div>
</Marquee>


<style lang="postcss">
* {
Expand Down
25 changes: 22 additions & 3 deletions dressly/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import animate from "tailwindcss-animate";

/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{html,ts,svelte}'],
content: [
'./src/**/*.{html,ts,svelte}',
'./node_modules/@selemondev/svelte-marquee/dist/*.svelte'
],
theme: {
extend: {
colors: {
Expand All @@ -16,7 +21,21 @@ module.exports = {
Lora: ['Lora', 'serif'],
OpenSans: ['Open Sans', 'sans-serif'],
},
keyframes: {
'marquee-left': {
from: { transform: 'translateX(0)' },
to: { transform: 'translateX(calc(-100% - var(--gap)))' }
},
'marquee-up': {
from: { transform: 'translateY(0)' },
to: { transform: 'translateY(calc(-100% - var(--gap)))' }
}
},
animation: {
'marquee-left': 'marquee-left var(--duration, 40s) linear infinite',
'marquee-up': 'marquee-up var(--duration, 40s) linear infinite'
},
},
},
plugins: [],
};
plugins: [animate],
};

0 comments on commit 6523d53

Please sign in to comment.