Modularize UI, make it a bit more Lisp independent
This commit is contained in:
parent
e1e1b90579
commit
c3edf193c4
19 changed files with 973 additions and 884 deletions
21
src/ui/SpanChip.tsx
Normal file
21
src/ui/SpanChip.tsx
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import type { CodePointSpan } from 'source-region';
|
||||
import { spanLabel } from './format';
|
||||
import type { HoverTarget } from './types';
|
||||
|
||||
export function SpanChip(props: {
|
||||
label: string;
|
||||
span: CodePointSpan;
|
||||
onHover: (target: HoverTarget | undefined) => void;
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
class="span-chip"
|
||||
type="button"
|
||||
onMouseEnter={() => props.onHover({ label: props.label, span: props.span })}
|
||||
onMouseLeave={() => props.onHover(undefined)}
|
||||
>
|
||||
<span>{props.label}</span>
|
||||
<span>{spanLabel(props.span)}</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue