likec4 0.40.1-build.2 → 0.40.1-build.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/__app__/likec4.css +4 -71
- package/dist/__app__/src/App.jsx +3 -7
- package/dist/__app__/src/components/DiagramNotFound.jsx +2 -2
- package/dist/__app__/src/components/ThemePanelToggle.jsx +11 -9
- package/dist/__app__/src/components/sidebar/Sidebar.jsx +1 -1
- package/dist/__app__/src/components/view-page/ShareDialog.jsx +5 -2
- package/dist/__app__/src/components/view-page/ViewActionsToolbar.jsx +4 -2
- package/dist/__app__/src/main.jsx +1 -4
- package/dist/__app__/src/pages/export.page.jsx +7 -6
- package/dist/__app__/src/router.js +18 -2
- package/dist/cli/index.js +97 -97
- package/package.json +6 -5
- package/dist/__app__/src/pages/export.module.css +0 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Denis Davydkov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/__app__/likec4.css
CHANGED
|
@@ -4,78 +4,7 @@
|
|
|
4
4
|
@tailwind components;
|
|
5
5
|
@tailwind utilities;
|
|
6
6
|
|
|
7
|
-
/* @layer base {
|
|
8
|
-
|
|
9
|
-
:root {
|
|
10
|
-
--background: 0 0% 100%;
|
|
11
|
-
--foreground: 222.2 84% 4.9%;
|
|
12
|
-
|
|
13
|
-
--card: 0 0% 100%;
|
|
14
|
-
--card-foreground: 222.2 84% 4.9%;
|
|
15
|
-
|
|
16
|
-
--popover: 0 0% 100%;
|
|
17
|
-
--popover-foreground: 222.2 84% 4.9%;
|
|
18
|
-
|
|
19
|
-
--primary: 222.2 47.4% 11.2%;
|
|
20
|
-
--primary-foreground: 210 40% 98%;
|
|
21
|
-
|
|
22
|
-
--secondary: 210 40% 96.1%;
|
|
23
|
-
--secondary-foreground: 222.2 47.4% 11.2%;
|
|
24
|
-
yarn add @fontsource-variable/noto-sans-tc
|
|
25
|
-
--muted: 210 40% 96.1%;
|
|
26
|
-
--muted-foreground: 215.4 16.3% 46.9%;
|
|
27
|
-
|
|
28
|
-
--accent: 210 40% 96.1%;
|
|
29
|
-
--accent-foreground: 222.2 47.4% 11.2%;
|
|
30
|
-
|
|
31
|
-
--destructive: 0 84.2% 60.2%;
|
|
32
|
-
--destructive-foreground: 210 40% 98%;
|
|
33
|
-
|
|
34
|
-
--border: 214.3 31.8% 91.4%;
|
|
35
|
-
--input: 214.3 31.8% 91.4%;
|
|
36
|
-
--ring: 222.2 84% 4.9%;
|
|
37
|
-
|
|
38
|
-
--radius: 0.5rem;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.dark {
|
|
42
|
-
--background: 222.2 84% 4.9%;
|
|
43
|
-
--foreground: 210 40% 98%;
|
|
44
|
-
|
|
45
|
-
--card: 222.2 84% 4.9%;
|
|
46
|
-
--card-foreground: 210 40% 98%;
|
|
47
|
-
|
|
48
|
-
--popover: 222.2 84% 4.9%;
|
|
49
|
-
--popover-foreground: 210 40% 98%;
|
|
50
|
-
|
|
51
|
-
--primary: 210 40% 98%;
|
|
52
|
-
--primary-foreground: 222.2 47.4% 11.2%;
|
|
53
|
-
|
|
54
|
-
--secondary: 217.2 32.6% 17.5%;
|
|
55
|
-
--secondary-foreground: 210 40% 98%;
|
|
56
|
-
|
|
57
|
-
--muted: 217.2 32.6% 17.5%;
|
|
58
|
-
--muted-foreground: 215 20.2% 65.1%;
|
|
59
|
-
|
|
60
|
-
--accent: 217.2 32.6% 17.5%;
|
|
61
|
-
--accent-foreground: 210 40% 98%;
|
|
62
|
-
|
|
63
|
-
--destructive: 0 62.8% 30.6%;
|
|
64
|
-
--destructive-foreground: 210 40% 98%;
|
|
65
|
-
|
|
66
|
-
--border: 217.2 32.6% 17.5%;
|
|
67
|
-
--input: 217.2 32.6% 17.5%;
|
|
68
|
-
--ring: 212.7 26.8% 83.9%;
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
} */
|
|
73
|
-
|
|
74
7
|
.radix-themes {
|
|
75
|
-
/* --default-font-family: 'Rubik Variable',-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji'; */
|
|
76
|
-
--font-weight-light: 200;
|
|
77
|
-
--font-weight-regular: 400;
|
|
78
|
-
--font-weight-medium: 500;
|
|
79
8
|
--font-weight-bold: 600;
|
|
80
9
|
}
|
|
81
10
|
|
|
@@ -83,3 +12,7 @@ html, body {
|
|
|
83
12
|
margin: 0;
|
|
84
13
|
padding: 0;
|
|
85
14
|
}
|
|
15
|
+
|
|
16
|
+
.export-page {
|
|
17
|
+
--color-page-background: transparent !important;
|
|
18
|
+
}
|
package/dist/__app__/src/App.jsx
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import { Provider } from 'jotai';
|
|
2
|
-
// import { useAtomsDevtools } from 'jotai-devtools'
|
|
3
2
|
import { Fragment } from 'react';
|
|
4
3
|
import { Sidebar } from './components';
|
|
5
4
|
import { ExportPage, IndexPage, ViewPage } from './pages';
|
|
6
5
|
import { useRoute } from './router';
|
|
6
|
+
import { Theme } from '@radix-ui/themes';
|
|
7
7
|
const Routes = () => {
|
|
8
8
|
const r = useRoute();
|
|
9
|
-
return (
|
|
9
|
+
return (<Theme accentColor='iris' panelBackground='translucent' appearance={r.params?.theme} radius='small'>
|
|
10
10
|
{r.route === 'index' && <IndexPage key='index'/>}
|
|
11
11
|
{r.route === 'view' && <ViewPage key='view' viewId={r.params.viewId} showUI={r.showUI}/>}
|
|
12
12
|
{r.route === 'export' && (<ExportPage key='export' viewId={r.params.viewId} padding={r.params.padding}/>)}
|
|
13
13
|
{r.showUI && (<Fragment key='ui'>
|
|
14
14
|
<Sidebar />
|
|
15
15
|
</Fragment>)}
|
|
16
|
-
|
|
16
|
+
</Theme>);
|
|
17
17
|
};
|
|
18
|
-
// const AtomsDevTools = import.meta.env.DEV ? ({ children }: PropsWithChildren) => {
|
|
19
|
-
// useAtomsDevtools('demo')
|
|
20
|
-
// return <>{children}</>
|
|
21
|
-
// } : Fragment
|
|
22
18
|
export default function App() {
|
|
23
19
|
return (<Provider>
|
|
24
20
|
<Routes />
|
|
@@ -15,9 +15,9 @@ export const DiagramNotFound = () => {
|
|
|
15
15
|
Diagram not found
|
|
16
16
|
</Heading>
|
|
17
17
|
<Text as='div'>The diagram you are looking for does not exist.</Text>
|
|
18
|
-
<Box>
|
|
18
|
+
<Box pt='2'>
|
|
19
19
|
<Button variant='soft' color='amber' onClick={() => $pages.index.open()}>
|
|
20
|
-
|
|
20
|
+
Go to overview
|
|
21
21
|
</Button>
|
|
22
22
|
</Box>
|
|
23
23
|
</Flex>
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { MoonIcon } from '@radix-ui/react-icons';
|
|
2
2
|
import { IconButton, ThemePanel } from '@radix-ui/themes';
|
|
3
3
|
import { useToggle } from '@react-hookz/web/esm';
|
|
4
|
-
export const ThemePanelToggle =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
4
|
+
export const ThemePanelToggle = import.meta.env.PROD
|
|
5
|
+
? () => null
|
|
6
|
+
: () => {
|
|
7
|
+
const [isOpened, toggle] = useToggle(false, true);
|
|
8
|
+
return (<>
|
|
9
|
+
<IconButton color='gray' variant={isOpened ? 'solid' : 'soft'} onClick={toggle} size={'2'}>
|
|
10
|
+
<MoonIcon width={16} height={16}/>
|
|
11
|
+
</IconButton>
|
|
12
|
+
{isOpened && <ThemePanel style={{ top: 50 }}/>}
|
|
13
|
+
</>);
|
|
14
|
+
};
|
|
@@ -26,7 +26,7 @@ const embedCode = (diagram, theme) => {
|
|
|
26
26
|
export const ShareDialog = ({ diagram }) => {
|
|
27
27
|
const [theme, setTheme] = useState('system');
|
|
28
28
|
const { code, href } = embedCode(diagram, theme);
|
|
29
|
-
return (<Dialog.Content size=
|
|
29
|
+
return (<Dialog.Content size='2' style={{ maxWidth: 800, minWidth: 280 }}>
|
|
30
30
|
<Tabs.Root defaultValue='embed'>
|
|
31
31
|
<Tabs.List>
|
|
32
32
|
<Tabs.Trigger value='embed'>Embed</Tabs.Trigger>
|
|
@@ -42,8 +42,11 @@ export const ShareDialog = ({ diagram }) => {
|
|
|
42
42
|
<ExclamationTriangleIcon />
|
|
43
43
|
</Callout.Icon>
|
|
44
44
|
<Callout.Text>
|
|
45
|
-
This is a local URL. You need to build and deploy
|
|
45
|
+
This is a local URL. You need to build your project and deploy to a public URL
|
|
46
46
|
to make it available for embedding.
|
|
47
|
+
<br />
|
|
48
|
+
<Code>likec4 build --help</Code> builds your project as static website (single
|
|
49
|
+
.html file)
|
|
47
50
|
</Callout.Text>
|
|
48
51
|
</Callout.Root>)}
|
|
49
52
|
<label>
|
|
@@ -25,9 +25,11 @@ const ExportMenu = ({ diagramApi, children }) => (<DropdownMenu.Root>
|
|
|
25
25
|
// },
|
|
26
26
|
// })
|
|
27
27
|
}}>
|
|
28
|
-
Export as
|
|
28
|
+
Export as .png
|
|
29
29
|
</DropdownMenu.Item>
|
|
30
|
-
<DropdownMenu.Item>Export as
|
|
30
|
+
<DropdownMenu.Item>Export as .dot</DropdownMenu.Item>
|
|
31
|
+
<DropdownMenu.Item>Export as .d2</DropdownMenu.Item>
|
|
32
|
+
<DropdownMenu.Item>Export as .mmd</DropdownMenu.Item>
|
|
31
33
|
</DropdownMenu.Group>
|
|
32
34
|
<DropdownMenu.Separator />
|
|
33
35
|
<DropdownMenu.Label>
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { Theme } from '@radix-ui/themes';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import ReactDOM from 'react-dom/client';
|
|
4
3
|
import App from './App';
|
|
5
4
|
ReactDOM.createRoot(document.getElementById('like4-root')).render(<React.StrictMode>
|
|
6
|
-
<
|
|
7
|
-
<App />
|
|
8
|
-
</Theme>
|
|
5
|
+
<App />
|
|
9
6
|
</React.StrictMode>);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Diagram } from '@likec4/diagrams';
|
|
2
|
-
import {
|
|
3
|
-
import { useLayoutEffect } from 'react';
|
|
4
|
-
import styles from './export.module.css';
|
|
2
|
+
import { useIsomorphicLayoutEffect, useWindowSize } from '@react-hookz/web/esm';
|
|
5
3
|
import { DiagramNotFound } from '../components';
|
|
4
|
+
import { useLikeC4View } from '../data';
|
|
6
5
|
export function ExportPage({ viewId, padding }) {
|
|
6
|
+
const { width, height } = useWindowSize();
|
|
7
7
|
const diagram = useLikeC4View(viewId);
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
useIsomorphicLayoutEffect(() => {
|
|
9
|
+
// see ../../likec4.css
|
|
10
|
+
const classname = 'export-page';
|
|
10
11
|
document.body.parentElement?.classList.add(classname);
|
|
11
12
|
return () => {
|
|
12
13
|
document.body.parentElement?.classList.remove(classname);
|
|
@@ -15,5 +16,5 @@ export function ExportPage({ viewId, padding }) {
|
|
|
15
16
|
if (!diagram) {
|
|
16
17
|
return <DiagramNotFound />;
|
|
17
18
|
}
|
|
18
|
-
return (<Diagram animate={false} pannable={false} zoomable={false} diagram={diagram} padding={padding} width={
|
|
19
|
+
return (<Diagram animate={false} pannable={false} zoomable={false} diagram={diagram} padding={padding} width={width} height={height}/>);
|
|
19
20
|
}
|
|
@@ -4,13 +4,28 @@ import { useStore } from '@nanostores/react';
|
|
|
4
4
|
import { createSearchParams } from '@nanostores/router';
|
|
5
5
|
import { computed } from 'nanostores';
|
|
6
6
|
const $searchParams = createSearchParams();
|
|
7
|
+
const asTheme = (v) => {
|
|
8
|
+
const vlower = v?.toLowerCase();
|
|
9
|
+
if (vlower === 'light' || vlower === 'dark') {
|
|
10
|
+
return vlower;
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
};
|
|
14
|
+
const asPadding = (v) => {
|
|
15
|
+
const parsed = v ? parseFloat(v) : undefined;
|
|
16
|
+
if (parsed && isFinite(parsed) && isNaN(parsed) === false) {
|
|
17
|
+
return Math.round(parsed);
|
|
18
|
+
}
|
|
19
|
+
return 20;
|
|
20
|
+
};
|
|
7
21
|
const $route = computed($searchParams, v => {
|
|
8
22
|
if ('embed' in v) {
|
|
9
23
|
return {
|
|
10
24
|
route: 'export',
|
|
11
25
|
params: {
|
|
12
26
|
viewId: v.embed,
|
|
13
|
-
padding:
|
|
27
|
+
padding: asPadding(v.padding),
|
|
28
|
+
theme: asTheme(v.theme)
|
|
14
29
|
},
|
|
15
30
|
showUI: false
|
|
16
31
|
};
|
|
@@ -20,7 +35,8 @@ const $route = computed($searchParams, v => {
|
|
|
20
35
|
route: 'export',
|
|
21
36
|
params: {
|
|
22
37
|
viewId: v.export,
|
|
23
|
-
padding:
|
|
38
|
+
padding: asPadding(v.padding),
|
|
39
|
+
theme: asTheme(v.theme)
|
|
24
40
|
},
|
|
25
41
|
showUI: false
|
|
26
42
|
};
|