Repository navigation
I4917 screenshot size fix - #5307
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
willdurand
left a comment
There was a problem hiding this comment.
Looks good, thanks! Here are a few questions and comments.
| const HEIGHT = 400; | ||
| const WIDTH = 200; | ||
|
|
||
| describe('<ScreenShots />', () => { |
There was a problem hiding this comment.
Could you please update this description with __filename?
There was a problem hiding this comment.
Also, I see that we are using renderIntoDocument. It could be nice to rewrite the test case with Enzyme.
|
|
||
| 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 }; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
|
|
||
| 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} /> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
just curious what is not best practice here - do you mean adding the title for alt?
There was a problem hiding this comment.
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.").
|
|
||
| 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} /> |
There was a problem hiding this comment.
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 }; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
you should reuse these variables in the expect().toEqual().
44d677e to
3f0a5a1
Compare
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:

after:
