-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
264 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Box, Flex, Tabs } from '@radix-ui/themes' | ||
import { updateSearchParams, type ViewMode } from '../../router' | ||
import ViewAsD2 from './other-formats/ViewAsD2' | ||
import ViewAsDot from './other-formats/ViewAsDot' | ||
import ViewAsMmd from './other-formats/ViewAsMmd' | ||
import styles from './view-page.module.css' | ||
|
||
type Props = { | ||
viewMode: Exclude<ViewMode, 'react'> | ||
viewId: string | ||
} | ||
export default function ViewDiagramInOtherFormats({ viewId, viewMode }: Props) { | ||
return ( | ||
<Flex | ||
asChild | ||
position={'fixed'} | ||
inset={'0'} | ||
pt={'8'} | ||
align={'stretch'} | ||
px={'2'} | ||
direction={'column'} | ||
> | ||
<Tabs.Root | ||
value={viewMode} | ||
onValueChange={mode => mode !== viewMode && updateSearchParams({ mode: mode as ViewMode })} | ||
> | ||
<Box asChild shrink={'0'} grow={'0'}> | ||
<Tabs.List> | ||
<Tabs.Trigger value='dot'>Graphviz</Tabs.Trigger> | ||
<Tabs.Trigger value='mmd'>Mermaid</Tabs.Trigger> | ||
<Tabs.Trigger value='d2'>D2</Tabs.Trigger> | ||
</Tabs.List> | ||
</Box> | ||
|
||
<Box p='2' className={styles.otherFormats}> | ||
<Tabs.Content value='dot'> | ||
<ViewAsDot viewId={viewId} /> | ||
</Tabs.Content> | ||
|
||
<Tabs.Content value='mmd'> | ||
<ViewAsMmd viewId={viewId} /> | ||
</Tabs.Content> | ||
|
||
<Tabs.Content value='d2'> | ||
<ViewAsD2 viewId={viewId} /> | ||
</Tabs.Content> | ||
</Box> | ||
</Tabs.Root> | ||
</Flex> | ||
) | ||
|
||
// switch (viewMode) { | ||
// case 'dot': | ||
// return <ViewAsDot viewId={viewId} /> | ||
// case 'd2': | ||
// return <ViewAsD2 viewId={viewId} /> | ||
// case 'mmd': | ||
// return <ViewAsMmd viewId={viewId} /> | ||
// default: | ||
// nonexhaustive(viewMode) | ||
// } | ||
} |
32 changes: 10 additions & 22 deletions
32
packages/likec4/app/src/pages/view-page/other-formats/ViewAsD2.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,25 @@ | ||
import { Box, Code, Flex, ScrollArea } from '@radix-ui/themes' | ||
import { D2Source } from '~likec4-d2-sources' | ||
import { d2Source } from 'virtual:likec4/d2-sources' | ||
|
||
type ViewAsDotProps = { | ||
viewId: string | ||
} | ||
|
||
export default function ViewAsD2({ viewId }: ViewAsDotProps) { | ||
return ( | ||
<Flex position={'fixed'} inset='0' pt={'8'} align={'stretch'} direction={'row'} px={'2'}> | ||
<ScrollArea scrollbars='both'> | ||
<Box | ||
grow={'1'} | ||
shrink={'1'} | ||
py={'3'} | ||
asChild | ||
display={'block'} | ||
p='2' | ||
style={{ | ||
overflow: 'scroll' | ||
whiteSpace: 'pre' | ||
}} | ||
> | ||
<ScrollArea scrollbars='both'> | ||
<Box | ||
asChild | ||
display={'block'} | ||
p='2' | ||
style={{ | ||
whiteSpace: 'pre' | ||
}} | ||
> | ||
<Code variant='soft' autoFocus> | ||
<D2Source viewId={viewId} /> | ||
</Code> | ||
</Box> | ||
</ScrollArea> | ||
<Code variant='soft' autoFocus> | ||
{d2Source(viewId)} | ||
</Code> | ||
</Box> | ||
<Box grow={'1'}>...</Box> | ||
</Flex> | ||
</ScrollArea> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
packages/likec4/app/src/pages/view-page/other-formats/index.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.