More work on docs

This commit is contained in:
Benjamin Bädorf 2022-03-16 00:38:33 +01:00
parent b699a39b0f
commit 516c82d5c0
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C
12 changed files with 90 additions and 35 deletions

View file

@ -13,7 +13,7 @@ import {
ITreeNode, ITreeNode,
} from '../types'; } from '../types';
import { model } from '../block-helpers'; import { model } from '../block-helpers';
import { Mode, SbMode } from '../mode'; import { SymMode, SbMode } from '../mode';
import { SymBlockLibrary} from '../use-dynamic-blocks'; import { SymBlockLibrary} from '../use-dynamic-blocks';
import { import {
SymBlockTree, SymBlockTree,
@ -58,7 +58,7 @@ export const SbMain = defineComponent({
useResizeObserver(el, SymEditorDimensions); useResizeObserver(el, SymEditorDimensions);
const mode = ref(props.mode); const mode = ref(props.mode);
provide(Mode, mode); provide(SymMode, mode);
const activeBlock = ref(null); const activeBlock = ref(null);
provide(SymActiveBlock, activeBlock); provide(SymActiveBlock, activeBlock);

View file

@ -1,5 +1,8 @@
/**
* The mode the Schlechtenburg editor is currently in
*/
export enum SbMode { export enum SbMode {
Edit = 'edit', Edit = 'edit',
Display = 'display', Display = 'display',
} }
export const Mode = Symbol('Schlechtenburg mode'); export const SymMode = Symbol('Schlechtenburg mode');

View file

@ -4,11 +4,11 @@ import {
reactive, reactive,
} from 'vue'; } from 'vue';
import { IBlockLibrary } from './types'; import { IBlockLibrary } from './types';
import { Mode, SbMode } from './mode'; import { SymMode, SbMode } from './mode';
export const SymBlockLibrary = Symbol('Schlechtenburg block library'); export const SymBlockLibrary = Symbol('Schlechtenburg block library');
export function useDynamicBlocks() { export function useDynamicBlocks() {
const mode = inject(Mode, ref(SbMode.Edit)); const mode = inject(SymMode, ref(SbMode.Edit));
const customBlocks: IBlockLibrary = inject(SymBlockLibrary, reactive({})); const customBlocks: IBlockLibrary = inject(SymBlockLibrary, reactive({}));
const getBlock = (name: string) => customBlocks[name]; const getBlock = (name: string) => customBlocks[name];

View file

@ -3,9 +3,20 @@
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
color: #2c3e50; color: #2c3e50;
padding: 3rem 4rem; display: flex;
&--mode { &--sidemenu {
margin-bottom: 2rem; 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;
} }
} }

View file

@ -11,8 +11,8 @@ export default defineComponent({
setup() { setup() {
return () => <div class="app"> return () => <div class="app">
<SideMenu></SideMenu> <SideMenu class="app--sidemenu"></SideMenu>
<RouterView></RouterView> <RouterView class="app--main"></RouterView>
</div>; </div>;
}, },
}); });

View file

@ -18,8 +18,26 @@ export default defineComponent({
setup(props) { setup(props) {
const docs = props.docs; const docs = props.docs;
console.log(docs);
return () => <section class="docs component-docs"> return () => <section class="docs component-docs">
<h2 id={docs.exportName}>{docs.exportName}</h2> <header class="docs--header">
<h2
class="docs--title"
id={docs.exportName}
>{docs.exportName}</h2>
<p class="docs--type">Component <code>&lt;{docs.displayName} /&gt;</code></p>
</header>
<p class="docs--description">{docs.description}</p>
<h3>Props</h3>
{...(docs.props || []).map(prop => <div class="component-docs--prop">
<h4 class="component-docs--prop-name">{prop.name}</h4>
<p class="component-docs--prop-description">{prop.description}</p>
{prop.type ? <p>Type: <code>{prop.type.name}</code></p> : null}
{prop.defaultValue ? <p>Default: <code>{prop.defaultValue.value}</code></p>: null}
</div>)}
</section>; </section>;
}, },
}); });

View file

@ -23,14 +23,23 @@ export default defineComponent({
setup(props) { setup(props) {
const docs = props.docs; const docs = props.docs;
console.log(docs);
return () => <section class="docs ts-docs"> return () => <section class="docs ts-docs">
<h2 id={docs.name}> <header class="docs--header">
<h2
class="docs--title"
id={docs.name}
>
{docs.name} {docs.name}
{docs.typeParameters ? getTypeParamString(docs.typeParameters) : ''} {docs.typeParameters ? getTypeParamString(docs.typeParameters) : ''}
</h2> </h2>
<p>{docs.kindString}</p> <p class="docs--type">{docs.kindString}</p>
<p>{docs.comment}</p> </header>
<p class="docs--description">{docs.comment?.shortText || ''}</p>
{...(docs.children || []).map(child => <pre><code>
{child.name}: {child.type?.name}
</code></pre>)}
</section>; </section>;
}, },
}); });

View file

@ -1,5 +1,4 @@
export const getShortPackageName = (name: string) => { export const getShortPackageName = (name: string) => {
const parts = name.split('/'); const parts = name.split('/');
console.log(parts);
return parts[1] || parts[0] || name; return parts[1] || parts[0] || name;
} }

View file

@ -17,7 +17,7 @@ export default defineComponent({
const packageName = route.params.package; const packageName = route.params.package;
const docs = getByName(Array.isArray(packageName) ? packageName[0] : packageName); const docs = getByName(Array.isArray(packageName) ? packageName[0] : packageName);
if (!docs) { if (!docs) {
return () => <div>Unknown package name {packageName}</div> return () => <div>Unknown package name {packageName}</div>;
} }
const { lib, components } = docs; const { lib, components } = docs;

View file

@ -1,13 +1,12 @@
export default [ export default [
{ {
name: 'home', name: 'home',
path: '/', path: '/',
component: () => import('./pages/Introduction').then(d => d.default), component: () => import('./pages/Introduction'),
}, },
{ {
name: 'package', name: 'package',
path: '/@schlechtenburg/:package', path: '/@schlechtenburg/:package',
component: () => import('./pages/Package').then(d => d.default), component: () => import('./pages/Package'),
}, },
] ]

View file

@ -0,0 +1,10 @@
.sidemenu {
&--link {
color: #0080ff;
padding:
}
&--package-child {
}
}

View file

@ -19,18 +19,24 @@ export default defineComponent({
setup(props) { setup(props) {
const { lib, components } = props.package; const { lib, components } = props.package;
const shortName = getShortPackageName(lib.name); const shortName = getShortPackageName(lib.name);
return () => <div class="sidemenu-package"> return () => <div>
<RouterLink to={{ <RouterLink
class="sidemenu--link sidemenu--link_package"
to={{
name: 'package', name: 'package',
params: { package: shortName }, params: { package: shortName },
}}>{lib.name}</RouterLink> }}
<ul> >{lib.name}</RouterLink>
{...(lib.children || []).map(child => <li> <ul class="sidemenu--package-children">
<RouterLink to={{ {...(lib.children || []).map(child => <li class="sidemenu--package-child">
<RouterLink
class="sidemenu--link"
to={{
name: 'package', name: 'package',
params: { package: shortName }, params: { package: shortName },
hash: '#' + child.name, hash: '#' + child.name,
}}>{child.name}</RouterLink> }}
>{child.name}</RouterLink>
</li>)} </li>)}
</ul> </ul>
</div>; </div>;