Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 14 additions & 0 deletions packages/react-notion-x/src/third-party/collection-view.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'

import { useNotionContext } from '../context'
import { type CollectionViewProps } from '../types'
import { CollectionViewBoard } from './collection-view-board'
import { CollectionViewGallery } from './collection-view-gallery'
Expand All @@ -8,18 +9,31 @@ import { CollectionViewTable } from './collection-view-table'

export function CollectionViewImpl(props: CollectionViewProps) {
const { collectionView } = props
const { components } = useNotionContext()

switch (collectionView.type) {
case 'table':
if (components.CollectionViewTable) {
return <components.CollectionViewTable {...props} />
}
return <CollectionViewTable {...props} />

case 'gallery':
if (components.CollectionViewGallery) {
return <components.CollectionViewGallery {...props} />
}
return <CollectionViewGallery {...props} />

case 'list':
if (components.CollectionViewList) {
return <components.CollectionViewList {...props} />
}
return <CollectionViewList {...props} />

case 'board':
if (components.CollectionViewBoard) {
return <components.CollectionViewBoard {...props} />
}
return <CollectionViewBoard {...props} />

default:
Expand Down
6 changes: 6 additions & 0 deletions packages/react-notion-x/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export interface NotionComponents {
Collection: any
Property?: any

// collection view components
CollectionViewGallery?: any
CollectionViewTable?: any
CollectionViewList?: any
CollectionViewBoard?: any

propertyTextValue: ComponentOverrideFn
propertySelectValue: ComponentOverrideFn
propertyRelationValue: ComponentOverrideFn
Expand Down