Skip to content

Commit 6099f45

Browse files
committedJul 9, 2021
refactor(field): migrate string, url diff to @sanity/ui
1 parent 0ac2377 commit 6099f45

File tree

5 files changed

+22
-42
lines changed

5 files changed

+22
-42
lines changed
 

‎packages/@sanity/field/src/types/string/diff/StringFieldDiff.css

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
import React from 'react'
2+
import styled from 'styled-components'
23
import {DiffComponent, DiffFromTo, DiffString, StringDiff} from '../../../diff'
34
import {StringPreview} from '../preview/StringPreview'
45

5-
import styles from './StringFieldDiff.css'
6+
const StringWrapper = styled.div`
7+
white-space: pre-wrap;
8+
word-wrap: break-word;
9+
`
610

711
export const StringFieldDiff: DiffComponent<StringDiff> = ({diff, schemaType}) => {
812
const {options} = schemaType as any
913

1014
if (options?.list) {
1115
// When the string is considered to be an "enum", don't show individual
1216
// string segment changes, rather treat is as a "from -> to" diff
13-
return (
14-
<DiffFromTo
15-
cardClassName={styles.card}
16-
diff={diff}
17-
previewComponent={StringPreview}
18-
schemaType={schemaType}
19-
/>
20-
)
17+
return <DiffFromTo diff={diff} previewComponent={StringPreview} schemaType={schemaType} />
2118
}
2219

2320
return (
24-
<div className={styles.root}>
21+
<StringWrapper>
2522
<DiffString diff={diff} />
26-
</div>
23+
</StringWrapper>
2724
)
2825
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
import {Box} from '@sanity/ui'
12
import React from 'react'
3+
import styled from 'styled-components'
24
import {PreviewComponent} from '../../../preview/types'
35

6+
const StringWrapper = styled.div`
7+
display: inline-block;
8+
word-break: break-all;
9+
white-space: pre-wrap;
10+
`
11+
412
export const StringPreview: PreviewComponent<string> = (props) => {
513
const {value} = props
614

7-
return <>{value}</>
15+
return (
16+
<Box as={StringWrapper} paddingX={2} paddingY={1}>
17+
{value}
18+
</Box>
19+
)
820
}

‎packages/@sanity/field/src/types/url/diff/UrlFieldDiff.css

-7
This file was deleted.

‎packages/@sanity/field/src/types/url/diff/UrlFieldDiff.tsx

+1-10
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@ import React from 'react'
22
import {DiffComponent, DiffFromTo, StringDiff} from '../../../diff'
33
import {StringPreview} from '../../string/preview'
44

5-
import styles from './UrlFieldDiff.css'
6-
75
export const UrlFieldDiff: DiffComponent<StringDiff> = ({diff, schemaType}) => {
8-
return (
9-
<DiffFromTo
10-
cardClassName={styles.card}
11-
diff={diff}
12-
schemaType={schemaType}
13-
previewComponent={StringPreview}
14-
/>
15-
)
6+
return <DiffFromTo diff={diff} schemaType={schemaType} previewComponent={StringPreview} />
167
}

0 commit comments

Comments
 (0)
Please sign in to comment.