Skip to content

Commit 355d3a4

Browse files
Merge pull request #348 from lara-learning/fix/format
fix: format
2 parents de95938 + 6ca973f commit 355d3a4

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

packages/components/src/entry-input-layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ const ValueBase = styled.div`
111111
font-size: ${FontSizes.copy};
112112
padding: ${Spacings.m} ${Spacings.l};
113113
`
114+
114115
const TextWrapper = styled(ValueBase)`
115116
position: relative;
116117
flex: 1;

packages/components/src/highlighter.tsx

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,45 @@
1+
import { styled } from 'styled-components'
2+
13
interface highlighterProps {
24
term: string
35
children: string
46
}
57

8+
const Text = styled.p`
9+
margin: 0;
10+
padding: 0;
11+
white-space: pre-wrap;
12+
word-break: break-word;
13+
`
14+
615
const Highlighter: React.FC<highlighterProps> = ({ term, children }) => {
716
if (!term) {
8-
return <>{children}</>
17+
return <Text>{children}</Text>
918
}
1019
const regex = new RegExp(`(${term})`, 'gi')
1120
const parts = children.split(regex)
1221

1322
return (
1423
<>
15-
<div>test</div>
16-
{parts.map((part: string, index: number) =>
17-
regex.test(part) ? (
18-
<span
19-
key={index}
20-
style={{
21-
margin: 0,
22-
backgroundColor: 'rgb(84 198 247)',
23-
padding: 0,
24-
whiteSpace: 'pre-wrap',
25-
wordBreak: 'break-word',
26-
fontWeight: 'bold',
27-
}}
28-
>
29-
{part}
30-
</span>
31-
) : (
32-
part
33-
)
34-
)}
24+
<Text>
25+
<>
26+
{parts.map((part: string, index: number) =>
27+
regex.test(part) ? (
28+
<span
29+
key={index}
30+
style={{
31+
backgroundColor: 'rgb(84 198 247)',
32+
fontWeight: 'bold',
33+
}}
34+
>
35+
{part}
36+
</span>
37+
) : (
38+
part
39+
)
40+
)}
41+
</>
42+
</Text>
3543
</>
3644
)
3745
}

0 commit comments

Comments
 (0)