Skip to content

Commit 697e36f

Browse files
committedJul 12, 2021
refactor(field): migrate ptdiff text to @sanity/io
1 parent c414b18 commit 697e36f

File tree

2 files changed

+6
-34
lines changed

2 files changed

+6
-34
lines changed
 

‎packages/@sanity/field/src/types/portableText/diff/components/Text.css

-19
This file was deleted.

‎packages/@sanity/field/src/types/portableText/diff/components/Text.tsx

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import classNames from 'classnames'
21
import {isKeySegment, Path} from '@sanity/types'
32
import React, {SyntheticEvent, useCallback} from 'react'
43
import {ConnectorContext} from '@sanity/base/lib/change-indicators'
54
import {startCase} from 'lodash'
65
import {DiffCard, DiffContext, ObjectDiff, StringDiff, StringDiffSegment} from '../../../../diff'
7-
import styles from './Text.css'
6+
import {InlineBox} from './styledComponents'
87

98
interface TextProps {
109
diff?: StringDiff
@@ -32,21 +31,13 @@ export function Text({
3231
</TextWithDiff>
3332
)
3433
}
35-
return <span className={styles.root}>{children}</span>
34+
return <InlineBox>{children}</InlineBox>
3635
}
3736

38-
export function TextWithDiff({
39-
diff,
40-
childDiff,
41-
children,
42-
path,
43-
segment,
44-
...restProps
45-
}: TextProps & Omit<React.HTMLProps<HTMLSpanElement>, 'onClick'>) {
37+
export function TextWithDiff({diff, childDiff, children, path, segment, ...restProps}: TextProps) {
4638
const {onSetFocus} = React.useContext(ConnectorContext)
4739
const {path: fullPath} = React.useContext(DiffContext)
4840
const spanSegment = path.slice(-2, 1)[0]
49-
const className = classNames(styles.root, styles.changed)
5041
const isRemoved = diff && diff.action === 'removed'
5142
const prefix = fullPath.slice(
5243
0,
@@ -83,10 +74,10 @@ export function TextWithDiff({
8374
</DiffCard>
8475
) : null
8576
return (
86-
<span {...restProps} className={className} onClick={handleClick}>
87-
<span className={styles.previewContainer}>
77+
<InlineBox {...restProps} onClick={handleClick} data-changed="">
78+
<span>
8879
<>{diffCard || children}</>
8980
</span>
90-
</span>
81+
</InlineBox>
9182
)
9283
}

0 commit comments

Comments
 (0)
Please sign in to comment.