Skip to content

[WIP] [BREAKING] Exporting existing components props to allow extension #362

Description

@petertodorov

Hi there, I am wondering if there is a way to create a new custom component (e.g. MyCustomTabs) based on react-bulma-components Tabs component by also adding a new type to the already existing ones type?: 'toggle' | 'boxed' | 'toggle-rounded' | 'MYCUSTOMTYPE'?

I see that the interface coming with Tabs from 'react-bulma-components'

interface TabsProps {
  align?: 'center' | 'right';
  size?: Size;
  type?: 'toggle' | 'boxed' | 'toggle-rounded';
  fullwidth?: boolean;
}

is not exported so I cannot import it and extend it with additional types where I need it.The dummy example I provide will end up with TS throwing an error that <Tabs> Type 'MYCUSTOTYPE' is not assignable to type '"toggle" | "boxed" | "toggle-rounded" | undefined'.

  export interface MyCustomTabsProps {
  className?: string
  renderAs?: string
  align?: 'center' | 'right'
  size?: 'small' | 'medium' | 'large' | string
  type?: 'toggle' | 'boxed' | 'toggle-rounded' | 'MYCUSTOMTYPE'
  fullwidth?: boolean
}
  export const MyCustomTabs: React.FC<MyCustomTabsProps> = ({
  className, 
  renderAs,
  ...props
  }): JSX.Element => {
    return (
      <Tabs  className={className} {...props}>
        <Tabs.Tab renderAs={renderAs || 'span'}>
           Tab content
         </Tabs.Tab>
      </Tabs>
     )
  }

If you can provide any advice if what I am trying to do is feasible at all or any way to solve the issue, I will be thankful.
I was also wondering if there is any particular reason for not exporting the interfaces of the of the elements/components from bulma-react-components, since this might be of use in cases like that?

Last but not least,
thank you for the amazing work you're all doing with react-bulma-components
All the best,

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions