mirror of
https://github.com/fergalmoran/turnstone.git
synced 2026-01-08 03:59:49 +00:00
Fix css issue in matchingText component
This commit is contained in:
@@ -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": [
|
||||
|
||||
@@ -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>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user