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

[NO JIRA][BpkSpinner]: Updating TS types and removing propTypes ahead of React 18 #3586

Merged
merged 1 commit into from
Aug 16, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* limitations under the License.
*/

/* @flow strict */

import { render } from '@testing-library/react';

import BpkExtraLargeSpinner from './BpkExtraLargeSpinner';
Expand Down
28 changes: 9 additions & 19 deletions packages/bpk-component-spinner/src/BpkExtraLargeSpinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* limitations under the License.
*/

import PropTypes from 'prop-types';

import XlSpinner from '@skyscanner/bpk-svgs/dist/js/spinners/xl';

import { cssModules } from '../../bpk-react-utils';
Expand All @@ -31,12 +29,16 @@ import STYLES from './BpkSpinner.module.scss';
const getClassName = cssModules(STYLES);

type Props = {
type: SpinnerTypes,
className?: string,
type?: SpinnerTypes;
className?: string | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we need semantic difference between null and undefined here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Possibly? I was jsut setting it here based on what we had as the previous right now to avoid any unexpected change or issues

[rest: string]: any;
};

const BpkExtraLargeSpinner = (props: Props) => {
const { className, type, ...rest } = props;
const BpkExtraLargeSpinner = ({
className = null,
type = SPINNER_TYPES.dark,
...rest
}: Props) => {
const classNames = getClassName(
'bpk-spinner',
'bpk-spinner--extra-large',
Expand All @@ -46,21 +48,9 @@ const BpkExtraLargeSpinner = (props: Props) => {

return (
<span className={classNames}>
<XlSpinner
{...rest}
/>
<XlSpinner {...rest} />
</span>
);
};

BpkExtraLargeSpinner.propTypes = {
type: PropTypes.oneOf(Object.keys(SPINNER_TYPES)),
className: PropTypes.string,
};

BpkExtraLargeSpinner.defaultProps = {
type: SPINNER_TYPES.dark,
className: null,
};

export default BpkExtraLargeSpinner;
29 changes: 10 additions & 19 deletions packages/bpk-component-spinner/src/BpkLargeSpinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* limitations under the License.
*/

import PropTypes from 'prop-types';

import LgSpinner from '@skyscanner/bpk-svgs/dist/js/spinners/lg';

import { cssModules } from '../../bpk-react-utils';
Expand All @@ -31,13 +29,18 @@ import STYLES from './BpkSpinner.module.scss';
const getClassName = cssModules(STYLES);

type Props = {
type: SpinnerTypes,
className?: string,
alignToButton: boolean,
type?: SpinnerTypes,
className?: string | null,
alignToButton?: boolean,
[rest: string]: any,
};

const BpkLargeSpinner = (props: Props) => {
const { alignToButton, className, type, ...rest } = props;
const BpkLargeSpinner = ({
alignToButton = false,
className = null,
type = SPINNER_TYPES.dark,
...rest
}: Props) => {

const classNames = getClassName(
'bpk-spinner',
Expand All @@ -57,16 +60,4 @@ const BpkLargeSpinner = (props: Props) => {
);
};

BpkLargeSpinner.propTypes = {
type: PropTypes.oneOf(Object.keys(SPINNER_TYPES)),
className: PropTypes.string,
alignToButton: PropTypes.bool,
};

BpkLargeSpinner.defaultProps = {
type: SPINNER_TYPES.dark,
className: null,
alignToButton: false,
};

export default BpkLargeSpinner;
35 changes: 11 additions & 24 deletions packages/bpk-component-spinner/src/BpkSpinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
* limitations under the License.
*/


import PropTypes from 'prop-types';

import SmSpinner from '@skyscanner/bpk-svgs/dist/js/spinners/sm';

import { cssModules } from '../../bpk-react-utils';
Expand All @@ -32,14 +29,18 @@ import STYLES from './BpkSpinner.module.scss';
const getClassName = cssModules(STYLES);

type Props = {
type: SpinnerTypes,
className?: string,
alignToButton: boolean,
type?: SpinnerTypes;
className?: string | null;
alignToButton?: boolean;
[rest: string]: any;
};

const BpkSpinner = (props: Props) => {
const { alignToButton, className, type, ...rest } = props;

const BpkSpinner = ({
alignToButton = false,
className = null,
type = SPINNER_TYPES.dark,
...rest
}: Props) => {
const classNames = getClassName(
'bpk-spinner',
`bpk-spinner--${type}`,
Expand All @@ -49,23 +50,9 @@ const BpkSpinner = (props: Props) => {

return (
<span className={classNames}>
<SmSpinner
{...rest}
/>
<SmSpinner {...rest} />
</span>
);
};

BpkSpinner.propTypes = {
type: PropTypes.oneOf(Object.keys(SPINNER_TYPES)),
className: PropTypes.string,
alignToButton: PropTypes.bool,
};

BpkSpinner.defaultProps = {
type: SPINNER_TYPES.dark,
className: null,
alignToButton: false,
};

export default BpkSpinner;
Loading