diff --git a/package.json b/package.json index 3ed3b0d..692f055 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "build": "turbo build", "changeset": "changeset", "changeset.apply": "changeset version && pnpm i --no-frozen-lockfile && git add .", + "changeset.publish": "pnpm changeset.release", "changeset.release": "pnpm build && pnpm publint && changeset publish", "clear-cache": "rm -rf packages/*/.turbo && rm -rf packages/*/.next && jest --clearCache", "dev": "turbo run build && turbo run dev --no-deps --no-cache --parallel --concurrency 20", diff --git a/packages/examples/react/app.tsx b/packages/examples/react/app.tsx index c456b10..8631be7 100644 --- a/packages/examples/react/app.tsx +++ b/packages/examples/react/app.tsx @@ -3,10 +3,18 @@ import '@storylite/storylite/dist/index.css' import React from 'react' import ReactDOM from 'react-dom/client' -import { StoryLiteRouter } from '@storylite/storylite' +import { StoryLiteApp } from '@storylite/storylite' +import stories from 'virtual:storylite-stories' ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( - + , ) diff --git a/packages/examples/react/tsconfig.json b/packages/examples/react/tsconfig.json index eb5d406..15a3770 100644 --- a/packages/examples/react/tsconfig.json +++ b/packages/examples/react/tsconfig.json @@ -3,6 +3,7 @@ "include": ["stories", "src", "*.ts", "*.tsx"], "compilerOptions": { "jsx": "react-jsx", - "allowSyntheticDefaultImports": true + "allowSyntheticDefaultImports": true, + "types": ["node", "react", "react-dom", "@storylite/storylite/dist/virtual-modules.d.ts"] } } diff --git a/packages/examples/react/vite.config.ts b/packages/examples/react/vite.config.ts index a0cf921..4355f9e 100644 --- a/packages/examples/react/vite.config.ts +++ b/packages/examples/react/vite.config.ts @@ -15,9 +15,7 @@ export default defineConfig({ }, plugins: [ storylitePlugin({ - title: 'StoryLite - React', // Sidebar title stories: 'stories/**/*.stories.tsx', // relative to the CWD - defaultStory: 'index', // index page file prefix, e.g. index = index.stories.tsx }), react(), ], diff --git a/packages/storylite/package.json b/packages/storylite/package.json index 9c9a242..da6a1b4 100644 --- a/packages/storylite/package.json +++ b/packages/storylite/package.json @@ -1,6 +1,6 @@ { "name": "@storylite/storylite", - "version": "0.1.4", + "version": "0.1.5", "description": "A lightweight alternative to StoryBook, built on top of Vite⚡️", "license": "MIT", "type": "module", diff --git a/packages/storylite/src/router.tsx b/packages/storylite/src/app.tsx similarity index 86% rename from packages/storylite/src/router.tsx rename to packages/storylite/src/app.tsx index 5a902a0..b0019ff 100644 --- a/packages/storylite/src/router.tsx +++ b/packages/storylite/src/app.tsx @@ -1,6 +1,7 @@ import React from 'react' import { ActionFunction, createHashRouter, LoaderFunction, RouterProvider } from 'react-router-dom' +import { StoryliteDataContext } from './context/StoriesDataContext' import MainLayout from './layouts/MainLayout' import Error404, { Layout as ErrorLayout } from './pages/404' import * as IndexPage from './pages/index' @@ -8,6 +9,7 @@ import * as SandboxDashboardPage from './pages/sandbox/dashboard' import * as SandboxStoryIndex from './pages/sandbox/stories/$story' import * as SandboxExportedStory from './pages/sandbox/stories/$story/$export_name' import * as ExportedStory from './pages/stories/$story/$export_name' +import { StoryLiteAppConfig, StoryModulesMap } from './types' type PageType = { default?: React.FC @@ -99,8 +101,12 @@ const router = createHashRouter( })), ) -const Router = () => { - return +const StoryLiteApp = (props: { config?: StoryLiteAppConfig; stories: StoryModulesMap }) => { + return ( + + + + ) } -export default Router +export default StoryLiteApp diff --git a/packages/storylite/src/components/Sidebar.tsx b/packages/storylite/src/components/Sidebar.tsx index 8357134..b39200e 100644 --- a/packages/storylite/src/components/Sidebar.tsx +++ b/packages/storylite/src/components/Sidebar.tsx @@ -2,8 +2,8 @@ import React, { useState } from 'react' import { Link, useParams } from 'react-router-dom' import { Bookmark, MinusSquare, PlusSquare } from 'lucide-react' -import storyMap from 'storylite-user-stories' +import { useStoryliteStories } from '@/context/StoriesDataContext' import { ElementIds, StoryMeta, StoryModule, StoryModulesMapValue } from '@/types' type SidebarProps = { @@ -18,8 +18,6 @@ type SidebarItemBaseProps = { currentExportName?: string } -const minTooltipLength = 16 - export default function Sidebar({ title, ...rest }: SidebarProps) { const { story, export_name } = useParams() @@ -40,10 +38,12 @@ function SidebarNav({ currentStoryName?: string currentExportName?: string }): JSX.Element { + const stories = useStoryliteStories() + return (