Skip to content

Commit

Permalink
Improve duotone support in River (#894)
Browse files Browse the repository at this point in the history
* improve duotone support in river

* update changeset

* fix linter
  • Loading branch information
rezrah authored Jan 17, 2025
1 parent e85c731 commit aecc8d8
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 51 deletions.
7 changes: 7 additions & 0 deletions .changeset/friendly-carrots-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@primer/react-brand': patch
---

Improvements to duotone text in `River` component. Now supports `<b>` elements using a semi-bold font weight.

🔗 [See documentation for usage examples](https://primer.style/brand/components/River/react#duotone)
34 changes: 27 additions & 7 deletions apps/docs/content/components/River/react.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {River, RiverBreakout} from '@primer/react-brand'
<River>
<River.Visual>
<img
src="https://via.placeholder.com/600x400/f5f5f5/f5f5f5.png"
src="/brand/assets/placeholder-600x400.png"
alt="placeholder, blank area with an off-white background color"
/>
</River.Visual>
Expand All @@ -46,7 +46,7 @@ import {River, RiverBreakout} from '@primer/react-brand'
<River align="end">
<River.Visual>
<img
src="https://via.placeholder.com/600x400/f5f5f5/f5f5f5.png"
src="/brand/assets/placeholder-600x400.png"
alt="placeholder, blank area with an off-white background color"
/>
</River.Visual>
Expand All @@ -63,7 +63,7 @@ import {River, RiverBreakout} from '@primer/react-brand'
<River align="center">
<River.Visual>
<img
src="https://via.placeholder.com/600x400/f5f5f5/f5f5f5.png"
src="/brand/assets/placeholder-600x400.png"
alt="placeholder, blank area with an off-white background color"
/>
</River.Visual>
Expand All @@ -89,7 +89,7 @@ import {River, RiverBreakout} from '@primer/react-brand'
<River>
<River.Visual>
<img
src="https://via.placeholder.com/600x400/f5f5f5/f5f5f5.png"
src="/brand/assets/placeholder-600x400.png"
alt="placeholder, blank area with an off-white background color"
/>
</River.Visual>
Expand All @@ -104,7 +104,7 @@ import {River, RiverBreakout} from '@primer/react-brand'
<River imageTextRatio="60:40">
<River.Visual>
<img
src="https://via.placeholder.com/600x400/f5f5f5/f5f5f5.png"
src="/brand/assets/placeholder-600x400.png"
alt="placeholder, blank area with an off-white background color"
/>
</River.Visual>
Expand Down Expand Up @@ -156,7 +156,7 @@ import {River, RiverBreakout} from '@primer/react-brand'
<River imageTextRatio="60:40">
<River.Visual>
<img
src="https://via.placeholder.com/600x400/f5f5f5/f5f5f5.png"
src="/brand/assets/placeholder-600x400.png"
alt="placeholder with an off-white background color"
/>
</River.Visual>
Expand All @@ -170,14 +170,34 @@ import {River, RiverBreakout} from '@primer/react-brand'
</River>
```

### Duotone

```jsx live
<River>
<River.Visual>
<img
src="/brand/assets/placeholder-600x400.png"
alt="placeholder, blank area with an off-white background color"
/>
</River.Visual>
<River.Content>
<Text size="300">
<b>This first sentence is highlighted</b> and here is where the body copy
starts. Remember to keep this nice and succinct.
</Text>
<Link href="#">Call to action</Link>
</River.Content>
</River>
```

### River breakout

```jsx live
<RiverBreakout>
<RiverBreakout.A11yHeading>Accelerate workflows</RiverBreakout.A11yHeading>
<RiverBreakout.Visual>
<img
src="https://via.placeholder.com/600x400/f5f5f5/f5f5f5.png"
src="/brand/assets/placeholder-600x400.png"
alt="placeholder, blank area with an off-white background color"
/>
</RiverBreakout.Visual>
Expand Down
Binary file added apps/docs/static/assets/placeholder-600x400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions packages/react/src/river/River/River.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ export const Center: StoryFn<typeof River> = () => (
</River>
)

export const DuoTone: StoryFn<typeof River> = () => (
<River>
<River.Visual>
<PlaceholderImage />
</River.Visual>
<River.Content>
<Text size="300">
<b>This first sentence is highlighted</b> and here is where the body copy starts. Remember to keep this nice and
succinct.
</Text>
<Link href="#">Call to action</Link>
</River.Content>
</River>
)

export const ColumnRatio6040: StoryFn<typeof River> = () => (
<Container>
<River imageTextRatio="60:40">
Expand Down
12 changes: 6 additions & 6 deletions packages/react/src/river/River/River.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export const Copilot: StoryFn<typeof River> = args => (
<PlaceholderImage />
</River.Visual>
<River.Content>
<Text variant="default">
<strong> Convert comments to code.</strong> Write a comment describing the logic you want, and let GitHub
Copilot assemble the code for you.
<Text size="300">
<b> Convert comments to code.</b> Write a comment describing the logic you want, and let GitHub Copilot
assemble the code for you.
</Text>
</River.Content>
</River>
Expand All @@ -84,9 +84,9 @@ export const Copilot: StoryFn<typeof River> = args => (
<PlaceholderImage />
</River.Visual>
<River.Content>
<Text variant="default">
<strong>Autofill for repetitive code.</strong> GitHub Copilot works great for quickly producing boilerplate
and repetitive code patterns. Feed it a few examples and let it generate the rest!
<Text size="300">
<b>Autofill for repetitive code.</b> GitHub Copilot works great for quickly producing boilerplate and
repetitive code patterns. Feed it a few examples and let it generate the rest!
</Text>
</River.Content>
</River>
Expand Down
7 changes: 7 additions & 0 deletions packages/react/src/river/River/River.visual.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ test.describe('Visual Comparison: River', () => {
expect(await page.screenshot({fullPage: true})).toMatchSnapshot()
})

test('River / Duo Tone', async ({page}) => {
await page.goto('http://localhost:6006/iframe.html?args=&id=components-river-features--duo-tone&viewMode=story')

await page.waitForTimeout(500)
expect(await page.screenshot({fullPage: true})).toMatchSnapshot()
})

test('River / 60:40 image ratio', async ({page}) => {
await page.goto(
'http://localhost:6006/iframe.html?args=&id=components-river-features--column-ratio-6040&viewMode=story',
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ const Template: StoryFn<TemplateProps> = args => {
/>
</River.Visual>
<River.Content trailingComponent={args.withTrailingComponent ? TimelineExample : undefined}>
<Heading>Heading 1</Heading>
<Text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed
turpis felis nam pulvinar risus elementum.
<Text size="300">
<b>This first sentence is highlighted</b> and here is where the body copy starts. Remember to keep this nice
and succinct.
</Text>
<Link href="#">Call to action</Link>
</River.Content>
Expand All @@ -66,10 +65,9 @@ const Template: StoryFn<TemplateProps> = args => {
/>
</River.Visual>
<River.Content trailingComponent={args.withTrailingComponent ? TimelineExample : undefined}>
<Heading>Heading 2</Heading>
<Text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed
turpis felis nam pulvinar risus elementum.
<Text size="300">
<b>This first sentence is highlighted</b> and here is where the body copy starts. Remember to keep this nice
and succinct.
</Text>
<Link href="#">Call to action</Link>
</River.Content>
Expand All @@ -82,10 +80,9 @@ const Template: StoryFn<TemplateProps> = args => {
/>
</River.Visual>
<River.Content trailingComponent={args.withTrailingComponent ? TimelineExample : undefined}>
<Heading>Heading 3 </Heading>
<Text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed
turpis felis nam pulvinar risus elementum.
<Text size="300">
<b>This first sentence is highlighted</b> and here is where the body copy starts. Remember to keep this nice
and succinct.
</Text>
<Link href="#">Call to action</Link>
</River.Content>
Expand All @@ -98,10 +95,9 @@ const Template: StoryFn<TemplateProps> = args => {
/>
</River.Visual>
<River.Content trailingComponent={args.withTrailingComponent ? TimelineExample : undefined}>
<Heading>Heading 4</Heading>
<Text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed
turpis felis nam pulvinar risus elementum.
<Text size="300">
<b>This first sentence is highlighted</b> and here is where the body copy starts. Remember to keep this nice
and succinct.
</Text>
<Link href="#">Call to action</Link>
</River.Content>
Expand Down Expand Up @@ -218,7 +214,7 @@ export const Video = args => (
</River.Visual>
<River.Content trailingComponent={args.withTrailingComponent ? TimelineExample : undefined}>
<Heading>Heading 1</Heading>
<Text>
<Text size="300">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed
turpis felis nam pulvinar risus elementum.
</Text>
Expand All @@ -237,7 +233,7 @@ export const Video = args => (
</River.Visual>
<River.Content trailingComponent={args.withTrailingComponent ? TimelineExample : undefined}>
<Heading>Heading 2</Heading>
<Text>
<Text size="300">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed
turpis felis nam pulvinar risus elementum.
</Text>
Expand All @@ -256,7 +252,7 @@ export const Video = args => (
</River.Visual>
<River.Content trailingComponent={args.withTrailingComponent ? TimelineExample : undefined}>
<Heading>Heading 3 </Heading>
<Text>
<Text size="300">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed
turpis felis nam pulvinar risus elementum.
</Text>
Expand All @@ -275,7 +271,7 @@ export const Video = args => (
</River.Visual>
<River.Content trailingComponent={args.withTrailingComponent ? TimelineExample : undefined}>
<Heading>Heading 4</Heading>
<Text>
<Text size="300">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed
turpis felis nam pulvinar risus elementum.
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import {StoryFn, Meta} from '@storybook/react'

import {RiverStoryScroll} from '.'
import {Heading, Text, Link, River, Box} from '../..'
import {Text, Link, River, Box} from '../..'
import {Container} from '../../component-helpers'

export default {
Expand All @@ -22,10 +22,9 @@ const Template: StoryFn<typeof RiverStoryScroll> = args => (
/>
</River.Visual>
<River.Content>
<Heading>Heading 1</Heading>
<Text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed
turpis felis nam pulvinar risus elementum.
<Text size="300">
<b>This first sentence is highlighted</b> and here is where the body copy starts. Remember to keep this
nice and succinct.
</Text>
<Link href="#">Call to action</Link>
</River.Content>
Expand All @@ -38,10 +37,9 @@ const Template: StoryFn<typeof RiverStoryScroll> = args => (
/>
</River.Visual>
<River.Content>
<Heading>Heading 2</Heading>
<Text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed
turpis felis nam pulvinar risus elementum.
<Text size="300">
<b>This first sentence is highlighted</b> and here is where the body copy starts. Remember to keep this
nice and succinct.
</Text>
<Link href="#">Call to action</Link>
</River.Content>
Expand All @@ -54,10 +52,9 @@ const Template: StoryFn<typeof RiverStoryScroll> = args => (
/>
</River.Visual>
<River.Content>
<Heading>Heading 3 </Heading>
<Text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed
turpis felis nam pulvinar risus elementum.
<Text size="300">
<b>This first sentence is highlighted</b> and here is where the body copy starts. Remember to keep this
nice and succinct.
</Text>
<Link href="#">Call to action</Link>
</River.Content>
Expand All @@ -70,10 +67,9 @@ const Template: StoryFn<typeof RiverStoryScroll> = args => (
/>
</River.Visual>
<River.Content>
<Heading>Heading 4</Heading>
<Text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed
turpis felis nam pulvinar risus elementum.
<Text size="300">
<b>This first sentence is highlighted</b> and here is where the body copy starts. Remember to keep this
nice and succinct.
</Text>
<Link href="#">Call to action</Link>
</River.Content>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion packages/react/src/river/river-shared.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
margin-top: var(--base-size-24);
}

.River__text strong {
.River__text strong,
.River__text b {
font-weight: var(--base-text-weight-semibold);
color: var(--brand-color-text-default);
}

Expand Down

0 comments on commit aecc8d8

Please sign in to comment.