mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +02:00
show current album name in header
This commit is contained in:
@@ -34,7 +34,19 @@
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.header-left-album-name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-size: var(--theme-font-size-sm);
|
||||
font-weight: 500;
|
||||
color: var(--theme-colors-foreground);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.header-right {
|
||||
|
||||
@@ -606,6 +606,7 @@ RowComponent.displayName = 'ItemDetailRow';
|
||||
interface DetailListHeaderProps {
|
||||
columnWidthPercents: number[];
|
||||
enableVerticalBorders: boolean;
|
||||
headerLeftRef: React.RefObject<HTMLSpanElement | null>;
|
||||
trackColumns: ItemTableListColumnConfig[];
|
||||
trackTableSize: 'compact' | 'default' | 'large';
|
||||
}
|
||||
@@ -626,12 +627,19 @@ const DetailListHeader = memo(
|
||||
({
|
||||
columnWidthPercents,
|
||||
enableVerticalBorders,
|
||||
headerLeftRef,
|
||||
trackColumns,
|
||||
trackTableSize,
|
||||
}: DetailListHeaderProps) => {
|
||||
return (
|
||||
<header className={styles.detailListHeader} role="rowgroup">
|
||||
<div aria-hidden className={styles.headerLeft} />
|
||||
<div className={styles.headerLeft}>
|
||||
<span
|
||||
className={styles.headerLeftAlbumName}
|
||||
data-title=""
|
||||
ref={headerLeftRef}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.headerRight}>
|
||||
<div
|
||||
className={clsx(styles.tracksTableHeader, {
|
||||
@@ -768,8 +776,20 @@ export const ItemDetailList = ({
|
||||
return trackColumns.map((c) => (c.width / total) * 100);
|
||||
}, [trackColumns]);
|
||||
|
||||
const headerLeftRef = useRef<HTMLSpanElement>(null);
|
||||
const dataSourceRef = useRef(dataSource);
|
||||
dataSourceRef.current = dataSource;
|
||||
|
||||
const handleRowsRendered = useCallback(
|
||||
(range: { startIndex: number; stopIndex: number }) => {
|
||||
const el = headerLeftRef.current;
|
||||
if (el) {
|
||||
const album = dataSourceRef.current[range.startIndex] as Album | undefined;
|
||||
const name = album?.name ?? '';
|
||||
el.textContent = name;
|
||||
el.setAttribute('data-title', name);
|
||||
el.title = name;
|
||||
}
|
||||
if (onRangeChanged) {
|
||||
onRangeChanged(range);
|
||||
}
|
||||
@@ -871,6 +891,7 @@ export const ItemDetailList = ({
|
||||
<DetailListHeader
|
||||
columnWidthPercents={columnWidthPercents}
|
||||
enableVerticalBorders={enableVerticalBorders}
|
||||
headerLeftRef={headerLeftRef}
|
||||
trackColumns={trackColumns}
|
||||
trackTableSize={trackTableSize}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user