Skip to content

Commit 9ea0803

Browse files
Joseph Lozanojoseph-lozano
Joseph Lozano
andauthored
Prose list style image fix (#457)
* prototype * add changeset * update story to only have unordered list * update changeset * github-actions[bot] Regenerated snapshots * change listStyleImageUrl to imageUrl * reset Avatar snapshot * move Unordered List sotry to Prose.Features * use Box instead of inline styles * change token to --brand-Prose-unorderedList-imageUrl * github-actions[bot] Regenerated snapshots * reset Avatar snapshot --------- Co-authored-by: joseph-lozano <[email protected]>
1 parent b2b6d50 commit 9ea0803

File tree

8 files changed

+70
-10
lines changed

8 files changed

+70
-10
lines changed

.changeset/purple-books-sneeze.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@primer/brand-primitives': patch
3+
'@primer/react-brand': patch
4+
---
5+
6+
Fixed issue with prose un-ordered lists in dark mode

packages/design-tokens/scripts/build-tokens.js

+1
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ const colorModeFormat = require('../src/formats/color-mode-attributes')
206206
`tokens/functional/components/grid/colors.json`,
207207
`tokens/functional/components/logosuite/colors.json`,
208208
`tokens/functional/components/timeline/colors.json`,
209+
`tokens/functional/components/prose/colors.js`,
209210
]
210211

211212
for (const path of filesForColorModes) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
brand: {
3+
Prose: {
4+
unorderedList: {
5+
imageUrl: {
6+
value: `url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' aria-hidden='true' focusable='false' role='img' viewBox='0 -3 16 16' width='16' height='16' fill='black' style='display: inline-block; vertical-align: text-bottom; overflow: visible;'%3e%3cpath d='M2 7.75A.75.75 0 0 1 2.75 7h10a.75.75 0 0 1 0 1.5h-10A.75.75 0 0 1 2 7.75Z'%3e%3c/path%3e%3c/svg%3e ")`,
7+
dark: `url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' aria-hidden='true' focusable='false' role='img' viewBox='0 -3 16 16' width='16' height='16' fill='white' style='display: inline-block; vertical-align: text-bottom; overflow: visible;'%3e%3cpath d='M2 7.75A.75.75 0 0 1 2.75 7h10a.75.75 0 0 1 0 1.5h-10A.75.75 0 0 1 2 7.75Z'%3e%3c/path%3e%3c/svg%3e ")`,
8+
},
9+
},
10+
},
11+
},
12+
}

packages/react/src/Prose/Prose.features.stories.tsx

+40-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import React from 'react'
2-
import {ComponentMeta, ComponentStory} from '@storybook/react'
2+
import {Meta, StoryFn} from '@storybook/react'
33
import {INITIAL_VIEWPORTS} from '@storybook/addon-viewport'
44
import {Prose} from './Prose'
55
import placeholderImage from '../fixtures/images/placeholder-600x400.png'
6+
import {ThemeProvider} from '../ThemeProvider'
7+
import {Box} from '../Box'
68

79
export default {
810
title: 'Components/Prose/Features',
@@ -13,7 +15,7 @@ export default {
1315
viewports: INITIAL_VIEWPORTS,
1416
},
1517
},
16-
} as ComponentMeta<typeof Prose>
18+
} as Meta
1719

1820
const ExampleHtmlMarkup = `
1921
<h2>Heading level 2</h2>
@@ -59,24 +61,53 @@ const ExampleHtmlMarkup = `
5961
<p>Nunc velit odio, posuere eu felis eget, consectetur fermentum nisi. Aenean tempor odio id ornare ultrices. Quisque blandit condimentum tellus, semper efficitur sapien dapibus nec. </p>
6062
`
6163

62-
export const FullWidth: ComponentStory<typeof Prose> = () => <Prose enableFullWidth html={ExampleHtmlMarkup} />
64+
export const FullWidth: StoryFn = () => <Prose enableFullWidth html={ExampleHtmlMarkup} />
6365

64-
export const NarrowViewFullWidth: ComponentStory<typeof Prose> = () => (
65-
<Prose enableFullWidth html={ExampleHtmlMarkup} />
66-
)
66+
export const NarrowViewFullWidth: StoryFn = () => <Prose enableFullWidth html={ExampleHtmlMarkup} />
6767
NarrowViewFullWidth.parameters = {
6868
viewport: {
6969
defaultViewport: 'iphonexr',
7070
},
7171
}
7272
NarrowViewFullWidth.storyName = 'Narrow view, full width (mobile)'
7373

74-
export const RegularViewFullWidth: ComponentStory<typeof Prose> = () => (
75-
<Prose enableFullWidth html={ExampleHtmlMarkup} />
76-
)
74+
export const RegularViewFullWidth: StoryFn = () => <Prose enableFullWidth html={ExampleHtmlMarkup} />
7775
RegularViewFullWidth.parameters = {
7876
viewport: {
7977
defaultViewport: 'ipad10p',
8078
},
8179
}
8280
RegularViewFullWidth.storyName = 'Regular view, full width (tablet)'
81+
82+
const UnorderedListHtmlMarkup = `
83+
<ul>
84+
<li>
85+
Vivamus eu risus nec lectus consequat rutrum at vel lacus.
86+
</li>
87+
<li>
88+
Donec at dolor ut metus imperdiet congue vel porta nunc.
89+
</li>
90+
<li>
91+
Quisque eu tortor suscipit, congue quam in, bibendum tellus.
92+
</li>
93+
</ul>
94+
`
95+
const UnorderedListStory: StoryFn = args => <Prose {...args} html={UnorderedListHtmlMarkup} />
96+
export const UnorderedList = UnorderedListStory.bind({})
97+
UnorderedList.args = {
98+
darkMode: true,
99+
}
100+
UnorderedList.argTypes = {
101+
colorMode: {
102+
darkMode: 'boolean',
103+
},
104+
}
105+
UnorderedList.decorators = [
106+
(Story, {args: {darkMode}}) => (
107+
<ThemeProvider colorMode={darkMode ? 'dark' : 'light'}>
108+
<Box backgroundColor="default">
109+
<Story />
110+
</Box>
111+
</ThemeProvider>
112+
),
113+
]

packages/react/src/Prose/Prose.module.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140

141141
.Prose ul {
142142
list-style-type: image;
143-
list-style-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' aria-hidden='true' focusable='false' role='img' viewBox='0 -3 16 16' width='16' height='16' fill='currentColor' style='display: inline-block; vertical-align: text-bottom; overflow: visible;'%3e%3cpath d='M2 7.75A.75.75 0 0 1 2.75 7h10a.75.75 0 0 1 0 1.5h-10A.75.75 0 0 1 2 7.75Z'%3e%3c/path%3e%3c/svg%3e ");
143+
list-style-image: var(--brand-Prose-unorderedList-imageUrl);
144144
}
145145

146146
.Prose li {

packages/react/src/Prose/Prose.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import clsx from 'clsx'
33
import type {BaseProps} from '../component-helpers'
44
import styles from './Prose.module.css'
55
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/prose/base.css'
6+
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/prose/colors-with-modes.css'
67
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/inline-link/base.css'
78

89
export type ProseProps = {

packages/react/src/Prose/Prose.visual.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ test.describe('Visual Comparison: Prose', () => {
3939
expect(await page.screenshot()).toMatchSnapshot()
4040
})
4141
})
42+
test('Prose / Unordered List', async ({page}) => {
43+
await page.goto(
44+
'http://localhost:6006/iframe.html?args=&id=components-prose-features--unordered-list&viewMode=story',
45+
)
46+
47+
await page.waitForTimeout(500)
48+
expect(await page.screenshot()).toMatchSnapshot()
49+
})
50+
4251
test('Prose / Playground', async ({page}) => {
4352
await page.goto('http://localhost:6006/iframe.html?args=&id=components-prose--playground&viewMode=story')
4453

0 commit comments

Comments
 (0)