Created
July 1, 2020 18:29
-
-
Save krukid/64b93569baad5fc74c900035a75dee4d to your computer and use it in GitHub Desktop.
ember-stacking-lightbox
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
import Component from '@glimmer/component'; | |
import { inject as service } from '@ember/service'; | |
import { action } from '@ember/object'; | |
export default class extends Component { | |
@service lightbox; | |
@action | |
click(response) { | |
this.args.close(response); | |
} | |
} |
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
import Component from '@glimmer/component'; | |
import { inject as service } from '@ember/service'; | |
import { action } from '@ember/object'; | |
export default class extends Component { | |
@service lightbox; | |
@action | |
close(item, result) { | |
this.lightbox.close(item, result); | |
} | |
} |
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
import Component from '@glimmer/component'; | |
import { inject as service } from '@ember/service'; | |
import { action } from '@ember/object'; | |
export default class extends Component { | |
@service lightbox; | |
modalFields = { | |
name: 'Nikolaj', | |
surname: 'Teslya', | |
}; | |
@action | |
async updateUser() { | |
const result = await this.lightbox.open('confirm', { | |
message: 'Are you sure you want to update this user?', | |
}); | |
if (result === 'yes') { | |
console.log('Updating user with', this.modalFields); | |
// @note close lb on successful update | |
this.args.close('updated'); | |
} | |
else { | |
console.log('Cancelled user update'); | |
} | |
} | |
@action | |
close() { | |
this.args.close('normal'); | |
} | |
} |
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
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
appName = 'Stacking Lightbox Demo'; | |
} |
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
import Controller from '@ember/controller'; | |
import { inject as service } from '@ember/service'; | |
import { action } from '@ember/object'; | |
export default class IndexController extends Controller { | |
@service lightbox; | |
@action | |
showUser() { | |
this.lightbox.open('user', {username: 'Melon Usk'}); | |
} | |
} |
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
import Service from '@ember/service'; | |
export default Service.extend({ | |
items: null, | |
id: 0, | |
init() { | |
this._super(...arguments); | |
this.set('items', []); | |
}, | |
open(name, fields) { | |
return new Promise(resolve => { | |
const id = this.incrementProperty('id'); | |
this.items.pushObject({id, name, resolve, fields}); | |
}); | |
}, | |
close(item, result) { | |
this.items.removeObject(item); | |
item.resolve(result); | |
}, | |
}); |
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
html { | |
background: no-repeat url('https://source.unsplash.com/600x600?window') 50% 100% / cover; | |
box-sizing: border-box; | |
min-height: 100vh; | |
} | |
body { | |
background: rgba(255,255,255,0.85); | |
margin: 12px 16px; | |
padding: 12px 16px; | |
font: 12pt sans-serif; | |
} | |
h1 { | |
margin-top: 0; | |
} |
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
{ | |
"version": "0.17.1", | |
"EmberENV": { | |
"FEATURES": {}, | |
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false, | |
"_APPLICATION_TEMPLATE_WRAPPER": true, | |
"_JQUERY_INTEGRATION": true | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js", | |
"ember": "3.18.1", | |
"ember-template-compiler": "3.18.1", | |
"ember-testing": "3.18.1" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0", | |
"ember-data": "3.18.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment