Skip to content

Commit 213f6be

Browse files
committed
Austin and Erin feedback
1 parent 13e7033 commit 213f6be

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

packages/react-core/src/components/Hero/Hero.tsx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import heroGradientStop1Dark from '@patternfly/react-tokens/dist/esm/c_hero_grad
99
import heroGradientStop2Dark from '@patternfly/react-tokens/dist/esm/c_hero_gradient_stop_2_dark';
1010
import heroGradientStop3Dark from '@patternfly/react-tokens/dist/esm/c_hero_gradient_stop_3_dark';
1111

12-
/** The main Hero component that allowws adjusting of its background images and gradients in different color modes (such as light and dark). */
12+
/** The main Hero component that allows adjusting of its background images and gradients in different color modes (such as light and dark). */
1313

1414
export interface HeroProps extends Omit<React.HTMLProps<HTMLDivElement>, 'content'> {
1515
/** Content of the hero */
@@ -54,27 +54,23 @@ export const Hero: React.FunctionComponent<HeroProps> = ({
5454
backgroundImageStyles[heroBackgroundImageDark.name] = `url(${backgroundSrcDark})`;
5555
}
5656

57-
if (gradientLight) {
58-
if (gradientLight.stop1) {
59-
backgroundImageStyles[heroGradientStop1Light.name] = gradientLight.stop1;
60-
}
61-
if (gradientLight.stop2) {
62-
backgroundImageStyles[heroGradientStop2Light.name] = gradientLight.stop2;
63-
}
64-
if (gradientLight.stop3) {
65-
backgroundImageStyles[heroGradientStop3Light.name] = gradientLight.stop3;
66-
}
57+
if (gradientLight?.stop1) {
58+
backgroundImageStyles[heroGradientStop1Light.name] = gradientLight.stop1;
6759
}
68-
if (gradientDark) {
69-
if (gradientDark.stop1) {
70-
backgroundImageStyles[heroGradientStop1Dark.name] = gradientDark.stop1;
71-
}
72-
if (gradientDark.stop2) {
73-
backgroundImageStyles[heroGradientStop2Dark.name] = gradientDark.stop2;
74-
}
75-
if (gradientDark.stop3) {
76-
backgroundImageStyles[heroGradientStop3Dark.name] = gradientDark.stop3;
77-
}
60+
if (gradientLight?.stop2) {
61+
backgroundImageStyles[heroGradientStop2Light.name] = gradientLight.stop2;
62+
}
63+
if (gradientLight?.stop3) {
64+
backgroundImageStyles[heroGradientStop3Light.name] = gradientLight.stop3;
65+
}
66+
if (gradientDark?.stop1) {
67+
backgroundImageStyles[heroGradientStop1Dark.name] = gradientDark.stop1;
68+
}
69+
if (gradientDark?.stop2) {
70+
backgroundImageStyles[heroGradientStop2Dark.name] = gradientDark.stop2;
71+
}
72+
if (gradientDark?.stop3) {
73+
backgroundImageStyles[heroGradientStop3Dark.name] = gradientDark.stop3;
7874
}
7975

8076
return (

packages/react-core/src/components/Hero/examples/Hero.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ propComponents: ['Hero', 'HeroBody']
1010

1111
### Basic
1212

13-
When using a `<Hero>` with a background image, you can use the `<HeroBody>` to prevent text content from overlapping the background image, which helps ensure the text is more easily readable. Keep in mind that you should still check the color contrast when using the `gradientLight` or `gradientDark` properties.
13+
To ensure readability and prevent text from overlapping with the background image, use the `<HeroBody>` component. The `<HeroBody>` is optional and can be omitted if there's no background image or if you'd like finer control over text placement.
1414

15-
You can omit the `<HeroBody>` for finer control over the text placement, or if no background image is applied to the `<Hero>`.
15+
When using `gradientLight` or `gradientDark`, regardless of the presence of a `<HeroBody>`, check the color contrast to ensure proper accessibility.
1616

1717
```ts file="HeroBasic.tsx"
1818

0 commit comments

Comments
 (0)