Skip to content

Commit

Permalink
trial using context for renderingTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
cemms1 committed Aug 30, 2023
1 parent 90f0039 commit 8342952
Show file tree
Hide file tree
Showing 27 changed files with 71 additions and 218 deletions.
11 changes: 11 additions & 0 deletions dotcom-rendering/.storybook/decorators/RenderingTargetDecorator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { RenderingTargetContext } from '../../src/components/RenderingTarget';

export const RenderingTargetDecorator = (Story, { args }) => {
return (
<RenderingTargetContext.Provider value={args.renderingTarget}>
<Story />
</RenderingTargetContext.Provider>
);
};

export default RenderingTargetDecorator;
4 changes: 0 additions & 4 deletions dotcom-rendering/src/components/ArticleBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { revealStyles } from '../lib/revealStyles';
import type { ServerSideTests, Switches } from '../types/config';
import type { TableOfContentsItem } from '../types/frontend';
import type { Palette } from '../types/palette';
import type { RenderingTarget } from '../types/renderingTarget';
import type { TagType } from '../types/tag';
import { Island } from './Island';
import { RecipeMultiplier } from './RecipeMultiplier.importable';
Expand Down Expand Up @@ -47,7 +46,6 @@ type Props = {
tableOfContents?: TableOfContentsItem[];
lang?: string;
isRightToLeftLang?: boolean;
renderingTarget: RenderingTarget;
};

const globalH2Styles = (display: ArticleDisplay) => css`
Expand Down Expand Up @@ -139,7 +137,6 @@ export const ArticleBody = ({
tableOfContents,
lang,
isRightToLeftLang = false,
renderingTarget,
}: Props) => {
const isInteractive = format.design === ArticleDesign.Interactive;
const palette = decidePalette(format);
Expand Down Expand Up @@ -240,7 +237,6 @@ export const ArticleBody = ({
isAdFreeUser={isAdFreeUser}
isSensitive={isSensitive}
abTests={abTests}
renderingTarget={renderingTarget}
/>
</div>
</>
Expand Down
26 changes: 0 additions & 26 deletions dotcom-rendering/src/components/ArticleHeadline.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const ArticleStory = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand All @@ -65,7 +64,6 @@ export const Feature = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand Down Expand Up @@ -98,7 +96,6 @@ export const ShowcaseInterview = () => {
tags={[]}
webPublicationDateDeprecated=""
byline="Byline text"
renderingTarget="Web"
/>
</div>
<MainMedia
Expand Down Expand Up @@ -143,7 +140,6 @@ export const ShowcaseInterviewNobyline = () => {
tags={[]}
webPublicationDateDeprecated=""
byline=""
renderingTarget="Web"
/>
</div>
<MainMedia
Expand Down Expand Up @@ -183,7 +179,6 @@ export const Interview = () => {
tags={[]}
webPublicationDateDeprecated=""
byline="Byline text"
renderingTarget="Web"
/>
<Standfirst
format={format}
Expand Down Expand Up @@ -226,7 +221,6 @@ export const InterviewSpecialReport = () => {
tags={[]}
webPublicationDateDeprecated=""
byline="Byline text"
renderingTarget="Web"
/>
<Standfirst
format={format}
Expand Down Expand Up @@ -270,7 +264,6 @@ export const InterviewNoByline = () => {
tags={[]}
webPublicationDateDeprecated=""
byline=""
renderingTarget="Web"
/>
<Standfirst
format={format}
Expand Down Expand Up @@ -312,7 +305,6 @@ export const Comment = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand Down Expand Up @@ -350,7 +342,6 @@ export const Analysis = () => {
format={format(theme)}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand Down Expand Up @@ -381,7 +372,6 @@ export const Gallery = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand All @@ -408,7 +398,6 @@ export const Review = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand All @@ -435,7 +424,6 @@ export const PhotoEssay = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand All @@ -462,7 +450,6 @@ export const Explainer = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand All @@ -489,7 +476,6 @@ export const Quiz = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand All @@ -516,7 +502,6 @@ export const Recipe = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand All @@ -543,7 +528,6 @@ export const Immersive = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand All @@ -570,7 +554,6 @@ export const ImmersiveNoMainMedia = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand Down Expand Up @@ -602,7 +585,6 @@ export const ImmersiveComment = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand All @@ -629,7 +611,6 @@ export const Editorial = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand All @@ -656,7 +637,6 @@ export const MatchReport = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand All @@ -683,7 +663,6 @@ export const SpecialReport = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand All @@ -710,7 +689,6 @@ export const SpecialReportAlt = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand All @@ -737,7 +715,6 @@ export const LiveBlog = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand Down Expand Up @@ -777,7 +754,6 @@ export const DeadBlog = () => {
format={format}
tags={[]}
webPublicationDateDeprecated=""
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand Down Expand Up @@ -805,7 +781,6 @@ export const ReviewWithoutStars = () => {
tags={[]}
webPublicationDateDeprecated=""
byline="Byline text"
renderingTarget="Web"
/>
<Standfirst
format={format}
Expand Down Expand Up @@ -856,7 +831,6 @@ export const AgeWarning = () => {
},
]}
webPublicationDateDeprecated="2020-03-28T07:27:19.000Z"
renderingTarget="Web"
/>
</ArticleContainer>
</Flex>
Expand Down
7 changes: 0 additions & 7 deletions dotcom-rendering/src/components/ArticleHeadline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { getAgeWarning } from '../lib/age-warning';
import { decidePalette } from '../lib/decidePalette';
import { getZIndex } from '../lib/getZIndex';
import type { Palette } from '../types/palette';
import type { RenderingTarget } from '../types/renderingTarget';
import type { TagType } from '../types/tag';
import { AgeWarning } from './AgeWarning';
import { DesignTag } from './DesignTag';
Expand All @@ -28,7 +27,6 @@ type Props = {
hasStarRating?: boolean;
hasAvatar?: boolean;
isMatch?: boolean;
renderingTarget: RenderingTarget;
};

const topPadding = css`
Expand Down Expand Up @@ -342,7 +340,6 @@ export const ArticleHeadline = ({
hasStarRating,
hasAvatar,
isMatch,
renderingTarget,
}: Props) => {
const palette = decidePalette(format);
switch (format.display) {
Expand Down Expand Up @@ -418,7 +415,6 @@ export const ArticleHeadline = ({
format={format}
byline={byline}
tags={tags}
renderingTarget={renderingTarget}
/>
)}
</div>
Expand Down Expand Up @@ -574,7 +570,6 @@ export const ArticleHeadline = ({
format={format}
byline={byline}
tags={tags}
renderingTarget={renderingTarget}
/>
)}
</div>
Expand Down Expand Up @@ -665,7 +660,6 @@ export const ArticleHeadline = ({
format={format}
byline={byline}
tags={tags}
renderingTarget={renderingTarget}
/>
)}
</div>
Expand Down Expand Up @@ -706,7 +700,6 @@ export const ArticleHeadline = ({
format={format}
byline={byline}
tags={tags}
renderingTarget={renderingTarget}
/>
)}
</div>
Expand Down
Loading

0 comments on commit 8342952

Please sign in to comment.