Skip to content

Commit

Permalink
Removes unnecessary code from the jsx example for modal nested compon…
Browse files Browse the repository at this point in the history
…ents

We were showing the whole Modal.js file for the final jsx example in the tutorial for nested components. That's not necessary though, since we only really want to show the new "render" function, so there's no need to repeat code that the developer has seen other times before. It's best to focus on the code we're currently working on.

Also, it was giving the wrong impression that the `close` method wasn't in the file anymore. Showing just the part that changes will be clearer and without unnecessary repetition.
  • Loading branch information
mairatma authored and jbalsas committed Jan 18, 2018
1 parent 9aebbcb commit 12a7d74
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions packages/metaljs.com/src/public/docs/modal_nested.soy
Original file line number Diff line number Diff line change
Expand Up @@ -133,31 +133,28 @@ export default CloseHeader;{/literal}
{/template}{/literal}
</textarea>
<textarea class="code hidden" data-mode="javascript">
{literal}import CloseHeader from './CloseHeader';
class Modal extends JSXComponent {
render() {
var cssClass = 'modal';
if (this.shown) {
cssClass += 'show';
}
return &lt;div class={cssClass}&gt;
&lt;div class="modal-dialog"&gt;
&lt;div class="modal-content"&gt;
&lt;CloseHeader
cssClass="modal-header"
onClick={this.close.bind(this)}
title={this.config.header}
/&gt;
&lt;section class="modal-body"&gt;
{this.config.body}
&lt;/section&gt;
&lt;footer class="modal-footer"&gt;
&lt;button type="button" class="btn btn-primary"&gt;OK&lt;/button&gt;
&lt;/footer&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;;
{literal}render() {
var cssClass = 'modal';
if (this.shown) {
cssClass += 'show';
}
return &lt;div class={cssClass}&gt;
&lt;div class="modal-dialog"&gt;
&lt;div class="modal-content"&gt;
&lt;CloseHeader
cssClass="modal-header"
onClick={this.close.bind(this)}
title={this.config.header}
/&gt;
&lt;section class="modal-body"&gt;
{this.config.body}
&lt;/section&gt;
&lt;footer class="modal-footer"&gt;
&lt;button type="button" class="btn btn-primary"&gt;OK&lt;/button&gt;
&lt;/footer&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;;
}{/literal}
</textarea>
{/param}
Expand Down

0 comments on commit 12a7d74

Please sign in to comment.