diff --git a/.changeset/config.json b/.changeset/config.json index f240d9445..09819c4f7 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -7,5 +7,10 @@ "access": "public", "baseBranch": "main", "updateInternalDependencies": "patch", - "ignore": ["@react-grab/website", "@react-grab/web-extension", "@react-grab/storybook"] + "ignore": [ + "@react-grab/website", + "@react-grab/website-v2", + "@react-grab/web-extension", + "@react-grab/storybook" + ] } diff --git a/apps/storybook/.storybook/preview.tsx b/apps/storybook/.storybook/preview.tsx index 7e0716df5..9bb85d52e 100644 --- a/apps/storybook/.storybook/preview.tsx +++ b/apps/storybook/.storybook/preview.tsx @@ -19,4 +19,32 @@ export default definePreview({ test: "todo", }, }, + globalTypes: { + theme: { + description: "Color scheme for react-grab UI", + toolbar: { + title: "Theme", + icon: "mirror", + items: [ + { value: "dark", title: "Dark", icon: "moon" }, + { value: "light", title: "Light", icon: "sun" }, + ], + dynamicTitle: true, + }, + }, + }, + initialGlobals: { + theme: "dark", + }, + decorators: [ + (Story, context) => { + const theme = context.globals.theme ?? "dark"; + const canvasBg = theme === "light" ? "#f0f0f0" : "#1a1a1a"; + return ( +
+ +
+ ); + }, + ], }); diff --git a/apps/storybook/stories/comments-dropdown.stories.tsx b/apps/storybook/stories/comments-dropdown.stories.tsx deleted file mode 100644 index 12a27a051..000000000 --- a/apps/storybook/stories/comments-dropdown.stories.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import type { Meta, StoryObj } from "storybook-solidjs-vite"; -import { expect, waitFor } from "storybook/test"; -import { CommentsDropdown } from "react-grab/src/components/comments-dropdown.js"; -import type { DropdownAnchor } from "react-grab/src/types.js"; -import type { CommentPreset } from "./fixtures.js"; -import { COMMENT_PRESET_KEYS, getItemPresets } from "./fixtures.js"; -import { Canvas } from "./target-box.js"; -import { noop } from "./noop.js"; - -interface CommentsDropdownSceneProps { - preset: CommentPreset; -} - -const TOOLBAR_WIDTH_PX = 200; -const FALLBACK_VIEWPORT_WIDTH = 1024; -const FALLBACK_VIEWPORT_HEIGHT = 640; - -const viewportWidth = typeof window === "undefined" ? FALLBACK_VIEWPORT_WIDTH : window.innerWidth; -const viewportHeight = - typeof window === "undefined" ? FALLBACK_VIEWPORT_HEIGHT : window.innerHeight; - -const DROPDOWN_ANCHOR: DropdownAnchor = { - x: Math.round(viewportWidth / 2), - y: Math.round(viewportHeight / 3), - edge: "top", - toolbarWidth: TOOLBAR_WIDTH_PX, -}; - -const meta: Meta = { - title: "Components/CommentsDropdown", - render: (args) => ( - - - - ), - play: async ({ canvasElement }) => { - await waitFor(() => { - expect(canvasElement.querySelector("[data-react-grab-comments-dropdown]")).not.toBeNull(); - }); - }, - args: { preset: "multiple" }, - argTypes: { - preset: { control: "select", options: COMMENT_PRESET_KEYS }, - }, -}; - -export default meta; - -type Story = StoryObj; - -export const Empty: Story = { args: { preset: "empty" } }; -export const SingleItem: Story = { args: { preset: "single" } }; -export const MultipleItems: Story = { args: { preset: "multiple" } }; -export const Annotated: Story = { args: { preset: "annotated" } }; -export const LongNames: Story = { args: { preset: "long-names" } }; -export const Many: Story = { args: { preset: "many" } }; -export const TagOnly: Story = { args: { preset: "tag-only" } }; diff --git a/apps/storybook/stories/fixtures.ts b/apps/storybook/stories/fixtures.ts index d3d3fd782..7360c5a0d 100644 --- a/apps/storybook/stories/fixtures.ts +++ b/apps/storybook/stories/fixtures.ts @@ -1,216 +1,9 @@ -import type { CommentItem, ContextMenuAction } from "react-grab/src/types.js"; +import type { ContextMenuAction } from "react-grab/src/types.js"; import { noop } from "./noop.js"; -export type CommentPreset = - | "empty" - | "single" - | "multiple" - | "annotated" - | "long-names" - | "many" - | "tag-only"; - -export const COMMENT_PRESET_KEYS: readonly CommentPreset[] = [ - "empty", - "single", - "multiple", - "annotated", - "long-names", - "many", - "tag-only", -] as const; - export const createMenuActions = (openEnabled: boolean): ContextMenuAction[] => [ { id: "copy", label: "Copy", shortcut: "C", onAction: noop }, { id: "copy-details", label: "Copy details", onAction: noop }, { id: "open", label: "Open", shortcut: "O", enabled: openEnabled, onAction: noop }, { id: "comment", label: "Comment", shortcut: "Enter", onAction: noop }, ]; - -export const getItemPresets = (): Record => { - const now = Date.now(); - return { - empty: [], - single: [ - { - id: "c1", - content: " + + + setTheme("light")}>Light + setTheme("dark")}>Dark + setTheme("system")}>System + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + Default + Secondary + Outline + Destructive + +
+ +
+ + + Default Alert + + This is a default alert with some helpful information. + + + + + Destructive Alert + Something went wrong. Please try again. + +
+ +
+ + + SM + + + + CN + + + + LG + + + + + + A + + + B + + + C + + + +
+ +
+ + + Card Title + Card description goes here with supporting text. + + +

Card content with any elements inside.

+
+ + + + +
+
+ +
+ + + + + +