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

Add a new type to @clayui/nav in Vertical interface #4121

Closed
kevenleone opened this issue Jun 9, 2021 · 1 comment · Fixed by #4123
Closed

Add a new type to @clayui/nav in Vertical interface #4121

kevenleone opened this issue Jun 9, 2021 · 1 comment · Fixed by #4123
Labels
comp: clay-components Issues related to Clay components. (e.g ClayCard, ClayLabel...) rfc Similar to the RFC that are used in React.js, Ember.js, Gatsby.js and Rust, but to mark problems tha

Comments

@kevenleone
Copy link
Member

kevenleone commented Jun 9, 2021

What is your proposal?

Hi everyone, I'm using this @clayui/nav to build a sidebar menu, and I'm facing a Type Error that i want to propose the change.

In this interface

interface IItem extends React.ComponentProps<typeof Nav.Item> {
    active?: boolean;
    onClick?: () => void;
    href?: string;
    label?: string;
}

The label only accepts a string as value, but in the real scenario, you can pass React Component as well.
I had this particular use case to need to use a React Component in the label spot

{
      items: [
        {
          label: i18n.get("scheduled"),
          onClick: () => router.push("/session"),
        },
      ],
      label: (
        <>
          <ClayIcon symbol="home-full" className="mr-2" />
          {i18n.get("sessions")}
        </>
      ),
    },

So my suggestion is just to add React.ReactElement along with String type.

interface IItem extends React.ComponentProps<typeof Nav.Item> {
    active?: boolean;
    onClick?: () => void;
    href?: string;
    label?: string | React.ReactNode;
}

Why would adopting this proposal be beneficial?

This change can avoid type error, since is already possible to pass a React Component to the label

What are the alternatives to this proposal?

I don't see any

@kevenleone kevenleone added the rfc Similar to the RFC that are used in React.js, Ember.js, Gatsby.js and Rust, but to mark problems tha label Jun 9, 2021
kevenleone added a commit to kevenleone/clay that referenced this issue Jun 9, 2021
@matuzalemsteles matuzalemsteles added the comp: clay-components Issues related to Clay components. (e.g ClayCard, ClayLabel...) label Jun 9, 2021
kevenleone added a commit to kevenleone/clay that referenced this issue Jun 9, 2021
@github-actions
Copy link

This issue has been merged and will be released in DXP at https://issues.liferay.com/browse/LPS-130566

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: clay-components Issues related to Clay components. (e.g ClayCard, ClayLabel...) rfc Similar to the RFC that are used in React.js, Ember.js, Gatsby.js and Rust, but to mark problems tha
Projects
None yet
2 participants