mirror of
https://github.com/voideditor/void
synced 2026-05-23 09:28:23 +00:00
added tooltip for selected files the prevent ambiguity
This commit is contained in:
parent
b5a41840a0
commit
42c50413f5
1 changed files with 78 additions and 71 deletions
|
|
@ -664,81 +664,88 @@ export const SelectedFiles = (
|
|||
key={thisKey}
|
||||
className={`flex flex-col space-y-[1px]`}
|
||||
>
|
||||
{/* summarybox */}
|
||||
<div
|
||||
className={`
|
||||
flex items-center gap-1 relative
|
||||
px-1
|
||||
w-fit h-fit
|
||||
select-none
|
||||
text-xs text-nowrap
|
||||
border rounded-sm
|
||||
${isThisSelectionProspective ? 'bg-void-bg-1 text-void-fg-3 opacity-80' : 'bg-void-bg-1 hover:brightness-95 text-void-fg-1'}
|
||||
${isThisSelectionProspective
|
||||
? 'border-void-border-2'
|
||||
: 'border-void-border-1'
|
||||
}
|
||||
hover:border-void-border-1
|
||||
transition-all duration-150
|
||||
`}
|
||||
onClick={() => {
|
||||
if (type !== 'staging') return; // (never)
|
||||
if (isThisSelectionProspective) { // add prospective selection to selections
|
||||
setSelections([...selections, selection])
|
||||
}
|
||||
else if (selection.type === 'File') { // open files
|
||||
voidOpenFileFn(selection.uri, accessor);
|
||||
|
||||
const wasAddedAsCurrentFile = selection.state.wasAddedAsCurrentFile
|
||||
if (wasAddedAsCurrentFile) {
|
||||
// make it so the file is added permanently, not just as the current file
|
||||
const newSelection: StagingSelectionItem = { ...selection, state: { ...selection.state, wasAddedAsCurrentFile: false } }
|
||||
setSelections([
|
||||
...selections.slice(0, i),
|
||||
newSelection,
|
||||
...selections.slice(i + 1)
|
||||
])
|
||||
}
|
||||
}
|
||||
else if (selection.type === 'CodeSelection') {
|
||||
voidOpenFileFn(selection.uri, accessor, selection.range);
|
||||
}
|
||||
else if (selection.type === 'Folder') {
|
||||
// TODO!!! reveal in tree
|
||||
}
|
||||
}}
|
||||
{/* tooltip for file path */}
|
||||
<span className="truncate overflow-hidden text-ellipsis"
|
||||
data-tooltip-id='void-tooltip'
|
||||
data-tooltip-content={getRelative(selection.uri, accessor)}
|
||||
data-tooltip-place='top'
|
||||
>
|
||||
{<SelectionIcon size={10} />}
|
||||
{/* summarybox */}
|
||||
<div
|
||||
className={`
|
||||
flex items-center gap-1 relative
|
||||
px-1
|
||||
w-fit h-fit
|
||||
select-none
|
||||
text-xs text-nowrap
|
||||
border rounded-sm
|
||||
${isThisSelectionProspective ? 'bg-void-bg-1 text-void-fg-3 opacity-80' : 'bg-void-bg-1 hover:brightness-95 text-void-fg-1'}
|
||||
${isThisSelectionProspective
|
||||
? 'border-void-border-2'
|
||||
: 'border-void-border-1'
|
||||
}
|
||||
hover:border-void-border-1
|
||||
transition-all duration-150
|
||||
`}
|
||||
onClick={() => {
|
||||
if (type !== 'staging') return; // (never)
|
||||
if (isThisSelectionProspective) { // add prospective selection to selections
|
||||
setSelections([...selections, selection])
|
||||
}
|
||||
else if (selection.type === 'File') { // open files
|
||||
voidOpenFileFn(selection.uri, accessor);
|
||||
|
||||
{ // file name and range
|
||||
getBasename(selection.uri.fsPath)
|
||||
+ (selection.type === 'CodeSelection' ? ` (${selection.range[0]}-${selection.range[1]})` : '')
|
||||
}
|
||||
const wasAddedAsCurrentFile = selection.state.wasAddedAsCurrentFile
|
||||
if (wasAddedAsCurrentFile) {
|
||||
// make it so the file is added permanently, not just as the current file
|
||||
const newSelection: StagingSelectionItem = { ...selection, state: { ...selection.state, wasAddedAsCurrentFile: false } }
|
||||
setSelections([
|
||||
...selections.slice(0, i),
|
||||
newSelection,
|
||||
...selections.slice(i + 1)
|
||||
])
|
||||
}
|
||||
}
|
||||
else if (selection.type === 'CodeSelection') {
|
||||
voidOpenFileFn(selection.uri, accessor, selection.range);
|
||||
}
|
||||
else if (selection.type === 'Folder') {
|
||||
// TODO!!! reveal in tree
|
||||
}
|
||||
}}
|
||||
>
|
||||
{<SelectionIcon size={10} />}
|
||||
|
||||
{selection.type === 'File' && selection.state.wasAddedAsCurrentFile && messageIdx === undefined && currentURI?.fsPath === selection.uri.fsPath ?
|
||||
<span className={`text-[8px] 'void-opacity-60 text-void-fg-4`}>
|
||||
{`(Current File)`}
|
||||
</span>
|
||||
: null
|
||||
}
|
||||
{ // file name and range
|
||||
getBasename(selection.uri.fsPath)
|
||||
+ (selection.type === 'CodeSelection' ? ` (${selection.range[0]}-${selection.range[1]})` : '')
|
||||
}
|
||||
|
||||
{type === 'staging' && !isThisSelectionProspective ? // X button
|
||||
<div // box for making it easier to click
|
||||
className='cursor-pointer z-1 self-stretch flex items-center justify-center'
|
||||
onClick={(e) => {
|
||||
e.stopPropagation(); // don't open/close selection
|
||||
if (type !== 'staging') return;
|
||||
setSelections([...selections.slice(0, i), ...selections.slice(i + 1)])
|
||||
}}
|
||||
>
|
||||
<IconX
|
||||
className='stroke-[2]'
|
||||
size={10}
|
||||
/>
|
||||
</div>
|
||||
: <></>
|
||||
}
|
||||
</div>
|
||||
{selection.type === 'File' && selection.state.wasAddedAsCurrentFile && messageIdx === undefined && currentURI?.fsPath === selection.uri.fsPath ?
|
||||
<span className={`text-[8px] 'void-opacity-60 text-void-fg-4`}>
|
||||
{`(Current File)`}
|
||||
</span>
|
||||
: null
|
||||
}
|
||||
|
||||
{type === 'staging' && !isThisSelectionProspective ? // X button
|
||||
<div // box for making it easier to click
|
||||
className='cursor-pointer z-1 self-stretch flex items-center justify-center'
|
||||
onClick={(e) => {
|
||||
e.stopPropagation(); // don't open/close selection
|
||||
if (type !== 'staging') return;
|
||||
setSelections([...selections.slice(0, i), ...selections.slice(i + 1)])
|
||||
}}
|
||||
>
|
||||
<IconX
|
||||
className='stroke-[2]'
|
||||
size={10}
|
||||
/>
|
||||
</div>
|
||||
: <></>
|
||||
}
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
})}
|
||||
|
|
|
|||
Loading…
Reference in a new issue