Skip to content

Commit

Permalink
feat(core): add better slides to the carousel
Browse files Browse the repository at this point in the history
  • Loading branch information
chanceaclark committed Oct 21, 2024
1 parent a22233f commit ec01760
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 36 deletions.
72 changes: 41 additions & 31 deletions core/components/slideshow/index.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,47 @@
import { useTranslations } from 'next-intl';

import { Slideshow as ComponentsSlideshow } from '~/components/ui/slideshow';

import SlideshowBG from './slideshow-bg-01.jpg';
import Slide1 from './slide-1.jpg';
import Slide2 from './slide-2.jpg';
import Slide3 from './slide-3.jpg';

const slides = [
{
cta: { label: 'Shop now', href: '/#' },
description:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.',
image: {
src: SlideshowBG,
altText: 'An assortment of brandless products against a blank background',
blurDataUrl:
'data:image/jpeg;base64,/9j/4QC8RXhpZgAASUkqAAgAAAAGABIBAwABAAAAAQAAABoBBQABAAAAVgAAABsBBQABAAAAXgAAACgBAwABAAAAAgAAABMCAwABAAAAAQAAAGmHBAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAAABgAAkAcABAAAADAyMTABkQcABAAAAAECAwAAoAcABAAAADAxMDABoAMAAQAAAP//AAACoAQAAQAAAAoAAAADoAQAAQAAAAcAAAAAAAAA/9sAQwADAgIDAgIDAwMDBAMDBAUIBQUEBAUKBwcGCAwKDAwLCgsLDQ4SEA0OEQ4LCxAWEBETFBUVFQwPFxgWFBgSFBUU/9sAQwEDBAQFBAUJBQUJFA0LDRQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgABwAKAwERAAIRAQMRAf/EABUAAQEAAAAAAAAAAAAAAAAAAAMJ/8QAIBAAAQQBBAMAAAAAAAAAAAAAAQIDBAURABIhMQYjgf/EABYBAQEBAAAAAAAAAAAAAAAAAAEAAv/EABkRAAIDAQAAAAAAAAAAAAAAAAARAQIhQf/aAAwDAQACEQMRAD8AoZ5EzayKWW3Syo0GyKPTJlsF9ts9klsKTu46GQOfms2awJfAKywmt1sRNgqK7PS0gSHI4WltTmBuKQckJJzgE9aYa0tP/9k=',
},
key: 1,
title: '25% Off Sale',
},
export const Slideshow = () => {
const t = useTranslations('Components.Slideshow');

{
cta: { label: 'Shop now', href: '/#' },
description:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.',
key: 2,
title: 'Great Deals',
},
return (
<ComponentsSlideshow
slides={[
{
cta: { label: t('SlideOne.cta'), href: '/#' },
description: t('SlideOne.description'),
image: {
src: Slide1,
altText: t('SlideOne.imageAltText'),
},
title: t('SlideOne.title'),
},

{
cta: { label: 'Shop now', href: '/#' },
description:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.',
key: 3,
title: 'Low Prices',
},
];
{
cta: { label: t('SlideTwo.cta'), href: '/#' },
description: t('SlideTwo.description'),
image: {
src: Slide2,
altText: t('SlideTwo.imageAltText'),
},
title: t('SlideTwo.title'),
},

export const Slideshow = () => <ComponentsSlideshow slides={slides} />;
{
cta: { label: t('SlideThree.cta'), href: '/#' },
description: t('SlideThree.description'),
image: {
src: Slide3,
altText: t('SlideThree.imageAltText'),
},
title: t('SlideThree.title'),
},
]}
/>
);
};
Binary file added core/components/slideshow/slide-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/components/slideshow/slide-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/components/slideshow/slide-3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed core/components/slideshow/slideshow-bg-01.jpg
Binary file not shown.
12 changes: 9 additions & 3 deletions core/components/ui/slideshow/slideshow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const Slideshow = ({ className, interval = 15_000, slides }: Props) => {
inert={index === activeSlide - 1 ? null : 'true'}
key={index}
>
<div className="relative">
<div className="relative h-full">
{slide.image && (
<NextImage
alt={slide.image.altText}
Expand All @@ -132,8 +132,14 @@ const Slideshow = ({ className, interval = 15_000, slides }: Props) => {
!slide.image && 'bg-gray-100',
)}
>
<h2 className="text-5xl font-black lg:text-6xl">{slide.title}</h2>
{Boolean(slide.description) && <p className="max-w-xl">{slide.description}</p>}
<h2 className="text-5xl font-black drop-shadow-[0_0_3px_rgba(255,255,255,0.3)] lg:text-6xl">
{slide.title}
</h2>
{Boolean(slide.description) && (
<p className="max-w-xl drop-shadow-[0_0_3px_rgba(255,255,255,0.3)]">
{slide.description}
</p>
)}
{slide.cta && (
<Button asChild className="w-fit">
<a href={slide.cta.href}>{slide.cta.label}</a>
Expand Down
20 changes: 20 additions & 0 deletions core/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,26 @@
"phone": "Enter a phone number",
"postalCode": "Enter a zip / postcode"
}
},
"Slideshow": {
"SlideOne": {
"title": "Fall Collection",
"description": "Cozy up with our newest arrivals for the fall season! From stylish jackets to soft knits, discover the must-haves to keep you warm and trendy.",
"imageAltText": "Three people staggered wearing different shades of sweaters.",
"cta": "Shop the Fall Collection"
},
"SlideTwo": {
"title": "Exclusive Offer: 20% Off!",
"description": "Limited-time sale! Get 20% off on all items for a fresh wardrobe update. Don't miss out on these savings, available for a short time only.",
"imageAltText": "A woman with a red top, looking to the right with a smile.",
"cta": "Grab Your Discount"
},
"SlideThree": {
"title": "Sustainable Fashion",
"description": "Fashion with a purpose. Explore our eco-friendly clothing line, made from sustainable materials. Look good and feel good knowing you're making a difference.",
"imageAltText": "A man wearing a green jacket and backpack looks confidently into the distance.",
"cta": "Explore Sustainable Styles"
}
}
}
}
4 changes: 2 additions & 2 deletions core/tests/ui/components/slideshow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ test.beforeEach(async ({ page }) => {
test('Navigate to next slide', async ({ page }) => {
await page.getByLabel('Next slide').click();

await expect(page.getByRole('heading', { name: 'Great Deals' })).toBeVisible();
await expect(page.getByRole('heading', { name: 'Exclusive Offer: 20% Off!' })).toBeVisible();
});

test('Navigate to previous slide', async ({ page }) => {
await page.getByLabel('Previous slide').click();

await expect(page.getByRole('heading', { name: 'Low Prices' })).toBeVisible();
await expect(page.getByRole('heading', { name: 'Sustainable Fashion' })).toBeVisible();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ec01760

Please sign in to comment.