gsoft-inc/sg-orbit

๐Ÿ› ButtonAsLink should export its props

Closed this issue ยท 3 comments

Describe the bug

The current ButtonAsLink button is exported like this.

export const ButtonAsLink = slot("button", as(Button, "a"));

But the other component have the following line after

export type ButtonProps = ComponentProps<typeof Button>;

i'd like the ButtonAsLink button to export its property like this as well

Steps to reproduce

the current way we have to type is the following.

import { ButtonAsLink } from "@sharegate/orbit-ui

type ConnectTenantButton = Omit<ComponentProps<typeof ButtonAsLink>, "children">

function ConnectTenantButton(props: ConnectTenantButton) {
        return (
           <ButtonAsLink variant="secondary" {...props}>
              <AddIcon />
              <Text>Connect Tenant</Text>
          </ButtonAsLink>
         );
}

Expected results

the current way we have to type is the following.

import { ButtonAsLink, ButtonAsLinkProps } from "@sharegate/orbit-ui

type ConnectTenantButton = Omit<ButtonAsLinkProps, "children">

function ConnectTenantButton(props: ConnectTenantButton) {
        return (
           <ButtonAsLink variant="secondary" {...props}>
              <AddIcon />
              <Text>Connect Tenant</Text>
          </ButtonAsLink>
         );
}

In your example, you are comparing the export of a component with the export of props. This isnโ€™t comparable.

The idea is that if a consumer want the ButtonAsLink props itโ€™s supposed to use the ButtonProps as they are the same. ButtonAsLink is a regular button render as a โ€œaโ€ element rather than a โ€œbuttonโ€ element.

If you really want to export props specific to ButtonAsLink, you can do ButtonAsLinkProps = ButtonProps and export this.

ButtonAsLinkProps contains href, buttonProps does not. So they are not the same no!

Meh, you're right! Sorry.