|
| 1 | +# React Sample Configuration |
| 2 | + |
| 3 | +## Adding your sample folder |
| 4 | +Create new folder in 'src' location and name the folder as control name for example "grid” it is control name. |
| 5 | + |
| 6 | +_Note: Do not use whitespace at any cause in folder’s name. Use “-” instead of space._ |
| 7 | + |
| 8 | +## Adding the sample |
| 9 | + |
| 10 | +Add the sample component tsx file in the sample folder.Below steps are need to be considered on sample creation |
| 11 | + |
| 12 | + * Sample component must extend the "SampleBase" component class from the path "src/common/sample-base" file. |
| 13 | + * Sample tag must be enclosed between the "control-section" div. |
| 14 | + * In all samples description is need to be added. Add sample description within the div tag with id as **description**. |
| 15 | + |
| 16 | +```javascript |
| 17 | +import * as ReactDOM from 'react-dom'; |
| 18 | +import * as React from 'react'; |
| 19 | +import { SampleBase } from '../common/sample-base'; |
| 20 | +export class Default extends SampleBase<{}, {}> { |
| 21 | + |
| 22 | + render() { |
| 23 | + return ( |
| 24 | + <div className = 'control-pane'> |
| 25 | + <div className='control-section'> |
| 26 | + //sample component tags |
| 27 | + </div> |
| 28 | + <div id="description"> |
| 29 | + // sample description |
| 30 | + </div> |
| 31 | + </div> |
| 32 | + ) |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +``` |
| 37 | +Refer the [sample](https://gitlab.syncfusion.com/essential-studio/development/src/grid/default.tsx ) for example sample component. |
| 38 | + |
| 39 | +Note: Do not use whitespace at any cause in file’s name. Use “-” instead of space. |
| 40 | + |
| 41 | +## Adding property section |
| 42 | +To add the "propertypane” in the sample use tag `PropertyPane` from "common/property-pane" .Configure your sample properties as like below code snippet. |
| 43 | + |
| 44 | +``` |
| 45 | +<PropertyPane title='Properties'> |
| 46 | + <table id="property" title="Properties" className='property-panel-table' style={{ width: '100%' }}> |
| 47 | + <tr> |
| 48 | + <td style={{ width: '30%' }}> |
| 49 | + <div className="col-md-4" style={{ paddingTop: "8px" }}> |
| 50 | + GridLines |
| 51 | + </div> |
| 52 | + </td> |
| 53 | + <td style={{ width: '70%', paddingRight: '10px' }}> |
| 54 | + <div> |
| 55 | + <select id="ddl" name="ddl" onChange={this.change.bind(this)} className="form-control" style={{ padding: "6px" }} ref={d => this.dropElement = d}> |
| 56 | + <option value="default">Default</option> |
| 57 | + <option value="both">Both</option> |
| 58 | + <option value="none">None</option> |
| 59 | + <option value="horizontal">Horizontal</option> |
| 60 | + <option value="vertical">Vertical</option> |
| 61 | + </select> |
| 62 | + </div> |
| 63 | + </td> |
| 64 | + </tr> |
| 65 | + </table> |
| 66 | + </PropertyPane> |
| 67 | +
|
| 68 | +``` |
| 69 | +Refer the [PropertyPanesample](https://gitlab.syncfusion.com/essential-studio/development/src/grid/gridlines.tsx ) for propertyPane example. |
| 70 | + |
| 71 | +## Add Routing for your sample |
| 72 | + |
| 73 | +Create the "config.tsx” file inside of your control folder.Configure your "config.tsx file" file as like below code snippet. |
| 74 | + |
| 75 | +``` |
| 76 | +export const GridSampleOrder:Object = [ |
| 77 | + { 'path': 'grid/default', 'component':'Default', 'name': 'Default Functionalities', 'order': '01', 'category': 'Grid' }, |
| 78 | + { 'path': 'grid/gridlines', 'component':'GridLines', 'name': 'GridLines', 'order': '01', 'category': 'Grid', hideOnDevice: true } |
| 79 | +] |
| 80 | +
|
| 81 | +``` |
| 82 | + |
| 83 | +**Fields Description:** |
| 84 | + |
| 85 | + path : Specifies the sample router path. Path must be same as "sampleFolderName/sampleFileName". |
| 86 | + component: Specifies the name of the sample component. |
| 87 | + name: Specifies the sample name to be displayed. |
| 88 | + order: Specifies the order in which sample to be displayed. |
| 89 | + category: Specifies the sample category. |
| 90 | + |
| 91 | +*Note: set **hideOnDevice** as true if you want to hide a sample in devices.* |
| 92 | + |
| 93 | +## Configure Sample List |
| 94 | + |
| 95 | +Add your samples in “samplelist.tsx” located in “/src/common” folder |
| 96 | +1. Import your sampleOrder array from the component config file. |
| 97 | +2. Add your samples in samplesList as Like below |
| 98 | + |
| 99 | +``` |
| 100 | +import * as React from 'react'; |
| 101 | +import { GridSampleOrder } from '../grid/config'; |
| 102 | +
|
| 103 | +export let samplesList: any = [ |
| 104 | +
|
| 105 | + { |
| 106 | + 'name': 'Grid', 'category': 'Grids', 'order': '02', 'path': 'grid', 'samples': GridSampleOrder |
| 107 | + } |
| 108 | +]; |
| 109 | +``` |
| 110 | + |
| 111 | +## Adding your control dependency |
| 112 | + |
| 113 | +Add your dependency in “package.json” file inside the dependencies. |
| 114 | + |
| 115 | +Note: Here, '\*' Specifies that install the latest published package form the online. '\*' is recommended for Syncfusion packages. |
| 116 | + |
| 117 | +``` |
| 118 | +"dependencies": { |
| 119 | + "@syncfusion/ej2-react-grids": "*" |
| 120 | +}, |
| 121 | +``` |
| 122 | +## Run your Sample Browser |
| 123 | + |
| 124 | +To run your sample browser you can use any of the following command. |
| 125 | + |
| 126 | +``` |
| 127 | +gulp serve |
| 128 | +``` |
0 commit comments