Skip to content

Commit 53c1258

Browse files
committedJul 12, 2021
refactor(field): migrate ptdiff decorator to styled-components
1 parent 468117a commit 53c1258

File tree

2 files changed

+28
-32
lines changed

2 files changed

+28
-32
lines changed
 

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

-30
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
1+
import {Theme} from '@sanity/ui'
12
import React from 'react'
2-
import styles from './Decorator.css'
3+
import styled from 'styled-components'
4+
5+
const DecoratorWrapper = styled.span`
6+
display: inline;
7+
${({theme, decoration}: {theme: Theme; decoration: string}) => {
8+
switch (decoration) {
9+
case 'strong':
10+
return 'font-weight: bold;'
11+
case 'em':
12+
return 'font-style: italic;'
13+
case 'underline':
14+
return 'text-decoration: underline;'
15+
case 'overline':
16+
return 'text-decoration: overline;'
17+
case 'strike-through':
18+
return 'text-decoration: line-through;'
19+
case 'code':
20+
return `
21+
font-family: ${theme.sanity.fonts.code.family};
22+
background: ${theme.sanity.color.muted.default.enabled.bg};
23+
`
24+
default:
25+
return ''
26+
}
27+
}}
28+
`
329

430
export default function Decorator({mark, children}: {mark: string; children: JSX.Element}) {
5-
return <span className={`${styles[mark]}`}>{children}</span>
31+
return <DecoratorWrapper decoration={mark}>{children}</DecoratorWrapper>
632
}

0 commit comments

Comments
 (0)
Please sign in to comment.