Skip to content

Commit

Permalink
docs: output example
Browse files Browse the repository at this point in the history
  • Loading branch information
BroKun committed Oct 19, 2023
1 parent c8494f5 commit ab1d4a6
Show file tree
Hide file tree
Showing 8 changed files with 775 additions and 1 deletion.
10 changes: 10 additions & 0 deletions apps/docs/docs/examples/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: 输出示例
order: 0
nav:
path: /examples
---

# Libro 输出示例

<code src="../../src/output" compact="true"></code>
2 changes: 1 addition & 1 deletion apps/docs/docs/examples/workbench.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 工作台
order: 0
order: 1
nav:
path: /examples
---
Expand Down
1 change: 1 addition & 0 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@difizen/mana-app": "alpha",
"@difizen/mana-react": "alpha",
"@difizen/libro-jupyter": "^0.0.2-alpha.0",
"@difizen/libro-core": "^0.0.2-alpha.0",
"@ant-design/icons": "^4.7.0",
"react": "^18.2.0",
"antd": "^5.8.6"
Expand Down
707 changes: 707 additions & 0 deletions apps/docs/src/output/OutputExamples.ipynb.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions apps/docs/src/output/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { LibroService } from '@difizen/libro-core';
import { RootSlotId } from '@difizen/mana-app';
import { ApplicationContribution, SlotViewManager } from '@difizen/mana-app';
import { inject, singleton } from '@difizen/mana-app';

@singleton({ contrib: ApplicationContribution })
export class LibroApp implements ApplicationContribution {
@inject(LibroService) libroService: LibroService;
@inject(SlotViewManager) slotViewManager: SlotViewManager;

async onStart() {
const view = await this.libroService.getOrCreateView({});
this.slotViewManager.addView(view, RootSlotId);
}
}
15 changes: 15 additions & 0 deletions apps/docs/src/output/content.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { INotebookContent } from '@difizen/libro-jupyter';
import { ContentContribution } from '@difizen/libro-jupyter';
import { singleton } from '@difizen/mana-app';

import content from './OutputExamples.ipynb.json';

@singleton({ contrib: ContentContribution })
export class ExampleContentContribution implements ContentContribution {
canHandle = () => {
return 10;
};
async loadContent() {
return content as INotebookContent;
}
}
4 changes: 4 additions & 0 deletions apps/docs/src/output/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.libro-example-output {
width: 100%;
height: calc(100vh - 190px);
}
22 changes: 22 additions & 0 deletions apps/docs/src/output/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { LibroJupyterModule } from '@difizen/libro-jupyter';
import { ManaAppPreset, ManaComponents, ManaModule } from '@difizen/mana-app';

import { LibroApp } from './app.js';
import { ExampleContentContribution } from './content.js';
import './index.less';

const BaseModule = ManaModule.create().register(LibroApp, ExampleContentContribution);

const App = (): JSX.Element => {
return (
<div className="libro-example-output">
<ManaComponents.Application
key={'libro'}
asChild={true}
modules={[ManaAppPreset, LibroJupyterModule, BaseModule]}
/>
</div>
);
};

export default App;

0 comments on commit ab1d4a6

Please sign in to comment.