@aurelia/storybook 2.0.0 → 2.1.0

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.
Files changed (56) hide show
  1. package/CONTINUITY.md +22 -0
  2. package/README.md +210 -156
  3. package/apps/hello-world/.storybook/main.ts +0 -1
  4. package/apps/hello-world/package-lock.json +4485 -2626
  5. package/apps/hello-world/package.json +6 -16
  6. package/apps/hello-world/src/components/feedback-form.html +111 -0
  7. package/apps/hello-world/src/components/feedback-form.ts +45 -0
  8. package/apps/hello-world/src/components/notification-center.html +119 -0
  9. package/apps/hello-world/src/components/notification-center.ts +27 -0
  10. package/apps/hello-world/src/components/stat-card.html +107 -0
  11. package/apps/hello-world/src/components/stat-card.ts +33 -0
  12. package/apps/hello-world/src/components/weather-widget.html +89 -0
  13. package/apps/hello-world/src/components/weather-widget.ts +30 -0
  14. package/apps/hello-world/src/hello-world.html +44 -2
  15. package/apps/hello-world/src/services/weather-service.ts +15 -0
  16. package/apps/hello-world/src/stories/feedback-form.stories.ts +52 -0
  17. package/apps/hello-world/src/stories/hello-world.stories.ts +4 -5
  18. package/apps/hello-world/src/stories/notification-center.stories.ts +81 -0
  19. package/apps/hello-world/src/stories/stat-card.stories.ts +65 -0
  20. package/apps/hello-world/src/stories/weather-widget.stories.ts +57 -0
  21. package/apps/hello-world/tsconfig.json +4 -3
  22. package/apps/hello-world/vite.config.ts +0 -2
  23. package/apps/hello-world-webpack/.storybook/main.ts +0 -1
  24. package/apps/hello-world-webpack/package-lock.json +3646 -836
  25. package/apps/hello-world-webpack/package.json +2 -5
  26. package/apps/hello-world-webpack/src/components/feedback-form.html +111 -0
  27. package/apps/hello-world-webpack/src/components/feedback-form.ts +45 -0
  28. package/apps/hello-world-webpack/src/components/notification-center.html +119 -0
  29. package/apps/hello-world-webpack/src/components/notification-center.ts +27 -0
  30. package/apps/hello-world-webpack/src/components/stat-card.html +107 -0
  31. package/apps/hello-world-webpack/src/components/stat-card.ts +33 -0
  32. package/apps/hello-world-webpack/src/components/weather-widget.html +89 -0
  33. package/apps/hello-world-webpack/src/components/weather-widget.ts +30 -0
  34. package/apps/hello-world-webpack/src/hello-world.html +44 -2
  35. package/apps/hello-world-webpack/src/services/weather-service.ts +15 -0
  36. package/apps/hello-world-webpack/src/stories/feedback-form.stories.ts +52 -0
  37. package/apps/hello-world-webpack/src/stories/hello-world.stories.ts +5 -6
  38. package/apps/hello-world-webpack/src/stories/notification-center.stories.ts +81 -0
  39. package/apps/hello-world-webpack/src/stories/stat-card.stories.ts +65 -0
  40. package/apps/hello-world-webpack/src/stories/weather-widget.stories.ts +57 -0
  41. package/apps/hello-world-webpack/tsconfig.json +1 -1
  42. package/package.json +5 -5
  43. package/apps/hello-world/.yarnrc.yml +0 -2
  44. package/apps/hello-world-webpack/.yarnrc.yml +0 -2
  45. package/dist/index.mjs +0 -132
  46. package/dist/index.mjs.map +0 -1
  47. package/dist/preset.mjs +0 -60
  48. package/dist/preset.mjs.map +0 -1
  49. package/dist/preview/render.mjs +0 -114
  50. package/dist/preview/render.mjs.map +0 -1
  51. package/dist/preview/types.mjs +0 -2
  52. package/dist/preview/types.mjs.map +0 -1
  53. package/dist/preview.mjs +0 -114
  54. package/dist/preview.mjs.map +0 -1
  55. package/dist/webpack.mjs +0 -21
  56. package/dist/webpack.mjs.map +0 -1
@@ -0,0 +1,52 @@
1
+ import { fn, userEvent, within } from 'storybook/test';
2
+ import { FeedbackForm } from '../components/feedback-form';
3
+
4
+ const meta = {
5
+ title: 'Dashboard/FeedbackForm',
6
+ component: FeedbackForm,
7
+ parameters: {
8
+ layout: 'centered',
9
+ },
10
+ render: (args) => ({
11
+ template: `<feedback-form topics.bind="topics"
12
+ submitting.bind="submitting"
13
+ on-submit.bind="onSubmit"></feedback-form>`,
14
+ props: args,
15
+ components: [FeedbackForm],
16
+ }),
17
+ };
18
+
19
+ export default meta;
20
+
21
+ type Story = typeof meta;
22
+
23
+ export const DefaultForm = {
24
+ args: {
25
+ topics: ['Bug report', 'Feature request', 'General question'],
26
+ onSubmit: fn(),
27
+ submitting: false,
28
+ },
29
+ };
30
+
31
+ export const SubmittingState = {
32
+ args: {
33
+ topics: ['Design review', 'Accessibility', 'Performance'],
34
+ submitting: true,
35
+ onSubmit: fn(),
36
+ },
37
+ };
38
+
39
+ export const FillAndSubmit = {
40
+ args: {
41
+ topics: ['Beta feedback', 'Success story'],
42
+ onSubmit: fn(),
43
+ },
44
+ play: async ({ canvasElement }) => {
45
+ const canvas = within(canvasElement);
46
+ await userEvent.type(canvas.getByLabelText('Name'), 'Jordan');
47
+ await userEvent.type(canvas.getByLabelText('Email'), 'jordan@example.com');
48
+ await userEvent.selectOptions(canvas.getByLabelText('Topic'), 'Success story');
49
+ await userEvent.type(canvas.getByLabelText('Message'), 'The new timeline view is great');
50
+ await userEvent.click(canvas.getByRole('button', { name: /send feedback/i }));
51
+ },
52
+ };
@@ -1,6 +1,5 @@
1
1
  import { HelloWorld } from '../hello-world';
2
- import { fn } from '@storybook/test';
3
- import { userEvent, within } from '@storybook/test';
2
+ import { fn, userEvent, within } from 'storybook/test';
4
3
 
5
4
  const meta = {
6
5
  title: 'Example/HelloWorld',
@@ -18,14 +17,14 @@ export default meta;
18
17
 
19
18
  export const DefaultHelloWorld = {
20
19
  args: {
21
- message: "Hello frof",
20
+ message: 'Hello from Aurelia Storybook',
22
21
  onIncrement: fn()
23
22
  }
24
23
  };
25
24
 
26
25
  export const InteractiveHelloWorld = {
27
26
  args: {
28
- message: "fsdfdddsdsdsdsdddddfdddd",
27
+ message: 'Try clicking the button!',
29
28
  onIncrement: fn()
30
29
  },
31
30
  play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
@@ -49,6 +48,6 @@ export const WithCustomTemplate = {
49
48
  template: `<hello-world message.bind="message">Click me!</hello-world>`
50
49
  }),
51
50
  args: {
52
- message: "This is a custom messageddd"
51
+ message: 'This is a custom message'
53
52
  }
54
53
  };
@@ -0,0 +1,81 @@
1
+ import { fn, userEvent, within } from 'storybook/test';
2
+ import { NotificationCenter, NotificationItem } from '../components/notification-center';
3
+
4
+ const baseNotifications: NotificationItem[] = [
5
+ {
6
+ id: 1,
7
+ title: 'Build succeeded',
8
+ message: 'Main pipeline finished in 4m 12s.',
9
+ level: 'success',
10
+ timestamp: 'Today - 09:24',
11
+ },
12
+ {
13
+ id: 2,
14
+ title: 'New comment',
15
+ message: 'Samira replied to your review on PR #512.',
16
+ level: 'info',
17
+ timestamp: 'Today - 08:51',
18
+ },
19
+ {
20
+ id: 3,
21
+ title: 'Usage warning',
22
+ message: 'API quota is at 85% of the monthly allocation.',
23
+ level: 'warning',
24
+ timestamp: 'Yesterday - 17:05',
25
+ },
26
+ {
27
+ id: 4,
28
+ title: 'Error spike',
29
+ message: 'Synthetic tests detected an uptick in 500s.',
30
+ level: 'error',
31
+ timestamp: 'Yesterday - 15:33',
32
+ },
33
+ ];
34
+
35
+ const meta = {
36
+ title: 'Dashboard/NotificationCenter',
37
+ component: NotificationCenter,
38
+ render: (args) => ({
39
+ template: `<notification-center notifications.bind="notifications"
40
+ max-visible.bind="maxVisible"
41
+ on-dismiss.bind="onDismiss"
42
+ show-timestamp.bind="showTimestamp"></notification-center>`,
43
+ props: args,
44
+ components: [NotificationCenter],
45
+ }),
46
+ };
47
+
48
+ export default meta;
49
+
50
+ type Story = typeof meta;
51
+
52
+ export const DefaultNotifications = {
53
+ args: {
54
+ notifications: baseNotifications,
55
+ maxVisible: 3,
56
+ showTimestamp: true,
57
+ onDismiss: fn(),
58
+ },
59
+ };
60
+
61
+ export const CompactList = {
62
+ args: {
63
+ notifications: baseNotifications.slice(0, 2),
64
+ maxVisible: 2,
65
+ onDismiss: fn(),
66
+ showTimestamp: false,
67
+ },
68
+ };
69
+
70
+ export const Interactions = {
71
+ args: {
72
+ notifications: baseNotifications,
73
+ maxVisible: 4,
74
+ onDismiss: fn(),
75
+ },
76
+ play: async ({ canvasElement }) => {
77
+ const canvas = within(canvasElement);
78
+ const dismissButtons = await canvas.findAllByRole('button', { name: /dismiss/i });
79
+ await userEvent.click(dismissButtons[0]);
80
+ },
81
+ };
@@ -0,0 +1,65 @@
1
+ import { fn, userEvent, within } from 'storybook/test';
2
+ import { StatCard } from '../components/stat-card';
3
+
4
+ const meta = {
5
+ title: 'Dashboard/StatCard',
6
+ component: StatCard,
7
+ parameters: {
8
+ layout: 'centered',
9
+ },
10
+ render: (args) => ({
11
+ components: [StatCard],
12
+ template: `<stat-card title.bind="title"
13
+ value.bind="value"
14
+ unit.bind="unit"
15
+ change.bind="change"
16
+ change-copy.bind="changeCopy"
17
+ description.bind="description"
18
+ on-refresh.bind="onRefresh"></stat-card>`,
19
+ props: args,
20
+ }),
21
+ };
22
+
23
+ export default meta;
24
+
25
+ type Story = typeof meta;
26
+
27
+ export const DefaultCard = {
28
+ args: {
29
+ title: 'Active users',
30
+ value: 1284,
31
+ unit: '',
32
+ change: 12.5,
33
+ changeCopy: 'vs last week',
34
+ description: 'Rolling 7-day average of unique user sessions.',
35
+ onRefresh: fn(),
36
+ },
37
+ };
38
+
39
+ export const NegativeTrend = {
40
+ args: {
41
+ title: 'NPS score',
42
+ value: 42,
43
+ change: -6.3,
44
+ changeCopy: 'vs previous survey',
45
+ description: 'Direct feedback collected from in-app survey responses.',
46
+ onRefresh: fn(),
47
+ },
48
+ };
49
+
50
+ export const ManualRefreshDemo = {
51
+ args: {
52
+ title: 'Deploy success rate',
53
+ value: '99.2',
54
+ unit: '%',
55
+ change: 1.1,
56
+ changeCopy: 'vs last 24h',
57
+ description: 'Completed deploys without rollbacks.',
58
+ onRefresh: fn(),
59
+ },
60
+ play: async ({ canvasElement }) => {
61
+ const canvas = within(canvasElement);
62
+ const refreshButton = await canvas.findByRole('button', { name: /refresh metric/i });
63
+ await userEvent.click(refreshButton);
64
+ },
65
+ };
@@ -0,0 +1,57 @@
1
+ import { Registration } from 'aurelia';
2
+ import { fn, userEvent, within } from 'storybook/test';
3
+ import { WeatherWidget } from '../components/weather-widget';
4
+ import { IWeatherService, WeatherService, WeatherSummary } from '../services/weather-service';
5
+
6
+ const mockService: WeatherService = {
7
+ async getWeather(location: string): Promise<WeatherSummary> {
8
+ return {
9
+ location,
10
+ condition: location.includes('Berlin') ? 'Cloudy' : 'Sunny',
11
+ temperature: location.includes('Berlin') ? 16 : 24,
12
+ high: location.includes('Berlin') ? 18 : 27,
13
+ low: location.includes('Berlin') ? 11 : 19,
14
+ };
15
+ },
16
+ };
17
+
18
+ const meta = {
19
+ title: 'Dashboard/WeatherWidget',
20
+ component: WeatherWidget,
21
+ parameters: {
22
+ layout: 'centered',
23
+ },
24
+ render: (args) => ({
25
+ template: `<weather-widget location.bind="location"></weather-widget>`,
26
+ props: args,
27
+ components: [WeatherWidget],
28
+ items: [Registration.instance(IWeatherService, mockService)],
29
+ }),
30
+ };
31
+
32
+ export default meta;
33
+
34
+ type Story = typeof meta;
35
+
36
+ export const DefaultWeather = {
37
+ args: {
38
+ location: 'Seattle, WA',
39
+ },
40
+ };
41
+
42
+ export const EuropeanCity = {
43
+ args: {
44
+ location: 'Berlin, Germany',
45
+ },
46
+ };
47
+
48
+ export const RefreshInteraction = {
49
+ args: {
50
+ location: 'Lisbon, Portugal',
51
+ },
52
+ play: async ({ canvasElement }) => {
53
+ const canvas = within(canvasElement);
54
+ const refreshButton = await canvas.findByRole('button', { name: /refresh/i });
55
+ await userEvent.click(refreshButton);
56
+ },
57
+ };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "module": "esnext",
4
- "moduleResolution": "node",
4
+ "moduleResolution": "bundler",
5
5
  "skipLibCheck": true,
6
6
  "target": "ES2017",
7
7
  "esModuleInterop": true,
@@ -10,8 +10,9 @@
10
10
  "sourceMap": true
11
11
  },
12
12
  "include": [
13
- "src"
14
- , "aurelia-sfc-plugin.js" ],
13
+ "src",
14
+ "aurelia-sfc-plugin.js"
15
+ ],
15
16
  "files": [
16
17
  "src/resource.d.ts"
17
18
  ]
@@ -1,5 +1,4 @@
1
1
  import { defineConfig } from 'vite';
2
- import { nodePolyfills } from 'vite-plugin-node-polyfills'
3
2
  import aurelia from '@aurelia/vite-plugin';
4
3
 
5
4
  export default defineConfig({
@@ -14,6 +13,5 @@ export default defineConfig({
14
13
  aurelia({
15
14
  useDev: true,
16
15
  }),
17
- nodePolyfills(),
18
16
  ],
19
17
  });
@@ -1,7 +1,6 @@
1
1
  const config = {
2
2
  stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
3
3
  addons: [
4
- "@storybook/addon-links"
5
4
  ],
6
5
  framework: {
7
6
  name: '@aurelia/storybook',