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

[Bug] Show Code doesn't work when using Svelte-native format and <Template/> tags #86

Closed
kyleshepherd opened this issue Dec 20, 2022 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@kyleshepherd
Copy link

Describe the bug

If you use a Svelte-native format for a story, and use the <Template/> tags along with args to reduce boilerplate, the Show Code option on the docs page doesn't display the actual code for the component.

Example:

// Container.stories.svelte
<script lang="ts">
  import { Meta, Template, Story } from "@storybook/addon-svelte-csf";
  import Container from "./Container.svelte";
</script>

<style lang="scss">
  .block {
    background-color: $dark;
    height: 100vh;
    width: 100%;
  }
</style>

<Meta title="Components/Container" component={Container} />

<Template let:args>
  <Container {...args}>
    <div class="block" />
  </Container>
</Template>

<Story name="Default" />

Results in this:
image

Steps to reproduce the behavior

  1. Create a Svelte-native story using Template tags (and using Vite Builder, maybe this is the issue)
  2. View Story Docs
  3. Click "Show Code"
  4. See error

Expected behavior

Viewing the code should display the component code the same way it does when not using Templates such as

<Story name="Default">
    <Container>
        <div class="block"/>
    </Container>
</Story>

Environment

  • OS: MacOS 13.1
  • Node.js version: v16.17.0
  • NPM version: 8.15.0
@kyleshepherd kyleshepherd added the bug Something isn't working label Dec 20, 2022
@kyleshepherd
Copy link
Author

bumping this after the holiday break :)

@kyleshepherd
Copy link
Author

is there anyone maintaining this repo?

on top of the mentioned issue, you can't create your own DocsPage (or even hide the default one) for some reason

The following doesn't work:

<Meta
  title="Components/SpriteIcon"
  component={SpriteIcon}
  argTypes={{
    icon: { control: "text" },
    iconPath: { control: "text" },
    width: { control: "number" },
    height: { control: "number" },
    color: { control: "color" },
  }}
  parameters={{
    docs: {
      page: null
    },
  }}
/>

@MilesWellsSVT
Copy link

I had the same bug crop up when upgrading from Storybook 6 to 7 while also swapping over from Webpack to Vite. Switching back to Webpack while still on Storybook 7 I get the expected code format:
image

However, when spreading args for controls like so:

<Story let:args>
	<Alert {...args}>Alert</Alert>
</Story>

I get this behavior for events (the Alert component here dispatches a "hide" event via the createEventDispatcher):
image

I don't know if this is related, but I did not see this behavior when on SB 6 with version 2.0.10 of this plugin. Now I'm on SB 7 and plugin version 3.0.2.

@crisward
Copy link

Also using svelte on 7. If I setup the story with no args, I get the correct code block

<Story name="Primary Extra Small">
  <Button mode="primary" size="xs">Button</Button>
</Story>
Screenshot 2023-06-21 at 09 02 05

However with args or template block, I get

Screenshot 2023-06-21 at 09 02 45

npm ls (if it helps)

├── @babel/[email protected]
├── @rollup/[email protected]
├── @rollup/[email protected]
├── @rollup/[email protected]
├── @storybook/[email protected]
├── @storybook/[email protected]
├── @storybook/[email protected]
├── @storybook/[email protected]
├── @storybook/[email protected]
├── @storybook/[email protected]
├── @storybook/[email protected]
├── @storybook/[email protected]
├── @sveltejs/[email protected]
├── @sveltejs/[email protected]
├── @testing-library/[email protected]
├── @web/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

@j3rem1e
Copy link
Contributor

j3rem1e commented Sep 2, 2023

Closing this issue because the generation of Svelte snippets are not done by this addon but is the responsibility of the core Storybook/svelte and there is already issues about this bug.

@j3rem1e j3rem1e closed this as not planned Won't fix, can't repro, duplicate, stale Sep 2, 2023
@github-project-automation github-project-automation bot moved this from Nice to have to Done in Core Team Projects Sep 2, 2023
@giamir
Copy link

giamir commented Sep 27, 2023

@j3rem1e Since this issue is now closed could you link here which issue in Storybook/svelte we should follow? Thank you.

@j3rem1e
Copy link
Contributor

j3rem1e commented Sep 27, 2023

At least this one : storybookjs/storybook#24008

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

6 participants