InstagramBlockComponent as an Island - #3824
Conversation
InstagramBlockComponent as an IslandInstagramBlockComponent as an Island
| key={1} | ||
| element={instagramInstramEmbed} | ||
| index={1} | ||
| isMainMedia={false} |
There was a problem hiding this comment.
I've added this prop so we can pass it to ClickToView
| <ClickToView | ||
| role={element.role} | ||
| isTracking={element.isThirdPartyTracking} | ||
| isMainMedia={isMainMedia} | ||
| source={element.source} | ||
| sourceDomain={element.sourceDomain} | ||
| onAccept={() => | ||
| updateIframeHeight(`iframe[name="instagram-embed-${index}"]`) | ||
| } | ||
| > |
There was a problem hiding this comment.
This is new code
| @@ -0,0 +1,42 @@ | |||
| import { css } from '@emotion/react'; | |||
| import { updateIframeHeight } from '../browser/updateIframeHeight'; | |||
|
Size Change: +1.11 kB (0%) Total Size: 3.18 MB
ℹ️ View Unchanged
|
|
👍 I like the move of click-to-view into the instagram component itself. Since we shouldn't be using the instagram component without c2v, I think it works to reinforce that c2v is a requirement for the instagram component (and others), rather than just what it happens to be wrapped in most of the time. It'll be great if we can continue this change with other components as the loadable -> island migration continues! |
Great point about having ClickToView being local meaning it's intrinsic to the definition of the embed. I like this |
|
part of #3629 |
What does this change?
Here we migrate the
InstagramBlockComponentto the Island pattern.Test article for future developers: https://www.theguardian.com/lifeandstyle/2020/apr/27/its-like-a-sexy-story-just-for-me-how-lockdown-has-triggered-a-wave-of-sexting
Why?
This is part of a wider refactor to remove
App.tsxWhy have I dropped
ClickToViewdown?We now wrap the element in a click to view overlay inside the component instead of setting it externally in
renderElementandApp. This was done because this approach makes more sense with the islands pattern where we only want to pass a single child toIslandNote. I did consider making a separate PR to refactor all usage of
ClickToViewto this new structure prior to moving them over to Islands but that would have meant adding a new prop (isMainMedia) only all the element type definitions which would have been unnecessary noise as this extra prop is not needed when using an Island so by making both changes in one place we remove the requirement for it completely.