Code Monkey home page Code Monkey logo

Comments (5)

Forthtilliath avatar Forthtilliath commented on July 20, 2024 1

Hum, it's not what à i posted few days ago. I'll remake it

Edit: Stackblitz fixed! Tell me if it's not good yet.

from storybook.

xeho91 avatar xeho91 commented on July 20, 2024 1

Inspecting this issue, I firstly suspected @storybookjs/addon-svelte-csf (because __docgen sounded familiar to me) code transformation - commenting out the export default or export { meta }. It wasn't the root cause for this issue, I've verified it quickly by changing the plugin to remove instead of commenting out. No luck.

Below is my observations notes, perhaps could help other maintainers debug quicker to figure out why it doesn't work.

In this reproduction case, I noticed the Calendar is using "compound component", quite common pattern in React AFAIK.

<!-- calendar-svelte -->
<script lang="ts">
	import { Calendar as CalendarPrimitive } from "bits-ui";
	import * as Calendar from "./index.js"; // This breaks the Storybook
	import { cn } from "$lib/utils.js";
	// ...
</script>

The imported file content is:

// calendar/index.js
import Root from "./calendar.svelte";
import Cell from "./calendar-cell.svelte";
import Day from "./calendar-day.svelte";
import Grid from "./calendar-grid.svelte";
import Header from "./calendar-header.svelte";
import Months from "./calendar-months.svelte";
import GridRow from "./calendar-grid-row.svelte";
import Heading from "./calendar-heading.svelte";
import GridBody from "./calendar-grid-body.svelte";
import GridHead from "./calendar-grid-head.svelte";
import HeadCell from "./calendar-head-cell.svelte";
import NextButton from "./calendar-next-button.svelte";
import PrevButton from "./calendar-prev-button.svelte";

export {
	Day,
	Cell,
	Grid,
	Header,
	Months,
	GridRow,
	Heading,
	GridBody,
	GridHead,
	HeadCell,
	NextButton,
	PrevButton,
	//
	Root as Calendar,
};

For some reason which I haven't found yet, this breaks only in Storybook. It works with normal Vite build.

Current workaround

This is not what you want for sure, it will decrease code readability. But it will work, at least for the time being until the issue is resolved - if that's acceptable for you.

<script lang="ts">
	import { Calendar as CalendarPrimitive } from "bits-ui";
-	import * as Calendar from "./index.js"; // This breaks the Storybook
+	import { Day, Cell, Grid, Header, Months, GridRow, Heading, GridBody, GridHead, HeadCell, NextButton, PrevButton, Calendar } from "./index.js";
	import { cn } from "$lib/utils.js";
	// ...
</script>

from storybook.

phlrss avatar phlrss commented on July 20, 2024

i'm having the same issue - also with shadcn-svelte in storybook

from storybook.

xeho91 avatar xeho91 commented on July 20, 2024

The reproduction link doesn't show the setup you described, nor show the issue you have.

from storybook.

Forthtilliath avatar Forthtilliath commented on July 20, 2024

I tried, and it works. It's not optimal, but at least it works and it's simple to fix. Thanks a lot !

from storybook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.