Last active
August 26, 2020 17:58
-
-
Save thousand/8b6309e6f19b4e15d742642a9436a0f5 to your computer and use it in GitHub Desktop.
New Twiddle
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 { tracked } from '@glimmer/tracking'; | |
import { next } from '@ember/runloop'; | |
import { action } from '@ember/object'; | |
export default class extends Component { | |
@tracked showOldCount = false; | |
lastCounts = []; | |
get oldCount() { | |
this.lastCounts.push(this.args.count); | |
if (this.lastCounts.length > 1) { | |
next(() => { | |
this.showOldCount = true; | |
console.log(this.showOldCount); | |
}); | |
return this.lastCounts.shift(); | |
} else { | |
return null; | |
} | |
} | |
get normalizedCount() { | |
const c = parseInt(this.args.count); | |
return c; | |
} | |
@action | |
resetCountDisplay() { | |
this.showOldCount = false; | |
} | |
} |
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 { tracked } from '@glimmer/tracking'; | |
import { action } from '@ember/object'; | |
export default class ApplicationController extends Controller { | |
@tracked count = 5; | |
@action | |
incrementCount() { | |
this.count++; | |
} | |
} |
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
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.button { | |
display: block; | |
width: 64px; | |
height: 64px; | |
background: rgba(255, 0, 255, 0.2); | |
} | |
.badge-wrapper { | |
position: relative; | |
width: 64px; | |
height: 64px; | |
} | |
.badge { | |
display: block; | |
position: absolute; | |
top: -0.5em; | |
right: -0.5em; | |
color: white; | |
background: fuchsia; | |
padding: 0.25em 0.5em; | |
border-radius: 5em; /* lol */ | |
overflow: hidden; | |
} | |
.badge.show-old-count:after { | |
display: block; | |
animation: 0.5s slidein; | |
} | |
.badge:after { | |
content: attr(data-old-count); | |
display: none; | |
position: absolute; | |
box-sizing: border-box; | |
top: 0; | |
left: 0; | |
height: 100%; | |
width: 100%; | |
padding: 0.25em 0.5em; | |
background: cyan; | |
} | |
@keyframes slidein { | |
from { | |
transform: translateY(0%); | |
} | |
to { | |
transform: translateY(-100%); | |
} | |
} |
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" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment