= (props) => {
10 | const [count, setCount] = createSignal(props.initialValue ?? 0);
11 |
12 | const getColor = () => (props.theme === "red" ? "red" : "black");
13 |
14 | return (
15 |
16 |
22 |
23 | );
24 | };
25 |
--------------------------------------------------------------------------------
/src/index.jsx:
--------------------------------------------------------------------------------
1 | /* @refresh reload */
2 | import { render } from "solid-js/web";
3 |
4 | render(() => Test app
, document.getElementById("root"));
5 |
--------------------------------------------------------------------------------
/src/stories/Counter.stories.tsx:
--------------------------------------------------------------------------------
1 | import type { Meta, StoryObj } from "@storybook/html";
2 | import type { ComponentProps } from "solid-js";
3 |
4 | import { Counter } from "../Counter";
5 | import type { CounterProps } from "../Counter";
6 |
7 | type Story = StoryObj;
8 |
9 | export const Default: Story = {
10 | args: {
11 | initialValue: 12,
12 | theme: "default",
13 | },
14 | };
15 |
16 | export const Second: Story = {
17 | args: {
18 | initialValue: 35,
19 | },
20 | };
21 |
22 | export const Thrid: Story = {
23 | args: {
24 | initialValue: 3225,
25 | },
26 | };
27 |
28 | export default {
29 | title: "Example/Counter",
30 | tags: ["autodocs"],
31 | /**
32 | * Here you need to render JSX for HMR work!
33 | *
34 | * render: Counter won't trigger HMR updates
35 | */
36 | render: (props) => ,
37 | argTypes: {
38 | initialValue: { control: "number" },
39 | theme: {
40 | options: ["default", "red"],
41 | control: { type: "radio" },
42 | },
43 | },
44 | } as Meta>;
45 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "strict": true,
4 | "target": "ESNext",
5 | "module": "ESNext",
6 | "moduleResolution": "node",
7 | "allowSyntheticDefaultImports": true,
8 | "esModuleInterop": true,
9 | "jsx": "preserve",
10 | "jsxImportSource": "solid-js",
11 | "types": ["vite/client"],
12 | "noEmit": true,
13 | "isolatedModules": true
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 | import solidPlugin from 'vite-plugin-solid';
3 |
4 | export default defineConfig({
5 | plugins: [solidPlugin()],
6 | server: {
7 | port: 3000,
8 | },
9 | build: {
10 | target: 'esnext',
11 | },
12 | });
13 |
--------------------------------------------------------------------------------