-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1298 from flo-sch/feature/paragraph
feat: paragraph component
- Loading branch information
Showing
8 changed files
with
168 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react' | ||
import Box from './Box' | ||
|
||
export const Paragraph = React.forwardRef(({ sx, ...props }, ref) => ( | ||
<Box | ||
ref={ref} | ||
as="p" | ||
variant="paragraph" | ||
{...props} | ||
sx={{ | ||
// reset margin by default: avoid relying on user-agent margins (not aware of theme-ui space scale) | ||
margin: 0, | ||
// set a max-width: avoid full-page paragraphs | ||
'@media screen and (min-width: 36em)': { | ||
maxWidth: '48rem', | ||
}, | ||
...sx, | ||
}} | ||
__themeKey="text" | ||
__css={{ | ||
fontFamily: 'body', | ||
fontWeight: 'body', | ||
lineHeight: 'body', | ||
}} | ||
/> | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
title: Paragraph | ||
--- | ||
|
||
# Paragraph | ||
|
||
Primitive typographic component meant to display text blocks, defaults to `<p>`. | ||
|
||
```js | ||
import { Paragraph } from 'theme-ui' | ||
``` | ||
|
||
```jsx live=true | ||
<Paragraph>Hello World!</Paragraph> | ||
<Paragraph variant="block"> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec nunc elit, | ||
feugiat ut velit eget, pellentesque accumsan libero. Duis interdum ante sed | ||
ipsum imperdiet congue nec non mauris. Quisque ac ultricies nunc. Sed nisi | ||
diam, suscipit eu laoreet a, bibendum nec mauris. Aliquam tristique rhoncus | ||
ipsum scelerisque egestas. Maecenas rhoncus malesuada mauris, vel porta ex | ||
tincidunt non. Duis ac sapien in felis fermentum tristique. Nam a erat | ||
faucibus, varius magna ac, interdum tortor. Aenean quis varius mi, nec | ||
molestie neque. In dignissim diam in velit pharetra cursus. Integer gravida, | ||
arcu non sagittis iaculis, justo leo facilisis augue, consequat mollis risus | ||
erat quis velit. In turpis nibh, ornare ut facilisis id, dignissim non enim. | ||
Fusce maximus elit sit amet dolor aliquet, et tristique elit eleifend. Aenean | ||
ornare tortor sem, at sollicitudin ipsum scelerisque a. | ||
</Paragraph> | ||
<Paragraph as="small" sx={{ fontStyle: 'italic' }}>Something a bit less important</Paragraph> | ||
``` | ||
|
||
Use the `as` prop to set the correct HTML element independent from styling. | ||
|
||
## Variants | ||
|
||
Text style variants can be defined in the `theme.text` object. | ||
The Paragraph component uses `theme.text.paragraph` as its default variant style. | ||
|
||
```js | ||
// example theme variants | ||
{ | ||
text: { | ||
block: { | ||
variant: 'paragraph', | ||
my: 2, | ||
textAlign: 'justify', | ||
textAlignLast: 'start', | ||
textJustify: 'auto', | ||
}, | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters