@@ -86,11 +86,10 @@ watch(
8686 </script >
8787
8888<template >
89- <div class =" code-viewer flex min-h-full max-w-full" >
89+ <div class =" code-viewer flex min-h-full max-w-full" :style = " { '--line-digits': lineDigits } " >
9090 <!-- Line numbers column -->
9191 <div
9292 class =" line-numbers shrink-0 bg-bg-subtle border-ie border-solid border-border text-end select-none relative"
93- :style =" { '--line-digits': lineDigits }"
9493 aria-hidden =" true"
9594 >
9695 <!-- This needs to be a native <a> element, because `LinkBase` (or specifically `NuxtLink`) does not seem to work when trying to prevent default behavior (jumping to the anchor) -->
@@ -113,9 +112,9 @@ watch(
113112 </div >
114113
115114 <!-- Code content -->
116- <div class =" code-content flex-1 overflow-x-auto min-w-0 " >
115+ <div class =" code-content" >
117116 <!-- eslint-disable vue/no-v-html -- HTML is generated server-side by Shiki -->
118- <div ref =" codeRef" class =" code-lines min-w-full w-fit " v-html =" html" />
117+ <div ref =" codeRef" class =" code-lines" v-html =" html" />
119118 <!-- eslint-enable vue/no-v-html -->
120119 </div >
121120 </div >
@@ -124,59 +123,69 @@ watch(
124123<style scoped>
125124.code-viewer {
126125 font-size : 14px ;
127- }
128-
129- .line-numbers {
130126 /* 1ch per digit + 1.5rem (px-3 * 2) padding */
131- min-width : calc (var (--line-digits ) * 1ch + 1.5rem );
132- }
133-
134- .code-content :deep(pre ) {
135- margin : 0 ;
136- padding : 0 ;
137- background : transparent !important ;
138- overflow : visible ;
139- }
140-
141- .code-content :deep(code ) {
142- display : block ;
143- padding : 0 1rem ;
144- background : transparent !important ;
145- }
146-
147- .code-content :deep(.line ) {
148- display : block ;
149- /* Ensure consistent height matching line numbers */
150- line-height : 24px ;
151- min-height : 24px ;
152- max-height : 24px ;
153- white-space : pre ;
154- overflow : hidden ;
155- transition : background-color 0.1s ;
127+ --line-numbers-width : calc (var (--line-digits ) * 1ch + 1.5rem );
156128}
157129
158- /* Highlighted lines in code content - extend full width with negative margin */
159- .code-content :deep(.line.highlighted ) {
160- @apply bg-yellow- 500/20;
161- margin : 0 -1rem ;
162- padding : 0 1rem ;
163- }
164-
165- /* Clickable import links */
166- .code-content :deep(.import-link ) {
167- color : inherit ;
168- text-decoration : underline ;
169- text-decoration-style : dotted ;
170- text-decoration-color : rgba (158 , 203 , 255 , 0.5 ); /* syntax.str with transparency */
171- text-underline-offset : 2px ;
172- transition :
173- text-decoration-color 0.15s ,
174- text-decoration-style 0.15s ;
175- cursor : pointer ;
130+ .line-numbers {
131+ min-width : var (--line-numbers-width );
176132}
177133
178- .code-content :deep(.import-link :hover ) {
179- text-decoration-style : solid ;
180- text-decoration-color : #9ecbff ; /* syntax.str - light blue */
134+ .code-content {
135+ flex : 1 ;
136+ min-width : 0 ;
137+ max-width : calc (100% - var (--line-numbers-width ));
138+
139+ &:deep(pre ) {
140+ margin : 0 ;
141+ padding : 0 ;
142+ background : transparent !important ;
143+ overflow : visible ;
144+ max-width : 100% ;
145+ }
146+
147+ &:deep(code ) {
148+ display : block ;
149+ padding : 0 1rem ;
150+ background : transparent !important ;
151+ max-width : 100% ;
152+ }
153+
154+ &:deep(.line ) {
155+ display : flex ;
156+ flex-wrap : wrap ;
157+ /* Ensure consistent height matching line numbers */
158+ line-height : 24px ;
159+ min-height : 24px ;
160+ white-space : pre-wrap ;
161+ overflow : hidden ;
162+ transition : background-color 0.1s ;
163+ max-width : 100% ;
164+ }
165+
166+ /* Highlighted lines in code content - extend full width with negative margin */
167+ &:deep(.line.highlighted ) {
168+ @apply bg-yellow- 500/20;
169+ margin : 0 -1rem ;
170+ padding : 0 1rem ;
171+ }
172+
173+ /* Clickable import links */
174+ &:deep(.import-link ) {
175+ color : inherit ;
176+ text-decoration : underline ;
177+ text-decoration-style : dotted ;
178+ text-decoration-color : rgba (158 , 203 , 255 , 0.5 ); /* syntax.str with transparency */
179+ text-underline-offset : 2px ;
180+ transition :
181+ text-decoration-color 0.15s ,
182+ text-decoration-style 0.15s ;
183+ cursor : pointer ;
184+ }
185+
186+ &:deep(.import-link :hover ) {
187+ text-decoration-style : solid ;
188+ text-decoration-color : #9ecbff ; /* syntax.str - light blue */
189+ }
181190}
182191 </style >
0 commit comments