Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(AboutModal): provide a way to set the background using props #1940

Merged
merged 1 commit into from
May 8, 2019

Conversation

seanforyou23
Copy link
Collaborator

@seanforyou23 seanforyou23 commented May 6, 2019

What: This PR removes the logoImageSrc and logoImageAlt props from about modal as they were never actually used. Beyond removing these dead API parts, I've replaced them with a single prop, bgImgSrc which I believe fulfills the original intent - which is making the background graphic on the right side of the modal configurable.

I've added a new example for AboutModal, one that illustrates how to set a custom background image.

The value passed for backgroundImageSrc is used to set the value for the css variable "--pf-c-about-modal-box__hero--sm--BackgroundImage". This is different than how we typically set CSS vars, and the need for it is described here #1919. In a nutshell, the need is driven by having assets served by a caching service or using generated asset filenames of which you don't know the exact name of a file, which in turn prevents you from setting this in a stylesheet.

Additional issues: #1919

Screen Shot 2019-05-06 at 3 33 55 PM

@patternfly-build
Copy link
Contributor

PatternFly-React preview: https://1940-pr-patternfly-react-patternfly.surge.sh

@codecov-io
Copy link

codecov-io commented May 6, 2019

Codecov Report

Merging #1940 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1940      +/-   ##
==========================================
- Coverage   82.59%   82.59%   -0.01%     
==========================================
  Files         624      624              
  Lines        6878     6876       -2     
  Branches       93       93              
==========================================
- Hits         5681     5679       -2     
  Misses       1157     1157              
  Partials       40       40
Flag Coverage Δ
#patternfly3 84.89% <ø> (ø) ⬆️
#patternfly4 79.27% <100%> (-0.02%) ⬇️
#patternflymisc 95.68% <ø> (ø) ⬆️
Impacted Files Coverage Δ
...e/src/components/AboutModal/AboutModalContainer.js 88.88% <ø> (ø) ⬆️
...react-core/src/components/AboutModal/AboutModal.js 66.66% <ø> (-4.17%) ⬇️
...ore/src/components/AboutModal/AboutModalBoxHero.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 82f8002...09cbd42. Read the comment docs.

mcoker
mcoker previously approved these changes May 6, 2019
Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@seanforyou23 seanforyou23 requested a review from redallen May 6, 2019 21:32
Copy link
Contributor

@dlabaj dlabaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments. Other then that it looks good.

"--pf-c-about-modal-box__hero--sm--BackgroundImage": `url(${bgImgSrc})`
} : {};
return (
<div {...props} style={bgStyle} className={css(styles.aboutModalBoxHero, className)} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if it doesn't find the image?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, so if you're referencing a local module like in the example, and it can't be found, your IDE should notice this and throw an error. If you're providing a value like https://www.site.com/image.svg and that asset doesn't properly fetch, you'd get a standard 404 just as if you provide an inaccessible asset in any regular background definition, in which case you'd get a black background.

logoImageAlt: props => {
if (props.logoImageSrc && !props.logoImageAlt) {
return new Error('logoImageAlt is required when a logoImageSrc is specified');
brandImageAlt: props => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since brandImageSrc is already required, we can also simply set brandImageAlt to required.
Although i'm questioning whether the brand image should be required...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I left it as required, can change at a later point if you like. The main focus for this PR is just to make the background image configurable.

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jschuler jschuler merged commit 4ad711d into patternfly:master May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants