Fix naming to be right (thanks James!)

This commit is contained in:
Marshall Polaris 2022-07-25 13:25:57 -07:00
parent 0fe1da150f
commit 93dcf3e944
2 changed files with 8 additions and 8 deletions

View File

@ -19,7 +19,7 @@ type TabProps = {
currentPageForAnalytics?: string currentPageForAnalytics?: string
} }
export function UncontrolledTabs(props: TabProps & { activeIndex: number }) { export function ControlledTabs(props: TabProps & { activeIndex: number }) {
const { const {
tabs, tabs,
activeIndex, activeIndex,
@ -69,11 +69,11 @@ export function UncontrolledTabs(props: TabProps & { activeIndex: number }) {
) )
} }
export function ControlledTabs(props: TabProps & { defaultIndex?: number }) { export function UncontrolledTabs(props: TabProps & { defaultIndex?: number }) {
const { defaultIndex, onClick, ...rest } = props const { defaultIndex, onClick, ...rest } = props
const [activeIndex, setActiveIndex] = useState(defaultIndex ?? 0) const [activeIndex, setActiveIndex] = useState(defaultIndex ?? 0)
return ( return (
<UncontrolledTabs <ControlledTabs
{...rest} {...rest}
activeIndex={activeIndex} activeIndex={activeIndex}
onClick={(title, i) => { onClick={(title, i) => {
@ -93,7 +93,7 @@ const isTabSelected = (router: NextRouter, queryParam: string, tab: Tab) => {
} }
} }
export function QueryControlledTabs( export function QueryUncontrolledTabs(
props: TabProps & { defaultIndex?: number } props: TabProps & { defaultIndex?: number }
) { ) {
const { tabs, defaultIndex, onClick, ...rest } = props const { tabs, defaultIndex, onClick, ...rest } = props
@ -101,7 +101,7 @@ export function QueryControlledTabs(
const selectedIdx = tabs.findIndex((t) => isTabSelected(router, 'tab', t)) const selectedIdx = tabs.findIndex((t) => isTabSelected(router, 'tab', t))
const activeIndex = selectedIdx !== -1 ? selectedIdx : defaultIndex ?? 0 const activeIndex = selectedIdx !== -1 ? selectedIdx : defaultIndex ?? 0
return ( return (
<UncontrolledTabs <ControlledTabs
{...rest} {...rest}
tabs={tabs} tabs={tabs}
activeIndex={activeIndex} activeIndex={activeIndex}
@ -118,4 +118,4 @@ export function QueryControlledTabs(
} }
// legacy code that didn't know about any other kind of tabs imports this // legacy code that didn't know about any other kind of tabs imports this
export const Tabs = ControlledTabs export const Tabs = UncontrolledTabs

View File

@ -22,7 +22,7 @@ import { Linkify } from './linkify'
import { Spacer } from './layout/spacer' import { Spacer } from './layout/spacer'
import { Row } from './layout/row' import { Row } from './layout/row'
import { genHash } from 'common/util/random' import { genHash } from 'common/util/random'
import { QueryControlledTabs } from './layout/tabs' import { QueryUncontrolledTabs } from './layout/tabs'
import { UserCommentsList } from './comments-list' import { UserCommentsList } from './comments-list'
import { useWindowSize } from 'web/hooks/use-window-size' import { useWindowSize } from 'web/hooks/use-window-size'
import { Comment, getUsersComments } from 'web/lib/firebase/comments' import { Comment, getUsersComments } from 'web/lib/firebase/comments'
@ -272,7 +272,7 @@ export function UserPage(props: { user: User; currentUser?: User }) {
<Spacer h={10} /> <Spacer h={10} />
{usersContracts !== 'loading' && contractsById && usersComments ? ( {usersContracts !== 'loading' && contractsById && usersComments ? (
<QueryControlledTabs <QueryUncontrolledTabs
currentPageForAnalytics={'profile'} currentPageForAnalytics={'profile'}
labelClassName={'pb-2 pt-1 '} labelClassName={'pb-2 pt-1 '}
tabs={[ tabs={[