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

[BpkInfoBanner] Changed typing declarations to match common-types.ts file #3094

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Changes from 1 commit
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
18 changes: 12 additions & 6 deletions packages/bpk-component-info-banner/src/common-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,32 @@
import type { FunctionComponent, ReactNode } from 'react';

export declare const ALERT_TYPES: {
readonly PRIMARY: 'primary';
readonly SUCCESS: 'success';
readonly WARN: 'warn';
readonly ERROR: 'error';
readonly NEUTRAL: 'neutral';
readonly SUCCESS: 'success',
readonly WARNING: 'warning',
readonly ERROR: 'error',
readonly INFO: 'info',
};
export declare const STYLE_TYPES: {
readonly DEFAULT: 'default',
readonly ON_CONTRAST: 'onContrast',
};
export type AlertTypeValue = (typeof ALERT_TYPES)[keyof typeof ALERT_TYPES];
export type StyleTypeValue = (typeof STYLE_TYPES)[keyof typeof STYLE_TYPES];
export type CommonProps = {
type: AlertTypeValue;
type?: AlertTypeValue;
Copy link
Member

@olliecurtis olliecurtis Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value would always have a value right as we set a default in the Inner Banner should would never need to be optional here and may also need to be updated in the common-types file too?

Copy link
Contributor Author

@sambocharov sambocharov Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope I get it right, but won't BpkInfoBanner complain about typing if we'll remove optional here? I mean, we may not pass to BpkInfoBanner a type prop and it should still work and pass typechecking. Since BpkInfoBanner has CommonProps as type for props, if we'll make type required it would fail. According to figma, if I get it right, it has a default value which we specify in BpkInfoBannerInner, as you mentioned, and type marked as not required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah you are right my mistake here, apologies!

message: ReactNode | string;
animateOnEnter?: boolean;
animateOnLeave?: boolean;
show?: boolean;
bannerClassName?: string | null;
icon?: FunctionComponent<any> | null;
style?: StyleTypeValue;
[rest: string]: any;
};
export type OnExpandToggleHandler =
| ((expanded: boolean) => void)
| null
| undefined;
export type ExpandableBannerAction = { title: string, callback: () => void } | null | undefined;
export type OnDismissHandler = (() => void) | null | undefined;
export type OnHideHandler = (() => void) | null | undefined;
Loading