Skip to content

Commit c223727

Browse files
committed
Merge branch 'release/0.18.11'
2 parents 748816e + d8a9637 commit c223727

File tree

19 files changed

+1001
-866
lines changed

19 files changed

+1001
-866
lines changed

CHANGELOG.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ Prefix the change with one of these keywords:
1717

1818
## [Unreleased]
1919

20+
##[0.18.11]
21+
22+
### Added
23+
24+
- Custom Slider
25+
26+
### Fixed
27+
28+
- Figure component to display the image size for retina display
29+
30+
### Changed
31+
32+
- Refactored Full Banner to remove bg image, position and improve mobile experience
33+
2034
##[0.18.10]
2135

2236
### Changed
@@ -135,6 +149,10 @@ Prefix the change with one of these keywords:
135149
- Accordion Content style by removing extra padding in mobile screen
136150
- Margin classes for the PageHeader with and without children
137151

152+
### Fixed
153+
154+
- Form auto suggest menu, options style
155+
138156
### Refactored
139157

140158
- ImageGrid block to use aspect ratio and bg images

lib/components/Figure/Figure.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const FigureWrapper = ({
2828
return (
2929
<figure className={`cu-figure cu-component ${hideMobile}`}>
3030
<div
31-
className={`not-prose overflow-hidden bg-white shadow-lg ${figureSizeClasses[size]} ${borderRadiusClasses[rounded]} ${figureAlignClasses[align]}`}
31+
className={`not-prose overflow-hidden bg-white shadow-lg w-full ${figureSizeClasses[size]} ${borderRadiusClasses[rounded]} ${figureAlignClasses[align]}`}
3232
>
3333
{children}
3434
{caption && <figcaption className="px-5 py-4 text-base italic text-cu-black-700">{caption}</figcaption>}

lib/components/Form/AutoSuggest/styles.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,11 @@
2020
.cu-autosuggest .css-19bb58m {
2121
@apply m-0 py-0;
2222
}
23+
24+
.cu-autosuggest .css-1nmdiq5-menu {
25+
@apply rounded-lg overflow-hidden;
26+
}
27+
28+
.cu-autosuggest .css-10wo9uf-option {
29+
@apply text-base;
30+
}

lib/components/FullBanner/FullBanner.stories.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ export const Primary: Story = {
2424
title: 'The nostalgia is real.',
2525
headerType: 'h1',
2626
image: 'https://picsum.photos/id/20/1600/700',
27-
opacity: 70,
28-
focalPointX: 50,
29-
focalPointY: 50,
27+
opacity: 80,
3028
justify: 'start',
3129
},
3230
render: (args) => {
@@ -36,7 +34,7 @@ export const Primary: Story = {
3634
The launch of the iPod revolutionized how the world consumes music on the move! The launch of the iPod
3735
revolutionized how the world consumes music on the move!
3836
</p>
39-
<ButtonGroup>
37+
<ButtonGroup align={args.justify}>
4038
<Button title="Apply Now" />
4139
<Button color="grey" title="Request Information" />
4240
</ButtonGroup>

lib/components/FullBanner/FullBanner.tsx

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,48 @@
1+
import { justifyContentClasses, bgOpacityClasses } from '../../utils/propClasses'
12
import { PageHeader } from '../PageHeader/PageHeader'
2-
import { justifyContentClasses } from '../../utils/propClasses'
33

44
type justifyContentKeys = keyof typeof justifyContentClasses
5-
6-
const opacityValues = Array.from({ length: 21 }, (_, index) => 60 + index)
5+
type bgOpacityKeys = keyof typeof bgOpacityClasses
76

87
export interface FullBannerProps {
98
children?: React.ReactNode
109
as?: 'section' | 'div'
1110
title: string
1211
headerType?: 'h1' | 'h2'
1312
image?: string
14-
focalPointX?: number
15-
focalPointY?: number
1613
justify?: justifyContentKeys
17-
opacity?: (typeof opacityValues)[number]
14+
opacity?: bgOpacityKeys
1815
}
1916

20-
// Used in WideImage, make a helper function when moving this component into RDS
21-
const getBackgroundImageStyles = (image: string = '', focalPointX: number, focalPointY: number) => ({
22-
backgroundImage: `url(${image})`,
23-
backgroundPosition: `${focalPointX}% ${focalPointY}%`,
24-
})
25-
2617
export const FullBanner = ({
2718
children,
2819
as = 'section',
2920
title,
3021
headerType = 'h1',
3122
image,
32-
focalPointX = 50,
33-
focalPointY = 50,
3423
opacity = 70,
3524
justify = 'start',
3625
}: FullBannerProps) => {
37-
if (!opacityValues.includes(opacity)) {
38-
console.warn(`Invalid opacity value: ${opacity}. It should be one of ${opacityValues.join(', ')}.`)
39-
}
40-
4126
const FullBannerComponent = as
42-
const inlineStyle = getBackgroundImageStyles(image, focalPointX, focalPointY)
43-
const opacityStyle = {
44-
opacity: `0.${opacity}`,
45-
}
46-
const contentAlign = justify === 'center' ? 'text-center [&>*]:justify-center' : ''
4727

4828
return (
4929
<FullBannerComponent
50-
className={`cu-fullbanner cu-fullbanner--${justify} cu-component cu-no-browsers-edge cu-prose cu-prose-light not-contained overflow-hidden bg-cu-black-200 bg-cover mb-6 pt-80 pb-0 md:pt-48 md:pb-12 lg:pt-64 lg:pb-24 xl:pt-96 xl:pb-36 px-0 md:px-10`}
51-
style={inlineStyle}
30+
className={`cu-fullbanner cu-component bg-cu-black-900 relative cu-no-browsers-edge not-prose not-contained`}
5231
>
53-
<div className="mx-auto max-w-screen-2xl">
54-
<div className={`flex ${justifyContentClasses[justify]}`}>
32+
{image && (
33+
<div className="relative">
34+
<img src={image} className="rounded-none w-full h-auto" />
35+
</div>
36+
)}
37+
38+
<div className="lg:absolute lg:bottom-8 w-full px-8 lg:px-10">
39+
<div className={`max-w-screen-2xl mx-auto flex ${justifyContentClasses[justify]}`}>
5540
<div
56-
className={`relative overflow-hidden min-w-[420px] md:max-w-xl lg:max-w-2xl xl:max-w-3xl md:rounded-lg ${contentAlign}`}
41+
className={`w-full lg:max-w-2xl bg-cu-black-900 ${bgOpacityClasses[opacity]} lg:px-8 pt-3 pb-5 lg:pt-6 lg:pb-8 rounded-lg text-white`}
5742
>
58-
<div className="relative z-10 px-5 md:px-8 pt-3 pb-5 md:pt-6 md:pb-8">
59-
<PageHeader header={title} as={headerType} size={headerType === 'h1' ? 'md' : 'sm'} noUnderline isWhite>
60-
{children}
61-
</PageHeader>
62-
</div>
63-
64-
<div className="absolute top-0 left-0 w-full h-full bg-black" style={opacityStyle}></div>
43+
<PageHeader header={title} as={headerType} size={headerType === 'h1' ? 'md' : 'sm'} noUnderline isWhite>
44+
{children}
45+
</PageHeader>
6546
</div>
6647
</div>
6748
</div>
Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.cu-fullbanner--content > * {
2+
@apply z-50 relative;
3+
}
4+
15
/* Top spacing when first block */
26

37
main.cu-main > .cu-fullbanner:first-of-type,
@@ -16,23 +20,11 @@ section.cu-section > .cu-fullbanner:first-of-type {
1620
}
1721

1822
.cu-fullbanner .cu-pageheader p {
19-
@apply leading-7 md:leading-8 mt-0;
23+
@apply md:text-xl;
2024
}
2125

2226
/* Justification */
2327

24-
.cu-fullbanner--center {
28+
.cu-fullbanner .justify-center {
2529
@apply text-center;
2630
}
27-
28-
.cu-fullbanner--center .cu-buttongroup {
29-
@apply justify-center;
30-
}
31-
32-
.cu-fullbanner--end {
33-
@apply text-right justify-end;
34-
}
35-
36-
.cu-fullbanner--end .cu-buttongroup {
37-
@apply justify-end;
38-
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { aspectRatioClasses } from '../../utils/propClasses'
2+
import { useLinkContext } from '../LinkProvider/useLinkContext'
3+
4+
type aspectRatioKeys = keyof typeof aspectRatioClasses
5+
6+
export interface ImageProps {
7+
imageUrl: string
8+
focalPointX?: number
9+
focalPointY?: number
10+
title?: string
11+
link?: string
12+
aspectRatio?: aspectRatioKeys
13+
}
14+
15+
export const Image = ({
16+
imageUrl,
17+
focalPointX = 50,
18+
focalPointY = 50,
19+
title,
20+
link,
21+
aspectRatio = 'landscape',
22+
}: ImageProps) => {
23+
const LinkComponent = useLinkContext()
24+
const inlineImageStyles = {
25+
backgroundImage: `url(${imageUrl})`,
26+
backgroundPosition: `${focalPointX}% ${focalPointY}%`,
27+
}
28+
29+
return (
30+
<div
31+
className={`relative ${aspectRatioClasses[aspectRatio]} bg-cover bg-center rounded-lg bg-black w-full h-full transition-[width] duration-[5000] ease-in-out`}
32+
style={inlineImageStyles}
33+
>
34+
{title && (
35+
<div
36+
className={`bg-black/75 text-white absolute bottom-2 left-2 right-2 px-4 py-2.5 rounded-md ${link ? 'hover:bg-cu-red/85' : ''}`}
37+
>
38+
{link ? (
39+
<LinkComponent href={link} className="cursor-pointer block hover-bg-cu-red">
40+
<p className="text-sm md:text-base font-semibold line-clamp-2">{title}</p>
41+
</LinkComponent>
42+
) : (
43+
<p className="text-sm md:text-base font-semibold line-clamp-2">{title}</p>
44+
)}
45+
</div>
46+
)}
47+
</div>
48+
)
49+
}

lib/components/ImageSlider/ImageSlider.stories.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,27 @@ type Story = StoryObj<typeof ImageSlider>
1919

2020
export const Primary: Story = {
2121
args: {
22-
customClass: 'slider',
22+
slidesPerViewDesktop: 3,
23+
slidesPerViewTablet: 2,
2324
slidesPerViewMobile: 1,
24-
slidesPerViewTablet: 3,
25-
slidesPerViewDesktop: 4,
26-
loop: true,
27-
speed: 1000,
2825
},
2926
render: (args) => {
3027
return (
3128
<ImageSlider {...args}>
3229
{sliderData.map((image, index) => {
3330
const { image: imageUrl, title, link, focalPointX, focalPointY, aspectRatio } = image
3431
return (
35-
<ImageSlider.Item
36-
key={index}
37-
imageUrl={imageUrl}
38-
title={title}
39-
link={link}
40-
focalPointX={focalPointX}
41-
focalPointY={focalPointY}
42-
aspectRatio={aspectRatio}
43-
className={index == 0 ? `swiper-slide-active` : ``}
44-
/>
32+
<ImageSlider.Slide key={index}>
33+
<ImageSlider.Image
34+
key={index}
35+
imageUrl={imageUrl}
36+
title={title}
37+
link={link}
38+
focalPointX={focalPointX}
39+
focalPointY={focalPointY}
40+
aspectRatio={aspectRatio}
41+
/>
42+
</ImageSlider.Slide>
4543
)
4644
})}
4745
</ImageSlider>
Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,58 @@
11
import { useEffect } from 'react'
22
import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/solid'
3-
import { ImageSliderItem } from './ImageSliderItem'
4-
import SwiperSlider from './script'
3+
import { Slide } from './Slide'
4+
import { Image } from './Image'
5+
import SliderScript from './script.ts'
56

67
export interface ImageSliderProp {
78
children: React.ReactNode
8-
loop?: boolean
9-
speed?: number
10-
slidesPerViewMobile?: number
11-
slidesPerViewTablet?: number
129
slidesPerViewDesktop: number
13-
customClass?: string
10+
slidesPerViewTablet?: number
11+
slidesPerViewMobile?: number
1412
}
1513

1614
export const ImageSliderWrapper = ({
1715
children,
18-
loop = false,
19-
speed = 500,
20-
slidesPerViewMobile = 1,
21-
slidesPerViewTablet = 2,
22-
slidesPerViewDesktop = 3,
23-
customClass,
16+
slidesPerViewDesktop,
17+
slidesPerViewTablet,
18+
slidesPerViewMobile,
2419
}: ImageSliderProp) => {
2520
useEffect(() => {
26-
SwiperSlider()
27-
}, [])
21+
SliderScript()
22+
})
23+
24+
const arrowButtons = `bg-cu-black-50 text-cu-black-800 hover:bg-cu-red hover:text-white hover:bg-cu-red relative flex items-center justify-center rounded-md h-8 w-8 z-50`
25+
const arrowIcons = `w-5 h-5 [&>path]:stroke-[2]`
2826

2927
return (
3028
<div
31-
className={`swiper swiper--slider ${customClass ? customClass : ''}`}
32-
data-swiper-class={`${customClass ? customClass : 'swiper'}`}
33-
data-swiper-loop={loop}
34-
data-swiper-speed={speed}
35-
data-swiper-perview-mobile={slidesPerViewMobile}
36-
data-swiper-perview-tablet={slidesPerViewTablet}
37-
data-swiper-perview-desktop={slidesPerViewDesktop}
29+
className="slider overflow-hidden"
30+
data-slides-desktop={slidesPerViewDesktop}
31+
data-slides-tablet={slidesPerViewTablet}
32+
data-slides-mobile={slidesPerViewMobile}
3833
>
39-
<div className="swiper-wrapper">{children}</div>
40-
<div className="swiper__footer">
41-
<button type="button" className="swiper__button swiper__button--prev" aria-label="Previous slide">
42-
<ChevronLeftIcon className="w-8 h-8 [&>path]:stroke-[2]" aria-hidden="true" />
34+
{/* Slider Slides */}
35+
<div className="slider__wrap flex align-items-center">{children}</div>
36+
37+
{/* Slider Arrow */}
38+
<div className="flex align-items-center gap-3 justify-center mt-4">
39+
<button className={`slider__arrow slider__arrow--prev ${arrowButtons}`}>
40+
<span className="sr-only">Go to Previous Slide</span>
41+
<ChevronLeftIcon className={arrowIcons} aria-hidden="true" />
4342
</button>
44-
<button type="button" className="swiper__button swiper__button--next" aria-label="Next slide">
45-
<ChevronRightIcon className="w-8 h-8 [&>path]:stroke-[2]" aria-hidden="true" />
43+
44+
<button className={`slider__arrow slider__arrow--next ${arrowButtons}`}>
45+
<span className="sr-only">Go to Next Slide</span>
46+
<ChevronRightIcon className={arrowIcons} aria-hidden="true" />
4647
</button>
4748
</div>
4849
</div>
4950
)
5051
}
5152

5253
export const ImageSlider = Object.assign(ImageSliderWrapper, {
53-
Item: ImageSliderItem,
54+
Slide: Slide,
55+
Image: Image,
5456
})
5557

5658
ImageSliderWrapper.displayName = 'ImageSlider'

0 commit comments

Comments
 (0)