diff --git a/dotcom-rendering/.storybook/decorators/splitThemeDecorator.tsx b/dotcom-rendering/.storybook/decorators/splitThemeDecorator.tsx index c7f478b9a98..010ddb9e6a9 100644 --- a/dotcom-rendering/.storybook/decorators/splitThemeDecorator.tsx +++ b/dotcom-rendering/.storybook/decorators/splitThemeDecorator.tsx @@ -21,6 +21,11 @@ interface Orientation { orientation?: 'horizontal' | 'vertical'; } +type SplitThemeOptions = Orientation & { + /** Allows the format heading to be omitted on the split theme decorator */ + hideFormatHeading?: boolean; +}; + /** * The `splitTheme` decorator displays a story simultaneously in both light and * dark mode. @@ -226,6 +231,11 @@ type ThemeProps = { Story: Parameters[0]; context: Context; colourScheme: ColourScheme; + /** + * For stories without article theming where we fallback to the default theme, + * we can choose to omit the format heading as it's not relevant + */ + hideFormatHeading?: boolean; }; /** @@ -242,7 +252,13 @@ type ThemeProps = { * `colourSchemeBackground` and `colourSchemeTextColour` parameters from the * story, or provides defaults when these are not supplied. */ -const Theme = ({ formats, Story, context, colourScheme }: ThemeProps) => ( +const Theme = ({ + formats, + Story, + context, + colourScheme, + hideFormatHeading = false, +}: ThemeProps) => (
( {formats.map((format) => ( <> - + {!hideFormatHeading && ( + + )} ( export const splitTheme = ( formats: ArticleFormat[] = [...defaultFormats], - { orientation = 'horizontal' }: Orientation = {}, + { + orientation = 'horizontal', + hideFormatHeading = false, + }: SplitThemeOptions = {}, ): Decorator => (Story, context) => (
); diff --git a/dotcom-rendering/src/components/LabsSectionHeader.stories.tsx b/dotcom-rendering/src/components/LabsSectionHeader.stories.tsx index cc316fd2d82..52d6094effc 100644 --- a/dotcom-rendering/src/components/LabsSectionHeader.stories.tsx +++ b/dotcom-rendering/src/components/LabsSectionHeader.stories.tsx @@ -1,11 +1,11 @@ +import { css } from '@emotion/react'; +import { from } from '@guardian/source/foundations'; import type { Meta, StoryObj } from '@storybook/react'; import { userEvent, within } from '@storybook/test'; -import { splitTheme } from '../../.storybook/decorators/splitThemeDecorator'; import { - ArticleDesign, - ArticleDisplay, - ArticleSpecial, -} from '../lib/articleFormat'; + defaultFormats, + splitTheme, +} from '../../.storybook/decorators/splitThemeDecorator'; import { LabsSectionHeader } from './LabsSectionHeader'; const meta = { @@ -15,24 +15,34 @@ const meta = { title: 'Container Title', url: '/', }, - render: (args) => , + render: (args) => ( +
+ +
+ ), decorators: [ - splitTheme( - [ - { - theme: ArticleSpecial.Labs, - design: ArticleDesign.Feature, - display: ArticleDisplay.Standard, - }, - ], - { orientation: 'vertical' }, - ), + splitTheme([defaultFormats[0]], { + orientation: 'vertical', + hideFormatHeading: true, + }), ], } satisfies Meta; export default meta; type Story = StoryObj; +export const Default: Story = {}; + export const WithDetailsOpen: Story = { play: async ({ canvasElement }) => { const canvas = within(canvasElement); diff --git a/dotcom-rendering/src/components/LabsSectionHeader.tsx b/dotcom-rendering/src/components/LabsSectionHeader.tsx index 5d26dd73e4c..13fe2faf8cd 100644 --- a/dotcom-rendering/src/components/LabsSectionHeader.tsx +++ b/dotcom-rendering/src/components/LabsSectionHeader.tsx @@ -82,6 +82,14 @@ const aboutStyles = css` ${textSans14} `; +const positionStyles = css` + right: 0; + ${from.leftCol} { + left: 0; + right: auto; + } +`; + const detailsStyles = css` background-color: ${schemePalette('--labs-about-dropdown-background')}; color: ${schemePalette('--labs-about-dropdown-text')}; @@ -101,9 +109,7 @@ export const LabsSectionHeader = ({ title, url }: Props) => (