diff --git a/dotcom-rendering/src/components/ElectionTrackers/SideBySide.stories.tsx b/dotcom-rendering/src/components/ElectionTrackers/SideBySide.stories.tsx new file mode 100644 index 00000000000..a9d6f9de193 --- /dev/null +++ b/dotcom-rendering/src/components/ElectionTrackers/SideBySide.stories.tsx @@ -0,0 +1,39 @@ +import { textEgyptian17Object } from '@guardian/source/foundations'; +import { allModes } from '../../../.storybook/modes'; +import preview from '../../../.storybook/preview'; +import { SideBySide as SideBySideComponent } from './SideBySide'; + +const meta = preview.meta({ + title: 'Components/Election Trackers/Side By Side', + component: SideBySideComponent, + parameters: { + chromatic: { + modes: { + 'vertical mobileMedium': allModes['vertical mobileMedium'], + 'vertical tablet': allModes['vertical tablet'], + }, + }, + }, +}); + +export const SideBySide = meta.story({ + args: { + from: 'tablet', + left: { + heading: 'Senate', + children: ( +
+ Some components on the left from the "tablet" breakpoint. +
+ ), + }, + right: { + heading: 'House', + children: ( ++ Some components on the right from the "tablet" breakpoint. +
+ ), + }, + }, +}); diff --git a/dotcom-rendering/src/components/ElectionTrackers/SideBySide.tsx b/dotcom-rendering/src/components/ElectionTrackers/SideBySide.tsx new file mode 100644 index 00000000000..4d2712c62ff --- /dev/null +++ b/dotcom-rendering/src/components/ElectionTrackers/SideBySide.tsx @@ -0,0 +1,80 @@ +import { + type Breakpoint, + from, + headlineBold20Object, + headlineBold24Object, + space, +} from '@guardian/source/foundations'; +import type { ReactNode } from 'react'; +import { palette } from '../../palette'; + +type Props = { + /** + * The breakpoint from which to place the components side-by-side. + */ + from: Breakpoint; + left: { + heading: string; + children: ReactNode; + }; + right: { + heading: string; + children: ReactNode; + }; +}; + +/** + * Handles a common design pattern, where components are placed above one + * another at narrower breakpoints and side-by-side at wider ones. + */ +export const SideBySide = (props: Props) => ( +