Skip to content

Commit

Permalink
Share button (#10422)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielCliftonGuardian authored Feb 21, 2024
1 parent cb69ea9 commit 572f327
Show file tree
Hide file tree
Showing 13 changed files with 614 additions and 510 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const FormatHeading = ({ format }: { format: ArticleFormat }) => (
// ----- Decorators ----- //

/** A list of the most typical formats */
const defaultFormats = [
export const defaultFormats = [
{
display: ArticleDisplay.Standard,
design: ArticleDesign.Standard,
Expand Down
2 changes: 1 addition & 1 deletion dotcom-rendering/playwright/fixtures/tweet-block.js

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions dotcom-rendering/src/components/ArticleMeta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Contributor } from './Contributor';
import { Dateline } from './Dateline';
import { Island } from './Island';
import { SendAMessage } from './SendAMessage.importable';
import { ShareIcons } from './ShareIcons';
import { ShareButton } from './ShareButton.importable';

type Props = {
format: ArticleFormat;
Expand Down Expand Up @@ -415,14 +415,17 @@ export const ArticleMeta = ({
),
]}
>
<ShareIcons
pageId={pageId}
webTitle={webTitle}
format={format}
displayIcons={['facebook', 'twitter', 'email']}
size="medium"
context="ArticleMeta"
/>
<Island
priority="feature"
defer={{ until: 'visible' }}
>
<ShareButton
pageId={pageId}
webTitle={webTitle}
format={format}
context="ArticleMeta"
/>
</Island>
</div>
)}
<div
Expand Down
22 changes: 22 additions & 0 deletions dotcom-rendering/src/components/Island.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { ReaderRevenueLinks } from './ReaderRevenueLinks.importable';
import { SendTargetingParams } from './SendTargetingParams.importable';
import { SetABTests } from './SetABTests.importable';
import { SetAdTargeting } from './SetAdTargeting.importable';
import { ShareButton } from './ShareButton.importable';
import { ShowHideContainers } from './ShowHideContainers.importable';
import { SignInGateSelector } from './SignInGateSelector.importable';
import { SlotBodyEnd } from './SlotBodyEnd.importable';
Expand Down Expand Up @@ -448,4 +449,25 @@ describe('Island: server-side rendering', () => {
),
).not.toThrow();
});

test('ShareButton', () => {
expect(() =>
renderToString(
<ConfigProvider
value={{ renderingTarget: 'Web', darkModeAvailable: false }}
>
<ShareButton
pageId={'123'}
webTitle={'The the'}
format={{
display: ArticleDisplay.Standard,
theme: Pillar.News,
design: ArticleDesign.Standard,
}}
context="ArticleMeta"
/>
</ConfigProvider>,
),
).not.toThrow();
});
});
22 changes: 12 additions & 10 deletions dotcom-rendering/src/components/LiveBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { isUndefined } from '@guardian/libs';
import type { EditionId } from '../lib/edition';
import { RenderArticleElement } from '../lib/renderElement';
import type { ServerSideTests, Switches } from '../types/config';
import { Island } from './Island';
import { LastUpdated } from './LastUpdated';
import { LiveBlockContainer } from './LiveBlockContainer';
import { ShareIcons } from './ShareIcons';
import { ShareButton } from './ShareButton.importable';

type Props = {
format: ArticleFormat;
Expand Down Expand Up @@ -93,15 +94,16 @@ export const LiveBlock = ({
justify-content: space-between;
`}
>
<ShareIcons
pageId={pageId}
blockId={block.id}
webTitle={webTitle}
displayIcons={['facebook', 'twitter']}
format={format}
size="small"
context="LiveBlock"
/>
<Island priority="feature" defer={{ until: 'visible' }}>
<ShareButton
size="xsmall"
pageId={pageId}
blockId={block.id}
webTitle={webTitle}
format={format}
context="LiveBlock"
/>
</Island>
{!isUndefined(lastUpdated) && (
<LastUpdated
lastUpdated={lastUpdated}
Expand Down
Loading

0 comments on commit 572f327

Please sign in to comment.