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

Incorrect element name in StoryBook #289

Open
Kye-NG opened this issue Jan 1, 2023 · 4 comments
Open

Incorrect element name in StoryBook #289

Kye-NG opened this issue Jan 1, 2023 · 4 comments

Comments

@Kye-NG
Copy link

Kye-NG commented Jan 1, 2023

Tab Element Name Incorrect.

Currently all the Tabs in storybook show Tab as the element name.
https://react.daisyui.com/?path=/story/navigation-tabs--lifted

Screen Shot 2023-01-01 at 1 39 26 pm

But Tab is not exported by react-daisyui.
Screen Shot 2023-01-01 at 1 43 52 pm

The correct element name is Tabs.Tab like below:
Screen Shot 2023-01-01 at 1 41 33 pm

Fix

Update storybook to show Tabs.Tab for Tab elements.

This is probably a good "first-fix" kind of ticket.

@benjitrosch
Copy link
Collaborator

Hi @Kye-NG, you can accomplish this with destructuring at the top of your file.

e.g.:

import { Tabs } from 'react-daisyui'

const { Tab } = Tabs

export default (props) => {
  return (
    <Tabs>
      <Tab value="one">Tab 1</Tab>
      <Tab value="two">Tab 2</Tab>
    </Tabs>
  )
}

@Kye-NG
Copy link
Author

Kye-NG commented Jan 2, 2023

Thanks @benjitrosch Would it be a good idea to note this in StoryBook?

@benjitrosch
Copy link
Collaborator

benjitrosch commented Jan 3, 2023

Good question @Kye-NG— it might seem obvious to just include it, but I'm a little conflicted. Would love to hear your thoughts!

The Problem:
At the moment, our stories show a preview of the component's code (local state, return value), but not the surrounding code from the .stories file. You can see that the Tab component gets destructured at the top of the file (https://github.com/daisyui/react-daisyui/blob/main/src/Tabs/Tabs.stories.tsx#L6), which means it would not be included in the code preview.

If we move it into the component's code, that would promote bad practices, and I'm concerned people would take that to be the "correct" way to access subcomponents.

Alternatively, we could rewrite all of the Storybook examples to remove destructuring of subcomponents, aka replace Tab with Tabs.Tab, which might be a little uglier/more verbose but would clear up all ambiguity about the component's origin.

@dev0T
Copy link
Contributor

dev0T commented Apr 5, 2023

As someone that just started to get familiar with the code base, my opinion is that would be better if it was consistent, so your solution @benjitrosch of rewriting the Storybook examples would be the best.

For example, Stats, Steps and Table are shown in the examples as being accessed without being deconstructed. Select on the other hand is being deconstructed the same way as Tab is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants