Skip to content

Commit f84f0bf

Browse files
committedJul 12, 2021
refactor(field): migrate array of options diff to @sanity/ui
1 parent e89cd7d commit f84f0bf

File tree

2 files changed

+12
-37
lines changed

2 files changed

+12
-37
lines changed
 

‎packages/@sanity/field/src/types/array/diff/ArrayOfOptionsFieldDiff.css

-27
This file was deleted.

‎packages/@sanity/field/src/types/array/diff/ArrayOfOptionsFieldDiff.tsx

+12-10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Preview from 'part:@sanity/base/preview'
22
import {useUserColorManager} from '@sanity/base/user-color'
33
import {isKeyedObject, TypedObject} from '@sanity/types'
44
import React from 'react'
5+
import {Box, Flex} from '@sanity/ui'
56
import {
67
Annotation,
78
ArrayDiff,
@@ -16,7 +17,6 @@ import {
1617
} from '../../../diff'
1718
import {Checkbox} from '../../boolean/preview'
1819
import {isEqual} from '../util/arrayUtils'
19-
import styles from './ArrayOfOptionsFieldDiff.css'
2020

2121
interface NamedListOption {
2222
title?: string
@@ -51,18 +51,20 @@ export const ArrayOfOptionsFieldDiff: DiffComponent<ArrayDiff> = ({diff, schemaT
5151
const color = getAnnotationColor(colorManager, annotation)
5252
const action = isPresent ? 'Added' : 'Removed'
5353
return (
54-
<div className={styles.item} key={getItemKey(diff, index)}>
54+
<Flex align="center" key={getItemKey(diff, index)}>
5555
<DiffTooltip annotations={annotation ? [annotation] : []} description={action}>
56-
<div className={styles.checkboxes}>
56+
<Flex align="center">
5757
<Checkbox checked={!isPresent} color={color} />
58-
<FromToArrow />
58+
<Box margin={2}>
59+
<FromToArrow />
60+
</Box>
5961
<Checkbox checked={isPresent} color={color} />
60-
</div>
62+
</Flex>
6163
</DiffTooltip>
62-
<div className={styles.label}>
64+
<Flex align="center">
6365
<ItemPreview value={title || value} memberType={memberType} />
64-
</div>
65-
</div>
66+
</Flex>
67+
</Flex>
6668
)
6769
})}
6870
</div>
@@ -102,13 +104,13 @@ function sortItems(itemA: NormalizedListOption, itemB: NormalizedListOption): nu
102104

103105
function ItemPreview({value, memberType}: {memberType?: SchemaType; value: unknown}) {
104106
return (
105-
<div className={styles.itemPreview}>
107+
<Box marginX={2} marginY={1}>
106108
{typeof value === 'string' || typeof value === 'number' ? (
107109
value
108110
) : (
109111
<Preview type={memberType} value={value} layout="default" />
110112
)}
111-
</div>
113+
</Box>
112114
)
113115
}
114116

0 commit comments

Comments
 (0)
Please sign in to comment.