mirror of
https://github.com/zadam/trilium.git
synced 2026-03-16 09:00:25 +01:00
chore(mermaid): basic logic for content switcher
This commit is contained in:
15
apps/client/src/widgets/layout/NoteContentSwitcher.css
Normal file
15
apps/client/src/widgets/layout/NoteContentSwitcher.css
Normal file
@@ -0,0 +1,15 @@
|
||||
.note-content-switcher {
|
||||
--badge-radius: 12px;
|
||||
position: relative;
|
||||
top: 5px;
|
||||
display: flex;
|
||||
min-height: 35px;
|
||||
gap: 5px;
|
||||
|
||||
.ext-badge {
|
||||
--color: var(--input-background-color);
|
||||
color: var(--main-text-color);
|
||||
font-size: 0.9rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,25 @@
|
||||
import { ComponentChildren } from "preact";
|
||||
import "./NoteContentSwitcher.css";
|
||||
|
||||
import { Badge } from "../react/Badge";
|
||||
|
||||
export interface NoteContentTemplate {
|
||||
name: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
interface NoteContentSwitcherProps {
|
||||
children: ComponentChildren;
|
||||
templates: NoteContentTemplate[];
|
||||
}
|
||||
|
||||
export default function NoteContentSwitcher({ children }: NoteContentSwitcherProps) {
|
||||
return <p>{children}</p>;
|
||||
export default function NoteContentSwitcher({ templates }: NoteContentSwitcherProps) {
|
||||
return (
|
||||
<div className="note-content-switcher">
|
||||
{templates.map(sample => (
|
||||
<Badge
|
||||
key={sample.name}
|
||||
text={sample.name}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { getMermaidConfig, loadElkIfNeeded, postprocessMermaidSvg } from "../../
|
||||
import NoteContentSwitcher from "../../layout/NoteContentSwitcher";
|
||||
import SvgSplitEditor from "../helpers/SvgSplitEditor";
|
||||
import { TypeWidgetProps } from "../type_widget";
|
||||
import SAMPLE_DIAGRAMS from "./sample_diagrams";
|
||||
|
||||
let idCounter = 1;
|
||||
let registeredErrorReporter = false;
|
||||
@@ -33,9 +34,7 @@ export default function Mermaid(props: TypeWidgetProps) {
|
||||
renderSvg={renderSvg}
|
||||
noteType="mermaid"
|
||||
extraContent={(
|
||||
<NoteContentSwitcher>
|
||||
Foo
|
||||
</NoteContentSwitcher>
|
||||
<NoteContentSwitcher templates={SAMPLE_DIAGRAMS} />
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { NoteContentTemplate } from "../../layout/NoteContentSwitcher";
|
||||
|
||||
const SAMPLE_DIAGRAMS: NoteContentTemplate[] = [
|
||||
{
|
||||
name: "Flowchart",
|
||||
content: `\
|
||||
flowchart TD
|
||||
A[Christmas] -->|Get money| B(Go shopping)
|
||||
B --> C{Let me think}
|
||||
C -->|One| D[Laptop]
|
||||
C -->|Two| E[iPhone]
|
||||
C -->|Three| F[fa:fa-car Car]
|
||||
`
|
||||
}
|
||||
];
|
||||
|
||||
export default SAMPLE_DIAGRAMS;
|
||||
Reference in New Issue
Block a user