@@ -17,6 +17,7 @@ const props = defineProps<{
1717
1818/** Total column count including the optional no-dep column */
1919const totalColumns = computed (() => props .columns .length + (props .showNoDependency ? 1 : 0 ))
20+ const visibleColumns = computed (() => Math .min (totalColumns .value , 4 ))
2021
2122/** Compute plain-text tooltip for a replacement column */
2223function getReplacementTooltip(col : ComparisonGridColumn ): string {
@@ -30,32 +31,43 @@ function getReplacementTooltip(col: ComparisonGridColumn): string {
3031 <div class =" overflow-x-auto" >
3132 <div
3233 class =" comparison-grid"
33- :class =" [totalColumns === 4 ? 'min-w-[800px]' : 'min-w-[600px]', `columns-${totalColumns}`]"
34- :style =" { '--columns': totalColumns }"
34+ :style =" {
35+ '--package-count': totalColumns,
36+ '--visible-columns': visibleColumns,
37+ }"
3538 >
3639 <!-- Header row -->
3740 <div class =" comparison-header" >
38- <div class =" comparison-label" />
41+ <div class =" comparison-label relative bg-bg " />
3942
4043 <!-- Package columns -->
41- <div v-for =" col in columns" :key =" col.name" class =" comparison-cell comparison-cell-header" >
42- <span class =" inline-flex items-center gap-1.5 truncate" >
44+ <div
45+ v-for =" col in columns"
46+ :key =" col.name"
47+ class =" comparison-cell comparison-cell-header min-w-0"
48+ >
49+ <div class =" flex items-start justify-center gap-1.5 min-w-0" >
4350 <LinkBase
4451 :to =" packageRoute(col.name, col.version)"
45- class =" text-sm truncate"
46- block
52+ class =" flex min-w-0 flex-col items-center text-center text-sm"
4753 :title =" col.version ? `${col.name}@${col.version}` : col.name"
4854 >
49- {{ col.name }}<template v-if =" col .version " >@{{ col.version }}</template >
55+ <span class =" min-w-0 break-words line-clamp-1" >
56+ {{ col.name }}
57+ </span >
58+ <span v-if =" col.version" class =" text-fg-muted line-clamp-1" >
59+ @{{ col.version }}
60+ </span >
5061 </LinkBase >
62+
5163 <TooltipApp v-if =" col.replacement" :text =" getReplacementTooltip(col)" position =" bottom" >
5264 <span
53- class =" i-lucide:lightbulb w-3 .5 h-3.5 text-amber-500 shrink-0 cursor-help"
65+ class =" i-lucide:lightbulb mt-0 .5 h-3.5 w-3.5 shrink-0 cursor-help text-amber-500 "
5466 role =" img"
5567 :aria-label =" $t('package.replacement.title')"
5668 />
5769 </TooltipApp >
58- </span >
70+ </div >
5971 </div >
6072
6173 <!-- "No dep" column (always last) -->
@@ -100,29 +112,30 @@ function getReplacementTooltip(col: ComparisonGridColumn): string {
100112
101113<style scoped>
102114.comparison-grid {
115+ --label-column-width : 140px ;
116+ --package-column-width : calc ((100% - var (--label-column-width )) / var (--visible-columns ));
103117 display : grid ;
104118 gap : 0 ;
105- }
106-
107- .comparison-grid.columns-2 {
108- grid-template-columns : minmax (120px , 180px ) repeat (2 , 1fr );
109- }
110-
111- .comparison-grid.columns-3 {
112- grid-template-columns : minmax (120px , 160px ) repeat (3 , 1fr );
113- }
114-
115- .comparison-grid.columns-4 {
116- grid-template-columns : minmax (100px , 140px ) repeat (4 , 1fr );
119+ grid-template-columns :
120+ var (--label-column-width )
121+ repeat (var (--package-count ), minmax (var (--package-column-width ), var (--package-column-width )));
117122}
118123
119124.comparison-header {
120125 display : contents ;
121126}
122127
123128.comparison-header > .comparison-label {
124- padding : 0.75rem 1rem ;
125- border-bottom : 1px solid var (--color-border );
129+ z-index : 3 ;
130+ }
131+
132+ .comparison-label {
133+ position : sticky ;
134+ left : 0 ;
135+ z-index : 2 ;
136+ inline-size : var (--label-column-width );
137+ min-inline-size : var (--label-column-width );
138+ isolation : isolate ;
126139}
127140
128141.comparison-header > .comparison-cell-header {
0 commit comments