From 516c82d5c0c3d0b697025fe91f412a2051bf6033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=A4dorf?= Date: Wed, 16 Mar 2022 00:38:33 +0100 Subject: [PATCH] More work on docs --- .../core/lib/components/Schlechtenburg.tsx | 4 +-- packages/core/lib/mode.ts | 5 +++- packages/core/lib/use-dynamic-blocks.ts | 4 +-- packages/docs/lib/App.scss | 17 +++++++++-- packages/docs/lib/App.tsx | 4 +-- packages/docs/lib/ComponentDocs.tsx | 20 ++++++++++++- packages/docs/lib/TsDocs.tsx | 23 +++++++++----- packages/docs/lib/package.ts | 1 - packages/docs/lib/pages/Package.tsx | 2 +- packages/docs/lib/routes.ts | 5 ++-- packages/docs/lib/sidemenu/Sidemenu.scss | 10 +++++++ .../docs/lib/sidemenu/SidemenuPackage.tsx | 30 +++++++++++-------- 12 files changed, 90 insertions(+), 35 deletions(-) diff --git a/packages/core/lib/components/Schlechtenburg.tsx b/packages/core/lib/components/Schlechtenburg.tsx index 16ef119..0fe44a3 100644 --- a/packages/core/lib/components/Schlechtenburg.tsx +++ b/packages/core/lib/components/Schlechtenburg.tsx @@ -13,7 +13,7 @@ import { ITreeNode, } from '../types'; import { model } from '../block-helpers'; -import { Mode, SbMode } from '../mode'; +import { SymMode, SbMode } from '../mode'; import { SymBlockLibrary} from '../use-dynamic-blocks'; import { SymBlockTree, @@ -58,7 +58,7 @@ export const SbMain = defineComponent({ useResizeObserver(el, SymEditorDimensions); const mode = ref(props.mode); - provide(Mode, mode); + provide(SymMode, mode); const activeBlock = ref(null); provide(SymActiveBlock, activeBlock); diff --git a/packages/core/lib/mode.ts b/packages/core/lib/mode.ts index 4139fb9..3325c31 100644 --- a/packages/core/lib/mode.ts +++ b/packages/core/lib/mode.ts @@ -1,5 +1,8 @@ +/** + * The mode the Schlechtenburg editor is currently in + */ export enum SbMode { Edit = 'edit', Display = 'display', } -export const Mode = Symbol('Schlechtenburg mode'); +export const SymMode = Symbol('Schlechtenburg mode'); diff --git a/packages/core/lib/use-dynamic-blocks.ts b/packages/core/lib/use-dynamic-blocks.ts index 23fe5a2..1da0ce0 100644 --- a/packages/core/lib/use-dynamic-blocks.ts +++ b/packages/core/lib/use-dynamic-blocks.ts @@ -4,11 +4,11 @@ import { reactive, } from 'vue'; import { IBlockLibrary } from './types'; -import { Mode, SbMode } from './mode'; +import { SymMode, SbMode } from './mode'; export const SymBlockLibrary = Symbol('Schlechtenburg block library'); export function useDynamicBlocks() { - const mode = inject(Mode, ref(SbMode.Edit)); + const mode = inject(SymMode, ref(SbMode.Edit)); const customBlocks: IBlockLibrary = inject(SymBlockLibrary, reactive({})); const getBlock = (name: string) => customBlocks[name]; diff --git a/packages/docs/lib/App.scss b/packages/docs/lib/App.scss index cce0aed..f0b8357 100644 --- a/packages/docs/lib/App.scss +++ b/packages/docs/lib/App.scss @@ -3,9 +3,20 @@ -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; color: #2c3e50; - padding: 3rem 4rem; + display: flex; - &--mode { - margin-bottom: 2rem; + &--sidemenu { + width: 300px; + padding: 3rem 1rem; + } + + &--main { + padding: 3rem 4rem; + margin: 0 auto; + flex-basis: 700px; + flex-shrink: 1; + flex-grow: 0; + display: flex; + flex-direction: column; } } diff --git a/packages/docs/lib/App.tsx b/packages/docs/lib/App.tsx index ac604d0..7a700ec 100644 --- a/packages/docs/lib/App.tsx +++ b/packages/docs/lib/App.tsx @@ -11,8 +11,8 @@ export default defineComponent({ setup() { return () =>
- - + +
; }, }); diff --git a/packages/docs/lib/ComponentDocs.tsx b/packages/docs/lib/ComponentDocs.tsx index acfc421..ce24fbb 100644 --- a/packages/docs/lib/ComponentDocs.tsx +++ b/packages/docs/lib/ComponentDocs.tsx @@ -18,8 +18,26 @@ export default defineComponent({ setup(props) { const docs = props.docs; + console.log(docs); return () =>
-

{docs.exportName}

+
+

{docs.exportName}

+

Component <{docs.displayName} />

+
+ +

{docs.description}

+ +

Props

+ + {...(docs.props || []).map(prop =>
+

{prop.name}

+

{prop.description}

+ {prop.type ?

Type: {prop.type.name}

: null} + {prop.defaultValue ?

Default: {prop.defaultValue.value}

: null} +
)}
; }, }); diff --git a/packages/docs/lib/TsDocs.tsx b/packages/docs/lib/TsDocs.tsx index e4d204c..10bfd86 100644 --- a/packages/docs/lib/TsDocs.tsx +++ b/packages/docs/lib/TsDocs.tsx @@ -23,14 +23,23 @@ export default defineComponent({ setup(props) { const docs = props.docs; - console.log(docs); return () =>
-

- {docs.name} - {docs.typeParameters ? getTypeParamString(docs.typeParameters) : ''} -

-

{docs.kindString}

-

{docs.comment}

+
+

+ {docs.name} + {docs.typeParameters ? getTypeParamString(docs.typeParameters) : ''} +

+

{docs.kindString}

+
+ +

{docs.comment?.shortText || ''}

+ + {...(docs.children || []).map(child =>

+        {child.name}: {child.type?.name}
+      
)}
; }, }); diff --git a/packages/docs/lib/package.ts b/packages/docs/lib/package.ts index 51b9557..9214c3d 100644 --- a/packages/docs/lib/package.ts +++ b/packages/docs/lib/package.ts @@ -1,5 +1,4 @@ export const getShortPackageName = (name: string) => { const parts = name.split('/'); - console.log(parts); return parts[1] || parts[0] || name; } diff --git a/packages/docs/lib/pages/Package.tsx b/packages/docs/lib/pages/Package.tsx index 1a0739a..c342666 100644 --- a/packages/docs/lib/pages/Package.tsx +++ b/packages/docs/lib/pages/Package.tsx @@ -17,7 +17,7 @@ export default defineComponent({ const packageName = route.params.package; const docs = getByName(Array.isArray(packageName) ? packageName[0] : packageName); if (!docs) { - return () =>
Unknown package name {packageName}
+ return () =>
Unknown package name {packageName}
; } const { lib, components } = docs; diff --git a/packages/docs/lib/routes.ts b/packages/docs/lib/routes.ts index f1959cd..27af133 100644 --- a/packages/docs/lib/routes.ts +++ b/packages/docs/lib/routes.ts @@ -1,13 +1,12 @@ - export default [ { name: 'home', path: '/', - component: () => import('./pages/Introduction').then(d => d.default), + component: () => import('./pages/Introduction'), }, { name: 'package', path: '/@schlechtenburg/:package', - component: () => import('./pages/Package').then(d => d.default), + component: () => import('./pages/Package'), }, ] diff --git a/packages/docs/lib/sidemenu/Sidemenu.scss b/packages/docs/lib/sidemenu/Sidemenu.scss index e69de29..61d01b8 100644 --- a/packages/docs/lib/sidemenu/Sidemenu.scss +++ b/packages/docs/lib/sidemenu/Sidemenu.scss @@ -0,0 +1,10 @@ +.sidemenu { + &--link { + color: #0080ff; + padding: + } + + &--package-child { + + } +} diff --git a/packages/docs/lib/sidemenu/SidemenuPackage.tsx b/packages/docs/lib/sidemenu/SidemenuPackage.tsx index 08238c9..686ed5d 100644 --- a/packages/docs/lib/sidemenu/SidemenuPackage.tsx +++ b/packages/docs/lib/sidemenu/SidemenuPackage.tsx @@ -19,18 +19,24 @@ export default defineComponent({ setup(props) { const { lib, components } = props.package; const shortName = getShortPackageName(lib.name); - return () =>
- {lib.name} -