Skip to content

Commit

Permalink
[form-builder] Declare list/item component pairs in outer scope
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge committed Jan 20, 2021
1 parent fb63395 commit cb01608
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@ import {
List as SortableList,
Item as SortableListItem,
} from 'part:@sanity/components/lists/sortable'

import {List as GridList, Item as GridListItem} from 'part:@sanity/components/lists/grid'

import {
List as SortableGridList,
Item as SortableGridListItem,
} from 'part:@sanity/components/lists/sortable-grid'

const SORTABLE_GRID = {List: SortableGridList, Item: SortableGridListItem}
const SORTABLE_LIST = {List: SortableList, Item: SortableListItem}
const NON_SORTABLE_GRID = {List: GridList, Item: GridListItem}
const NON_SORTABLE_LIST = {List: DefaultList, Item: DefaultListItem}

export default function resolveListComponents(isSortable: boolean, isGrid: boolean) {
if (isSortable) {
return isGrid
? {List: SortableGridList, Item: SortableGridListItem}
: {List: SortableList, Item: SortableListItem}
return isGrid ? SORTABLE_GRID : SORTABLE_LIST
}
return isGrid ? {List: GridList, Item: GridListItem} : {List: DefaultList, Item: DefaultListItem}
return isGrid ? NON_SORTABLE_GRID : NON_SORTABLE_LIST
}

0 comments on commit cb01608

Please sign in to comment.