Last active
November 14, 2019 00:14
-
-
Save chancancode/e55043ce86b0a7fd2117 to your computer and use it in GitHub Desktop.
<random-color>
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 Ember from 'ember'; | |
// Returns a random integer from 0 up to (and excluding) max | |
function randomInteger(max) { | |
return Math.floor( Math.random() * max ); | |
} | |
// Returns a random color in rgb(x,y,z) format | |
function randomColor() { | |
let r = randomInteger(256), | |
g = randomInteger(256), | |
b = randomInteger(256); | |
return `rgb(${r},${g},${b})`; | |
} | |
// Returns a text-shadow for the "glow" effect | |
function randomGlow() { | |
return `0px 0px 4px ${ randomColor() }`; | |
} | |
export default Ember.GlimmerComponent.extend({ | |
setColor() { | |
if (this.attrs.fill) { | |
this.element.style.color = randomColor(); | |
} | |
if (this.attrs.glow) { | |
this.element.style.textShadow = randomGlow(); | |
} | |
}, | |
didInsertElement() { | |
this.setColor(); | |
}, | |
click() { | |
this.setColor(); | |
} | |
}); |
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
body { | |
margin: 12px 16px; | |
font-family: "Comic Sans MS", "Comic Sans", cursive; | |
font-size: 20pt; | |
letter-spacing: 2px; | |
} | |
::moz-selection { background-color: transparent; } | |
::selection { background-color: transparent; } |
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
{ | |
"version": "0.4.10", | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"hax": "https://cdn.rawgit.com/chancancode/5b7b95b6268d51cdcaae/raw/92e0654083305c73cd601381a6cea705be9f8890/hax.js", | |
"ember": "http://builds.emberjs.com/canary/ember.debug.js", | |
"ember-template-compiler": "http://builds.emberjs.com/canary/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment