Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ In Jest:

For advanced usage including info about module vs. path-based imports, using an AMD bundler like Require, and deployment features, see our [advanced documentation](./ghdocs/BestPractices/Advanced.md).

## Contribute to Office UI Fabric React
## Contribute to Fabric React

Please take a look at our [contribution guidelines](./ghdocs/Contributing/Contributing.md) for more info. Also read [Contribute Bug fixes](./ghdocs/Contributing/BugFixes.md) and [Contribute New component](./ghdocs/Contributing/NewComponent.md).

Expand Down
50 changes: 24 additions & 26 deletions ghdocs/Contributing/NewComponent.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,24 @@ Fundamental components are the official React representation of our [Adobe XD To

#### Creating a component via the command line
1. This is the recommended way of creating a new component.
3. Open a command prompt in the root directory of your project directory.
2. Run `npm run create-component -- --name ExcitingNewComponent`.
2. Open a command prompt in the root directory of your project.
3. Run `npm run create-component -- --name ExcitingNewComponent`.

#### Creating a component manually
1. From the root of the project, navigate to `packages/experiments/src/components/`
2. Create a new folder here with your component name
* Our components use the Pascal Case naming convention.
* In this example the component will be called `ExcitingNewComponent`.
* Our components use the Pascal Case naming convention.
* In this example the component will be called `ExcitingNewComponent`.
3. Create a `ExcitingNewComponent.types.ts` file that will contain an interface for your component props

* Import React
* `import * as React from 'react'`;
* Import ExcitingNewComponent
* `import { ExcitingNewComponent } from './ExcitingNewComponent'`;
* Note: This class and file don't exist yet but they will during step 4 of this small tutorial.
* Create an empty interface `IExcitingNewComponent`
* `export interface IExcitingNewComponent {}`
* Add your props interface to this file.
* `export interface IExcitingNewComponentProps extends React.Props<ExcitingNewComponent> { … Props }`
* Create and export an interface for ExcitingNewComponent styles.
* Import React
* `import * as React from 'react'`;
* Import ExcitingNewComponent
* `import { ExcitingNewComponent } from './ExcitingNewComponent'`;
* Note: This class and file don't exist yet but they will during step 4 of this small tutorial.
* Create an empty interface `IExcitingNewComponent`
* `export interface IExcitingNewComponent {}`
* Add your props interface to this file.
* `export interface IExcitingNewComponentProps extends React.Props<ExcitingNewComponent> { … Props }`

4. Create a react file, `ExcitingNewComponent.tsx`.

Expand All @@ -89,19 +87,19 @@ import { BaseComponent } from '../../Utilities';
import { IExcitingNewComponentProps } from './ExcitingNewComponent.types';

export class ExcitingNewComponent extends BaseComponent <IExcitingNewComponentProps, {}> {
public render() {
public render(): JSX.Element {
return(
<div>Hello World!</div>
);
}
}; // @todo: this ; needs to be removed
}
```

5. Create a class names file `ExcitingNewComponent.classNames.ts`
5. Create a class names file `ExcitingNewComponent.styles.ts`

```ts
import { memoizeFunction } from '../../Utilities';
import { mergeStyleSets} from '../../Styling';
import { mergeStyleSets, IStyle } from '../../Styling';

export interface IExcitingNewComponentStyles {
/**
Expand All @@ -111,16 +109,16 @@ export interface IExcitingNewComponentStyles {
}

export interface IExcitingNewComponentNames {
/**
* Root html container for this component.
*/
root?: string;
/**
* Root html container for this component.
*/
root?: string;
}

export const getClassNames = memoizeFunction((): IExcitingNewComponentNames => {
return mergeStyleSets({
root: []
});
return mergeStyleSets({
root: []
});
});
```

Expand Down
16 changes: 8 additions & 8 deletions scripts/templates/EmptyClassNames.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { memoizeFunction } from '../../Utilities';
import { mergeStyleSets} from '../../Styling';
import { mergeStyleSets, IStyle } from '../../Styling';

export interface I{{componentName}}Styles {
/**
Expand All @@ -9,14 +9,14 @@ export interface I{{componentName}}Styles {
}

export interface I{{componentName}}Names {
/**
* Root html container for this component.
*/
root?: string;
/**
* Root html container for this component.
*/
root?: string;
}

export const getClassNames = memoizeFunction((): I{{componentName}}Names => {
return mergeStyleSets({
root: []
});
return mergeStyleSets({
root: []
});
});
4 changes: 2 additions & 2 deletions scripts/templates/EmptyComponent.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { BaseComponent } from '../../Utilities';
import { I{{componentName}}Props } from './{{componentName}}.types';

export class {{componentName}} extends BaseComponent < I{{componentName}}Props, {} > {
public render() {
public render(): JSX.Element {
return(
<div>Hello World!</div>
);
}
};
}
1 change: 0 additions & 1 deletion scripts/templates/EmptyProps.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';
import { {{componentName}} } from './{{componentName}}';
import { IStyle } from '../../Styling';

export interface I{{componentName}} {
}
Expand Down