Skip to content

Commit fbbb35d

Browse files
authored
nice prose mini for beautiful tooltips (#331)
1 parent 6235e52 commit fbbb35d

File tree

2 files changed

+148
-2
lines changed

2 files changed

+148
-2
lines changed

packages/web/src/components/cells/hover.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function formatDocumentation(documentation: TsServerJSDocType): HTMLElement | nu
9090
}
9191

9292
const div = document.createElement('div');
93-
div.className = 'text-xs text-secondary-foreground';
93+
div.className = 'sb-prose-mini text-secondary-foreground';
9494
div.innerHTML = parse(text) as string;
9595

9696
return div;
@@ -102,7 +102,7 @@ function formatTags(tags: TsServerJsDocTagsType): HTMLElement | null {
102102
}
103103

104104
const div = document.createElement('div');
105-
div.className = 'text-xs text-secondary-foreground space-y-2';
105+
div.className = 'sb-prose-mini text-secondary-foreground space-y-2';
106106

107107
for (const tag of tags) {
108108
const tagDiv = document.createElement('div');

packages/web/src/index.css

+146
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,14 @@
197197
@apply bg-muted;
198198
@apply text-inline-code-foreground;
199199
}
200+
201+
.code-mini {
202+
@apply text-xs;
203+
@apply rounded-sm;
204+
@apply px-0.5;
205+
@apply bg-muted;
206+
@apply text-inline-code-foreground;
207+
}
200208
}
201209

202210
@layer base {
@@ -345,6 +353,144 @@
345353
border-radius: 3px;
346354
}
347355

356+
.sb-prose-mini {
357+
@apply font-sans;
358+
@apply text-xs;
359+
@apply leading-3;
360+
}
361+
362+
.sb-prose-mini > *:first-child {
363+
margin-top: 0;
364+
}
365+
366+
.sb-prose-mini > *:last-child {
367+
margin-bottom: 0;
368+
}
369+
370+
.sb-prose-mini p {
371+
@apply my-1;
372+
}
373+
374+
.sb-prose-mini a {
375+
font-weight: bold;
376+
@apply underline;
377+
@apply decoration-1;
378+
@apply underline-offset-1;
379+
}
380+
381+
.sb-prose-mini a:hover {
382+
@apply text-primary-hover;
383+
}
384+
385+
.sb-prose-mini blockquote {
386+
@apply font-semibold;
387+
@apply my-3;
388+
@apply italic;
389+
@apply text-tertiary-foreground;
390+
@apply ps-2;
391+
@apply border-s-2;
392+
@apply border-s-border;
393+
quotes: '\201C' '\201D' '\2018' '\2019';
394+
}
395+
396+
.sb-prose-mini blockquote p:first-of-type::before {
397+
content: open-quote;
398+
}
399+
400+
.sb-prose-mini blockquote p:last-of-type::after {
401+
content: close-quote;
402+
}
403+
404+
.sb-prose-mini pre {
405+
@apply text-xs;
406+
@apply overflow-x-auto;
407+
@apply bg-muted;
408+
@apply text-foreground;
409+
@apply p-2;
410+
@apply rounded-sm;
411+
@apply border;
412+
@apply border-border;
413+
}
414+
415+
.sb-prose-mini code:not(pre code) {
416+
@apply code-mini;
417+
}
418+
419+
.sb-prose-mini h1 > code,
420+
.sb-prose-mini h2 > code,
421+
.sb-prose-mini h3 > code,
422+
.sb-prose-mini h4 > code,
423+
.sb-prose-mini h5 > code {
424+
@apply font-mono;
425+
/* No way to avoid !important given specificity priority and the fact that we don't generate the HTML */
426+
font-size: 80% !important;
427+
@apply px-1.5 !important;
428+
@apply font-normal;
429+
}
430+
431+
.sb-prose-mini h1 {
432+
@apply text-xl;
433+
@apply my-2;
434+
}
435+
436+
.sb-prose-mini h2 {
437+
@apply text-lg;
438+
@apply my-2;
439+
}
440+
441+
.sb-prose-mini h3 {
442+
@apply text-lg;
443+
@apply my-2;
444+
}
445+
446+
.sb-prose-mini h4 {
447+
@apply text-sm;
448+
@apply my-1;
449+
}
450+
451+
.sb-prose-mini h5 {
452+
@apply text-sm;
453+
@apply my-1;
454+
}
455+
456+
.sb-prose-mini hr {
457+
@apply my-2;
458+
}
459+
460+
.sb-prose-mini ol {
461+
@apply list-decimal;
462+
@apply ps-2;
463+
margin: 1.15em 0;
464+
}
465+
466+
.sb-prose-mini ol > li:marker {
467+
@apply font-normal;
468+
}
469+
470+
.sb-prose-mini ul {
471+
@apply list-disc;
472+
@apply ps-2;
473+
margin: 0.75em 0;
474+
}
475+
476+
.sb-prose-mini li {
477+
margin: 3px 0;
478+
}
479+
480+
.sb-prose-mini ol > li {
481+
@apply ps-1.5;
482+
@apply my-1;
483+
}
484+
485+
.sb-prose-mini ul > li {
486+
@apply ps-1.5;
487+
@apply my-1;
488+
}
489+
490+
.sb-prose-mini img {
491+
border-radius: 1.5px;
492+
}
493+
348494
.cm-editor {
349495
@apply rounded-b;
350496
max-height: 80vh;

0 commit comments

Comments
 (0)