-
-
Save drub0y/7d087a011cf7a0c3341eae48eb1f4ed6 to your computer and use it in GitHub Desktop.
Aurelia-Materialize bridge badge with custom caption
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> | |
<ul class="collection"> | |
<li class="collection-item">Sent</li> | |
<li class="collection-item">Inbox<span md-badge="is-new: true;">3</span></li> | |
<li class="collection-item">Spam<span show.bind="spamCount > 0" class="yellow black-text" md-badge="is-new: true; caption.bind: spamCaption">${spamCount}</span></li> | |
</ul> | |
</div> | |
<div class="actions"> | |
<hr /> | |
Add/Remove some emails to/from the Spam folder: | |
<button md-button="flat: true;" md-waves click.delegate="cleanSomeSpam()"><i class="material-icons">remove</i></button><button md-button="flat: true;" md-waves click.delegate="addSomeSpam()"><i class="material-icons">add</i></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 {bindable, computedFrom} from 'aurelia-framework'; | |
export class App { | |
@bindable spamCount = 131; | |
addSomeSpam() { | |
this.spamCount += this.getRandomSpamAmount(); | |
} | |
cleanSomeSpam() { | |
this.spamCount -= this.getRandomSpamAmount(); | |
if(this.spamCount < 0) { | |
this.spamCount = 0; | |
} | |
} | |
@computedFrom('spamCount') | |
get spamCaption() { | |
let caption = null; | |
if(this.spamCount > 100) { | |
caption = "Spam overload!!!"; | |
} else if(this.spamCount > 80) { | |
caption = "Spam level: critical." | |
} else if(this.spamCount > 30) { | |
caption = "Spam level: concerning"; | |
} | |
return caption; | |
} | |
getRandomSpamAmount() { | |
return Math.floor(Math.random() * 25) + 1; | |
} | |
} |
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> | |
<title>Aurelia</title> | |
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body aurelia-app="main"> | |
<h1>Loading...</h1> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.6/system.js"></script> | |
<script src="https://rawgit.com/aurelia-ui-toolkits/aurelia-materialize-bundles/0.20.2/config2.js"></script> | |
<script> | |
System.import('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
/******************************************************************************* | |
* The following two lines enable async/await without using babel's | |
* "runtime" transformer. Uncomment the lines if you intend to use async/await. | |
* | |
* More info here: https://github.com/jdanyow/aurelia-plunker/issues/2 | |
*/ | |
//import regeneratorRuntime from 'babel-runtime/regenerator'; | |
//window.regeneratorRuntime = regeneratorRuntime; | |
/******************************************************************************/ | |
import 'materialize'; | |
export function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging() | |
.plugin('aurelia-materialize-bridge', bridge => bridge.useAll() ); | |
aurelia.start().then(a => a.setRoot()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment