Skip to content

Commit

Permalink
Merge pull request #12407 from guardian/quiz-atom-darkmode
Browse files Browse the repository at this point in the history
Quiz Atom Dark Mode
  • Loading branch information
DanielCliftonGuardian committed Sep 20, 2024
2 parents 5fe2bd4 + 4731853 commit c0135a2
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 10 deletions.
12 changes: 11 additions & 1 deletion dotcom-rendering/src/components/Answers.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { css } from '@emotion/react';
import { Pillar } from '@guardian/libs';
import { ArticleDesign, ArticleDisplay, Pillar } from '@guardian/libs';
import { Radio, RadioGroup } from '@guardian/source/react-components';
import type { Meta, StoryObj } from '@storybook/react';
import { splitTheme } from '../../.storybook/decorators/splitThemeDecorator';
import {
CorrectSelectedAnswer,
IncorrectAnswer,
Expand All @@ -12,6 +13,15 @@ import {

const meta = {
title: 'Components/Answers',
decorators: [
splitTheme([
{
display: ArticleDisplay.Standard,
design: ArticleDesign.Comment,
theme: Pillar.News,
},
]),
],
} satisfies Meta;

export default meta;
Expand Down
18 changes: 11 additions & 7 deletions dotcom-rendering/src/components/Answers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
textSans17,
} from '@guardian/source/foundations';
import { SvgCheckmark, SvgCross } from '@guardian/source/react-components';
import { palette as schemedPalette } from '../palette';

// We export Radio wrapper styles to override Source Radio buttons to align
// with our custom answers for the quiz
Expand All @@ -21,14 +22,15 @@ export const radioButtonWrapperStyles = (theme: ArticleTheme) => css`
margin-bottom: ${space[2]}px;
background-color: ${palette.neutral[97]};
background-color: ${schemedPalette('--quiz-atom-answers-background')};
:hover {
background-color: ${palette.neutral[86]};
background-color: ${schemedPalette('--quiz-atom-answers-hover')};
}
/* TODO: apply same styles on focus (requires source update) */
div {
color: inherit;
${fontStyles(theme)};
}
}
Expand Down Expand Up @@ -70,7 +72,7 @@ const BlackCheckmark = () => (
height: ${space[6]}px;
svg {
fill: ${palette.neutral[0]};
fill: ${schemedPalette('--quiz-atom-check-mark')};
height: ${space[6]}px;
width: ${space[6]}px;
}
Expand Down Expand Up @@ -155,7 +157,7 @@ const BlackText = ({
}) => (
<label
css={css`
color: ${palette.neutral[0]};
color: inherit;
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -217,7 +219,9 @@ const incorrectSelectedAnswerStyles = css`
display: flex;
flex-direction: row;
background-color: ${palette.news[400]};
background-color: ${schemedPalette(
'--quiz-atom-incorrect-answer-background',
)};
`;

export const IncorrectAnswer = ({
Expand Down Expand Up @@ -246,7 +250,7 @@ const correctNonSelectedAnswerStyles = css`
border: 2px solid ${palette.success[400]};
padding-left: 10px;
background-color: ${palette.neutral[97]};
background-color: ${schemedPalette('--quiz-atom-answers-background')};
`;

export const NonSelectedCorrectAnswer = ({
Expand All @@ -273,7 +277,7 @@ export const NonSelectedCorrectAnswer = ({
);

const unselectedAnswerStyles = css`
background-color: ${palette.neutral[97]};
background-color: ${schemedPalette('--quiz-atom-answers-background')};
margin-bottom: ${space[2]}px;
padding-top: ${space[2]}px;
Expand Down
35 changes: 34 additions & 1 deletion dotcom-rendering/src/components/KnowledgeQuizAtom.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { ArticleSpecial, Pillar } from '@guardian/libs';
import {
ArticleDesign,
ArticleDisplay,
ArticleSpecial,
Pillar,
} from '@guardian/libs';
import type { Meta, StoryObj } from '@storybook/react';
import { splitTheme } from '../../.storybook/decorators/splitThemeDecorator';
import {
exampleKnowledgeQuestions,
natureQuestions,
Expand All @@ -26,6 +32,15 @@ export const Default = {
sharingUrls,
theme: Pillar.News,
},
decorators: [
splitTheme([
{
display: ArticleDisplay.Standard,
design: ArticleDesign.Comment,
theme: Pillar.News,
},
]),
],
} satisfies Story;

export const BatchedResults = {
Expand All @@ -34,11 +49,29 @@ export const BatchedResults = {
questions: natureQuestions,
resultGroups: natureResultGroups,
},
decorators: [
splitTheme([
{
display: ArticleDisplay.Standard,
design: ArticleDesign.Comment,
theme: Pillar.News,
},
]),
],
} satisfies Story;

export const LabsTheme = {
args: {
...Default.args,
theme: ArticleSpecial.Labs,
},
decorators: [
splitTheme([
{
display: ArticleDisplay.Standard,
design: ArticleDesign.Comment,
theme: ArticleSpecial.Labs,
},
]),
],
} satisfies Story;
26 changes: 25 additions & 1 deletion dotcom-rendering/src/components/PersonalityQuizAtom.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { ArticleSpecial, Pillar } from '@guardian/libs';
import {
ArticleDesign,
ArticleDisplay,
ArticleSpecial,
Pillar,
} from '@guardian/libs';
import type { Meta, StoryObj } from '@storybook/react';
import { splitTheme } from '../../.storybook/decorators/splitThemeDecorator';
import {
examplePersonalityQuestions,
exampleResultBuckets,
Expand All @@ -24,6 +30,15 @@ export const Default = {
sharingUrls,
theme: Pillar.News,
},
decorators: [
splitTheme([
{
display: ArticleDisplay.Standard,
design: ArticleDesign.Comment,
theme: Pillar.News,
},
]),
],
} satisfies Story;

export const LabsTheme = {
Expand All @@ -32,4 +47,13 @@ export const LabsTheme = {
id: '2c6bf552-2827-4256-b3a0-f557d215c394',
theme: ArticleSpecial.Labs,
},
decorators: [
splitTheme([
{
display: ArticleDisplay.Standard,
design: ArticleDesign.Comment,
theme: ArticleSpecial.Labs,
},
]),
],
} satisfies Story;
16 changes: 16 additions & 0 deletions dotcom-rendering/src/palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6564,6 +6564,22 @@ const paletteColours = {
light: pullQuoteTextLight,
dark: pullQuoteTextDark,
},
'--quiz-atom-answers-background': {
light: () => sourcePalette.neutral[97],
dark: () => sourcePalette.neutral[20],
},
'--quiz-atom-answers-hover': {
light: () => sourcePalette.neutral[86],
dark: () => sourcePalette.neutral[38],
},
'--quiz-atom-check-mark': {
light: () => sourcePalette.neutral[0],
dark: () => sourcePalette.neutral[97],
},
'--quiz-atom-incorrect-answer-background': {
light: () => sourcePalette.news[400],
dark: () => sourcePalette.news[300],
},
'--quote-icon-fill': {
light: richLinkQuoteFillLight,
dark: richLinkFillDark,
Expand Down

0 comments on commit c0135a2

Please sign in to comment.