add custom tooltip to search

pull/3081/head
Joseph Izang 2 years ago
parent c604d85deb
commit e310db1f56
  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 { SearchContext } from '../context/context'
@ -42,48 +43,66 @@ export const Find = () => {
onKeyUp={handleKeypress}
></input>
<div className="search_plugin_controls">
<div
data-id="search_case_sensitive"
title="Match Case"
className={`monaco-custom-checkbox codicon codicon-case-sensitive ${
state.casesensitive ? 'checked' : ''
}`}
role="checkbox"
aria-checked="false"
aria-label="Match Case"
aria-disabled="false"
onClick={() => {
toggleCaseSensitive()
}}
></div>
<div
data-id="search_whole_word"
title="Match Whole Word"
className={`monaco-custom-checkbox codicon codicon-whole-word ${
state.matchWord ? 'checked' : ''
}`}
role="checkbox"
aria-checked="false"
aria-label="Match Whole Word"
aria-disabled="false"
onClick={() => {
toggleMatchWholeWord()
}}
></div>
<div
data-id="search_use_regex"
title="Use Regular Expression"
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
tooltipText="Match Case"
tooltipClasses="text-nowrap"
tooltipId="searchCaseSensitiveTooltip"
placement="top-start"
>
<div
data-id="search_case_sensitive"
className={`monaco-custom-checkbox codicon codicon-case-sensitive ${
state.casesensitive ? 'checked' : ''
}`}
role="checkbox"
aria-checked="false"
aria-label="Match Case"
aria-disabled="false"
onClick={() => {
toggleCaseSensitive()
}}
></div>
</CustomTooltip>
<CustomTooltip
tooltipText="Match Whole Word"
tooltipClasses="text-nowrap"
tooltipId="searchWholeWordTooltip"
placement="top-start"
>
<div
data-id="search_whole_word"
className={`monaco-custom-checkbox codicon codicon-whole-word ${
state.matchWord ? 'checked' : ''
}`}
role="checkbox"
aria-checked="false"
aria-label="Match Whole Word"
aria-disabled="false"
onClick={() => {
toggleMatchWholeWord()
}}
></div>
</CustomTooltip>
<CustomTooltip
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>

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

@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react'
import { SearchResult } from '../../types'
import { getPathIcon } from '@remix-ui/helper'
import { CustomTooltip, getPathIcon } from '@remix-ui/helper'
import * as path from 'path'
interface ResultItemProps {
file: SearchResult
@ -18,10 +18,17 @@ export const ResultFileName = (props: ResultItemProps) => {
return (
<>
{icon ? <div className={`${icon} caret caret_tv`}></div> : null}
<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
tooltipText={props.file.filename}
tooltipClasses="text-nowrap"
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 { CustomTooltip } from '@remix-ui/helper'
import React, { useContext } from 'react'
import { SearchContext } from '../../context/context'
import { SearchResult, SearchResultLine, SearchResultLineLine } from '../../types'
@ -53,9 +54,16 @@ export const ResultSummary = (props: ResultSummaryProps) => {
</div>
{state.replaceEnabled?
<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 () => {
replace(lineItem)
}} className="codicon codicon-find-replace" role="button" aria-label="Replace" aria-disabled="false"></div>
<CustomTooltip
tooltipText="Replace"
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>
))}

Loading…
Cancel
Save