Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adjust label and icon props optionality #3613

Merged
merged 1 commit into from
Jan 23, 2023
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 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