add custom tooltip to search

pull/3081/head
Joseph Izang 2 years ago
parent d619103ad0
commit 05c7ce8b40
  1. 103
      libs/remix-ui/search/src/lib/components/Find.tsx
  2. 31
      libs/remix-ui/search/src/lib/components/FindContainer.tsx
  3. 17
      libs/remix-ui/search/src/lib/components/results/ResultFileName.tsx
  4. 14
      libs/remix-ui/search/src/lib/components/results/ResultSummary.tsx

@ -1,3 +1,4 @@
import { CustomTooltip } from '@remix-ui/helper'
import React, { useContext, useEffect, useRef, useState } from 'react' import React, { useContext, useEffect, useRef, useState } from 'react'
import { SearchContext } from '../context/context' import { SearchContext } from '../context/context'
@ -42,48 +43,66 @@ export const Find = () => {
onKeyUp={handleKeypress} onKeyUp={handleKeypress}
></input> ></input>
<div className="search_plugin_controls"> <div className="search_plugin_controls">
<div <CustomTooltip
data-id="search_case_sensitive" tooltipText="Match Case"
title="Match Case" tooltipClasses="text-nowrap"
className={`monaco-custom-checkbox codicon codicon-case-sensitive ${ tooltipId="searchCaseSensitiveTooltip"
state.casesensitive ? 'checked' : '' placement="top-start"
}`} >
role="checkbox" <div
aria-checked="false" data-id="search_case_sensitive"
aria-label="Match Case" className={`monaco-custom-checkbox codicon codicon-case-sensitive ${
aria-disabled="false" state.casesensitive ? 'checked' : ''
onClick={() => { }`}
toggleCaseSensitive() role="checkbox"
}} aria-checked="false"
></div> aria-label="Match Case"
<div aria-disabled="false"
data-id="search_whole_word" onClick={() => {
title="Match Whole Word" toggleCaseSensitive()
className={`monaco-custom-checkbox codicon codicon-whole-word ${ }}
state.matchWord ? 'checked' : '' ></div>
}`} </CustomTooltip>
role="checkbox" <CustomTooltip
aria-checked="false" tooltipText="Match Whole Word"
aria-label="Match Whole Word" tooltipClasses="text-nowrap"
aria-disabled="false" tooltipId="searchWholeWordTooltip"
onClick={() => { placement="top-start"
toggleMatchWholeWord() >
}} <div
></div> data-id="search_whole_word"
<div className={`monaco-custom-checkbox codicon codicon-whole-word ${
data-id="search_use_regex" state.matchWord ? 'checked' : ''
title="Use Regular Expression" }`}
className={`monaco-custom-checkbox codicon codicon-regex ${ role="checkbox"
state.useRegExp ? 'checked' : '' aria-checked="false"
}`} aria-label="Match Whole Word"
role="checkbox" aria-disabled="false"
aria-checked="false" onClick={() => {
aria-label="Use Regular Expression" toggleMatchWholeWord()
aria-disabled="false" }}
onClick={() => { ></div>
toggleUseRegex() </CustomTooltip>
}} <CustomTooltip
></div> tooltipText="Use Regular Expression"
tooltipClasses="text-nowrap"
tooltipId="useRegularExpressionTooltip"
placement="bottom-start"
>
<div
data-id="search_use_regex"
className={`monaco-custom-checkbox codicon codicon-regex ${
state.useRegExp ? 'checked' : ''
}`}
role="checkbox"
aria-checked="false"
aria-label="Use Regular Expression"
aria-disabled="false"
onClick={() => {
toggleUseRegex()
}}
></div>
</CustomTooltip>
</div> </div>
</div> </div>
</div> </div>

@ -1,3 +1,4 @@
import { CustomTooltip } from '@remix-ui/helper'
import React, { useContext, useEffect, useState } from 'react' import React, { useContext, useEffect, useState } from 'react'
import { SearchContext } from '../context/context' import { SearchContext } from '../context/context'
import { Find } from './Find' import { Find } from './Find'
@ -13,18 +14,24 @@ export const FindContainer = props => {
}, [expanded]) }, [expanded])
return ( return (
<div className="search_plugin_find_container"> <div className="search_plugin_find_container">
<div <CustomTooltip
title="Toggle Replace" tooltipText="Toggle Replace"
data-id="toggle_replace" tooltipClasses="text-nowrap"
className={`codicon codicon-find-${ tooltipId="toggleReplaceTooltip"
expanded ? 'expanded' : 'collapsed' placement="left-start"
} search_plugin_find_container_arrow`} >
role="button" <div
onClick={toggleExpand} data-id="toggle_replace"
aria-label="Toggle Replace" className={`codicon codicon-find-${
aria-expanded="true" expanded ? 'expanded' : 'collapsed'
aria-disabled="false" } search_plugin_find_container_arrow`}
></div> role="button"
onClick={toggleExpand}
aria-label="Toggle Replace"
aria-expanded="true"
aria-disabled="false"
></div>
</CustomTooltip>
<div className="search_plugin_find_container_internal"> <div className="search_plugin_find_container_internal">
<Find></Find> <Find></Find>
{expanded ? {expanded ?

@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import { SearchResult } from '../../types' import { SearchResult } from '../../types'
import { getPathIcon } from '@remix-ui/helper' import { CustomTooltip, getPathIcon } from '@remix-ui/helper'
import * as path from 'path' import * as path from 'path'
interface ResultItemProps { interface ResultItemProps {
file: SearchResult file: SearchResult
@ -18,10 +18,17 @@ export const ResultFileName = (props: ResultItemProps) => {
return ( return (
<> <>
{icon ? <div className={`${icon} caret caret_tv`}></div> : null} {icon ? <div className={`${icon} caret caret_tv`}></div> : null}
<div title={props.file.filename} className="search_plugin_search_file_name ml-2"> <CustomTooltip
{path.basename(props.file.path)} tooltipText={props.file.filename}
<span className='pl-1 text-muted text-lowercase'>{path.dirname(props.file.path)}</span> tooltipClasses="text-nowrap"
</div> tooltipId="resultFileNameTooltip"
placement="top-start"
>
<div title={props.file.filename} className="search_plugin_search_file_name ml-2">
{path.basename(props.file.path)}
<span className='pl-1 text-muted text-lowercase'>{path.dirname(props.file.path)}</span>
</div>
</CustomTooltip>
</> </>
) )
} }

@ -1,5 +1,6 @@
import { useDialogDispatchers } from '@remix-ui/app' import { useDialogDispatchers } from '@remix-ui/app'
import { CustomTooltip } from '@remix-ui/helper'
import React, { useContext } from 'react' import React, { useContext } from 'react'
import { SearchContext } from '../../context/context' import { SearchContext } from '../../context/context'
import { SearchResult, SearchResultLine, SearchResultLineLine } from '../../types' import { SearchResult, SearchResultLine, SearchResultLineLine } from '../../types'
@ -53,9 +54,16 @@ export const ResultSummary = (props: ResultSummaryProps) => {
</div> </div>
{state.replaceEnabled? {state.replaceEnabled?
<div className='search_plugin_search_control'> <div className='search_plugin_search_control'>
<div title="Replace" data-id={`replace-${props.searchResult.filename}-${lineItem.position.start.line}-${lineItem.position.start.column}`} onClick={async () => { <CustomTooltip
replace(lineItem) tooltipText="Replace"
}} className="codicon codicon-find-replace" role="button" aria-label="Replace" aria-disabled="false"></div> tooltipClasses="text-nowrap"
tooltipId="replaceTooltip"
placement="top-start"
>
<div data-id={`replace-${props.searchResult.filename}-${lineItem.position.start.line}-${lineItem.position.start.column}`} onClick={async () => {
replace(lineItem)
}} className="codicon codicon-find-replace" role="button" aria-label="Replace" aria-disabled="false"></div>
</CustomTooltip>
</div>:null} </div>:null}
</div> </div>
))} ))}

Loading…
Cancel
Save