-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(modal): change to a composable component (#307)
Changes the uk-modal component to be composable with header, body and footer. BREAKING CHANGE: This removes the default stying of "uk-modal-body", to migrate to this patch and keep the stying it will have to be changed from: ```hbs {{#uk-modal}} Lorem ipsum {{/uk-modal}} ``` to: ```hbs {{#uk-modal as |modal|}} {{#modal.body}} Lorem ipsum {{/modal.body}} {{/uk-modal}} ``` The footer can be migrated as follows: ```hbs {{#uk-modal}} <p class="uk-text-right"> Footer content </p> {{/uk-modal}} ``` to: ```hbs {{#uk-modal as |modal|}} {{#modal.footer class="uk-text-right"}} Footer content {{/modal.footer}} {{/uk-modal}} ```
- Loading branch information
Showing
20 changed files
with
191 additions
and
22 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,10 @@ | ||
import Component from "@ember/component"; | ||
import layout from "../../templates/components/uk-modal/body"; | ||
|
||
export default Component.extend({ | ||
layout, | ||
|
||
tagName: "div", | ||
|
||
classNames: ["uk-modal-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Component from "@ember/component"; | ||
import layout from "../../templates/components/uk-modal/footer"; | ||
|
||
export default Component.extend({ | ||
layout, | ||
|
||
tagName: "div", | ||
|
||
classNames: ["uk-modal-footer"] | ||
}); |
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,10 @@ | ||
import Component from "@ember/component"; | ||
import layout from "../../templates/components/uk-modal/header"; | ||
|
||
export default Component.extend({ | ||
layout, | ||
|
||
tagName: "div", | ||
|
||
classNames: ["uk-modal-header"] | ||
}); |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
{{#-in-element containerElement}} | ||
<div id={{this.modalId}}> | ||
<div class="uk-modal-dialog"> | ||
{{#if @btnClose}}<button class="uk-modal-close-default" type="button" uk-close></button>{{/if}} | ||
<div class="uk-modal-body"> | ||
{{yield}} | ||
</div> | ||
<div id={{this.modalId}} class={{@modalClass}}> | ||
<div class="uk-modal-dialog {{@dialogClass}}"> | ||
{{#if this.btnClose}}<button class="uk-modal-close-default" type="button" uk-close></button>{{/if}} | ||
{{yield (hash | ||
header = (component "uk-modal/header") | ||
body = (component "uk-modal/body") | ||
footer = (component "uk-modal/footer") | ||
)}} | ||
</div> | ||
</div> | ||
{{/-in-element}} | ||
{{/-in-element}} |
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 @@ | ||
{{yield}} |
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 @@ | ||
{{yield}} |
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 @@ | ||
{{yield}} |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
export { default } from "ember-uikit/components/uk-modal/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "ember-uikit/components/uk-modal/footer"; |
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 @@ | ||
export { default } from "ember-uikit/components/uk-modal/header"; |
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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
{{#uk-modal visible=visible on-hide=(action (mut visible) false)}} | ||
<h2 class="uk-modal-title">Attention</h2> | ||
<p>Do you really want to proceed?</p> | ||
<p class="uk-text-right"> | ||
{{#uk-modal visible=visible on-hide=(action (mut visible) false) as |modal|}} | ||
{{#modal.header}} | ||
<h2 class="uk-modal-title">Attention</h2> | ||
{{/modal.header}} | ||
{{#modal.body}} | ||
<p>Do you really want to proceed?</p> | ||
{{/modal.body}} | ||
{{#modal.footer class="uk-text-right"}} | ||
{{uk-button color="primary" label="Ok" on-click=(action "submit")}} | ||
</p> | ||
{{/modal.footer}} | ||
{{/uk-modal}} | ||
|
||
{{uk-button label="Open modal" on-click=(action (mut visible) true)}} | ||
{{uk-button label="Open modal" on-click=(action (mut visible) true)}} |
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,26 @@ | ||
import { module, test } from "qunit"; | ||
import { setupRenderingTest } from "ember-qunit"; | ||
import { render } from "@ember/test-helpers"; | ||
import { hbs } from "ember-cli-htmlbars"; | ||
|
||
module("Integration | Component | uk-modal/body", function(hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test("it renders", async function(assert) { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.set('myAction', function(val) { ... }); | ||
|
||
await render(hbs`{{uk-modal/body}}`); | ||
|
||
assert.equal(this.element.textContent.trim(), ""); | ||
|
||
// Template block usage: | ||
await render(hbs` | ||
{{#uk-modal/body}} | ||
template block text | ||
{{/uk-modal/body}} | ||
`); | ||
|
||
assert.equal(this.element.textContent.trim(), "template block text"); | ||
}); | ||
}); |
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 { module, test } from "qunit"; | ||
import { setupRenderingTest } from "ember-qunit"; | ||
import { render } from "@ember/test-helpers"; | ||
import { hbs } from "ember-cli-htmlbars"; | ||
|
||
module("Integration | Component | uk-modal/header", function(hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test("it renders", async function(assert) { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.set('myAction', function(val) { ... }); | ||
|
||
await render(hbs`{{uk-modal/footer}}`); | ||
|
||
assert.equal(this.element.textContent.trim(), ""); | ||
|
||
// Template block usage: | ||
await render(hbs` | ||
{{#uk-modal/footer}} | ||
template block text | ||
{{/uk-modal/footer}} | ||
`); | ||
|
||
assert.equal(this.element.textContent.trim(), "template block text"); | ||
}); | ||
}); |
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 { module, test } from "qunit"; | ||
import { setupRenderingTest } from "ember-qunit"; | ||
import { render } from "@ember/test-helpers"; | ||
import { hbs } from "ember-cli-htmlbars"; | ||
|
||
module("Integration | Component | uk-modal/footer", function(hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test("it renders", async function(assert) { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.set('myAction', function(val) { ... }); | ||
|
||
await render(hbs`{{uk-modal/header}}`); | ||
|
||
assert.equal(this.element.textContent.trim(), ""); | ||
|
||
// Template block usage: | ||
await render(hbs` | ||
{{#uk-modal/header}} | ||
template block text | ||
{{/uk-modal/header}} | ||
`); | ||
|
||
assert.equal(this.element.textContent.trim(), "template block text"); | ||
}); | ||
}); |