Changeset View
Changeset View
Standalone View
Standalone View
web/sidebar/community-drawer-utils.react.js
// @flow | // @flow | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import type { ThreadInfo } from 'lib/types/thread-types'; | import type { ThreadInfo } from 'lib/types/thread-types'; | ||||
import type { CommunityDrawerItemData } from 'lib/utils/drawer-utils.react'; | import type { CommunityDrawerItemData } from 'lib/utils/drawer-utils.react'; | ||||
import type { HandlerProps } from './community-drawer-item-handlers.react'; | |||||
import css from './community-drawer-item.css'; | import css from './community-drawer-item.css'; | ||||
import CommunityDrawerItemChat from './community-drawer-item.react.js'; | import CommunityDrawerItemChat from './community-drawer-item.react.js'; | ||||
import { ExpandButton } from './expand-buttons.react.js'; | import { ExpandButton } from './expand-buttons.react.js'; | ||||
import SubchannelsButton from './subchannels-button.react.js'; | import SubchannelsButton from './subchannels-button.react.js'; | ||||
import type { NavigationTab } from '../types/nav-types.js'; | |||||
const indentation = 14; | const indentation = 14; | ||||
const subchannelsButtonIndentation = 24; | const subchannelsButtonIndentation = 24; | ||||
function getChildren({ | function getChildren({ | ||||
expanded, | expanded, | ||||
hasSubchannelsButton, | hasSubchannelsButton, | ||||
itemChildren, | itemChildren, | ||||
paddingLeft, | paddingLeft, | ||||
threadInfo, | threadInfo, | ||||
expandable, | expandable, | ||||
handler, | handlerType, | ||||
}: { | }: { | ||||
expanded: boolean, | expanded: boolean, | ||||
hasSubchannelsButton: boolean, | hasSubchannelsButton: boolean, | ||||
itemChildren: $ReadOnlyArray<CommunityDrawerItemData<string>>, | itemChildren: $ReadOnlyArray<CommunityDrawerItemData<string>>, | ||||
paddingLeft: number, | paddingLeft: number, | ||||
threadInfo: ThreadInfo, | threadInfo: ThreadInfo, | ||||
expandable: boolean, | expandable: boolean, | ||||
handler: React.ComponentType<HandlerProps>, | handlerType: NavigationTab, | ||||
}): React.Node { | }): React.Node { | ||||
if (!expanded) { | if (!expanded) { | ||||
return null; | return null; | ||||
} | } | ||||
if (hasSubchannelsButton) { | if (hasSubchannelsButton) { | ||||
const buttonPaddingLeft = paddingLeft + subchannelsButtonIndentation; | const buttonPaddingLeft = paddingLeft + subchannelsButtonIndentation; | ||||
return ( | return ( | ||||
<div | <div | ||||
className={css.subchannelsButton} | className={css.subchannelsButton} | ||||
style={{ paddingLeft: buttonPaddingLeft }} | style={{ paddingLeft: buttonPaddingLeft }} | ||||
> | > | ||||
<SubchannelsButton threadInfo={threadInfo} /> | <SubchannelsButton threadInfo={threadInfo} /> | ||||
</div> | </div> | ||||
); | ); | ||||
} | } | ||||
return itemChildren.map(item => ( | return itemChildren.map(item => ( | ||||
<CommunityDrawerItemChat | <CommunityDrawerItemChat | ||||
itemData={item} | itemData={item} | ||||
key={item.threadInfo.id} | key={item.threadInfo.id} | ||||
paddingLeft={paddingLeft + indentation} | paddingLeft={paddingLeft + indentation} | ||||
expandable={expandable} | expandable={expandable} | ||||
handler={handler} | handlerType={handlerType} | ||||
/> | /> | ||||
)); | )); | ||||
} | } | ||||
function getExpandButton({ | function getExpandButton({ | ||||
expandable, | expandable, | ||||
childrenLength, | childrenLength, | ||||
hasSubchannelsButton, | hasSubchannelsButton, | ||||
Show All 27 Lines |