Skip to content

[PANGOO-2945][BpkPageIndicator]Bpk component page indicator ts support #3783

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

Merged
merged 25 commits into from
Apr 7, 2025

Conversation

senzg
Copy link
Contributor

@senzg senzg commented Apr 2, 2025

Remember to include the following changes:

  • Ensure the PR title includes the name of the component you are changing so it's clear in the release notes for consumers of the changes in the version e.g [Clover-123][BpkButton] Updating the colour
  • README.md (If you have created a new component)
  • Component README.md
  • Tests
  • Accessibility tests
    • The following checks were performed:
      • Ability to navigate using a keyboard only
      • Zoom functionality (Deque University explanation):
        • The page SHOULD be functional AND readable when only the text is magnified to 200% of its initial size
        • Pages must reflow as zoom increases up to 400% so that content continues to be presented in only one column i.e. Content MUST NOT require scrolling in two directions (both vertically and horizontally)
      • Ability to navigate using a screen reader only
  • Storybook examples created/updated
  • For breaking changes or deprecating components/properties, migration guides added to the description of the PR. If the guide has large changes, consider creating a new Markdown page inside the component's docs folder and link it here

@senzg senzg added the minor Non breaking change label Apr 2, 2025
@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

skyscanner-backpack-bot bot commented Apr 2, 2025

Warnings
⚠️

Package source files (e.g. packages/package-name/src/Component.js) were updated, but snapshots weren't. Have you checked that the tests still pass?

⚠️

Package source files (e.g. packages/package-name/src/Component.tsx) were updated, but type files weren't. Have you checked that no types have changed?

Browser support

If this is a visual change, make sure you've tested it in multiple browsers.

Generated by 🚫 dangerJS against 6ed2b75

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

Steven-Zeng added 2 commits April 2, 2025 16:41
@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

@senzg senzg changed the title [PANGOO-2945][BpkPageIndicator]Bpk component page indicator ts support[Part 1] [PANGOO-2945][BpkPageIndicator]Bpk component page indicator ts support Apr 2, 2025
@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds TypeScript support for the BpkPageIndicator component and updates related files to remove Flow types and PropTypes while improving type safety.

  • Migrated components from Flow to TypeScript by replacing PropTypes and defaultProps with proper interfaces and default values.
  • Updated related tests, examples, and the carousel integration to align with the new type definitions.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/bpk-component-page-indicator/src/NavButton.tsx Updated type definitions and removed PropTypes to use TypeScript's type system.
packages/bpk-component-page-indicator/src/BpkPageIndicator.tsx Replaced PropTypes and Flow types with TypeScript interfaces and default values.
packages/bpk-component-page-indicator/src/BpkPageIndicator-test.tsx Improved test props typing for better type safety.
packages/bpk-component-page-indicator/index.ts Adjusted type imports and exports for consistency.
packages/bpk-component-carousel/src/BpkCarousel.tsx Removed the ts-expect-error suppression; ensure compatibility with updated types.
examples/bpk-component-page-indicator/stories.tsx Updated Storybook stories using the CSF object notation.
examples/bpk-component-page-indicator/examples.tsx Added explicit type annotations to example container component props.
Comments suppressed due to low confidence (1)

packages/bpk-component-carousel/src/BpkCarousel.tsx:20

  • The removal of the ts-expect-error suppression comment implies that the type definitions for BpkPageIndicator should now be correct. Please verify that no TypeScript errors are introduced due to this change.
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

Copy link
Contributor

@GCpigsic GCpigsic left a comment

Choose a reason for hiding this comment

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

we also need to remove the /* @flow strict */ in packages/bpk-component-page-indicator/src/accessibility-test.tsx

describe('BpkPageIndicator', () => {
let props: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better if we reuse the type defined in packages/bpk-component-carousel/src/BpkCarousel.tsx

totalIndicators - DISPLAYED_TOTAL,
)
: 0,
} as React.CSSProperties
Copy link
Contributor

Choose a reason for hiding this comment

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

As I remember in banana, we are not recommending to use type assertion, therefore, i would prefer

import type { CSSProperties } from 'react';
...
type CustomCSSProperties = CSSProperties & {
  '--scroll-index'?: number;
}
  const customStyle: CustomCSSProperties = {
    '--scroll-index':
      totalIndicators > DISPLAYED_TOTAL
        ? Math.min(
          currentIndex - START_SCROLL_INDEX,
          totalIndicators - DISPLAYED_TOTAL,
        )
        : 0,
  }

      <div
        className={getClassName('bpk-page-indicator__indicators-container')}
        style={
          currentIndex > START_SCROLL_INDEX
            ? customStyle
            : undefined
        }
      >
...


@GCpigsic
Copy link
Contributor

GCpigsic commented Apr 3, 2025

I noticed the Percy failed here, I don't think the ts migration would cause the visual changes, could you help to check with it?

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

1 similar comment
@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3783 to see this build running in a browser.

Copy link
Contributor

@GCpigsic GCpigsic left a comment

Choose a reason for hiding this comment

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

LGTM

@senzg senzg merged commit 8b7b34c into main Apr 7, 2025
9 checks passed
@senzg senzg deleted the bpk-component-page-indicator-TS-support-Part-1 branch April 7, 2025 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Non breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants