Skip to content

Commit 4d5d666

Browse files
authored
Merge pull request #906 from data-driven-forms/dev-guide-examples
Custom examples guide.
2 parents dd01422 + 1722b45 commit 4d5d666

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

packages/react-renderer-demo/src/pages/development-setup.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,37 @@ yarn generate-template
9292
```
9393

9494
This command starts a CLI, that provides an interface for generating mappers. A mapper folder will be created and it will be populated with all neccesary files.
95+
## Adding form component example
96+
97+
To add additional examples of [custom form components](/examples/sample-example), please follow these steps.
98+
99+
1. Create a new markdown file in this directory: https://github.com/data-driven-forms/react-forms/tree/master/packages/react-renderer-demo/src/pages/examples.
100+
2. Wrap the whole content into `DocPage` component:
101+
```md
102+
import DocPage from '@docs/doc-page';
103+
104+
<DocPage>
105+
Your content
106+
</DocPage>
107+
108+
```
109+
3. Add this information to the file:
110+
1. Description of the component
111+
2. A problem it may help to solve
112+
3. Example of the component implementation and usage in a form
113+
4. To create an example follow these steps:
114+
1. Create a new JS file in this directory: https://github.com/data-driven-forms/react-forms/tree/master/packages/react-renderer-demo/src/examples/components/examples
115+
2. Import the code example using this path `components/examples/<file name without extenstion>`
116+
117+
```md
118+
119+
import CodeExample from '@docs/code-example';
120+
121+
<CodeExample source="components/examples/sample-example" mode="preview" />
122+
123+
```
124+
5. Add the component to the navigation. Add a new object to this file: https://github.com/data-driven-forms/react-forms/blob/master/packages/react-renderer-demo/src/components/navigation/schemas/custom-examples.schema.js
125+
1. Title: text of the link
126+
2. Component: exact filename of the **markdown file**
95127

96128
</DocPage>

0 commit comments

Comments
 (0)