Skip to content

Commit 9046dfd

Browse files
committed
css improvement of loggedin header button
1 parent 9699fae commit 9046dfd

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/v2/components/header/Header.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ifDefined } from 'lit/directives/if-defined.js'
88
const DEFAULT_HELP_MENU_ICON = icons.iconBase + 'noun_help.svg'
99
const DEFAULT_SOLID_ICON_URL = 'https://solidproject.org/assets/img/solid-emblem.svg'
1010
const DEFAULT_SIGNUP_URL = 'https://solidproject.org/get_a_pod'
11-
const DEFAULT_LOGGEDIN_MENU_BUTTON_AVATAR_LABEL = 'Accounts'
11+
const DEFAULT_LOGGEDIN_MENU_BUTTON_AVATAR_LABEL = 'Accounts' // empty space to preserve button size when no avatar is provided
1212

1313
export type HeaderAuthState = 'logged-out' | 'logged-in'
1414

@@ -601,15 +601,20 @@ export class Header extends LitElement {
601601
}
602602

603603
private renderLoggedInAvatar (avatar?: string) {
604+
const hasAvatar = Boolean(avatar)
605+
const avatarContent = hasAvatar
606+
? html`<img src="${avatar}" alt="" />`
607+
: DEFAULT_LOGGEDIN_MENU_BUTTON_AVATAR_LABEL
608+
604609
if (this.layout === 'mobile') {
605-
return avatar ? html`<img class="account-avatar-img" src="${avatar}" alt="" />` : html``
610+
return hasAvatar
611+
? html`<img class="account-avatar-img" src="${avatar}" alt="" />`
612+
: html`<span class="account-avatar account-avatar-text">${DEFAULT_LOGGEDIN_MENU_BUTTON_AVATAR_LABEL}</span>`
606613
}
607614

608615
return html`
609-
<span class="account-avatar ${avatar ? '' : 'account-avatar-text'}" aria-hidden="true">
610-
${avatar
611-
? html`<img src="${avatar}" alt="" />`
612-
: DEFAULT_LOGGEDIN_MENU_BUTTON_AVATAR_LABEL}
616+
<span class="account-avatar ${hasAvatar ? '' : 'account-avatar-text'}" aria-hidden="true">
617+
${avatarContent}
613618
</span>
614619
`
615620
}
@@ -619,7 +624,7 @@ export class Header extends LitElement {
619624
<span class="account-menu-avatar ${avatar ? '' : 'account-avatar-text'}" aria-hidden="true">
620625
${avatar
621626
? html`<img src="${avatar}" alt="" />`
622-
: DEFAULT_LOGGEDIN_MENU_BUTTON_AVATAR_LABEL}
627+
: '?'}
623628
</span>
624629
`
625630
}

0 commit comments

Comments
 (0)