File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 113113 {chapter .title }
114114 </h1 >
115115 <p class =" mt-3 text-sm leading-6 text-muted-foreground sm:text-base sm:leading-7" >
116- <TermRichText segments ={linkedCopy .intro } />
116+ <TermRichText segments ={linkedCopy .intro } currentChapterId ={ chapter . id } />
117117 </p >
118118 </header >
119119
152152
153153 <p class =" mt-4 text-sm leading-6 sm:text-base sm:leading-7" >
154154 {#if linked }
155- <TermRichText segments ={linked .teach } />
155+ <TermRichText segments ={linked .teach } currentChapterId ={ chapter . id } />
156156 {:else }
157157 {piece .teach }
158158 {/if }
165165 </p >
166166 <p class =" mt-1 text-sm leading-6 sm:text-base sm:leading-7" >
167167 {#if linked ?.watchFor }
168- <TermRichText segments ={linked .watchFor } />
168+ <TermRichText
169+ segments ={linked .watchFor }
170+ currentChapterId ={chapter .id }
171+ />
169172 {:else }
170173 {piece .watchFor }
171174 {/if }
234237 <section class =" mt-10 border-t pt-8 sm:mt-12" >
235238 {#if chapter .closing && linkedCopy .closing }
236239 <p class =" text-sm leading-6 text-muted-foreground sm:text-base sm:leading-7" >
237- <TermRichText segments ={linkedCopy .closing } />
240+ <TermRichText
241+ segments ={linkedCopy .closing }
242+ currentChapterId ={chapter .id }
243+ />
238244 </p >
239245 {/if }
240246 <div
Original file line number Diff line number Diff line change 88 let {
99 term,
1010 triggerClass,
11+ currentChapterId,
1112 children,
1213 }: {
1314 term: GlossaryTerm ;
1415 triggerClass: string ;
16+ /** When set, hide "Open chapter" if the term is defined in this chapter. */
17+ currentChapterId? : string ;
1518 children: Snippet ;
1619 } = $props ();
1720
2124 let titleEl: HTMLElement | null = $state (null );
2225
2326 let chapter = $derived (term .chapterId ? chapterById (term .chapterId ) : undefined );
27+ let showOpenChapter = $derived (
28+ Boolean (chapter && term .chapterId && term .chapterId !== currentChapterId ),
29+ );
2430
2531 function onOpenAutoFocus(event : Event ) {
2632 event .preventDefault ();
5460 {term .definition }
5561 </Popover .Description >
5662 </Popover .Header >
57- {#if chapter }
63+ {#if showOpenChapter && chapter }
5864 <a
5965 class =" mt-2 inline-block text-sm font-medium text-primary underline-offset-4 hover:underline"
6066 href ={learnChapterPath (chapter .unitId , chapter .id )}
Original file line number Diff line number Diff line change 55
66 let {
77 segments,
8+ currentChapterId,
89 }: {
910 segments: TextSegment [];
11+ /** Chapter the reader is currently viewing, if any. */
12+ currentChapterId? : string ;
1013 } = $props ();
1114 </script >
1215
1821 {#if term }
1922 <TermDefinitionPopover
2023 {term }
24+ {currentChapterId }
2125 triggerClass =" cursor-pointer rounded-sm text-primary underline decoration-dotted decoration-primary/70 underline-offset-2 outline-none hover:decoration-solid focus-visible:ring-2 focus-visible:ring-ring"
2226 >
2327 {segment .text }
You can’t perform that action at this time.
0 commit comments