Skip to content

Commit

Permalink
docs(callbacks): updates in typings (#1446)
Browse files Browse the repository at this point in the history
* docs(callbacks): updates in typings

* docs(readme): add Advertisement component to list
  • Loading branch information
layershifter authored and levithomason committed Mar 12, 2017
1 parent 7917f4f commit 9fb59f2
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 14 deletions.
7 changes: 5 additions & 2 deletions src/collections/Table/Table.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ interface TableProps {
padded?: boolean | 'very';

/**
* A function that takes (data, index) and returns shorthand for a TableRow
* to be placed within Table.Body.
* Mapped over `tableData` and should return shorthand for each Table.Row to be placed within Table.Body.
*
* @param {*} data - An element in the `tableData` array.
* @param {number} index - The index of the current element in `tableData`.
* @returns {*} Shorthand for a Table.Row.
*/
renderBodyRow?: (data: any, index: number) => any;

Expand Down
7 changes: 6 additions & 1 deletion src/modules/Accordion/Accordion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ interface AccordionProps {
/** Format for dark backgrounds. */
inverted?: string;

/** Called with (event, index) when a panel title is clicked. */
/**
* Called when a panel title is clicked.
*
* @param {SyntheticEvent} event - React's original SyntheticEvent.
* @param {number} index - The index of the clicked panel.
*/
onTitleClick?: (event: React.MouseEvent<HTMLDivElement>, index: number | number[]) => void;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Accordion/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class Accordion extends Component {
* Called when a panel title is clicked.
*
* @param {SyntheticEvent} event - React's original SyntheticEvent.
* @param {index} - The index of the clicked panel.
* @param {number} index - The index of the clicked panel.
*/
onTitleClick: PropTypes.func,

Expand Down
12 changes: 10 additions & 2 deletions src/modules/Dropdown/Dropdown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,16 @@ export interface DropdownProps {
/** A dropdown can be formatted so that its menu is pointing. */
pointing?: boolean | 'left' | 'right' | 'top' | 'top left' | 'top right' | 'bottom' | 'bottom left' | 'bottom right';

/** A function that takes (data, index, defaultLabelProps) and returns shorthand for Label. */
renderLabel?: (item: DropdownItemProps, index: number, defaultProps: LabelProps) => React.ReactElement<any>;
/**
* Mapped over the active items and returns shorthand for the active item Labels.
* Only applies to `multiple` Dropdowns.
*
* @param {object} item - A currently active dropdown item.
* @param {number} index - The current index.
* @param {object} defaultLabelProps - The default props for an active item Label.
* @returns {*} Shorthand for a Label.
*/
renderLabel?: (item: DropdownItemProps, index: number, defaultLabelProps: LabelProps) => React.ReactElement<any>;

/** A dropdown can have its menu scroll. */
scrolling?: boolean;
Expand Down
12 changes: 8 additions & 4 deletions src/modules/Search/Search.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@ interface SearchProps {
// ------------------------------------

/**
* A function that returns the category contents.
* Receives all SearchCategory props.
* Renders the SearchCategory contents.
*
* @param {object} props - The SearchCategory props object.
* @returns {*} - Renderable SearchCategory contents.
*/
categoryRenderer?: (props: SearchCategoryProps) => React.ReactElement<any>;

/**
* A function that returns the result contents.
* Receives all SearchResult props.
* Renders the SearchResult contents.
*
* @param {object} props - The SearchResult props object.
* @returns {*} - Renderable SearchResult contents.
*/
resultRenderer?: (props: SearchResultProps) => Array<React.ReactElement<any>>;

Expand Down
6 changes: 4 additions & 2 deletions src/modules/Search/SearchCategory.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ export interface SearchCategoryProps {
name?: string;

/**
* A function that returns the category contents.
* Receives all SearchCategory props.
* Renders the category contents.
*
* @param {object} props - The SearchCategory props object.
* @returns {*} - Renderable category contents.
*/
renderer?: (props: SearchCategoryProps) => React.ReactElement<any>;

Expand Down
6 changes: 4 additions & 2 deletions src/modules/Search/SearchResult.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ export interface SearchResultProps {
price?: string;

/**
* A function that returns the result contents.
* Receives all SearchResult props.
* Renders the result contents.
*
* @param {object} props - The SearchResult props object.
* @returns {*} - Renderable result contents.
*/
renderer?: (props: SearchResultProps) => Array<React.ReactElement<any>>;

Expand Down

0 comments on commit 9fb59f2

Please sign in to comment.