@uifabric/example-app-base
Components and utilities used to build internal documentation sites and inner loops for various Fluent UI React (formerly Office UI Fabric React) packages.
This package is in maintenance mode while we work on a replacement. It should only be used in new projects if you must have a published documentation site that looks like the official Fluent UI React docs. If all you need is an inner loop for component development, please use Storybook instead. Storybook is a well-supported, well-documented platform for component development and documentation.
Live editor support
To set up the live code editor in the demo app for a package other than the @fluentui/react
package itself:
-
Follow the setup steps from the @uifabric/monaco-editor
readme (the helpers mentioned are also re-exported from @uifabric/tsx-editor
for convenience).
-
Set up a .d.ts
rollup file for your package using API Extractor.
-
Add a dependency on raw-loader
to the package containing your demo app.
-
Define the custom list of supported packages. For demonstration purposes, we'll assume:
- You're building off the default set of supported packages
- The package you're demoing is
my-package
my-package
re-exports another package called my-package-utilities
(it's not required that your package export anything else, but this is included to demonstrate setting it up)- Each package's
.d.ts
rollup lives under <package-folder>/dist/<unscoped-package-name>.d.ts
import { IPackageGroup } from '@uifabric/tsx-editor';
import { defaultSupportedPackages } from '@uifabric/tsx-editor/lib/utilities/defaultSupportedPackages';
export const editorSupportedPackages: IPackageGroup[] = [
...defaultSupportedPackages,
{
globalName: 'MyPackage',
loadGlobal: () => import('my-package'),
packages: [
{
packageName: 'my-package',
loadTypes: () => {
return import('!raw-loader!my-package/dist/my-package.d.ts');
},
},
{
packageName: 'my-package-utilities',
loadTypes: () => {
return import('!raw-loader!my-package-utilities/dist/my-package-utilities.d.ts');
},
},
],
},
];
- To apply to a single
ExampleCard
:
import { editorSupportedPackages } from '<file path>';
import { MyExample } from './MyExample.Example';
const MyExampleCode = require('!raw-loader!./MyExample.Example.tsx');
<ExampleCard title="My example" code={MyExampleCode} editorSupportedPackages={editorSupportedPackages}>
<MyExample />
</ExampleCard>;
- To apply to all
ExampleCard
instances in your app:
import { editorSupportedPackages } from '<file path>';
import { IExampleCardProps, IAppDefinition } from '@uifabric/example-app-base';
const exampleCardProps: IExampleCardProps = { editorSupportedPackages };
const appDefinition: IAppDefinition = {
customizations: {
scopedSettings: {
ExampleCard: exampleCardProps,
},
},
};