Skip to content

Commit

Permalink
RichLink support darkmode (#9683)
Browse files Browse the repository at this point in the history
* richlink darkmode
  • Loading branch information
DanielCliftonGuardian authored Dec 1, 2023
1 parent d92bca3 commit 8c2d106
Show file tree
Hide file tree
Showing 6 changed files with 232 additions and 176 deletions.
16 changes: 14 additions & 2 deletions dotcom-rendering/.storybook/decorators/splitThemeDecorator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,13 @@ export const splitTheme =
{formats.map((format) => (
<div css={css(paletteDeclarations(format, 'light'))}>
<FormatHeading format={format} />
<Story args={{ ...context.args, format }} />
<Story
args={{
...context.args,
format,
theme: 'light',
}}
/>
</div>
))}
</div>
Expand All @@ -174,7 +180,13 @@ export const splitTheme =
{formats.map((format) => (
<div css={css(paletteDeclarations(format, 'dark'))}>
<FormatHeading format={format} />
<Story args={{ ...context.args, format }} />
<Story
args={{
...context.args,
format,
theme: 'dark',
}}
/>
</div>
))}
</div>
Expand Down
48 changes: 45 additions & 3 deletions dotcom-rendering/src/components/RichLink.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ import {
ArticleSpecial,
Pillar,
} from '@guardian/libs';
import { splitTheme } from '../../.storybook/decorators/splitThemeDecorator';
import { Figure } from './Figure';
import { RichLink } from './RichLink';
import { Section } from './Section';

interface AnalysisProps {
theme: string;
}

const someContributor =
'https://uploads.guim.co.uk/2017/10/09/Oliver-Wainwright,-L.png';

Expand Down Expand Up @@ -75,6 +80,8 @@ export const Article = () => {
</Section>
);
};
Article.storyName = 'Article';
Article.decorators = [splitTheme([mockFormatNews])];

export const Network = () => {
return (
Expand Down Expand Up @@ -106,6 +113,7 @@ Network.story = {
chromatic: { viewports: [380] },
},
};
Network.decorators = [splitTheme([mockFormatCulture])];

export const SectionStory = () => {
return (
Expand All @@ -132,6 +140,7 @@ export const SectionStory = () => {
);
};
SectionStory.storyName = 'Section';
SectionStory.decorators = [splitTheme([mockFormatNews])];

export const Inline = () => {
return (
Expand All @@ -158,6 +167,7 @@ export const Inline = () => {
);
};
Inline.storyName = 'Inline';
Inline.decorators = [splitTheme([mockFormatNews])];

export const ImageContent = () => {
return (
Expand Down Expand Up @@ -189,6 +199,7 @@ ImageContent.story = {
chromatic: { viewports: [1300] },
},
};
ImageContent.decorators = [splitTheme([mockFormatNews])];

export const Interactive = () => {
return (
Expand All @@ -206,7 +217,7 @@ export const Interactive = () => {
contentType="interactive"
url=""
linkFormat={mockFormatLifestyle}
format={mockFormatCulture}
format={mockFormatLifestyle}
tags={[]}
sponsorName=""
/>
Expand All @@ -219,6 +230,7 @@ Interactive.story = {
viewport: { defaultViewport: 'leftCol' },
},
};
Interactive.decorators = [splitTheme([mockFormatNews])];

export const Gallery = () => {
return (
Expand Down Expand Up @@ -258,6 +270,7 @@ Gallery.story = {
viewport: { defaultViewport: 'leftCol' },
},
};
Gallery.decorators = [splitTheme([mockFormatNews])];

export const Video = () => {
return (
Expand Down Expand Up @@ -290,6 +303,7 @@ Video.story = {
chromatic: { viewports: [380] },
},
};
Video.decorators = [splitTheme([mockFormatNews])];

export const Audio = () => {
return (
Expand All @@ -315,6 +329,8 @@ export const Audio = () => {
</Section>
);
};
Audio.storyName = 'Audio';
Audio.decorators = [splitTheme([mockFormatNews])];

export const LiveBlog = () => {
return (
Expand Down Expand Up @@ -362,6 +378,7 @@ LiveBlog.story = {
chromatic: { viewports: [380] },
},
};
LiveBlog.decorators = [splitTheme([mockFormatNews])];

export const Tag = () => {
return (
Expand All @@ -387,6 +404,8 @@ export const Tag = () => {
</Section>
);
};
Tag.storyName = 'Tag';
Tag.decorators = [splitTheme([mockFormatNews])];

export const Index = () => {
return (
Expand Down Expand Up @@ -419,6 +438,8 @@ export const Index = () => {
</Section>
);
};
Index.storyName = 'Index';
Index.decorators = [splitTheme([mockFormatNews])];

export const Crossword = () => {
return (
Expand All @@ -444,6 +465,8 @@ export const Crossword = () => {
</Section>
);
};
Crossword.storyName = 'Crossword';
Crossword.decorators = [splitTheme([mockFormatNews])];

export const Survey = () => {
return (
Expand All @@ -469,6 +492,8 @@ export const Survey = () => {
</Section>
);
};
Survey.storyName = 'Survey';
Survey.decorators = [splitTheme([mockFormatNews])];

export const Signup = () => {
return (
Expand All @@ -495,6 +520,8 @@ export const Signup = () => {
</Section>
);
};
Signup.storyName = 'Signup';
Signup.decorators = [splitTheme([mockFormatNews])];

export const Userid = () => {
return (
Expand All @@ -520,6 +547,8 @@ export const Userid = () => {
</Section>
);
};
Userid.storyName = 'Userid';
Userid.decorators = [splitTheme([mockFormatNews])];

export const PaidFor = () => {
return (
Expand Down Expand Up @@ -551,13 +580,16 @@ export const PaidFor = () => {
</Section>
);
};
PaidFor.storyName = 'PaidFor';
PaidFor.decorators = [splitTheme([mockFormatNews])];

export const Analysis = () => {
export const Analysis = ({ theme }: AnalysisProps) => {
return (
<div
className="light"
css={css`
/* stylelint-disable-next-line color-no-hex */
background-color: #fff4f2;
background-color: ${theme === 'light' ? '#fff4f2' : 'inherit'};
`}
>
Analysis Articles have a different color background, so rich links
Expand Down Expand Up @@ -601,3 +633,13 @@ export const Analysis = () => {
</div>
);
};
Analysis.storyName = 'Analysis';
Analysis.decorators = [
splitTheme([
{
display: ArticleDisplay.Standard,
design: ArticleDesign.Analysis,
theme: Pillar.Culture,
},
]),
];
Loading

0 comments on commit 8c2d106

Please sign in to comment.