Skip to content

Commit 5422924

Browse files
committed
feat(Introduction): add augmentation example
1 parent 09a1b17 commit 5422924

File tree

2 files changed

+74
-11
lines changed

2 files changed

+74
-11
lines changed

docs/app/Views/Introduction.js

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,31 @@ const MessageSubComponentsHTML = `<div class="ui icon message">
9494
We're fetching that content for you.
9595
</div>
9696
</div>`
97+
const HeaderAugmentationJSX = `<Header as='h3'>
98+
Learn More
99+
</Header>`
100+
const HeaderAugmentationHTML = `<h3 class="ui header">
101+
Learn More
102+
</h3>`
103+
const MenuItemLinkAugmentationJSX = `import { Link } from 'react-router'
104+
105+
<Menu>
106+
<MenuItem as={Link} to='/home'>
107+
Home
108+
</MenuItem>
109+
</Menu>`
110+
const MenuItemLinkAugmentationHTML = `<div class="ui menu">
111+
<a class="item">
112+
Learn More
113+
</a>
114+
</div>`
97115

98116
const Comparison = ({ jsx, html }) => (
99117
<Segment className='code-example'>
100118
<Grid columns='equal' centered textAlign='left'>
101119
<Grid.Column mobile='16' tablet='16' computer='8' largeScreen='7'>
102120
<Label size='tiny' attached='top left'>JSX</Label>
103-
<Highlight className='language-xml'>
121+
<Highlight className='language-javascript'>
104122
{jsx}
105123
</Highlight>
106124
</Grid.Column>
@@ -147,15 +165,19 @@ const Introduction = () => (
147165
<Message>
148166
<pre>$ npm install {pkg.name}</pre>
149167
</Message>
150-
<List>
151-
<List.Item icon='check mark'>jQuery Free</List.Item>
152-
<List.Item icon='check mark'>Declarative Components</List.Item>
153-
<List.Item icon='check mark'>Shorthand Props</List.Item>
154-
<List.Item icon='check mark'>Sub Components</List.Item>
155-
<List.Item icon='check mark'>Auto Controlled State</List.Item>
156-
</List>
168+
{/*<List>*/}
169+
{/*<List.Item icon='check mark'>jQuery Free</List.Item>*/}
170+
{/*<List.Item icon='check mark'>Declarative Components</List.Item>*/}
171+
{/*<List.Item icon='check mark'>Component Augmentation</List.Item>*/}
172+
{/*<List.Item icon='check mark'>Shorthand Props</List.Item>*/}
173+
{/*<List.Item icon='check mark'>Sub Components</List.Item>*/}
174+
{/*<List.Item icon='check mark'>Auto Controlled State</List.Item>*/}
175+
{/*</List>*/}
157176
</Segment>
158177

178+
{/* ----------------------------------------
179+
* jQuery Free
180+
* -------------------------------------- */}
159181
<Segment className='basic padded'>
160182
<Header as='h2' dividing>jQuery Free</Header>
161183
<p>
@@ -169,18 +191,46 @@ const Introduction = () => (
169191
</p>
170192
</Segment>
171193

194+
{/* ----------------------------------------
195+
* Declarative Components
196+
* -------------------------------------- */}
172197
<Segment className='basic padded'>
173198
<Header as='h2' dividing>Declarative Components</Header>
174-
Declarative APIs provide for robust features and prop validation.
199+
<p>
200+
Declarative APIs provide for robust features and prop validation.
201+
</p>
175202

176203
<Comparison jsx={RatingJSX} html={RatingHTML} />
177204
<Comparison jsx={ButtonJSX} html={ButtonHTML} />
178205
</Segment>
179206

207+
{/* ----------------------------------------
208+
* Component Augmentation
209+
* -------------------------------------- */}
210+
<Segment className='basic padded'>
211+
<Header as='h2' dividing>Component Augmentation</Header>
212+
<p>
213+
Control the rendered HTML tag, or render one component <code>as</code> another component.
214+
Extra props are passed to the component you are rending <code>as</code>.
215+
</p>
216+
217+
<p>
218+
Augmentation is powerful. You can compose component features and props without adding extra nested components.
219+
This is essential for working with <code>MenuLinks</code> and <code>react-router</code>.
220+
</p>
221+
222+
<Comparison jsx={HeaderAugmentationJSX} html={HeaderAugmentationHTML} />
223+
<Comparison jsx={MenuItemLinkAugmentationJSX} html={MenuItemLinkAugmentationHTML} />
224+
</Segment>
225+
226+
{/* ----------------------------------------
227+
* Shorthand Props
228+
* -------------------------------------- */}
180229
<Segment className='basic padded'>
181230
<Header as='h2' dividing>Shorthand Props</Header>
182231
<p>
183232
Shorthand props generate markup for you, making many use cases a breeze.
233+
All object props are spread on the child components.
184234
</p>
185235

186236
<Header as='h3'>Child Object Arrays</Header>
@@ -208,6 +258,9 @@ const Introduction = () => (
208258
<Comparison jsx={LabelJSX} html={LabelHTML} />
209259
</Segment>
210260

261+
{/* ----------------------------------------
262+
* Sub Components
263+
* -------------------------------------- */}
211264
<Segment className='basic padded'>
212265
<Header as='h2' dividing>Sub Components</Header>
213266
<p>
@@ -217,6 +270,9 @@ const Introduction = () => (
217270
<Comparison jsx={MessageSubComponentsJSX} html={MessageSubComponentsHTML} />
218271
</Segment>
219272

273+
{/* ----------------------------------------
274+
* Auto Controlled State
275+
* -------------------------------------- */}
220276
<Segment className='basic padded'>
221277
<Header as='h2' dividing>Auto Controlled State</Header>
222278

docs/app/index.ejs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,14 @@
5252
opacity: 1;
5353
}
5454
55-
.code-example pre {
55+
/* Doc site styles */
56+
57+
#introduction-page p {
58+
font-size: 1.125em;
59+
margin: 1.5em 0;
60+
}
61+
62+
pre {
5663
margin: 0;
5764
}
5865
@@ -61,7 +68,7 @@
6168
padding-top: 0.2em;
6269
padding-bottom: 0.2em;
6370
margin: 0;
64-
font-size: 90%;
71+
font-size: 85%;
6572
background-color: rgba(0, 0, 0, 0.04);
6673
border-radius: 3px;
6774
}

0 commit comments

Comments
 (0)