1
1
import React , { useCallback } from 'react'
2
2
import { ConnectorContext } from '@sanity/base/lib/change-indicators'
3
+ import { Box , Card , Stack , Text } from '@sanity/ui'
3
4
import { DiffContext , DiffTooltip , useDiffAnnotationColor } from '../../../../diff'
4
5
import { isHeader } from '../helpers'
5
6
import { PortableTextBlock , PortableTextDiff } from '../types'
6
- import styles from './Block.css'
7
7
import Blockquote from './Blockquote'
8
8
import Header from './Header'
9
9
import Paragraph from './Paragraph'
@@ -18,11 +18,6 @@ export default function Block({
18
18
children : JSX . Element
19
19
} ) : JSX . Element {
20
20
const color = useDiffAnnotationColor ( diff , [ ] )
21
- const classNames = [
22
- styles . root ,
23
- styles [ diff . action ] ,
24
- `style_${ diff . displayValue . style || 'undefined' } ` ,
25
- ]
26
21
const { path : fullPath } = React . useContext ( DiffContext )
27
22
const { onSetFocus} = React . useContext ( ConnectorContext )
28
23
const isRemoved = diff . action === 'removed'
@@ -54,27 +49,37 @@ export default function Block({
54
49
diff . origin . fields . style . action === 'changed' &&
55
50
diff . origin . fields . style . annotation
56
51
) {
57
- fromStyle = diff . origin . fromValue . style
58
- classNames . push ( `changed_from_style_${ fromStyle || 'undefined' } ` )
52
+ fromStyle = diff ?. origin ?. fromValue ?. style
59
53
const style = color ? { background : color . background , color : color . text } : { }
60
54
61
55
returned = (
62
- < div className = { styles . styleIsChanged } >
63
- < div className = { styles . changedBlockStyleNotice } >
56
+ < Card
57
+ padding = { 3 }
58
+ border
59
+ radius = { 2 }
60
+ style = { { borderStyle : 'dotted' } }
61
+ diff-block-action = { diff . action }
62
+ data-block-note = { `changed_from_style_${ fromStyle || 'undefined' } ` }
63
+ >
64
+ < Stack space = { 2 } >
64
65
< DiffTooltip
65
- annotations = { [ diff . origin . fields . style . annotation ] }
66
+ annotations = { [ diff . origin . fields . style ? .annotation ] }
66
67
diff = { diff . origin . fields . style }
67
68
>
68
- < div > Changed block style from '{ fromStyle } '</ div >
69
+ < Text size = { 0 } > Changed block style from '{ fromStyle } '</ Text >
69
70
</ DiffTooltip >
70
- </ div >
71
- < div style = { style } > { returned } </ div >
72
- </ div >
71
+ < Box style = { style } > { returned } </ Box >
72
+ </ Stack >
73
+ </ Card >
73
74
)
74
75
}
75
76
76
77
return (
77
- < div onClick = { handleClick } className = { classNames . join ( ' ' ) } >
78
+ < div
79
+ onClick = { handleClick }
80
+ diff-block-action = { diff . action }
81
+ data-block-note = { `changed_from_style_${ fromStyle || 'undefined' } ` }
82
+ >
78
83
{ returned }
79
84
</ div >
80
85
)
0 commit comments