Skip to content

Commit

Permalink
Removed {{action}} helper from docs-app (#410)
Browse files Browse the repository at this point in the history
* feature: Created <DemoModal> component to standardize demos

* refactor: Consumed <DemoModal> component (index)

* refactor: Consumed <DemoModal> component (animatable)

* refactor: Consumed <DemoModal> component (tethered)

* refactor: Consumed <DemoModal> component (tethered-animatable)

* chore: Removed unused code

* chore: Removed unused configuration

---------

Co-authored-by: ijlee2 <[email protected]>
  • Loading branch information
ijlee2 and ijlee2 authored Dec 5, 2024
1 parent f3c8301 commit d7c0e58
Show file tree
Hide file tree
Showing 21 changed files with 1,152 additions and 1,701 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ module.exports = {
},
rules: {
'no-setter-return': 'off',
'ember/classic-decorator-no-classic-methods': 'warn',
'ember/classic-decorator-hooks': 'warn',
'ember/no-classic-classes': 'warn',
'ember/no-classic-components': 'warn',
Expand Down
114 changes: 0 additions & 114 deletions tests/acceptance/basic-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,12 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) {
openSelector: '#example-basic button',
dialogText: 'Basic',
closeSelector: overlaySelector,
whileOpen: async function () {
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});

await assert.dialogOpensAndCloses({
openSelector: '#example-basic button',
dialogText: 'Basic',
closeSelector: dialogCloseButton,
whileOpen: async function () {
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});
});

Expand All @@ -55,26 +41,12 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) {
openSelector: '#example-translucent button',
dialogText: 'With Translucent Overlay',
closeSelector: overlaySelector,
whileOpen: async function () {
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});

await assert.dialogOpensAndCloses({
openSelector: '#example-translucent button',
dialogText: 'With Translucent Overlay',
closeSelector: dialogCloseButton,
whileOpen: async function () {
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});
});

Expand All @@ -83,26 +55,12 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) {
openSelector: '#example-without-overlay button',
dialogText: 'Without Overlay',
closeSelector: '#example-without-overlay',
whileOpen: async function () {
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});

await assert.dialogOpensAndCloses({
openSelector: '#example-without-overlay button',
dialogText: 'Without Overlay',
closeSelector: dialogCloseButton,
whileOpen: async function () {
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});
});

Expand All @@ -111,26 +69,12 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) {
openSelector: '#example-translucent button',
dialogText: 'With Translucent Overlay',
closeSelector: overlaySelector,
whileOpen: async function () {
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});

await assert.dialogOpensAndCloses({
openSelector: '#example-translucent button',
dialogText: 'With Translucent Overlay',
closeSelector: dialogCloseButton,
whileOpen: async function () {
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});
});

Expand All @@ -139,26 +83,12 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) {
openSelector: '#example-overlay-sibling button',
dialogText: 'With Translucent Overlay as Sibling',
closeSelector: overlaySelector,
whileOpen: async function () {
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});

await assert.dialogOpensAndCloses({
openSelector: '#example-overlay-sibling button',
dialogText: 'With Translucent Overlay as Sibling',
closeSelector: dialogCloseButton,
whileOpen: async function () {
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});
});

Expand Down Expand Up @@ -191,24 +121,12 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) {
'custom-styles-modal-container',
'has provided container-class',
);
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});
await assert.dialogOpensAndCloses({
openSelector: '#example-custom-styles button',
dialogText: 'Custom Styles',
closeSelector: dialogCloseButton,
whileOpen: async function () {
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});
});

Expand All @@ -224,11 +142,6 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) {
'ember-modal-dialog-target-attachment-left',
'has targetAttachment class name',
);
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});
});
Expand All @@ -238,13 +151,6 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) {
openSelector: '#example-target-element button',
dialogText: 'Target - Element',
closeSelector: dialogCloseButton,
whileOpen: async function () {
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});
});

Expand All @@ -257,11 +163,6 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) {
assert
.dom(dialogSelector)
.hasClass('my-cool-modal', 'has provided containerClassNames');
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});
});
Expand All @@ -278,11 +179,6 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) {
assert
.dom(dialogSelector)
.hasClass('my-cool-modal-2', 'has provided containerClassNames');
assert.hasDataTest(
dialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
},
});
});
Expand All @@ -302,11 +198,6 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) {
assert
.dom(inPlaceDialogSelector)
.hasClass('my-custom-class', 'has provided containerClass');
assert.hasDataTest(
inPlaceDialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
assert.strictEqual(
getComputedStyle(dialogElement).getPropertyValue('position'),
'static',
Expand Down Expand Up @@ -356,11 +247,6 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) {
assert
.dom(inPlaceDialogSelector)
.hasClass('my-custom-class-2', 'has provided containerClassNames');
assert.hasDataTest(
inPlaceDialogSelector,
'my-data-test',
'dialog has data-test attribute',
);
await click(inPlaceCloseButton);
});
});
17 changes: 0 additions & 17 deletions tests/dummy/app/components/component-that-uses-modal-dialog.hbs

This file was deleted.

16 changes: 0 additions & 16 deletions tests/dummy/app/components/component-that-uses-modal-dialog.js

This file was deleted.

34 changes: 34 additions & 0 deletions tests/dummy/app/components/demo-modal.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<div class="example" id={{@id}}>
<h2>{{@title}}</h2>

<div>
{{yield
(hash
OpenButton=(component
"demo-modal/button"
label="Open"
onClick=this.openModal
)
)
to="menu"
}}
</div>

<div>
{{yield to="code"}}
</div>

<div>
{{yield
(hash
CloseButton=(component
"demo-modal/button"
label="Close"
onClick=this.closeModal
)
closeModal=this.closeModal
isModalOpen=this.isModalOpen
)
}}
</div>
</div>
19 changes: 19 additions & 0 deletions tests/dummy/app/components/demo-modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { action } from '@ember/object';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

export default class DemoModal extends Component {
@tracked isModalOpen = false;

@action closeModal() {
this.isModalOpen = false;

this.args.onClose?.();
}

@action openModal() {
this.isModalOpen = true;

this.args.onOpen?.();
}
}
8 changes: 8 additions & 0 deletions tests/dummy/app/components/demo-modal/button.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<button
data-test-button={{@label}}
type="button"
{{on "click" @onClick}}
...attributes
>
{{@label}}
</button>
5 changes: 5 additions & 0 deletions tests/dummy/app/components/demo-modal/button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import templateOnlyComponent from '@ember/component/template-only';

const DemoModalButton = templateOnlyComponent();

export default DemoModalButton;
Loading

0 comments on commit d7c0e58

Please sign in to comment.