|
12 | 12 | lines = $bindable(), |
13 | 13 | actions, |
14 | 14 | class: className, |
| 15 | + headwordClass = '', |
| 16 | + highlightSenseId = undefined, |
| 17 | + hideExamples = false, |
15 | 18 | ...restProps |
16 | 19 | }: HTMLAttributes<HTMLDivElement> & { |
17 | 20 | entry: IEntry, |
18 | 21 | showLinks?: boolean, |
19 | 22 | lines?: number, |
20 | | - actions?: Snippet |
| 23 | + actions?: Snippet, |
| 24 | + headwordClass?: string, |
| 25 | + highlightSenseId?: string, |
| 26 | + hideExamples?: boolean, |
21 | 27 | } = $props(); |
22 | 28 |
|
23 | 29 | $effect(() => { |
|
101 | 107 | <div class="float-right group-[&:not(:hover)]/container:invisible relative -top-1"> |
102 | 108 | {@render actions?.()} |
103 | 109 | </div> |
104 | | - <strong class="mr-1"> |
| 110 | + <strong class={cn('mr-1', headwordClass)}> |
105 | 111 | {#each headwords as headword, i (headword.wsId)} |
106 | 112 | <!-- eslint-disable-next-line svelte/no-useless-mustaches This mustache is not useless, it preserves whitespace --> |
107 | 113 | {#if i > 0}{' / '}{/if} |
|
110 | 116 | </strong> |
111 | 117 | {#each senses as sense, i (sense.id)} |
112 | 118 | {#if senses.length > 1} |
113 | | - <br /> |
114 | | - {@render senseNumber(i)} |
| 119 | + <br/> |
115 | 120 | {/if} |
116 | | - {#if sense.partOfSpeech} |
117 | | - <i>{sense.partOfSpeech}</i> |
118 | | - {/if} |
119 | | - <span> |
120 | | - {#each sense.glossesAndDefs as glossAndDef (glossAndDef.wsId)} |
121 | | - <sub class="-mr-0.5">{glossAndDef.wsAbbr}</sub> |
122 | | - {#if glossAndDef.gloss} |
123 | | - <span class={glossAndDef.color}>{glossAndDef.gloss}</span>{#if glossAndDef.definition};{/if} |
124 | | - {/if} |
125 | | - {#if glossAndDef.definition} |
126 | | - <span class={glossAndDef.color}>{glossAndDef.definition}</span> |
127 | | - {/if} |
128 | | - <!-- eslint-disable-next-line svelte/no-useless-mustaches This mustache is not useless, it is deliberately an empty string with no whitespace --> |
129 | | - {''} |
| 121 | + <span class={cn(highlightSenseId === sense.id && 'rounded bg-secondary')}> |
| 122 | + {#if senses.length > 1} |
| 123 | + {@render senseNumber(i)} |
| 124 | + {/if} |
| 125 | + {#if sense.partOfSpeech} |
| 126 | + <i>{sense.partOfSpeech}</i> |
| 127 | + {/if} |
| 128 | + <span> |
| 129 | + {#each sense.glossesAndDefs as glossAndDef (glossAndDef.wsId)} |
| 130 | + <sub class="-mr-0.5">{glossAndDef.wsAbbr}</sub> |
| 131 | + {#if glossAndDef.gloss} |
| 132 | + <span class={glossAndDef.color}>{glossAndDef.gloss}</span>{#if glossAndDef.definition};{/if} |
| 133 | + {/if} |
| 134 | + {#if glossAndDef.definition} |
| 135 | + <span class={glossAndDef.color}>{glossAndDef.definition}</span> |
| 136 | + {/if} |
| 137 | + <!-- eslint-disable-next-line svelte/no-useless-mustaches This mustache is not useless, it is deliberately an empty string with no whitespace --> |
| 138 | + {''} |
| 139 | + {/each} |
| 140 | + </span> |
| 141 | + {#if !hideExamples} |
| 142 | + {#each sense.exampleSentences as example (example.id)} |
| 143 | + {#each example.sentences as sentence, j (sentence)} |
| 144 | + {@const first = j === 0} |
| 145 | + {@const last = j === example.sentences.length - 1} |
| 146 | + {#if j > 0};{/if} |
| 147 | + {#if first}[{/if}<span class={sentence.color}>{sentence.text}</span>{#if last}]{/if} |
| 148 | + {/each} |
130 | 149 | {/each} |
| 150 | + {/if} |
131 | 151 | </span> |
132 | | - {#each sense.exampleSentences as example (example.id)} |
133 | | - {#each example.sentences as sentence, j (sentence)} |
134 | | - {@const first = j === 0} |
135 | | - {@const last = j === example.sentences.length - 1} |
136 | | - {#if j > 0};{/if} |
137 | | - {#if first}[{/if}<span class={sentence.color}>{sentence.text}</span>{#if last}]{/if} |
138 | | - {/each} |
139 | | - {/each} |
140 | 152 | {/each} |
141 | 153 | </div> |
0 commit comments