storybook-framework-qwik 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook-framework-qwik",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Storybook for Qwik: View Qwik components in isolation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -42,6 +42,16 @@
|
|
|
42
42
|
},
|
|
43
43
|
"./package.json": "./package.json"
|
|
44
44
|
},
|
|
45
|
+
"typesVersions": {
|
|
46
|
+
"*": {
|
|
47
|
+
"*": [
|
|
48
|
+
"./dist/index.d.ts"
|
|
49
|
+
],
|
|
50
|
+
"qwik-city-decorator": [
|
|
51
|
+
"./dist/qwik-city-decorator.d.ts"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
45
55
|
"homepage": "https://github.com/literalpie/storybook-framework-qwik",
|
|
46
56
|
"bugs": {
|
|
47
57
|
"url": "https://github.com/literalpie/storybook-framework-qwik"
|
|
@@ -55,6 +65,7 @@
|
|
|
55
65
|
"files": [
|
|
56
66
|
"README.md",
|
|
57
67
|
"./dist/*.js",
|
|
68
|
+
"./template/cli/**",
|
|
58
69
|
"*.js",
|
|
59
70
|
"*.d.ts",
|
|
60
71
|
"./dist/*.d.ts"
|
|
@@ -70,10 +81,10 @@
|
|
|
70
81
|
"@storybook/builder-vite": "^7.0.0-beta.7"
|
|
71
82
|
},
|
|
72
83
|
"peerDependencies": {
|
|
73
|
-
"@builder.io/qwik": "
|
|
84
|
+
"@builder.io/qwik": ">=0.15.2"
|
|
74
85
|
},
|
|
75
86
|
"optionalDependencies": {
|
|
76
|
-
"@builder.io/qwik-city": "
|
|
87
|
+
"@builder.io/qwik-city": ">=0.0.128"
|
|
77
88
|
},
|
|
78
89
|
"devDependencies": {
|
|
79
90
|
"@types/node": "^16.0.0",
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { action } from '@storybook/addon-actions';
|
|
2
|
+
import { $ } from '@builder.io/qwik';
|
|
3
|
+
import { Meta, StoryObj } from 'storybook-framework-qwik';
|
|
4
|
+
import { ButtonProps, Button } from './button';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Button',
|
|
8
|
+
args: {
|
|
9
|
+
// automatic actions are not yet supported.
|
|
10
|
+
// See https://github.com/literalpie/storybook-framework-qwik/issues/16
|
|
11
|
+
// For now, use the legacy addon-actions API wrapped in a $ to make your own QRL action.
|
|
12
|
+
onClick$: $((event, element) => {
|
|
13
|
+
action('click action')({ event, element });
|
|
14
|
+
}),
|
|
15
|
+
},
|
|
16
|
+
argTypes: {
|
|
17
|
+
backgroundColor: { control: 'color' },
|
|
18
|
+
},
|
|
19
|
+
render: ({ label, backgroundColor, primary, onClick$, size }) => {
|
|
20
|
+
return (
|
|
21
|
+
<Button
|
|
22
|
+
backgroundColor={backgroundColor}
|
|
23
|
+
primary={primary}
|
|
24
|
+
onClick$={(args, element) => onClick$?.(args, element)}
|
|
25
|
+
size={size}
|
|
26
|
+
>
|
|
27
|
+
{label}
|
|
28
|
+
</Button>
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
component: Button,
|
|
32
|
+
} as Meta<ButtonProps & { label: string }>;
|
|
33
|
+
|
|
34
|
+
type Story = StoryObj<ButtonProps & { label: string }>;
|
|
35
|
+
|
|
36
|
+
// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args
|
|
37
|
+
export const Primary: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
primary: true,
|
|
40
|
+
label: 'Button',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const Secondary: Story = {
|
|
45
|
+
args: {
|
|
46
|
+
label: 'Button',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const Large: Story = {
|
|
51
|
+
args: {
|
|
52
|
+
size: 'large',
|
|
53
|
+
label: 'Button',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const Small: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
size: 'small',
|
|
60
|
+
label: 'Button',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
component$,
|
|
3
|
+
QRL,
|
|
4
|
+
QwikMouseEvent,
|
|
5
|
+
Slot,
|
|
6
|
+
useStylesScoped$,
|
|
7
|
+
} from "@builder.io/qwik";
|
|
8
|
+
import buttonStyles from "./button.css?inline";
|
|
9
|
+
|
|
10
|
+
export interface ButtonProps {
|
|
11
|
+
/**
|
|
12
|
+
* Is this the principal call to action on the page?
|
|
13
|
+
*/
|
|
14
|
+
primary?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* What background color to use
|
|
17
|
+
*/
|
|
18
|
+
backgroundColor?: string;
|
|
19
|
+
/**
|
|
20
|
+
* How large should the button be?
|
|
21
|
+
*/
|
|
22
|
+
size?: "small" | "medium" | "large";
|
|
23
|
+
/**
|
|
24
|
+
* Optional click handler
|
|
25
|
+
*/
|
|
26
|
+
onClick$?: QRL<onClickEvent> | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const getClassForSize = (size: "small" | "medium" | "large") => {
|
|
30
|
+
switch (size) {
|
|
31
|
+
case "small":
|
|
32
|
+
return "storybook-button--small";
|
|
33
|
+
case "medium":
|
|
34
|
+
return "storybook-button--medium";
|
|
35
|
+
case "large":
|
|
36
|
+
return "storybook-button--large";
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type onClickEvent = (
|
|
41
|
+
event: QwikMouseEvent<HTMLButtonElement, MouseEvent>,
|
|
42
|
+
element: Element
|
|
43
|
+
) => any;
|
|
44
|
+
|
|
45
|
+
export const Button = component$<ButtonProps>(
|
|
46
|
+
({ primary = false, size = "medium", backgroundColor, onClick$ }) => {
|
|
47
|
+
useStylesScoped$(buttonStyles);
|
|
48
|
+
const classes = [
|
|
49
|
+
"storybook-button",
|
|
50
|
+
primary ? "storybook-button--primary" : "storybook-button--secondary",
|
|
51
|
+
getClassForSize(size),
|
|
52
|
+
];
|
|
53
|
+
return (
|
|
54
|
+
<button
|
|
55
|
+
class={classes}
|
|
56
|
+
style={{ backgroundColor }}
|
|
57
|
+
onClick$={(event, element) => onClick$?.(event, element)}
|
|
58
|
+
>
|
|
59
|
+
<Slot />
|
|
60
|
+
</button>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Meta } from "storybook-framework-qwik";
|
|
2
|
+
import { StoryExample, StoryExampleProps } from "./story-example";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: "Story Example",
|
|
6
|
+
args: {
|
|
7
|
+
label: "Example label",
|
|
8
|
+
color: "red",
|
|
9
|
+
},
|
|
10
|
+
argTypes: {
|
|
11
|
+
color: {
|
|
12
|
+
options: ["red", "green", "blue"],
|
|
13
|
+
control: {
|
|
14
|
+
type: "select",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
render: ({ label, color }) => {
|
|
19
|
+
return <StoryExample color={color}>{label}</StoryExample>;
|
|
20
|
+
},
|
|
21
|
+
component: StoryExample,
|
|
22
|
+
} as Meta<Options>;
|
|
23
|
+
|
|
24
|
+
type Options = StoryExampleProps & { label: string };
|
|
25
|
+
|
|
26
|
+
export const Default = {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { component$, Slot, useStylesScoped$ } from '@builder.io/qwik';
|
|
2
|
+
|
|
3
|
+
export interface StoryExampleProps {
|
|
4
|
+
color: 'red' | 'green' | 'blue';
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const StoryExample = component$((props: StoryExampleProps) => {
|
|
8
|
+
useStylesScoped$(`
|
|
9
|
+
div {
|
|
10
|
+
align-items: center;
|
|
11
|
+
border-radius: 50%;
|
|
12
|
+
display: flex;
|
|
13
|
+
height: 200px;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
width: 200px;
|
|
16
|
+
}
|
|
17
|
+
`);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div style={`background-color: ${props.color}`}>
|
|
21
|
+
<span>
|
|
22
|
+
<Slot />
|
|
23
|
+
</span>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
});
|