Skip to content

I4917 screenshot size fix - #5307

Merged
rebmullin merged 3 commits into
mozilla:masterfrom
rebmullin:I4917-screenshot-size-fix
Jun 19, 2018
Merged

rebmullin merged 3 commits into
mozilla:masterfrom
rebmullin:I4917-screenshot-size-fix

Conversation

@rebmullin

@rebmullin rebmullin commented Jun 18, 2018 •

Copy link
Copy Markdown
Contributor

fixes mozilla/addons#11344 -

instead of scaling up we are now we are using the actual image size. My understanding is that eventually we want to use srcset when the images are all set up (let me know if this assumption is not correct)

With the smaller image it looks a little odd so I have also centered the caption a bit more (it was left aligned in it's container which was centered).

before:
Alt text

after:
Alt text

@codecov-io

codecov-io commented Jun 18, 2018 •

Copy link
Copy Markdown

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master    mozilla/addons-frontend#5307      +/-   ##
==========================================
- Coverage   96.95%   96.95%   -0.01%     
==========================================
  Files         215      215              
  Lines        5355     5353       -2     
  Branches     1048     1048              
==========================================
- Hits         5192     5190       -2     
  Misses        145      145              
  Partials       18       18
Impacted Files Coverage Δ
src/amo/components/ScreenShots.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 aa426c0...3f0a5a1. Read the comment docs.

@willdurand willdurand self-assigned this Jun 18, 2018

@willdurand willdurand left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, thanks! Here are a few questions and comments.

const HEIGHT = 400;
const WIDTH = 200;

describe('<ScreenShots />', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you please update this description with __filename?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, I see that we are using renderIntoDocument. It could be nice to rewrite the test case with Enzyme.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ahh..ok sure!


it('renders custom thumbnail', () => {
const item = { src: 'https://foo.com/img.png', title: 'test title' };
const item = { src: 'https://foo.com/img.png', title: 'test title', h: HEIGHT, w: WIDTH };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be better to pass different height/width here to make sure we use the values from image_size.

line-height: 0;
.ScreenShots {
.pswp-thumbnails {
line-height: 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is it needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

do you mean the line-height style? This was on the line above I just moved it so I could nest the caption style as well

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

heh. 🤕

Comment thread src/amo/components/ScreenShots.js Outdated

export const thumbnailContent = (item) => (
<img src={item.src} className="ScreenShots-image" height={HEIGHT} width={WIDTH} alt="" title={item.title} />
<img src={item.src} className="ScreenShots-image" height={item.h} width={item.w} alt="" title={item.title} />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could probably use item.title as alt content. It is not a super-best-practice, but it is better than having an empty alt I guess.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

just curious what is not best practice here - do you mean adding the title for alt?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For accessibility, we should not have the same content for both alt and title.

title should be the title of the image (e.g. The Treachery of Images) and alt should be a description of what the image shows (e.g., The picture shows a pipe. Below it, Magritte painted, "Ceci n'est pas une pipe.", French for "This is not a pipe.").

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ahh ok..

@willdurand willdurand left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

r+wc

Comment thread src/amo/components/ScreenShots.js Outdated

export const thumbnailContent = (item) => (
<img src={item.src} className="ScreenShots-image" height={HEIGHT} width={WIDTH} alt="" title={item.title} />
<img src={item.src} className="ScreenShots-image" height={item.h} width={item.w} alt={item.title} title={item.title} />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess we could also write the props on different lines:

<img
  src={item.src}
  ...
/>


it('renders custom thumbnail', () => {
const item = { src: 'https://foo.com/img.png', title: 'test title' };
const item = { src: 'https://foo.com/img.png', title: 'test title', h: 123, w: 1234 };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You could introduce the variables h and w.

it('renders custom thumbnail', () => {
const item = { src: 'https://foo.com/img.png', title: 'test title', h: 123, w: 1234 };
const h = 123;
const w = 1234;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you should reuse these variables in the expect().toEqual().

@rebmullin
rebmullin force-pushed the I4917-screenshot-size-fix branch from 44d677e to 3f0a5a1 Compare June 19, 2018 17:31
@rebmullin
rebmullin merged commit 6343dae into mozilla:master Jun 19, 2018
@rebmullin
rebmullin deleted the I4917-screenshot-size-fix branch June 21, 2018 18:04
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.

Add-on screenshot images up-scaling degrades quality

3 participants