MCPcopy Create free account
hub / github.com/pacexy/flow / SplitView

Function SplitView

apps/reader/src/components/base/SplitView.tsx:90–128  ·  view source on GitHub ↗
({
  children,
  className,
  vertical = false,
}: SplitViewProps)

Source from the content-addressed store, hash-verified

88}
89
90export const SplitView = ({
91 children,
92 className,
93 vertical = false,
94}: SplitViewProps) => {
95 const [viewMap, setViewMap] = useState(new Map<string, ISplitViewItem>())
96 const views = [...viewMap.values()]
97
98 const registerView = useCallback((key: string, view: ISplitViewItem) => {
99 setViewMap((map) => {
100 map.set(key, view)
101 return new Map(map)
102 })
103 }, [])
104
105 const childList = Children.toArray(children)
106 if (!childList.length) return null
107
108 return (
109 <div className={clsx('SplitView relative h-full', className)}>
110 <SplitViewContext.Provider value={{ registerView }}>
111 <div
112 className={clsx(
113 'SplitViewContainer flex h-full',
114 vertical && 'flex-col',
115 )}
116 >
117 {childList.reduce((a, c, i) => (
118 <>
119 {a}
120 <Sash vertical={vertical} views={[views[i - 1], views[i]]} />
121 {c}
122 </>
123 ))}
124 </div>
125 </SplitViewContext.Provider>
126 </div>
127 )
128}
129
130const SASH_SIZE = 4
131interface SashProps {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected