diff --git a/package.json b/package.json index bb6d480..bf433c2 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ }, "dependencies": { "dayjs": "^1.10.7", + "embla-carousel": "^5.0.1", "focus-visible": "^5.2.0", "sanitize.css": "^13.0.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 411b20d..ec0284d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,6 +7,7 @@ specifiers: '@typescript-eslint/eslint-plugin': ^5.2.0 '@typescript-eslint/parser': ^5.2.0 dayjs: ^1.10.7 + embla-carousel: ^5.0.1 eslint: ^8.1.0 eslint-plugin-svelte3: ^3.2.1 focus-visible: ^5.2.0 @@ -20,6 +21,7 @@ specifiers: dependencies: dayjs: 1.10.7 + embla-carousel: 5.0.1 focus-visible: 5.2.0 sanitize.css: 13.0.0 @@ -467,6 +469,10 @@ packages: esutils: 2.0.3 dev: true + /embla-carousel/5.0.1: + resolution: {integrity: sha512-pFvUI9mI/pxU92+4VDkPx0yP4Bs3VqJuRX/aw6ESYJdRBtzLx+6X2kXMu9aXK+SwO2zYsD2WURb1SeBaAv6zQA==} + dev: false + /enquirer/2.3.6: resolution: {integrity: sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==} engines: {node: '>=8.6'} diff --git a/src/components/organisms/Carousel.svelte b/src/components/organisms/Carousel.svelte new file mode 100644 index 0000000..be61786 --- /dev/null +++ b/src/components/organisms/Carousel.svelte @@ -0,0 +1,116 @@ + + + \ No newline at end of file diff --git a/src/style/organisms/_carousel.scss b/src/style/organisms/_carousel.scss new file mode 100644 index 0000000..ce30b9d --- /dev/null +++ b/src/style/organisms/_carousel.scss @@ -0,0 +1,112 @@ +.carousel { + position: relative; + overflow: hidden; + border-radius: 6px; + background: $color-primary-tertiary20; + + // Slides + &__slides { + display: flex; + } + &__slide { + position: relative; + flex: 0 0 100%; + color: $color-text; + cursor: pointer; + + img { + display: block; + width: 100%; + height: 100%; + object-fit: cover; + } + } + + // Dots + &__dots { + position: absolute; + bottom: 20px; + left: 50%; + transform: translateX(-50%); + display: flex; + align-items: center; + justify-content: center; + height: 32px; + padding: 0 12px; + background: rgba($color-tertiary, 0.5); + backdrop-filter: blur(16px); + border-radius: 100vh; + + @include bp (sm) { + bottom: 28px; + height: 40px; + padding: 0 16px; + } + + li { + display: block; + margin: 0 4px; + } + button { + $color-shadow: rgba(#533331, 0.1); + position: relative; + display: block; + width: 8px; + height: 8px; + border-radius: 100%; + background: #fff; + padding: 0; + overflow: hidden; + box-shadow: 0 1px 1px $color-shadow, 0 2px 2px $color-shadow; + + &:after { + content: ""; + display: block; + position: absolute; + top: 50%; + left: 50%; + width: 125%; + height: 125%; + border-radius: 100%; + background: $color-secondary-light; + transform: translate3d(-50%, -50%, 0) scale3d(0,0,0); + transform-origin: 50% 50%; + transition: transform 1s var(--ease-quart); + } + } + + // Active + .is-active { + button:after { + transform: translate3d(-50%, -50%, 0) scale3d(1,1,1); + } + } + } + + // Arrow + &__arrow { + $color-shadow: rgba(#000, 0.075); + position: absolute; + top: 0; + left: 0; + opacity: 0; + pointer-events: none; + display: block; + transform: translate3d(var(--x), var(--y), 0); + transition: transform 0.6s var(--ease-quart), opacity 0.6s var(--ease-quart); + transform-origin: 50% 50%; + filter: drop-shadow(0 2px 2px $color-shadow) drop-shadow(0 8px 8px $color-shadow) drop-shadow(0 16px 16px $color-shadow); + + // Flipped for previous direction + &.is-flipped { + transform: translate3d(var(--x), var(--y), 0) rotate(-180deg); + } + } + + // Show arrow on hover + &:hover { + .carousel__arrow { + opacity: 1; + } + } +} \ No newline at end of file diff --git a/src/style/style.scss b/src/style/style.scss index 9642901..c84bcbf 100644 --- a/src/style/style.scss +++ b/src/style/style.scss @@ -57,6 +57,7 @@ @import "organisms/locations"; @import "organisms/house"; @import "organisms/newsletter"; +@import "organisms/carousel"; @import "organisms/shop"; @import "organisms/poster-product"; @import "organisms/footer";