瀏覽代碼

Dynamicaly change avatar and header bg from account setting (#4289)

master
Yamagishi Kazutoshi 6 年之前
committed by Eugen Rochko
父節點
當前提交
f2390e2803
共有 2 個文件被更改,包括 18 次插入0 次删除
  1. +14
    -0
      app/javascript/packs/public.js
  2. +4
    -0
      app/javascript/styles/accounts.scss

+ 14
- 0
app/javascript/packs/public.js 查看文件

@@ -88,6 +88,20 @@ function main() {
noteCounter.textContent = 160 - length(target.value);
}
});

delegate(document, '#account_avatar', 'change', ({ target }) => {
const avatar = document.querySelector('.card.compact .avatar img');
const [file] = target.files || [];
const url = URL.createObjectURL(file);
avatar.src = url;
});

delegate(document, '#account_header', 'change', ({ target }) => {
const header = document.querySelector('.card.compact');
const [file] = target.files || [];
const url = URL.createObjectURL(file);
header.style.backgroundImage = `url(${url})`;
});
}

loadPolyfills().then(main).catch(error => {


+ 4
- 0
app/javascript/styles/accounts.scss 查看文件

@@ -32,6 +32,10 @@

.avatar {
margin-bottom: 0;

img {
object-fit: cover;
}
}
}



Loading…
取消
儲存