Skip to content

Commit 615fc11

Browse files
committed
added storybook for component testing
1 parent ef5ce21 commit 615fc11

14 files changed

Lines changed: 13709 additions & 2992 deletions

.storybook/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.storybook/preview.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const parameters = {
2+
actions: { argTypesRegex: "^on[A-Z].*" },
3+
controls: {
4+
matchers: {
5+
color: /(background|color)$/i,
6+
date: /Date$/,
7+
},
8+
},
9+
};

declaration.d.ts

Whitespace-only changes.

package.json

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,37 @@
1111
"build": "webpack",
1212
"test": "jest",
1313
"format": "yarn prettier --write .",
14-
"lint": "yarn eslint ."
14+
"lint": "yarn eslint .",
15+
"storybook": "start-storybook -p 6006",
16+
"build-storybook": "build-storybook"
1517
},
1618
"devDependencies": {
17-
"@types/jest": "^29.2.0",
19+
"@babel/core": "^7.20.2",
20+
"@mdx-js/react": "^1.6.22",
21+
"@storybook/addon-actions": "^6.5.13",
22+
"@storybook/addon-docs": "^6.5.13",
23+
"@storybook/addon-essentials": "^6.5.13",
24+
"@storybook/addon-interactions": "^6.5.13",
25+
"@storybook/addon-links": "^6.5.13",
26+
"@storybook/builder-webpack5": "^6.5.13",
27+
"@storybook/manager-webpack5": "^6.5.13",
28+
"@storybook/svelte": "^6.5.13",
29+
"@storybook/testing-library": "^0.0.13",
30+
"@tsconfig/svelte": "^3.0.0",
31+
"@types/jest": "^29.2.3",
1832
"@types/node": "*",
1933
"@typescript-eslint/eslint-plugin": "^5.41.0",
2034
"@typescript-eslint/parser": "^5.41.0",
35+
"babel-loader": "^8.3.0",
2136
"eslint": "^8.26.0",
2237
"eslint-config-prettier": "^8.5.0",
2338
"jest": "^29.2.2",
2439
"prettier": "^2.7.1",
2540
"sass": "^1.54.4",
2641
"sass-loader": "^13.0.2",
42+
"svelte": "^3.53.1",
43+
"svelte-loader": "^3.1.4",
44+
"svelte-preprocess": "^4.10.7",
2745
"ts-jest": "^29.0.3",
2846
"ts-loader": "^9.3.1",
2947
"ts-node": "^10.9.1",

src/app/CreatePlotModal.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Chart } from "function-plot";
2-
import { FunctionPlotDatum } from "function-plot/dist/types";
1+
import type { FunctionPlotDatum } from "function-plot/dist/types";
32
import { Editor, Modal, Setting } from "obsidian";
43
import { DEFAULT_PLOT_OPTIONS } from "../common/defaults";
5-
import { PlotOptions, rendererType, Line } from "../common/types";
4+
import type { PlotOptions, rendererType, Line } from "../common/types";
65
import type ObsidianFunctionPlot from "../main";
76
import { createPlot, renderPlotAsInteractive } from "../common/utils";
7+
import type { Chart } from "function-plot";
88

99
export default class CreatePlotModal extends Modal {
1010
options: PlotOptions;

src/app/SettingsTab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "obsidian";
88
import type ObsidianFunctionPlot from "../main.js";
99
import { DEFAULT_PLUGIN_SETTINGS } from "../common/defaults";
10-
import { PluginSettings } from "../common/types";
10+
import type { PluginSettings } from "../common/types";
1111

1212
export default class SettingsTab extends PluginSettingTab {
1313
plugin: ObsidianFunctionPlot;

src/common/defaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { rendererType, PlotOptions, PluginSettings } from "./types";
1+
import type { rendererType, PlotOptions, PluginSettings } from "./types";
22

33
/**
44
* The options displayed for renderers

src/common/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Chart } from "function-plot";
2-
import { EventEmitter } from "events";
1+
import type { Chart } from "function-plot";
2+
import type { EventEmitter } from "events";
33

44
/**
55
* The possible types of renderer.

src/common/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Editor, parseYaml } from "obsidian";
22
import type ObsidianFunctionPlot from "../main";
3-
import { PlotOptions, Line } from "./types";
4-
import { type FunctionPlotOptions } from "function-plot/dist/types";
3+
import type { PlotOptions, Line } from "./types";
54
import createStylingPlugin from "../plugins/styling";
65
import functionPlot, { Chart } from "function-plot";
6+
import type { FunctionPlotOptions } from "function-plot/dist/types";
77

88
/**
99
* Insert the text as a new paragraph (newline before and after), and place the active cursor below.

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { MarkdownPostProcessorContext, Plugin, Editor } from "obsidian";
1+
import { type MarkdownPostProcessorContext, Plugin, Editor } from "obsidian";
22
import CreatePlotModal from "./app/CreatePlotModal";
33
import SettingsTab from "./app/SettingsTab";
44
import { createPlot, parseCodeBlock } from "./common/utils";
5-
import { PlotOptions, PluginSettings } from "./common/types";
5+
import type { PlotOptions, PluginSettings } from "./common/types";
66
import {
77
DEFAULT_PLOT_OPTIONS,
88
DEFAULT_PLUGIN_SETTINGS,

0 commit comments

Comments
 (0)