pierreericgarcia / react-step-progress-bar

A library to create stunning progress bars with steps in React 🌑
https://pierreericgarcia.github.io/react-step-progress-bar/
MIT License
198 stars 27 forks source link

Typing for react-step-progress-bar #20

Open gothraven opened 4 years ago

gothraven commented 4 years ago

First of all, thank you for this amazing library, now that i'm using it in a Typescript project, i was looking for its types i tried npm install @types/react-step-progress-bar but it does not exist.

mannamh commented 4 years ago

Same issue when i tried in one f my react project

rknyra commented 3 years ago

same issue here πŸ€”πŸ˜•πŸ˜•

ghernandezr commented 3 years ago

I solve this issue declaring my own .d.ts file, I am using create-react-app, this search for the file src/global.d.ts This is how it look to me, any suggestion is welcome:

declare module 'react-step-progress-bar' {
  interface ProgressBarProps {
    percent?: number;
    filledBackground?: any;
    height?: string | number;
    stepPositions?: number;
  }

  interface StepProps {
    transition?: any;
    position?: any;
  }
  class ProgressBar extends React.Component<ProgressBarProps, any> {}
  class Step extends React.Component<StepProps, any> {}
}  

Thanks!!!!

pierreericgarcia commented 2 years ago

Thank you so much for your feedbacks ! I'll use typescript for the 2.0 !

andresdsep commented 2 years ago

Had a closer look to the package code and made a couple of changes to @ghernandezr's types:

declare module 'react-step-progress-bar' {
  import React from 'react';

  interface ProgressBarProps {
    percent: number;
    stepPositions?: Array<number>;
    unfilledBackground?: string;
    filledBackground?: string;
    width?: number;
    height?: number;
    hasStepZero?: boolean;
    text?: string;
  }
  interface StepProps {
    children: (props: {
      accomplished: boolean;
      transitionState: string;
      index: number;
      position: number;
    }) => React.ReactNode;
    transition?: 'scale' | 'rotate' | 'skew';
    transitionDuration?: number;
  }
  class ProgressBar extends React.Component<ProgressBarProps, any> {}
  class Step extends React.Component<StepProps, any> {}
}
pinefirst commented 1 year ago

I have same issue in typescript

tomniermann commented 1 year ago

ProgressBarProps also needs children so...

declare module 'react-step-progress-bar' {
  import React from 'react'

  interface ProgressBarProps {
    percent: number
    stepPositions?: number[]
    unfilledBackground?: string
    filledBackground?: string
    width?: number
    height?: number
    hasStepZero?: boolean
    text?: string
    children?:
    | React.ReactChild
    | React.ReactChild[]
  }
  interface StepProps {
    children: (props: {
      accomplished: boolean
      transitionState: string
      index: number
      position: number
    }) => React.ReactNode
    transition?: 'scale' | 'rotate' | 'skew'
    transitionDuration?: number
  }
  class ProgressBar extends React.Component<ProgressBarProps, any> {}
  class Step extends React.Component<StepProps, any> {}
}
gothraven commented 1 year ago

Thank you @tomniermann @andresdsep πŸ™ I hope the types will be included in future releases!

gothraven commented 1 year ago

@pierreericgarcia I'm looking forward to help with adding types and or transforming the code base into typescript but I don't see branches for that matter, I'd love to get in touch with you if there is more I should know about the migration to typescript πŸ™

temirovtemirlan commented 10 months ago

Thank you very much, for typing this awesome libraryπŸš€πŸš€πŸš€