Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(dashboard): sync banner layout to global
  • Loading branch information
mydearxym committed Jul 4, 2022
commit 76ae8541a7d76b195b53a4fe186efa07d5a7a77f
12 changes: 3 additions & 9 deletions src/containers/digest/CommunityDigest/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { FC, Fragment } from 'react'

import type { TMetric } from '@/spec'
import { METRIC, C11N } from '@/constant'
import { METRIC, BANNER_LAYOUT } from '@/constant'
import { buildLog } from '@/utils/logger'
import { bond } from '@/utils/mobx'

Expand All @@ -30,17 +30,11 @@ const CommunityDigestContainer: FC<TProps> = ({
}) => {
useInit(store)

const {
accountInfo: {
customization: { bannerLayout },
},
curThread,
curCommunity,
} = store
const { curThread, curCommunity, globalLayout } = store

return (
<Fragment>
{bannerLayout === C11N.CLASSIC ? (
{globalLayout.banner === BANNER_LAYOUT.TABBER ? (
<ClassicLayout
metric={metric}
community={curCommunity}
Expand Down
10 changes: 5 additions & 5 deletions src/containers/digest/CommunityDigest/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import type {
TViewing,
TRoute,
TCommunity,
TAccount,
TThread,
TGlobalLayout,
} from '@/spec'
import { markStates, toJS } from '@/utils/mobx'

Expand All @@ -37,10 +37,6 @@ const CommunityDigest = T.model('CommunityDigest', {
const root = getParent(self) as TRootStore
return root.footer.realtimeVisitors
},
get accountInfo(): TAccount {
const root = getParent(self) as TRootStore
return root.accountInfo
},
get curThread(): TThread {
const root = getParent(self) as TRootStore
return root.viewing.activeThread
Expand All @@ -50,6 +46,10 @@ const CommunityDigest = T.model('CommunityDigest', {

return toJS(root.viewing.community)
},
get globalLayout(): TGlobalLayout {
const root = getParent(self) as TRootStore
return root.dashboardThread.globalLayout
},
}))
.actions((self) => ({
authWarning(options): void {
Expand Down
9 changes: 4 additions & 5 deletions src/containers/layout/GlobalLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import { SIZE, BODY_SCROLLER } from '@/constant'
import { bond } from '@/utils/mobx'

import ThemePalette from '@/containers/layout/ThemePalette'
import Header from '@/widgets/Header'
// import Header from '@/widgets/Header'

// import Header from '@/containers/unit/Header'
// import Footer from '@/containers/unit/Footer'
// import ModeLine from '@/containers/unit/ModeLine'

Expand Down Expand Up @@ -62,7 +61,7 @@ const GlobalLayoutContainer: FC<TProps> = ({
// load debug graph
useInit(store, { isMobile })

const { accountInfo, sidebarPin, curCommunity, wallpaper, wallpapers } = store
const { sidebarPin, wallpaper, wallpapers } = store

return (
<ThemePalette>
Expand All @@ -87,11 +86,11 @@ const GlobalLayoutContainer: FC<TProps> = ({
<ContentWrapper offsetLeft={sidebarPin}>
{/* @ts-ignore */}

<Header
{/* <Header
metric={metric}
accountInfo={accountInfo}
community={curCommunity}
/>
/> */}
<BodyWrapper isMobile={isMobile}>
{childrenWithProps(children, { metric })}
</BodyWrapper>
Expand Down
24 changes: 13 additions & 11 deletions src/widgets/Switcher/Tabs/DesktopView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { FC, useEffect, useRef, useState, useCallback, memo } from 'react'
import { isEmpty, findIndex } from 'ramda'
import { isEmpty, findIndex, pluck, includes } from 'ramda'
import { isMobile } from 'react-device-detect'

import type { TSizeSM, TTabItem, TC11NLayout } from '@/spec'
Expand Down Expand Up @@ -70,6 +70,8 @@ const Tabs: FC<TProps> = ({
bottomSpace = 0,
}) => {
const defaultActiveTabIndex = getDefaultActiveTabIndex(items, activeKey)
// @ts-ignore
const hasActiveItem: boolean = includes(activeKey, pluck('raw', items))

const [active, setActive] = useState(defaultActiveTabIndex)
const [slipWidth, setSlipWidth] = useState(0)
Expand All @@ -87,7 +89,7 @@ const Tabs: FC<TProps> = ({
setSlipWidth(activeSlipWidth)
}
setActive(defaultActiveTabIndex)
}, [defaultActiveTabIndex])
}, [defaultActiveTabIndex, hasActiveItem])

// set slipbar with for current nav item
// 为下面的滑动条设置当前 TabItem 的宽度
Expand Down Expand Up @@ -133,15 +135,15 @@ const Tabs: FC<TProps> = ({
/>
))}

<SlipBar
translateX={translateX}
width={`${tabWidthList[active]}px`}
slipHeight={slipHeight}
>
<RealBar
width={`${size === SIZE.MEDIUM ? slipWidth : slipWidth - 6}px`}
/>
</SlipBar>
{hasActiveItem && (
<SlipBar
translateX={translateX}
width={`${tabWidthList[active]}px`}
slipHeight={slipHeight}
>
<RealBar width={`${slipWidth}px`} />
</SlipBar>
)}
</Nav>
</Wrapper>
)
Expand Down