Fix css issue in matchingText component

This commit is contained in:
Tom Southall
2022-02-11 23:15:39 +00:00
parent fb824b3060
commit 49d3beffbd
2 changed files with 2 additions and 4 deletions

View File

@@ -4,7 +4,7 @@
"author": "Tom Southall",
"keywords": [],
"version": "0.2.0",
"private": true,
"private": false,
"main": "dist/index.js",
"module": "dist/index.js",
"files": [

View File

@@ -1,12 +1,10 @@
import React, { useContext } from 'react'
import { TurnstoneContext } from '../context/turnstone'
import classNameHelper from '../utils/classNameHelper'
import escapeStringRegExp from 'escape-string-regexp'
export default function ResultMatch(props) {
const { text } = props
const { customStyles, queryState } = useContext(TurnstoneContext)
const className = classNameHelper({}, customStyles)
const regex = new RegExp('(' + escapeStringRegExp(queryState) + ')', 'i')
const parts = text.split(regex)
const index = parts.findIndex(
@@ -14,7 +12,7 @@ export default function ResultMatch(props) {
)
parts[index] = (
<span className={className('match')} key={index}>
<span className={customStyles.match} key={index}>
{parts[index]}
</span>
)