Show your avatar and balance in mobile bottom bar instead of 'More'
This commit is contained in:
parent
8ccf834724
commit
f577437a8b
|
@ -8,8 +8,10 @@ export function Avatar(props: {
|
||||||
noLink?: boolean
|
noLink?: boolean
|
||||||
size?: number | 'xs' | 'sm'
|
size?: number | 'xs' | 'sm'
|
||||||
className?: string
|
className?: string
|
||||||
|
containerClassName?: string
|
||||||
}) {
|
}) {
|
||||||
const { username, avatarUrl, noLink, size, className } = props
|
const { username, avatarUrl, noLink, size, className, containerClassName } =
|
||||||
|
props
|
||||||
const s = size == 'xs' ? 6 : size === 'sm' ? 8 : size || 10
|
const s = size == 'xs' ? 6 : size === 'sm' ? 8 : size || 10
|
||||||
|
|
||||||
const onClick =
|
const onClick =
|
||||||
|
@ -20,7 +22,12 @@ export function Avatar(props: {
|
||||||
Router.push(`/${username}`)
|
Router.push(`/${username}`)
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className={`flex-shrink-0 rounded-full bg-white w-${s} h-${s}`}>
|
<div
|
||||||
|
className={clsx(
|
||||||
|
`flex-shrink-0 rounded-full bg-white w-${s} h-${s}`,
|
||||||
|
containerClassName
|
||||||
|
)}
|
||||||
|
>
|
||||||
{avatarUrl ? (
|
{avatarUrl ? (
|
||||||
<img
|
<img
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
|
|
@ -10,10 +10,16 @@ import {
|
||||||
import { Transition, Dialog } from '@headlessui/react'
|
import { Transition, Dialog } from '@headlessui/react'
|
||||||
import { useState, Fragment } from 'react'
|
import { useState, Fragment } from 'react'
|
||||||
import Sidebar from './sidebar'
|
import Sidebar from './sidebar'
|
||||||
|
import { useUser } from '../../hooks/use-user'
|
||||||
|
import { formatMoney } from '../../../common/util/format'
|
||||||
|
import { Avatar } from '../avatar'
|
||||||
|
|
||||||
// From https://codepen.io/chris__sev/pen/QWGvYbL
|
// From https://codepen.io/chris__sev/pen/QWGvYbL
|
||||||
export function BottomNavBar() {
|
export function BottomNavBar() {
|
||||||
const [sidebarOpen, setSidebarOpen] = useState(false)
|
const [sidebarOpen, setSidebarOpen] = useState(false)
|
||||||
|
|
||||||
|
const user = useUser()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="fixed inset-x-0 bottom-0 z-20 flex justify-between border-t-2 bg-white text-xs text-gray-700 lg:hidden">
|
<nav className="fixed inset-x-0 bottom-0 z-20 flex justify-between border-t-2 bg-white text-xs text-gray-700 lg:hidden">
|
||||||
<Link href="/home">
|
<Link href="/home">
|
||||||
|
@ -37,13 +43,30 @@ export function BottomNavBar() {
|
||||||
</a>
|
</a>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<span
|
<div
|
||||||
className="block w-full py-1 px-3 text-center hover:cursor-pointer hover:bg-indigo-200 hover:text-indigo-700"
|
className="w-full py-1 px-3 text-center hover:cursor-pointer hover:bg-indigo-200 hover:text-indigo-700"
|
||||||
onClick={() => setSidebarOpen(true)}
|
onClick={() => setSidebarOpen(true)}
|
||||||
>
|
>
|
||||||
<MenuAlt3Icon className="my-1 mx-auto h-6 w-6" aria-hidden="true" />
|
{user === null ? (
|
||||||
More
|
<>
|
||||||
</span>
|
<MenuAlt3Icon className="my-1 mx-auto h-6 w-6" aria-hidden="true" />
|
||||||
|
More
|
||||||
|
</>
|
||||||
|
) : user ? (
|
||||||
|
<>
|
||||||
|
<Avatar
|
||||||
|
containerClassName="mx-auto my-1"
|
||||||
|
size="xs"
|
||||||
|
username={user.username}
|
||||||
|
avatarUrl={user.avatarUrl}
|
||||||
|
noLink
|
||||||
|
/>
|
||||||
|
{formatMoney(user.balance)}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
<MobileSidebar
|
<MobileSidebar
|
||||||
sidebarOpen={sidebarOpen}
|
sidebarOpen={sidebarOpen}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user