Skip to content

Commit

Permalink
Making use of UI.authn.findProfileImage
Browse files Browse the repository at this point in the history
Do not merge this until https://github.com/solid/solid-ui/pull/119 is merged and pushed in a new release.

This adds solid-ui as a dependency for mashlib.

Partial fix for SolidOS/solid-panes#169
  • Loading branch information
megoth committed Sep 16, 2019
1 parent 0cd95f2 commit dd85431
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"normalize.css": "^8.0.1",
"rdflib": "^1.0.4",
"solid-namespace": "^0.2.0",
"solid-panes": "^2.0.0"
"solid-panes": "^2.0.0",
"solid-ui": "^1.1.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
Expand Down
7 changes: 4 additions & 3 deletions src/global/header.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import $rdf, { IndexedFormula, NamedNode, sym } from "rdflib"
import namespace from "solid-namespace"
import panes from "solid-panes"
import solidUI from "solid-ui"
import { icon } from "./icon"
import { SolidSession } from "../../typings/solid-auth-client"
import { emptyProfile } from "./empty-profile"
Expand Down Expand Up @@ -137,13 +138,13 @@ async function getMenuItems (outliner: any): Promise<Array<{
}

function getProfileImg (store: IndexedFormula, user: NamedNode): string | HTMLElement {
const hasPhoto = (store.anyValue as any)(user, ns.vcard("hasPhoto"), null, user.doc())
if (!hasPhoto) {
const profileUrl = solidUI.authn.findProfileImage(user)
if (!profileUrl) {
return emptyProfile
}
const profileImage = document.createElement("div")
profileImage.classList.add("header-user-menu__photo")
profileImage.style.backgroundImage = `url("${hasPhoto}")`
profileImage.style.backgroundImage = `url("${profileUrl}")`
return profileImage
}

Expand Down
4 changes: 4 additions & 0 deletions typings/solid-ui.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module 'solid-ui' {
const solidUI: any
export default solidUI
}

0 comments on commit dd85431

Please sign in to comment.