mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-12 02:35:42 +00:00
feat: autosize local character tooltip and increase hover target (#165)
This commit is contained in:
@@ -4,6 +4,12 @@
|
|||||||
z-index: 3;
|
z-index: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hoverTarget {
|
||||||
|
padding: 0.5rem;
|
||||||
|
margin: -0.5rem;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
.localCounter {
|
.localCounter {
|
||||||
mix-blend-mode: screen;
|
mix-blend-mode: screen;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -24,13 +24,12 @@ export const LocalCounter = ({ localCounterCharacters, hasUserCharacters, showIc
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
width: '300px',
|
width: '100%',
|
||||||
overflowX: 'hidden',
|
minWidth: '300px',
|
||||||
overflowY: 'auto',
|
overflow: 'hidden',
|
||||||
height: '300px',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<LocalCharactersList items={localCounterCharacters} itemTemplate={itemTemplate} itemSize={26} />
|
<LocalCharactersList items={localCounterCharacters} itemTemplate={itemTemplate} itemSize={26} autoSize={true} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}, [localCounterCharacters, itemTemplate]);
|
}, [localCounterCharacters, itemTemplate]);
|
||||||
@@ -45,12 +44,8 @@ export const LocalCounter = ({ localCounterCharacters, hasUserCharacters, showIc
|
|||||||
[classes.Pathfinder]: theme === AvailableThemes.pathfinder,
|
[classes.Pathfinder]: theme === AvailableThemes.pathfinder,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<WdTooltipWrapper
|
<WdTooltipWrapper content={pilotTooltipContent} position={TooltipPosition.right} offset={0} interactive={true}>
|
||||||
// @ts-ignore
|
<div className={clsx(classes.hoverTarget)}>
|
||||||
content={pilotTooltipContent}
|
|
||||||
position={TooltipPosition.right}
|
|
||||||
offset={0}
|
|
||||||
>
|
|
||||||
<div
|
<div
|
||||||
className={clsx(classes.localCounter, {
|
className={clsx(classes.localCounter, {
|
||||||
[classes.hasUserCharacters]: hasUserCharacters,
|
[classes.hasUserCharacters]: hasUserCharacters,
|
||||||
@@ -59,6 +54,7 @@ export const LocalCounter = ({ localCounterCharacters, hasUserCharacters, showIc
|
|||||||
{showIcon && <i className="pi pi-users" />}
|
{showIcon && <i className="pi pi-users" />}
|
||||||
<span>{localCounterCharacters.length}</span>
|
<span>{localCounterCharacters.length}</span>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</WdTooltipWrapper>
|
</WdTooltipWrapper>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ import { VirtualScroller, VirtualScrollerTemplateOptions } from 'primereact/virt
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { CharItemProps } from './types';
|
import { CharItemProps } from './types';
|
||||||
|
|
||||||
type LocalCharactersListProps = {
|
export type LocalCharactersListProps = {
|
||||||
items: Array<CharItemProps>;
|
items: Array<CharItemProps>;
|
||||||
itemSize: number;
|
itemSize: number;
|
||||||
itemTemplate: (char: CharItemProps, options: VirtualScrollerTemplateOptions) => React.ReactNode;
|
itemTemplate: (char: CharItemProps, options: VirtualScrollerTemplateOptions) => React.ReactNode;
|
||||||
containerClassName?: string;
|
containerClassName?: string;
|
||||||
|
style?: React.CSSProperties;
|
||||||
|
autoSize?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const LocalCharactersList = ({
|
export const LocalCharactersList = ({
|
||||||
@@ -15,7 +17,19 @@ export const LocalCharactersList = ({
|
|||||||
itemSize,
|
itemSize,
|
||||||
itemTemplate,
|
itemTemplate,
|
||||||
containerClassName,
|
containerClassName,
|
||||||
|
style = {},
|
||||||
|
autoSize = false,
|
||||||
}: LocalCharactersListProps) => {
|
}: LocalCharactersListProps) => {
|
||||||
|
const computedHeight = autoSize ? `${Math.max(items.length, 1) * itemSize}px` : style.height || '100%';
|
||||||
|
|
||||||
|
const localStyle: React.CSSProperties = {
|
||||||
|
...style,
|
||||||
|
height: computedHeight,
|
||||||
|
width: '100%',
|
||||||
|
boxSizing: 'border-box',
|
||||||
|
overflowX: 'hidden',
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<VirtualScroller
|
<VirtualScroller
|
||||||
items={items}
|
items={items}
|
||||||
@@ -23,6 +37,8 @@ export const LocalCharactersList = ({
|
|||||||
orientation="vertical"
|
orientation="vertical"
|
||||||
className={clsx('w-full h-full', containerClassName)}
|
className={clsx('w-full h-full', containerClassName)}
|
||||||
itemTemplate={itemTemplate}
|
itemTemplate={itemTemplate}
|
||||||
|
autoSize={autoSize}
|
||||||
|
style={localStyle}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user