git ssb

16+

Dominic / patchbay



Commit 1638374a92e57fa5d3788ab84e8b19036bbc9044

teach about/html/avatar to be able to be able to make different sized avatars

mixmix committed on 9/26/2018, 10:27:07 PM
Parent: c4488f18986b2f896e7c2655b025def9a2f8c7a2

Files changed

about/html/avatar.jschanged
about/html/avatar.mcsschanged
about/html/avatar.jsView
@@ -13,17 +13,20 @@
1313
1414 exports.create = function (api) {
1515 return nest('about.html.avatar', avatar)
1616
17- function avatar (id) {
17 + function avatar (id, size = 4) {
1818 const src = api.about.obs.imageUrl(id)
1919 const color = computed(src, src => src.match(/^http/) ? 'rgba(0,0,0,0)' : api.about.obs.color(id))
2020
21- return api.about.html.link(id,
21 + const avatar = api.about.html.link(id,
2222 h('img', {
23- className: 'Avatar',
2423 style: { 'background-color': color },
2524 src
2625 })
2726 )
27 + avatar.classList.add('Avatar')
28 + avatar.style.setProperty('--avatar-size', Number.isNaN(size) ? size : `${size}rem`)
29 +
30 + return avatar
2831 }
2932 }
about/html/avatar.mcssView
@@ -1,6 +1,13 @@
11 Avatar {
2- width: 4rem
3- height: 4rem
2 + --avatar-size: 4rem
43
4 + width: var(--avatar-size)
5 + height: var(--avatar-size)
6 +
57 transition: background-color .15s ease-out
8 +
9 + img {
10 + width: var(--avatar-size)
11 + height: var(--avatar-size)
12 + }
613 }

Built with git-ssb-web