Last active
September 25, 2020 00:00
-
-
Save 3cp/7b5e9b8f402136125ab4a7dd957d8e81 to your computer and use it in GitHub Desktop.
aurelia-dialog-lite: customise position
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Dumber Gist</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"> | |
<base href="/"> | |
</head> | |
<!-- | |
Dumber gist uses dumber bundler, the default bundle file | |
is /dist/entry-bundle.js. | |
The starting module is pointed to aurelia-bootstrapper | |
(data-main attribute on script) for Aurelia, | |
The aurelia bootstrapper then loads up user module "main" | |
(aurelia-app attribute on <body>) which is your src/main.js. | |
--> | |
<body aurelia-app="main"> | |
<script src="/dist/entry-bundle.js" data-main="aurelia-bootstrapper"></script> | |
</body> | |
</html> |
This file contains hidden or 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
{ | |
"dependencies": { | |
"aurelia-bootstrapper": "^2.3.3" | |
} | |
} |
This file contains hidden or 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
<template> | |
<require from="./app.scss"></require> | |
<button click.trigger="openDialog()">Open a dialog</button> | |
<p>${message}</p> | |
</template> |
This file contains hidden or 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 { inject } from 'aurelia-framework'; | |
import { DialogService } from 'aurelia-dialog-lite'; | |
import { TestDialog } from './test-dialog'; | |
@inject(DialogService) | |
export class App { | |
message = ''; | |
constructor(dialogService) { | |
this.dialogService = dialogService; | |
} | |
openDialog() { | |
this.message = ''; | |
this.dialogService.open({ | |
viewModel: TestDialog, | |
model: { title: 'Test dialog' } | |
}).then( | |
result => this.message = 'Got ' + JSON.stringify(result), | |
err => this.message = err.message | |
); | |
} | |
} |
This file contains hidden or 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
.my-dialog { | |
border-radius: 3px; | |
padding: .5rem; | |
box-shadow: 0 0 2rem gray; | |
} | |
.dialog-lite-overlay { | |
// only overwrite display: flex | |
display: block; | |
.my-dialog { | |
position: absolute; | |
top: 1rem; | |
text-align: center; | |
width: 10rem; | |
margin-left: auto; | |
margin-right: auto; | |
left: 0; | |
right: 0; | |
} | |
} |
This file contains hidden or 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
export function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging('info') | |
.plugin('aurelia-dialog-lite'); | |
aurelia.start().then(() => aurelia.setRoot()); | |
} |
This file contains hidden or 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
<template> | |
<div class="my-dialog"> | |
<h4>${title}</h4> | |
<p>Top and centered</p> | |
<button click.trigger="controller.cancel()">Cancel</button> | |
<button click.trigger="controller.ok({any: 'thing'})">OK</button> | |
</div> | |
</template> |
This file contains hidden or 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 { inject } from 'aurelia-framework'; | |
import { DialogController } from 'aurelia-dialog-lite'; | |
@inject(DialogController) | |
export class TestDialog { | |
constructor(controller) { | |
this.controller = controller; | |
} | |
activate(model) { | |
this.title = model.title; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment