Files: f282bf4a9ac0e60ba0de219dad5704df86000ec5 / about / html / avatar.js
648 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, computed } = require('mutant') |
3 | |
4 | exports.gives = nest('about.html.avatar') |
5 | |
6 | exports.needs = nest({ |
7 | 'about.obs': { |
8 | color: 'first', |
9 | imageUrl: 'first' |
10 | }, |
11 | 'about.html.link': 'first' |
12 | }) |
13 | |
14 | exports.create = function (api) { |
15 | return nest('about.html.avatar', avatar) |
16 | |
17 | function avatar (id) { |
18 | const src = api.about.obs.imageUrl(id) |
19 | const color = computed(src, src => src.match(/^http/) ? 'rgba(0,0,0,0)' : api.about.obs.color(id)) |
20 | |
21 | return api.about.html.link(id, |
22 | h('img', { |
23 | className: 'Avatar', |
24 | style: { 'background-color': color }, |
25 | src |
26 | }) |
27 | ) |
28 | } |
29 | } |
30 |
Built with git-ssb-web