godash/components/user.templ

40 lines
959 B
Text

package components
import (
"github.com/logto-io/go/core"
)
templ User(user *core.UserInfoResponse) {
<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">
<img src={ user.Picture }/>
</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.Name }</li>
<li>
<a href="/sign-out"><span class="icon-[bi--box-arrow-left]"></span> Logout</a>
</li>
</ul>
</div>
}