Skip to content

Commit c79eaf8

Browse files
authored
feat: New Prose component to style free-form HTML content consistently (#756)
* feat: New `Prose` component to style free-form HTML content consistently
1 parent 4228a38 commit c79eaf8

19 files changed

+616
-10
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Reactist follows [semantic versioning](https://semver.org/) and doesn't introduce breaking changes (API-wise) in minor or patch releases. However, the appearance of a component might change in a minor or patch release so keep an eye on redesigns and make sure your app still looks and feels like you expect it.
44

5+
# v20.1.0
6+
7+
- [Feat] New `Prose` component to style free-form HTML content consistently.
8+
59
# v20.0.3
610

711
- [Fix] Slightly tweak the height of the `Badge` component.

docs/iframe.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -476,4 +476,4 @@
476476

477477

478478

479-
window['STORIES'] = [{"titlePrefix":"","directory":"./src","files":"**/*.stories.@(tsx|mdx)","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(tsx|mdx))$"},{"titlePrefix":"","directory":"./stories","files":"**/*.stories.@(js|jsx|ts|tsx|mdx)","importPathMatcher":"^\\.[\\\\/](?:stories(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(js|jsx|ts|tsx|mdx))$"}];</script><script src="runtime~main.8b1ed5da.iframe.bundle.js"></script><script src="vendors~main.f0057794.iframe.bundle.js"></script><script src="main.e5d7635a.iframe.bundle.js"></script></body></html>
479+
window['STORIES'] = [{"titlePrefix":"","directory":"./src","files":"**/*.stories.@(tsx|mdx)","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(tsx|mdx))$"},{"titlePrefix":"","directory":"./stories","files":"**/*.stories.@(js|jsx|ts|tsx|mdx)","importPathMatcher":"^\\.[\\\\/](?:stories(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(js|jsx|ts|tsx|mdx))$"}];</script><script src="runtime~main.8b1ed5da.iframe.bundle.js"></script><script src="vendors~main.6eae3178.iframe.bundle.js"></script><script src="main.5b17ba62.iframe.bundle.js"></script></body></html>

docs/main.5b17ba62.iframe.bundle.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/main.e5d7635a.iframe.bundle.js

-1
This file was deleted.

docs/project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"generatedAt":1676988479996,"builder":{"name":"webpack4"},"hasCustomBabel":false,"hasCustomWebpack":true,"hasStaticDirs":false,"hasStorybookEslint":false,"refCount":0,"packageManager":{"type":"npm","version":"8.15.0"},"typescriptOptions":{"check":true,"checkOptions":{},"reactDocgen":"react-docgen-typescript","reactDocgenTypescriptOptions":{"shouldExtractLiteralValuesFromEnum":true}},"features":{"interactionsDebugger":true},"storybookVersion":"^6.5.3","language":"typescript","storybookPackages":{"@storybook/addon-knobs":{"version":"6.3.1"},"@storybook/addon-links":{"version":"6.5.3"},"@storybook/addons":{"version":"6.5.3"},"@storybook/jest":{"version":"0.0.10"},"@storybook/react":{"version":"6.5.3"},"@storybook/testing-library":{"version":"0.0.13"}},"framework":{"name":"react"},"addons":{"@storybook/addon-postcss":{"version":"2.0.0"},"@storybook/addon-actions":{"version":"6.5.3"},"@storybook/addon-docs":{"options":{"configureJSX":true},"version":"6.5.3"},"@storybook/addon-controls":{"version":"6.5.3"},"@geometricpanda/storybook-addon-badges":{"version":"0.2.2"},"@storybook/addon-interactions":{"version":"6.5.15"}}}
1+
{"generatedAt":1677608237660,"builder":{"name":"webpack4"},"hasCustomBabel":false,"hasCustomWebpack":true,"hasStaticDirs":false,"hasStorybookEslint":false,"refCount":0,"packageManager":{"type":"npm","version":"8.19.2"},"typescriptOptions":{"check":true,"checkOptions":{},"reactDocgen":"react-docgen-typescript","reactDocgenTypescriptOptions":{"shouldExtractLiteralValuesFromEnum":true}},"features":{"interactionsDebugger":true},"storybookVersion":"^6.5.3","language":"typescript","storybookPackages":{"@storybook/addon-knobs":{"version":"6.3.1"},"@storybook/addon-links":{"version":"6.5.3"},"@storybook/addons":{"version":"6.5.3"},"@storybook/jest":{"version":"0.0.10"},"@storybook/react":{"version":"6.5.3"},"@storybook/testing-library":{"version":"0.0.13"}},"framework":{"name":"react"},"addons":{"@storybook/addon-postcss":{"version":"2.0.0"},"@storybook/addon-actions":{"version":"6.5.3"},"@storybook/addon-docs":{"options":{"configureJSX":true},"version":"6.5.3"},"@storybook/addon-controls":{"version":"6.5.3"},"@geometricpanda/storybook-addon-badges":{"version":"0.2.2"},"@storybook/addon-interactions":{"version":"6.5.15"}}}

docs/vendors~main.f0057794.iframe.bundle.js renamed to docs/vendors~main.6eae3178.iframe.bundle.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/vendors~main.6eae3178.iframe.bundle.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/vendors~main.f0057794.iframe.bundle.js.map

-1
This file was deleted.

jest.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = {
44
'!**/*.stories.{js,jsx,ts,tsx}',
55
'!**/*storybook*.{js,jsx,ts,tsx}',
66
'!**/*-stories-components.{js,jsx,ts,tsx}',
7+
'!**/*-example.{js,jsx,ts,tsx}',
78
],
89
setupFilesAfterEnv: ['./scripts/jestSetup.ts'],
910
moduleNameMapper: {

package-lock.json

+34-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"email": "henning@doist.com",
77
"url": "http://doist.com"
88
},
9-
"version": "20.0.3",
9+
"version": "20.1.0",
1010
"license": "MIT",
1111
"homepage": "https://github.com/Doist/reactist#readme",
1212
"repository": {
@@ -89,6 +89,7 @@
8989
"@types/classnames": "^2.2.10",
9090
"@types/enzyme": "^3.10.7",
9191
"@types/jest-axe": "^3.5.3",
92+
"@types/marked": "^4.0.8",
9293
"@types/react": "^17.0.45",
9394
"@types/react-dom": "^17.0.17",
9495
"@typescript-eslint/eslint-plugin": "^5.25.0",
@@ -116,6 +117,7 @@
116117
"less": "^3.8.1",
117118
"less-loader": "^7.0.0",
118119
"lint-staged": "^10.4.0",
120+
"marked": "^4.2.12",
119121
"mini-css-extract-plugin": "^0.11.0",
120122
"mockdate": "^3.0.2",
121123
"optimize-css-assets-webpack-plugin": "^5.0.3",

src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export * from './toast'
1919
// text and typography
2020
export * from './heading'
2121
export * from './text'
22+
export * from './prose'
2223

2324
// links
2425
export * from './button'

src/prose/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { Prose } from './prose'
2+
export type { ProseProps } from './prose'

src/prose/prose-example.ts

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import { marked } from 'marked'
2+
3+
export const proseExample = marked(`
4+
# An h1 header
5+
6+
This is a paragraph. Paragraphs can have any length, and when long enough, their content wraps over
7+
multiple lines. This paragraph, for instance, should be long enough to do so in the most common
8+
screen sizes that are comfortable to read anyway.
9+
10+
A second paragraph now. One that contains [a link to Doist.com](https://doist.com), and text
11+
formatting examples, such as **bold text**, _italic text_, and \`monospace\`. Now let’s continue
12+
with a list:
13+
14+
- this one
15+
- that one
16+
- the other one
17+
18+
And a blockquote:
19+
20+
> Blockquotes are indented and have a border on the left. The text color is slightly dimmed.
21+
>
22+
> They can span multiple paragraphs, if you like.
23+
>
24+
> > And they can be nested too.
25+
26+
## An h2 header
27+
28+
Here's a numbered list:
29+
30+
1. first item
31+
2. second item
32+
3. third item
33+
34+
Here's a multi-line code example:
35+
36+
# Let me re-iterate ...
37+
for i in 1 .. 10 { do-something(i) }
38+
39+
And another one
40+
41+
\`\`\`python
42+
import time
43+
# Quick, count to ten!
44+
for i in range(10):
45+
# (but not *too* quick)
46+
time.sleep(0.5)
47+
print i
48+
\`\`\`
49+
50+
### An h3 header
51+
52+
Now a nested list:
53+
54+
1. First, get these ingredients:
55+
56+
- carrots
57+
- celery
58+
- lentils
59+
60+
2. Boil some water.
61+
62+
3. Dump everything in the pot and follow
63+
this algorithm:
64+
65+
find wooden spoon
66+
uncover pot
67+
stir
68+
cover pot
69+
balance wooden spoon precariously on pot handle
70+
wait 10 minutes
71+
goto first step (or shut off burner when done)
72+
73+
Do not bump wooden spoon or it will fall.
74+
75+
---
76+
77+
A horizontal rule follows.
78+
79+
---
80+
81+
The End
82+
`)

0 commit comments

Comments
 (0)