Skip to content

Commit

Permalink
chore: storybook update
Browse files Browse the repository at this point in the history
  • Loading branch information
henrynoowah committed Jan 6, 2025
1 parent 1474b4f commit 617d69f
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 30 deletions.
5 changes: 5 additions & 0 deletions apps/docs/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import type { StorybookConfig } from "@storybook/react-vite";
const config: StorybookConfig = {
framework: "@storybook/react-vite",
stories: ["../stories/*.stories.tsx", "../stories/**/*.stories.tsx"],
addons: [
"@storybook/addon-docs",
"@storybook/addon-essentials",
"@storybook/addon-links",
],
core: {
builder: "@storybook/builder-vite",
},
Expand Down
2 changes: 2 additions & 0 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
"@repo/config-eslint": "workspace:*",
"@repo/config-typescript": "workspace:*",
"@storybook/addon-actions": "^8.4.7",
"@storybook/addon-docs": "^8.4.7",
"@storybook/addon-essentials": "^8.4.7",
"@storybook/addon-links": "^8.4.7",
"@storybook/blocks": "^8.4.7",
"@storybook/react": "^8.4.7",
"@storybook/builder-vite": "^8.4.7",
"@storybook/react-vite": "^8.4.7",
Expand Down
13 changes: 4 additions & 9 deletions apps/docs/stories/editor.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ import Editor from "@noowah/content-builder/editor";

const meta: Meta<typeof Editor> = {
title: "UI/Editor",
component: (props) => (
<div className="nwcb-w-full nwcb-flex nwcb-justify-center">
<Editor {...props} />,
</div>
),
tags: ["autodocs"],
component: Editor,
decorators: [(Story) => <Story />],
tags: ["!autodocs"],
parameters: { layout: "full" },
// parameters: { layout: "centered" },
};

export default meta;
Expand All @@ -19,9 +15,8 @@ type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {
// children: (props) => <SettingsButton {...props} />,
onChange: () => {},
onSubmit: () => {},
onChange: () => {},
data: {
id: "page_1",
title: "About Us",
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"private": true,
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev",
"build": "turbo build",
"dev": "turbo dev",
"preview-storybook": "turbo run preview-storybook --filter=./apps/docs",
"lint": "turbo run lint",
"clean": "turbo run clean && rm -rf node_modules",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
Expand Down
5 changes: 3 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"description": "",
"license": "MIT",
"scripts": {
"build": "tsup",
"build": "npm run build:tailwind & tsup",
"lint": "eslint src/",
"dev": "tailwindcss -i ./src/global.css -o ./dist/index.css & tsup --watch",
"dev": "npm run build:tailwind & tsup --watch",
"build:tailwind": "tailwindcss -i ./src/global.css -o ./dist/index.css",
"type-check": "tsc --noEmit"
},
"main": "./dist/index.js",
Expand Down
16 changes: 1 addition & 15 deletions packages/ui/src/components/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { convertJSONToCSS } from "../../lib";
import type {
Block,
EditorContextProps,
EditorProps,
Page,
Section,
SectionEditor,
Expand All @@ -28,21 +29,6 @@ import { twMerge } from "tailwind-merge";

const SectionEditor = lazy(() => import("./section-editor"));

interface EditorProps {
view?: "web" | "mobile";
data: Page;
onChange?: (page: Page) => void;
onSubmit?: (page: Page) => void;
children?: (
ctx: EditorContextProps & {
addBlock: (sectionId: string, block: Block) => void;
}
) => React.ReactNode;
options?: {
focus: (() => React.ReactNode) | boolean;
};
}

const Editor = ({ view = "web", data, onSubmit, children }: EditorProps) => {
const methods = useForm<Page>({
values: data,
Expand Down
16 changes: 16 additions & 0 deletions packages/ui/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,24 @@ type Block = {
content?: string;
};

type EditorProps = {
view?: "web" | "mobile";
data: Page;
onChange?: (page: Page) => void;
onSubmit?: (page: Page) => void;
children?: (
ctx: EditorContextProps & {
addBlock: (sectionId: string, block: Block) => void;
}
) => React.ReactNode;
options?: {
focus: (() => React.ReactNode) | boolean;
};
};

export type {
EditorContextProps,
EditorProps,
Page,
Section,
SectionEditor,
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@repo/config-typescript/react-library.json",
"include": ["."],
"include": [".", "src/**/*"],
"exclude": ["dist", "build", "node_modules"],
"compilerOptions": {
"baseUrl": ".",
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
"cache": false,
"persistent": true
},
"preview-storybook": {
"cache": false
},
"clean": {
"cache": false
}
}
}
}

0 comments on commit 617d69f

Please sign in to comment.