From a2b89411b05fa6f2e721a49b7f90f46fad12d20b Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 7 Mar 2018 10:50:38 +0100 Subject: Move example to it's own folder --- packages/react-docs/example/ts/index.tsx | 67 ++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 packages/react-docs/example/ts/index.tsx (limited to 'packages/react-docs/example/ts/index.tsx') diff --git a/packages/react-docs/example/ts/index.tsx b/packages/react-docs/example/ts/index.tsx new file mode 100644 index 000000000..8cfa8451c --- /dev/null +++ b/packages/react-docs/example/ts/index.tsx @@ -0,0 +1,67 @@ +import 'basscss/css/basscss.css'; +import 'less/all.less'; +import { MuiThemeProvider } from 'material-ui/styles'; +import * as React from 'react'; +import { render } from 'react-dom'; +import * as injectTapEventPlugin from 'react-tap-event-plugin'; + +import { Documentation } from '../../src/ts/components/documentation'; +import { DocsInfo } from '../../src/ts/docs_info'; +import { DocsInfoConfig, SupportedDocJson } from '../../src/ts/types'; +injectTapEventPlugin(); + +/* tslint:disable:no-var-requires */ +const IntroMarkdown = require('md/introduction'); +/* tslint:enable:no-var-requires */ + +const docSections = { + introduction: 'introduction', + web3Wrapper: 'web3Wrapper', +}; + +const docsInfoConfig: DocsInfoConfig = { + id: 'web3Wrapper', + type: SupportedDocJson.TypeDoc, + displayName: 'Web3 Wrapper', + packageUrl: 'https://github.com/0xProject/0x-monorepo', + menu: { + introduction: [docSections.introduction], + web3Wrapper: [docSections.web3Wrapper], + }, + sectionNameToMarkdown: { + [docSections.introduction]: IntroMarkdown, + }, + // Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is + // currently no way to extract the re-exported types from index.ts via TypeDoc :( + publicTypes: ['TxData', 'TransactionReceipt', 'RawLogEntry'], + sectionNameToModulePath: { + [docSections.web3Wrapper]: ['"index"'], + }, + menuSubsectionToVersionWhenIntroduced: {}, + sections: docSections, + visibleConstructors: [docSections.web3Wrapper], +}; +const docsInfo = new DocsInfo(docsInfoConfig); + +const selectedVersion = '0.2.0'; +const availableVersions = ['0.1.12', '0.1.13', '0.1.14', '0.2.0']; + +const sourceUrl = `${ + docsInfoConfig.packageUrl +}/blob/@0xproject/web3-wrapper%40${selectedVersion}/packages/web3-wrapper`; + +import * as typeDocJson from './json/web3_wrapper_typedoc_output.json'; +const docAgnosticFormat = docsInfo.convertToDocAgnosticFormat(typeDocJson); + +render( + + + , + document.getElementById('app'), +); -- cgit v1.2.3 From 6f8a70834b72d678cd9d171d7bb0a3a2cfb4134d Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 7 Mar 2018 13:25:15 +0100 Subject: Add onSelectedVersion callback so it can be handled in any way the caller wishes --- packages/react-docs/example/ts/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'packages/react-docs/example/ts/index.tsx') diff --git a/packages/react-docs/example/ts/index.tsx b/packages/react-docs/example/ts/index.tsx index 8cfa8451c..bf7574e7b 100644 --- a/packages/react-docs/example/ts/index.tsx +++ b/packages/react-docs/example/ts/index.tsx @@ -50,7 +50,7 @@ const sourceUrl = `${ docsInfoConfig.packageUrl }/blob/@0xproject/web3-wrapper%40${selectedVersion}/packages/web3-wrapper`; -import * as typeDocJson from './json/web3_wrapper_typedoc_output.json'; +import * as typeDocJson from './json/0.2.0.json'; const docAgnosticFormat = docsInfo.convertToDocAgnosticFormat(typeDocJson); render( @@ -61,7 +61,12 @@ render( docsInfo={docsInfo} docAgnosticFormat={docAgnosticFormat} sourceUrl={sourceUrl} + onVersionSelected={onVersionSelected} /> , document.getElementById('app'), ); + +function onVersionSelected(semver: string) { + // TODO +} -- cgit v1.2.3 From e31309f213e9b900225b077cb27792958ba1ad5d Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 7 Mar 2018 13:57:17 +0100 Subject: Allow user to change versions in demo example --- packages/react-docs/example/ts/index.tsx | 61 ++------------------------------ 1 file changed, 3 insertions(+), 58 deletions(-) (limited to 'packages/react-docs/example/ts/index.tsx') diff --git a/packages/react-docs/example/ts/index.tsx b/packages/react-docs/example/ts/index.tsx index bf7574e7b..84a544766 100644 --- a/packages/react-docs/example/ts/index.tsx +++ b/packages/react-docs/example/ts/index.tsx @@ -5,68 +5,13 @@ import * as React from 'react'; import { render } from 'react-dom'; import * as injectTapEventPlugin from 'react-tap-event-plugin'; -import { Documentation } from '../../src/ts/components/documentation'; -import { DocsInfo } from '../../src/ts/docs_info'; -import { DocsInfoConfig, SupportedDocJson } from '../../src/ts/types'; -injectTapEventPlugin(); - -/* tslint:disable:no-var-requires */ -const IntroMarkdown = require('md/introduction'); -/* tslint:enable:no-var-requires */ - -const docSections = { - introduction: 'introduction', - web3Wrapper: 'web3Wrapper', -}; - -const docsInfoConfig: DocsInfoConfig = { - id: 'web3Wrapper', - type: SupportedDocJson.TypeDoc, - displayName: 'Web3 Wrapper', - packageUrl: 'https://github.com/0xProject/0x-monorepo', - menu: { - introduction: [docSections.introduction], - web3Wrapper: [docSections.web3Wrapper], - }, - sectionNameToMarkdown: { - [docSections.introduction]: IntroMarkdown, - }, - // Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is - // currently no way to extract the re-exported types from index.ts via TypeDoc :( - publicTypes: ['TxData', 'TransactionReceipt', 'RawLogEntry'], - sectionNameToModulePath: { - [docSections.web3Wrapper]: ['"index"'], - }, - menuSubsectionToVersionWhenIntroduced: {}, - sections: docSections, - visibleConstructors: [docSections.web3Wrapper], -}; -const docsInfo = new DocsInfo(docsInfoConfig); +import { Docs } from './docs'; -const selectedVersion = '0.2.0'; -const availableVersions = ['0.1.12', '0.1.13', '0.1.14', '0.2.0']; - -const sourceUrl = `${ - docsInfoConfig.packageUrl -}/blob/@0xproject/web3-wrapper%40${selectedVersion}/packages/web3-wrapper`; - -import * as typeDocJson from './json/0.2.0.json'; -const docAgnosticFormat = docsInfo.convertToDocAgnosticFormat(typeDocJson); +injectTapEventPlugin(); render( - + , document.getElementById('app'), ); - -function onVersionSelected(semver: string) { - // TODO -} -- cgit v1.2.3