Make clicking feed create focus input. Shrink create market button

This commit is contained in:
jahooma 2022-01-27 15:22:18 -06:00
parent 4ca1d33d65
commit 77eaf070e6
2 changed files with 31 additions and 13 deletions

View File

@ -43,10 +43,14 @@ import BetRow from './bet-row'
import clsx from 'clsx' import clsx from 'clsx'
import { parseTags } from '../../common/util/parse' import { parseTags } from '../../common/util/parse'
export function AvatarWithIcon(props: { username: string; avatarUrl: string }) { export function AvatarWithIcon(props: {
const { username, avatarUrl } = props username: string
return ( avatarUrl: string
<SiteLink className="relative" href={`/${username}`}> noLink?: boolean
}) {
const { username, avatarUrl, noLink } = props
const image = (
<img <img
className="rounded-full bg-gray-400 flex items-center justify-center" className="rounded-full bg-gray-400 flex items-center justify-center"
src={avatarUrl} src={avatarUrl}
@ -54,6 +58,13 @@ export function AvatarWithIcon(props: { username: string; avatarUrl: string }) {
height={40} height={40}
alt="" alt=""
/> />
)
if (noLink) return image
return (
<SiteLink className="relative" href={`/${username}`}>
{image}
</SiteLink> </SiteLink>
) )
} }

View File

@ -1,7 +1,6 @@
import { AvatarPlaceholder, AvatarWithIcon } from './contract-feed' import { AvatarPlaceholder, AvatarWithIcon } from './contract-feed'
import { Title } from './title'
import Textarea from 'react-expanding-textarea' import Textarea from 'react-expanding-textarea'
import { useState } from 'react' import { useRef, useState } from 'react'
import { Spacer } from './layout/spacer' import { Spacer } from './layout/spacer'
import { NewContract } from '../pages/create' import { NewContract } from '../pages/create'
import { firebaseLogin, User } from '../lib/firebase/users' import { firebaseLogin, User } from '../lib/firebase/users'
@ -79,13 +78,20 @@ export default function FeedCreate(props: {
) )
const placeholder = props.placeholder ?? `e.g. ${placeholders[randIndex]}` const placeholder = props.placeholder ?? `e.g. ${placeholders[randIndex]}`
const inputRef = useRef<HTMLInputElement | null>()
return ( return (
<div <div
className={clsx('w-full bg-white border-2 sm:rounded-md p-4', className)} className={clsx('w-full bg-white border-2 sm:rounded-md p-4', className)}
onClick={() => inputRef.current?.focus()}
> >
<div className="relative flex items-start space-x-3"> <div className="relative flex items-start space-x-3">
{user?.avatarUrl ? ( {user?.avatarUrl ? (
<AvatarWithIcon username={user.username} avatarUrl={user.avatarUrl} /> <AvatarWithIcon
username={user.username}
avatarUrl={user.avatarUrl}
noLink
/>
) : ( ) : (
<AvatarPlaceholder /> <AvatarPlaceholder />
)} )}
@ -101,6 +107,7 @@ export default function FeedCreate(props: {
value={question} value={question}
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}
onChange={(e) => setQuestion(e.target.value || '')} onChange={(e) => setQuestion(e.target.value || '')}
ref={inputRef}
/> />
<Spacer h={2} /> <Spacer h={2} />
</div> </div>
@ -114,7 +121,7 @@ export default function FeedCreate(props: {
{/* Show a fake "Create Market" button, which gets replaced with the NewContract one*/} {/* Show a fake "Create Market" button, which gets replaced with the NewContract one*/}
{!question && ( {!question && (
<div className="flex justify-end"> <div className="flex justify-end">
<button className="btn" disabled> <button className="btn btn-sm" disabled>
Create Market Create Market
</button> </button>
</div> </div>