Skip to content

Commit 4ab9836

Browse files
committed
Fix warning on <pre> inside <p>
1 parent cf47e1c commit 4ab9836

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

src-example/components/molecules/Feature/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
33
import styled from 'styled-components'
44
import { ifProp } from 'styled-tools'
55

6-
import { Icon, Link, Paragraph, Heading, Badge } from 'components'
6+
import { Icon, Link, Paragraph, Heading, Badge, PreformattedText } from 'components'
77

88
const Wrapper = styled.div`
99
position: relative;
@@ -31,7 +31,7 @@ const StyledBadge = styled(Badge)`
3131
right: 1rem;
3232
`
3333

34-
const Feature = ({ icon, title, link, children, ...props }) => {
34+
const Feature = ({ icon, title, link, code, children, ...props }) => {
3535
return (
3636
<Wrapper {...props}>
3737
{icon && <StyledIcon icon={icon} height={64} />}
@@ -40,6 +40,7 @@ const Feature = ({ icon, title, link, children, ...props }) => {
4040
{link ? <Link href={link}>{title}</Link> : title}
4141
</Heading>
4242
<Paragraph>{children}</Paragraph>
43+
{code && <PreformattedText block>{code}</PreformattedText>}
4344
</Text>
4445
{props.soon && <StyledBadge palette="grayscale">soon</StyledBadge>}
4546
</Wrapper>
@@ -52,6 +53,7 @@ Feature.propTypes = {
5253
link: PropTypes.string,
5354
soon: PropTypes.bool,
5455
children: PropTypes.any,
56+
code: PropTypes.node,
5557
}
5658

5759
export default Feature

src-example/components/organisms/FeatureList/index.js

+7-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import styled from 'styled-components'
33

4-
import { Feature, Link, Heading, PreformattedText, Paragraph } from 'components'
4+
import { Feature, Link, Heading, Paragraph } from 'components'
55

66
const Grid = styled.div`
77
display: flex;
@@ -39,41 +39,33 @@ const FeatureList = ({ ...props }) => (
3939
icon="react"
4040
link="https://facebook.github.io/react"
4141
title="React"
42+
code={'<MyComponent attr="value" />'}
4243
>
4344
The Facebook&apos;s JavaScript library for building user interfaces using components.
44-
<PreformattedText block wrap>
45-
{'<MyComponent attr="value" />'}
46-
</PreformattedText>
4745
</StyledFeature>
4846
<StyledFeature
4947
icon="react-router"
5048
link="https://github.com/ReactTraining/react-router"
5149
title="React Router"
50+
code={'<Route path="/sample-page" />'}
5251
>
5352
The most popular declarative routing library for React and React Native.
54-
<PreformattedText block wrap>
55-
{'<Route path="/sample-page" />'}
56-
</PreformattedText>
5753
</StyledFeature>
5854
<StyledFeature
5955
icon="webpack"
6056
link="https://webpack.github.io/"
6157
title="Webpack"
58+
code="npm run build"
6259
>
6360
The awesome module bundler with <Link href="https://webpack.github.io/docs/hot-module-replacement.html">Hot Module Replacement</Link> enabled.
64-
<PreformattedText block>
65-
npm run build
66-
</PreformattedText>
6761
</StyledFeature>
6862
<StyledFeature
6963
icon="jest"
7064
link="https://facebook.github.io/jest"
7165
title="Jest"
66+
code="npm run test"
7267
>
7368
The great testing framework used by Facebook to test all their Javascript code.
74-
<PreformattedText block>
75-
npm run test
76-
</PreformattedText>
7769
</StyledFeature>
7870
</Grid>
7971
<StyledHeading>Optional features</StyledHeading>
@@ -85,21 +77,17 @@ const FeatureList = ({ ...props }) => (
8577
icon="redux"
8678
link="https://github.com/diegohaz/arc/tree/redux"
8779
title="Redux"
80+
code="git clone -b redux https://github.com/diegohaz/arc my-app"
8881
>
8982
The predictable state container for JavaScript apps.
90-
<PreformattedText block>
91-
git clone -b redux https://github.com/diegohaz/arc my-app
92-
</PreformattedText>
9383
</StyledFeature>
9484
<StyledFeature
9585
icon="dist"
9686
link="https://github.com/diegohaz/arc/tree/redux-ssr"
9787
title="Server Side Rendering"
88+
code="git clone -b redux-ssr https://github.com/diegohaz/arc my-app"
9889
>
9990
Write once and run both on server and client.
100-
<PreformattedText block>
101-
git clone -b redux-ssr https://github.com/diegohaz/arc my-app
102-
</PreformattedText>
10391
</StyledFeature>
10492
</Grid>
10593
</div>

0 commit comments

Comments
 (0)