Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Inline-banner): refactored yield #151

Merged
merged 11 commits into from
Mar 19, 2020
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
{{#docs-demo as |demo|}}
{{#demo.example name="nucleus-inline-banner-2.hbs"}}
{{#nucleus-inline-banner type="warning" as |banner|}}
<div class="nucleus-inline-banner__icon">
{{nucleus-icon name="nucleus-circle-help" size="medium" variant="warning"}}
</div>
<div class="nucleus-inline-banner__content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim blandit volutpat maecenas volutpat.</p>
<a class="docs-link" href="#">Click here</a>
</div>
<div class="nucleus-inline-banner__close">
{{nucleus-button
variant="text"
size="mini"
icon="nucleus-cross"
iconOnly=true
onClick=(action banner.close)}}
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim blandit volutpat maecenas volutpat.</p>
<a class="docs-link" href="#">Click here</a>
{{/nucleus-inline-banner}}
{{/demo.example}}
{{demo.snippet "nucleus-inline-banner-2.hbs"}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
{{#if hasBlock}}
{{yield
(hash
close=(action "onCloseTip")
)
}}
{{else}}
<div class="nucleus-inline-banner__icon">
{{nucleus-icon name=_icon size="medium" variant=type}}
</div>
<div class="nucleus-inline-banner__content">
<div data-test-id="nucleus-inline-banner-title">{{title}}</div>
</div>
{{#if isDismissible}}
<div class="nucleus-inline-banner__close">
{{nucleus-button
variant="text"
size="mini"
icon="nucleus-cross"
iconOnly=true
onClick=(action "onCloseTip")}}
<div class="nucleus-inline-banner__icon">
{{nucleus-icon name=_icon size="medium" variant=type}}
</div>
<div class="nucleus-inline-banner__content">
{{#if hasBlock}}
{{yield}}
{{else}}
<div data-test-id="nucleus-inline-banner-title">
{{title}}
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you notice, you're repeating the code inside if/else of hasBlock. Can you refactor it so that the same code is not repeated?

Principle: D.R.Y Don't Repeat Yourself

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I"ll refactor this code

{{/if}}
</div>
{{#if isDismissible}}
<div class="nucleus-inline-banner__close">
{{nucleus-button
variant="text"
size="mini"
icon="nucleus-cross"
iconOnly=true
onClick=(action "onCloseTip")}}
</div>
{{/if}}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.