Skip to content

InstagramBlockComponent as an Island - #3824

Merged
oliverlloyd merged 1 commit into
mainfrom
oliver/instagram-island
Jan 12, 2022
Merged

oliverlloyd merged 1 commit into
mainfrom
oliver/instagram-island

Conversation

@oliverlloyd

@oliverlloyd oliverlloyd commented Jan 12, 2022 •

Copy link
Copy Markdown
Contributor

What does this change?

Here we migrate the InstagramBlockComponent to 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.tsx

Why have I dropped ClickToView down?

We now wrap the element in a click to view overlay inside the component instead of setting it externally in renderElement and App. This was done because this approach makes more sense with the islands pattern where we only want to pass a single child to Island

Note. I did consider making a separate PR to refactor all usage of ClickToView to 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.

@oliverlloyd oliverlloyd changed the title refactor: InstagramBlockComponent as an Island InstagramBlockComponent as an Island Jan 12, 2022
key={1}
element={instagramInstramEmbed}
index={1}
isMainMedia={false}

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.

I've added this prop so we can pass it to ClickToView

Comment on lines +20 to +29
<ClickToView
role={element.role}
isTracking={element.isThirdPartyTracking}
isMainMedia={isMainMedia}
source={element.source}
sourceDomain={element.sourceDomain}
onAccept={() =>
updateIframeHeight(`iframe[name="instagram-embed-${index}"]`)
}
>

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.

This is new code

@@ -0,0 +1,42 @@
import { css } from '@emotion/react';
import { updateIframeHeight } from '../browser/updateIframeHeight';

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.

New import

@github-actions

Copy link
Copy Markdown

Size Change: +1.11 kB (0%)

Total Size: 3.18 MB

Filename Size Change
dotcom-rendering/dist/331.js 16.2 kB +1.32 kB (+9%) 🔍
dotcom-rendering/dist/331.legacy.js 16.3 kB +467 B (+3%)
dotcom-rendering/dist/frontend.server.js 2.44 MB +338 B (0%)
dotcom-rendering/dist/InstagramBlockComponent.js 0 B -428 B (removed) 🏆
dotcom-rendering/dist/InstagramBlockComponent.legacy.js 0 B -448 B (removed) 🏆
dotcom-rendering/dist/islands.js 7.17 kB +29 B (0%)
dotcom-rendering/dist/islands.legacy.js 7.92 kB +28 B (0%)
dotcom-rendering/dist/react.js 137 kB -90 B (0%)
dotcom-rendering/dist/react.legacy.js 143 kB -106 B (0%)
ℹ️ View Unchanged
Filename Size
dotcom-rendering/dist/101.js 21.1 kB
dotcom-rendering/dist/101.legacy.js 21.1 kB
dotcom-rendering/dist/195.js 1.11 kB
dotcom-rendering/dist/195.legacy.js 1.23 kB
dotcom-rendering/dist/252.js 1.61 kB
dotcom-rendering/dist/252.legacy.js 1.69 kB
dotcom-rendering/dist/327.js 4.46 kB
dotcom-rendering/dist/327.legacy.js 4.47 kB
dotcom-rendering/dist/348.js 4.02 kB
dotcom-rendering/dist/348.legacy.js 4.12 kB
dotcom-rendering/dist/39.js 4.05 kB
dotcom-rendering/dist/413.js 4.23 kB
dotcom-rendering/dist/413.legacy.js 4.34 kB
dotcom-rendering/dist/433.legacy.js 4.19 kB
dotcom-rendering/dist/624.js 3.58 kB
dotcom-rendering/dist/624.legacy.js 3.7 kB
dotcom-rendering/dist/790.js 2.14 kB
dotcom-rendering/dist/790.legacy.js 2.19 kB
dotcom-rendering/dist/atomIframe.js 1.87 kB
dotcom-rendering/dist/atomIframe.legacy.js 2.14 kB
dotcom-rendering/dist/bootCmp.js 7.39 kB
dotcom-rendering/dist/bootCmp.legacy.js 10.9 kB
dotcom-rendering/dist/braze-web-sdk-core.js 36.1 kB
dotcom-rendering/dist/braze-web-sdk-core.legacy.js 36.1 kB
dotcom-rendering/dist/CalloutBlockComponent.js 4.14 kB
dotcom-rendering/dist/CalloutBlockComponent.legacy.js 4.46 kB
dotcom-rendering/dist/cmp.js 7.88 kB
dotcom-rendering/dist/coreVitals.js 4.03 kB
dotcom-rendering/dist/coreVitals.legacy.js 4.33 kB
dotcom-rendering/dist/DocumentBlockComponent.js 566 B
dotcom-rendering/dist/DocumentBlockComponent.legacy.js 596 B
dotcom-rendering/dist/dynamicImport.js 2.99 kB
dotcom-rendering/dist/dynamicImport.legacy.js 3.29 kB
dotcom-rendering/dist/embedIframe.js 1.88 kB
dotcom-rendering/dist/embedIframe.legacy.js 2.14 kB
dotcom-rendering/dist/ga.js 3.88 kB
dotcom-rendering/dist/ga.legacy.js 4.14 kB
dotcom-rendering/dist/guardian-braze-components-banner.js 9.57 kB
dotcom-rendering/dist/guardian-braze-components-banner.legacy.js 9.58 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.js 6.56 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.legacy.js 6.57 kB
dotcom-rendering/dist/InteractiveBlockComponent.js 2.95 kB
dotcom-rendering/dist/InteractiveBlockComponent.legacy.js 3.09 kB
dotcom-rendering/dist/InteractiveContentsBlockComponent.js 1.87 kB
dotcom-rendering/dist/InteractiveContentsBlockComponent.legacy.js 1.95 kB
dotcom-rendering/dist/MapEmbedBlockComponent.js 1.87 kB
dotcom-rendering/dist/MapEmbedBlockComponent.legacy.js 1.93 kB
dotcom-rendering/dist/MostViewedFooterData.js 6.26 kB
dotcom-rendering/dist/MostViewedFooterData.legacy.js 6.36 kB
dotcom-rendering/dist/MostViewedRightWrapper.js 3.89 kB
dotcom-rendering/dist/MostViewedRightWrapper.legacy.js 4.07 kB
dotcom-rendering/dist/newsletterEmbedIframe.js 1.83 kB
dotcom-rendering/dist/newsletterEmbedIframe.legacy.js 2.1 kB
dotcom-rendering/dist/OnwardsLower.js 9.67 kB
dotcom-rendering/dist/OnwardsLower.legacy.js 9.91 kB
dotcom-rendering/dist/OnwardsUpper.js 14.1 kB
dotcom-rendering/dist/OnwardsUpper.legacy.js 14.4 kB
dotcom-rendering/dist/ophan.js 7.18 kB
dotcom-rendering/dist/ophan.legacy.js 7.38 kB
dotcom-rendering/dist/relativeTime.js 2.41 kB
dotcom-rendering/dist/relativeTime.legacy.js 2.68 kB
dotcom-rendering/dist/RichLinkComponent.js 3.27 kB
dotcom-rendering/dist/RichLinkComponent.legacy.js 3.31 kB
dotcom-rendering/dist/sentry.js 677 B
dotcom-rendering/dist/sentry.legacy.js 687 B
dotcom-rendering/dist/sentryLoader.js 4.74 kB
dotcom-rendering/dist/sentryLoader.legacy.js 7.71 kB
dotcom-rendering/dist/shimport.js 2.75 kB
dotcom-rendering/dist/shimport.legacy.js 2.76 kB
dotcom-rendering/dist/SignInGateMain.js 1.82 kB
dotcom-rendering/dist/SignInGateMain.legacy.js 1.85 kB
dotcom-rendering/dist/SpotifyBlockComponent.js 1.8 kB
dotcom-rendering/dist/SpotifyBlockComponent.legacy.js 1.86 kB
dotcom-rendering/dist/VideoFacebookBlockComponent.js 1.88 kB
dotcom-rendering/dist/VideoFacebookBlockComponent.legacy.js 1.93 kB
dotcom-rendering/dist/VineBlockComponent.js 575 B
dotcom-rendering/dist/VineBlockComponent.legacy.js 591 B
dotcom-rendering/dist/YoutubeBlockComponent.js 2.57 kB
dotcom-rendering/dist/YoutubeBlockComponent.legacy.js 2.7 kB

compressed-size-action

@OllysCoding

Copy link
Copy Markdown
Contributor

👍 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!

@oliverlloyd

Copy link
Copy Markdown
Contributor Author

👍 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

@oliverlloyd
oliverlloyd merged commit 2dee845 into main Jan 12, 2022
@oliverlloyd
oliverlloyd deleted the oliver/instagram-island branch January 12, 2022 14:13
@jamesgorrie

Copy link
Copy Markdown
Contributor

part of #3629

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants