Skip to content

Commit

Permalink
fix: adjust label and icon props optionality (#3613)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewalczak authored Jan 23, 2023
1 parent 9e50236 commit 06af55e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/FAB/AnimatedFAB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export type Props = $RemoveChildren<typeof Surface> & {
*/
extended: boolean;
/**
* @supported Available in v3.x with theme version 3
* @supported Available in v5.x with theme version 3
*
* Color mappings variant for combinations of container and icon colors.
*/
Expand Down
20 changes: 16 additions & 4 deletions src/components/FAB/FAB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,25 @@ type FABSize = 'small' | 'medium' | 'large';

type FABMode = 'flat' | 'elevated';

type IconOrLabel =
| {
icon: IconSource;
label?: string;
}
| {
icon?: IconSource;
label: string;
};

export type Props = $RemoveChildren<typeof Surface> & {
// For `icon` and `label` props their types are duplicated due to the generation of documentation.
// Appropriate type for them is `IconOrLabel` contains the both union and intersection types.
/**
* Icon to display for the `FAB`.
* Icon to display for the `FAB`. It's optional only if `label` is defined.
*/
icon: IconSource;
icon?: IconSource;
/**
* Optional label for extended `FAB`.
* Optional label for extended `FAB`. It's optional only if `icon` is defined.
*/
label?: string;
/**
Expand Down Expand Up @@ -117,7 +129,7 @@ export type Props = $RemoveChildren<typeof Surface> & {
theme?: ThemeProp;
testID?: string;
ref?: React.RefObject<View>;
};
} & IconOrLabel;

/**
* A floating action button represents the primary action in an application.
Expand Down

0 comments on commit 06af55e

Please sign in to comment.