{
await expect(page).toHaveScreenshot({fullPage: true})
})
+ test('Statistic / Media Components', async ({page}) => {
+ await page.goto(
+ 'http://localhost:6006/iframe.html?args=&id=components-statistic-features--media-components&viewMode=story',
+ {waitUntil: 'networkidle'},
+ )
+ await page.locator('body.sb-show-main').waitFor({state: 'visible'})
+
+ await page.waitForTimeout(500)
+ await expect(page).toHaveScreenshot({fullPage: true})
+ })
+
test('Statistic / With Footnote', async ({page}) => {
await page.goto(
'http://localhost:6006/iframe.html?args=&id=components-statistic-features--with-footnote&viewMode=story',
diff --git a/packages/react/src/Statistic/Statistic.visual.spec.ts-snapshots/Visual-Comparison-Statistic-Statistic-Media-Components-1-darwin.png b/packages/react/src/Statistic/Statistic.visual.spec.ts-snapshots/Visual-Comparison-Statistic-Statistic-Media-Components-1-darwin.png
new file mode 100644
index 0000000000..65c08ebbf3
Binary files /dev/null and b/packages/react/src/Statistic/Statistic.visual.spec.ts-snapshots/Visual-Comparison-Statistic-Statistic-Media-Components-1-darwin.png differ
diff --git a/packages/react/src/Testimonial/Testimonial.module.css b/packages/react/src/Testimonial/Testimonial.module.css
index 457ec76a8f..c1de1e820a 100644
--- a/packages/react/src/Testimonial/Testimonial.module.css
+++ b/packages/react/src/Testimonial/Testimonial.module.css
@@ -134,6 +134,10 @@
margin-top: var(--base-size-24);
}
+.Testimonial-logo-image {
+ display: block;
+}
+
.Testimonial--size-large .Testimonial__media {
margin-top: var(--base-size-64);
}
diff --git a/packages/react/src/Testimonial/Testimonial.module.css.d.ts b/packages/react/src/Testimonial/Testimonial.module.css.d.ts
index 0713a7b573..27d4ec4fcc 100644
--- a/packages/react/src/Testimonial/Testimonial.module.css.d.ts
+++ b/packages/react/src/Testimonial/Testimonial.module.css.d.ts
@@ -9,6 +9,7 @@ declare const styles: {
readonly "Testimonial-caption": string;
readonly "Testimonial-from": string;
readonly "Testimonial-link": string;
+ readonly "Testimonial-logo-image": string;
readonly "Testimonial-quote": string;
readonly "Testimonial__media": string;
readonly "Testimonial__quoteMark": string;
diff --git a/packages/react/src/Testimonial/Testimonial.test.tsx b/packages/react/src/Testimonial/Testimonial.test.tsx
index 626111ec6e..371bc79b01 100644
--- a/packages/react/src/Testimonial/Testimonial.test.tsx
+++ b/packages/react/src/Testimonial/Testimonial.test.tsx
@@ -357,16 +357,17 @@ describe('Testimonial', () => {
expect(avatarContainer).toHaveClass('Avatar--size-48')
})
- it('renders logo with img element', () => {
+ it('renders logo with img element and preserves its class name', () => {
const logoSrc = '/logo.png'
const logoAlt = 'Company logo'
+ const logoClassName = 'custom-logo'
const {getByRole} = render(
Quote text
Name
-
+
,
)
@@ -374,6 +375,7 @@ describe('Testimonial', () => {
const logo = getByRole('img', {name: logoAlt})
expect(logo).toBeInTheDocument()
expect(logo).toHaveAttribute('src', logoSrc)
+ expect(logo).toHaveClass('Testimonial-logo-image', logoClassName)
})
it('renders logo container', () => {
diff --git a/packages/react/src/Testimonial/Testimonial.tsx b/packages/react/src/Testimonial/Testimonial.tsx
index ace3a96f24..a58798a1eb 100644
--- a/packages/react/src/Testimonial/Testimonial.tsx
+++ b/packages/react/src/Testimonial/Testimonial.tsx
@@ -192,7 +192,7 @@ function _Logo({children, ...rest}: LogoProps, ref) {
if (child.type === 'img') {
const imageChild = child as React.ReactElement
>
const imageProps: ComponentPropsWithRef<'img'> = {
- className: clsx(styles['Testimonial-logo-image']),
+ className: clsx(styles['Testimonial-logo-image'], imageChild.props.className),
ref: ref as ComponentPropsWithRef<'img'>['ref'],
}
diff --git a/packages/react/src/css/reset.css b/packages/react/src/css/reset.css
index d729d61542..1de512b697 100644
--- a/packages/react/src/css/reset.css
+++ b/packages/react/src/css/reset.css
@@ -33,11 +33,19 @@ ol[role='list'] {
list-style: none;
}
-/* Set core root defaults */
+/* Set core root scrolling behavior */
+html,
html:focus-within {
scroll-behavior: smooth;
}
+@media (prefers-reduced-motion: reduce) {
+ html,
+ html:focus-within {
+ scroll-behavior: auto;
+ }
+}
+
/* Set core body defaults */
body {
min-height: 100vh;
@@ -53,7 +61,6 @@ a:not([class]) {
img,
picture {
max-width: 100%;
- display: block;
}
/* Inherit fonts for inputs and buttons */
@@ -63,14 +70,3 @@ textarea,
select {
font: inherit;
}
-
-/* Remove all animations, transitions and smooth scroll for people that prefer not to see them */
-@media (prefers-reduced-motion: reduce) {
- html:focus-within {
- scroll-behavior: auto;
- }
-}
-
-html {
- scroll-behavior: smooth;
-}
diff --git a/packages/react/src/river/River/River.features.stories.tsx b/packages/react/src/river/River/River.features.stories.tsx
index 2eafb493b3..295faeeb1a 100644
--- a/packages/react/src/river/River/River.features.stories.tsx
+++ b/packages/react/src/river/River/River.features.stories.tsx
@@ -192,6 +192,30 @@ export const CustomTrailingContent: StoryFn = () => (
)
CustomTrailingContent.storyName = 'Custom trailing content'
+export const CustomMediaContent: StoryFn = () => (
+
+
+
+
+
+ (
+
+
+
+ )}
+ trailingComponent={() => (
+
+ )}
+ >
+ Heading
+ Test showing custom images in the slots
+
+
+
+)
+CustomMediaContent.storyName = 'Custom media content'
+
export const CustomTrailingContentWithDivider: StoryFn = () => (
diff --git a/packages/react/src/river/River/River.test.tsx b/packages/react/src/river/River/River.test.tsx
index 79c74aa516..281fae2e07 100644
--- a/packages/react/src/river/River/River.test.tsx
+++ b/packages/react/src/river/River/River.test.tsx
@@ -243,11 +243,14 @@ describe('River', () => {
})
it('provides an escape hatch to enter leading and trailing custom components', () => {
- const [mockLeading, mockTrailing] = ['custom-leading', 'custom-trailing']
- const MockLeadingComponent = () =>
- const MockTrailingComponent = () =>
+ const MockLeadingComponent = () => (
+
+
+
+ )
+ const MockTrailingComponent = () =>
- const {getByTestId} = render(
+ const {getByRole} = render(
@@ -258,11 +261,11 @@ describe('River', () => {
,
)
- const elLeading = getByTestId(mockLeading)
- const elTrailing = getByTestId(mockTrailing)
+ const leadingImage = getByRole('img', {name: 'Custom leading'})
+ const trailingImage = getByRole('img', {name: 'Custom trailing'})
- expect(elLeading).toBeInTheDocument()
- expect(elTrailing).toBeInTheDocument()
+ expect(leadingImage.closest('[class*="River__leadingComponent"]')).toBeInTheDocument()
+ expect(trailingImage.closest('[class*="River__trailingComponent"]')).toBeInTheDocument()
})
it('renders a h3 Heading by default', () => {
diff --git a/packages/react/src/river/River/River.tsx b/packages/react/src/river/River/River.tsx
index 5357a1a6f7..9370b65054 100644
--- a/packages/react/src/river/River/River.tsx
+++ b/packages/react/src/river/River/River.tsx
@@ -218,7 +218,7 @@ export const RiverContent = forwardRef(
)}
{!LabelChild && !EyebrowTextChild && LeadingComponent && (
-
+
)}
diff --git a/packages/react/src/river/River/River.visual.spec.ts b/packages/react/src/river/River/River.visual.spec.ts
index 64b912f7e4..8480079005 100644
--- a/packages/react/src/river/River/River.visual.spec.ts
+++ b/packages/react/src/river/River/River.visual.spec.ts
@@ -187,6 +187,17 @@ test.describe('Visual Comparison: River', () => {
await expect(page).toHaveScreenshot({fullPage: true})
})
+ test('River / Custom media content', async ({page}) => {
+ await page.goto(
+ 'http://localhost:6006/iframe.html?args=&id=components-river-features--custom-media-content&viewMode=story',
+ {waitUntil: 'networkidle'},
+ )
+ await page.locator('body.sb-show-main').waitFor({state: 'visible'})
+
+ await page.waitForTimeout(500)
+ await expect(page).toHaveScreenshot({fullPage: true})
+ })
+
test('River / Custom trailing content w/ divider', async ({page}) => {
await page.goto(
'http://localhost:6006/iframe.html?args=&id=components-river-features--custom-trailing-content-with-divider&viewMode=story',
diff --git a/packages/react/src/river/River/River.visual.spec.ts-snapshots/Visual-Comparison-River-River-Custom-media-content-1-darwin.png b/packages/react/src/river/River/River.visual.spec.ts-snapshots/Visual-Comparison-River-River-Custom-media-content-1-darwin.png
new file mode 100644
index 0000000000..4e4181f9d6
Binary files /dev/null and b/packages/react/src/river/River/River.visual.spec.ts-snapshots/Visual-Comparison-River-River-Custom-media-content-1-darwin.png differ
diff --git a/packages/react/src/river/River/River.visual.spec.ts-snapshots/Visual-Comparison-River-River-Larger-Placeholder-Image-1-darwin.png b/packages/react/src/river/River/River.visual.spec.ts-snapshots/Visual-Comparison-River-River-Larger-Placeholder-Image-1-darwin.png
index e0a0e2ac09..bd18a4621f 100644
Binary files a/packages/react/src/river/River/River.visual.spec.ts-snapshots/Visual-Comparison-River-River-Larger-Placeholder-Image-1-darwin.png and b/packages/react/src/river/River/River.visual.spec.ts-snapshots/Visual-Comparison-River-River-Larger-Placeholder-Image-1-darwin.png differ
diff --git a/packages/react/src/river/RiverStoryScroll/RiverStoryScroll.module.css b/packages/react/src/river/RiverStoryScroll/RiverStoryScroll.module.css
index 7cfa1c9099..8dd6463834 100644
--- a/packages/react/src/river/RiverStoryScroll/RiverStoryScroll.module.css
+++ b/packages/react/src/river/RiverStoryScroll/RiverStoryScroll.module.css
@@ -42,6 +42,7 @@
}
.RiverStoryScroll__image {
+ display: block;
margin-left: auto;
margin-right: auto;
width: auto;
diff --git a/packages/react/src/river/river-shared.module.css b/packages/react/src/river/river-shared.module.css
index b80137b198..3bf6a20008 100644
--- a/packages/react/src/river/river-shared.module.css
+++ b/packages/react/src/river/river-shared.module.css
@@ -34,6 +34,10 @@
order: 2;
}
+.River__visual :is(img, picture) {
+ display: block;
+}
+
.River__visual--fill-media img,
.River__visual--fill-media picture,
.River__visual--fill-media video {
@@ -154,6 +158,11 @@
line-height: calc(1lh * 1.1);
}
+.River__leadingComponent :is(img, picture),
+.River__trailingComponent :is(img, picture) {
+ display: block;
+}
+
.River__trailingComponent {
margin-block-start: var(--brand-River-spacing-inner);
}
diff --git a/packages/react/src/river/river-shared.module.css.d.ts b/packages/react/src/river/river-shared.module.css.d.ts
index 503bbf5e50..b264856a42 100644
--- a/packages/react/src/river/river-shared.module.css.d.ts
+++ b/packages/react/src/river/river-shared.module.css.d.ts
@@ -17,6 +17,7 @@ declare const styles: {
readonly "River__heading": string;
readonly "River__heading-inner": string;
readonly "River__label": string;
+ readonly "River__leadingComponent": string;
readonly "River__text": string;
readonly "River__trailingComponent": string;
readonly "River__trailingComponent--divider": string;