Use heatmap color for user list
This commit is contained in:
parent
e3486ddcc3
commit
d89d2ffc7b
2 changed files with 6 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
import { withComponent, props } from 'skatejs';
|
import { withComponent, props } from 'skatejs';
|
||||||
|
import interpolate from 'color-interpolate';
|
||||||
|
|
||||||
const Component = withComponent();
|
const Component = withComponent();
|
||||||
class UserList extends Component {
|
class UserList extends Component {
|
||||||
|
@ -71,11 +72,13 @@ class UserList extends Component {
|
||||||
|
|
||||||
render({ data }) {
|
render({ data }) {
|
||||||
const el = document.createElement('div');
|
const el = document.createElement('div');
|
||||||
|
const colormap = interpolate(['blue', 'green', 'yellow', 'red']);
|
||||||
|
const colorIndex = Math.min(data.length / 22, 22);
|
||||||
el.className = 'terminal';
|
el.className = 'terminal';
|
||||||
el.innerHTML = `
|
el.innerHTML = `
|
||||||
<div class="deco"><span class="prompt">user@c-beam></span> #who</div>
|
<div class="deco"><span class="prompt">user@c-beam></span> #who</div>
|
||||||
<div><span class="output">${data.join(', ')}</span></div>
|
<div><span class="output" style="color: ${colormap(colorIndex)}">${data.join(', ')}</span></div>
|
||||||
<div>total: <span class="output">${data.length}</span></div>
|
<div>total: <span class="output" style="color: ${colormap(colorIndex)}">${data.length}</span></div>
|
||||||
<div class="deco"><span class="prompt">user@c-beam></span> <blink>_</blink></div>
|
<div class="deco"><span class="prompt">user@c-beam></span> <blink>_</blink></div>
|
||||||
`;
|
`;
|
||||||
if (data.join(', ').length > 100) {
|
if (data.join(', ').length > 100) {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@webcomponents/webcomponentsjs": "^1.0.19",
|
"@webcomponents/webcomponentsjs": "^1.0.19",
|
||||||
|
"color-interpolate": "^1.0.2",
|
||||||
"d3": "^4.12.0",
|
"d3": "^4.12.0",
|
||||||
"dateformat": "^3.0.2",
|
"dateformat": "^3.0.2",
|
||||||
"msgflo-browser": "^0.2.0",
|
"msgflo-browser": "^0.2.0",
|
||||||
|
|
Loading…
Reference in a new issue