Skip to content

Commit fbc2fd5

Browse files
committed
WIP Remove old settings code, add new component
* Remove settings route etc. * Add new settings container component, open in modal * Port modal CSS to Tailwind (refs #222)
1 parent f0b4ff3 commit fbc2fd5

File tree

14 files changed

+54
-224
lines changed

14 files changed

+54
-224
lines changed

app/components/modal-target/component.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ export default class ModalTargetComponent extends Component {
66
modalAnimation () {
77
return this.lookup('explode').call(this, {
88
pick: '.modal-background',
9-
use: ['fade', { maxOpacity: 0.5, duration: 200 }]
9+
use: ['fade', { maxOpacity: 0.5, duration: 150 }]
1010
}, {
1111
pick: '.modal-dialog',
12-
use: ['scale', { duration: 200 }]
12+
use: ['scale', { duration: 150 }]
1313
});
1414
}
1515

app/components/modal-target/template.hbs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
<FromElsewhere @name="modal" as |modal|>
2-
<LiquidBind @value={{modal}} @containerless={{true}} @use={{this.modalAnimation}} as |currentModal|>
2+
<LiquidBind @value={{modal}}
3+
@containerless={{true}}
4+
@use={{this.modalAnimation}} as |currentModal|>
35
{{#if currentModal}}
4-
<div class="modal-container">
5-
<div class="modal-background" {{on "click" (fn this.outsideClick currentModal)}} role="button"></div>
6-
<div class="modal-dialog">
6+
<div class="modal-container fixed top-0 left-0 w-screen h-screen z-20
7+
flex flex-col justify-center">
8+
<div {{on "click" (fn this.outsideClick currentModal)}} role="button"
9+
class="modal-background fixed top-0 left-0 w-screen h-screen z-10
10+
bg-black opacity-50"></div>
11+
<div class="modal-dialog z-30 my-0 mx-auto rounded-md
12+
bg-white text-gray-800">
713
{{#if currentModal.body}}
814
{{component currentModal.body}}
915
{{else}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div>
2+
<h2>Settings</h2>
3+
<p>Foo</p>
4+
</div>

app/components/space-setting-modal/component.js

-28
This file was deleted.

app/components/space-setting-modal/template.hbs

-34
This file was deleted.

app/controllers/application.js

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default class ApplicationController extends Controller {
1111

1212
@tracked showGlobalMenu = false;
1313
@tracked showChannelMenu = false;
14+
@tracked showSettingsModal = false;
1415

1516
hammerInputClass = Hammer.SUPPORT_POINTER_EVENTS ? Hammer.PointerEventInput : Hammer.TouchInput;
1617

@@ -45,4 +46,8 @@ export default class ApplicationController extends Controller {
4546
}
4647
}
4748

49+
@action
50+
openSettingsModal () {
51+
this.showSettingsModal = true;
52+
}
4853
}

app/router.js

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Router.map(function() {
1313
});
1414
this.route('user-channel', { path: '/user/:slug' });
1515

16-
this.route('settings');
1716
this.route('welcome');
1817
this.route('add-account', function() {});
1918
});

app/routes/settings.js

-45
This file was deleted.

app/styles/_settings.scss

-14
This file was deleted.

app/styles/app.scss

-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ header {
106106
@import "components/date-headline";
107107
@import "components/message-chat";
108108
@import "components/message-input";
109-
@import "components/modal-target";
110109
@import "components/notification-topic-change";
111110
@import "components/user-list";
112-
@import "settings";
113111
@import "space";

app/styles/components/modal-target.scss

-33
This file was deleted.

app/templates/application.hbs

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<footer>
1818
<nav>
19-
<LinkTo @route="settings"><IconSettings /></LinkTo>
19+
<button {{on "click" this.openSettingsModal}}><IconSettings /></button>
2020
</nav>
2121
</footer>
2222
</div>
@@ -30,4 +30,10 @@
3030

3131
{{/if}}
3232

33+
{{#if this.showSettingsModal}}
34+
<ToElsewhere @named="modal"
35+
@send={{hash body=(component "settings-container" onCancel=(fn (mut this.showSettingsModal) false))
36+
onOutsideClick=(fn (mut this.showSettingsModal) false)}} />
37+
{{/if}}
38+
3339
<ModalTarget />

app/templates/settings.hbs

-60
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { module, test } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
3+
import { render } from '@ember/test-helpers';
4+
import { hbs } from 'ember-cli-htmlbars';
5+
6+
module('Integration | Component | settings-container', function(hooks) {
7+
setupRenderingTest(hooks);
8+
9+
test('it renders', async function(assert) {
10+
// Set any properties with this.set('myProperty', 'value');
11+
// Handle any actions with this.set('myAction', function(val) { ... });
12+
13+
await render(hbs`<SettingsContainer />`);
14+
15+
assert.equal(this.element.textContent.trim(), '');
16+
17+
// Template block usage:
18+
await render(hbs`
19+
<SettingsContainer>
20+
template block text
21+
</SettingsContainer>
22+
`);
23+
24+
assert.equal(this.element.textContent.trim(), 'template block text');
25+
});
26+
});

0 commit comments

Comments
 (0)