godash/components/user.templ
2024-03-27 22:43:36 +01:00

39 lines
1 KiB
Text

package components
import (
"github.com/zitadel/oidc/v3/pkg/oidc"
openid "github.com/zitadel/zitadel-go/v3/pkg/authentication/oidc"
)
templ User(user *openid.UserInfoContext[*oidc.IDTokenClaims, *oidc.UserInfo]) {
<div
x-data="{
open: false,
toggle() {
if (this.open) return this.close();
this.open = true;
},
close(focusAfter) {
if (! this.open) return;
this.open = false;
}
}"
class="relative"
>
<button x-on:click="toggle()" class="avatar" type="button">
<div class="w-10 h-10 rounded-xl bg-primary"></div>
</button>
<ul
x-show="open"
x-transition.origin.top.right
x-on:click.outside="close($refs.button)"
style="display: none;"
class="z-50 absolute right-0 mt-2 menu bg-base-200 rounded-box"
>
<li class="menu-title whitespace-nowrap">{ user.UserInfo.GivenName }</li>
<li>
<a href="/auth/logout"><span class="icon-[bi--box-arrow-left]"></span> Logout</a>
</li>
</ul>
</div>
}