storybook

This commit is contained in:
Michael Zhang 2023-08-24 17:21:48 -04:00
parent af97f17a2c
commit d1f84e06e9
8 changed files with 11612 additions and 9 deletions

22
.storybook/main.ts Normal file
View file

@ -0,0 +1,22 @@
import type { StorybookConfig } from "@storybook/react-vite";
const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-onboarding",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/react-vite",
options: {},
},
docs: {
autodocs: "tag",
},
core: {
disableTelemetry: true,
},
};
export default config;

17
.storybook/preview.ts Normal file
View file

@ -0,0 +1,17 @@
import type { Preview } from "@storybook/react";
import "../src/global.scss";
const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
},
};
export default preview;

View file

@ -48,9 +48,8 @@ function ScrollContainer<T>({
); );
// Viewport state // Viewport state
const { viewportWidth, viewportHeight, setViewportSize } = useContext( const { viewportWidth, viewportHeight, setViewportSize } =
CalendarContext useContext(CalendarContext);
);
const viewportMetric = const viewportMetric =
direction === "horizontal" ? viewportWidth : viewportHeight; direction === "horizontal" ? viewportWidth : viewportHeight;
@ -140,9 +139,7 @@ function ScrollContainer<T>({
}; };
setResetScrollToEl(newResetScrollToEl); setResetScrollToEl(newResetScrollToEl);
setTimeout(() => {
generateNextObject(lastChild); generateNextObject(lastChild);
}, 1000);
} }
} }
}); });

11523
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -8,14 +8,25 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"watch": "vite build --watch", "watch": "vite build --watch",
"build": "vite build" "build": "vite build",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
}, },
"devDependencies": { "devDependencies": {
"@logseq/libs": "^0.0.1-alpha.29", "@logseq/libs": "^0.0.1-alpha.29",
"@storybook/addon-essentials": "^7.3.2",
"@storybook/addon-interactions": "^7.3.2",
"@storybook/addon-links": "^7.3.2",
"@storybook/addon-onboarding": "^1.0.8",
"@storybook/blocks": "^7.3.2",
"@storybook/react": "^7.3.2",
"@storybook/react-vite": "^7.3.2",
"@storybook/testing-library": "^0.2.0",
"@types/react": "^18.2.21", "@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7", "@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.4", "@vitejs/plugin-react": "^4.0.4",
"sass": "^1.66.1", "sass": "^1.66.1",
"storybook": "^7.3.2",
"typescript": "^5.1.6", "typescript": "^5.1.6",
"vite": "^4.4.9", "vite": "^4.4.9",
"vite-tsconfig-paths": "^4.2.0" "vite-tsconfig-paths": "^4.2.0"

View file

@ -21,11 +21,16 @@
} }
.dateNumber { .dateNumber {
cursor: default; cursor: pointer;
text-align: right; text-align: right;
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
padding: 4px; padding: 4px;
transition: background-color 0.1s ease-out;
&:hover {
background-color: #eee;
}
span { span {
padding: 8px; padding: 8px;

View file

@ -1,5 +1,5 @@
.toggleSwitch { .toggleSwitch {
display: flex; display: inline-flex;
gap: 1px; gap: 1px;
border-radius: var(--border-radius); border-radius: var(--border-radius);

View file

@ -0,0 +1,28 @@
import type { Meta, StoryObj } from "@storybook/react";
import ToggleSwitch from "./ToggleSwitch";
import { createElement } from "react";
const meta: Meta<typeof ToggleSwitch> = {
component: ToggleSwitch,
argTypes: { setValue: { action: "changedTo" } },
};
export default meta;
type Story = StoryObj<typeof ToggleSwitch>;
export const Primary: Story = {
args: {
options: ["Hello", "World"],
renderValue: (x) => createElement("div", null, x),
},
parameters: {
backgrounds: {
values: [
{ name: "red", value: "#f00" },
{ name: "green", value: "#0f0" },
{ name: "blue", value: "#00f" },
],
},
},
};