@aarhus-university/au-lib-react-components 12.0.2 → 12.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.
@@ -1,11 +1,28 @@
1
1
  import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
2
+ import { StoryObj, Meta } from '@storybook/react';
3
3
  import AUErrorComponent from '../src/components/AUErrorComponent';
4
4
  import { ThemeWrapper } from './lib/helpers';
5
5
 
6
6
  export default {
7
7
  title: 'Delphinus/Error',
8
8
  component: AUErrorComponent,
9
+ argTypes: {
10
+ error: {
11
+ table: {
12
+ disable: true,
13
+ }
14
+ },
15
+ fetchError: {
16
+ table: {
17
+ disable: true,
18
+ }
19
+ },
20
+ serializedError: {
21
+ table: {
22
+ disable: true,
23
+ }
24
+ },
25
+ },
9
26
  decorators: [
10
27
  (Story, context) => (
11
28
  <ThemeWrapper theme={context.globals.theme}>
@@ -13,86 +30,104 @@ export default {
13
30
  </ThemeWrapper>
14
31
  )
15
32
  ],
16
- } as ComponentMeta<typeof AUErrorComponent>;
33
+ } as Meta<typeof AUErrorComponent>;
17
34
 
18
- const Template: ComponentStory<typeof AUErrorComponent> = (args) => <AUErrorComponent {...args} />;
35
+ type Story = StoryObj<typeof AUErrorComponent>;
19
36
 
20
- export const AU_Error = Template.bind({});
21
- AU_Error.args = {
22
- error: {
23
- header: 'Our own custom error',
24
- message: 'With a nice header and descriptive error message, maybe a hint of some <a href="mailto:#">contact support info</a>',
25
- status: 500,
37
+ export const AU_Error: Story = {
38
+ args: {
39
+ error: {
40
+ header: 'Our own custom error',
41
+ message: 'With a nice header and descriptive error message',
42
+ status: 500,
43
+ },
44
+ withStatus: false,
26
45
  },
46
+ render: (args) => <AUErrorComponent {...args} />,
27
47
  };
28
48
 
29
- export const AU_Error_With_Status = Template.bind({});
30
- AU_Error_With_Status.args = {
31
- error: {
32
- header: 'Our own custom error',
33
- message: 'With a nice header and descriptive error message',
34
- status: 500,
49
+ export const AU_Error_With_Status: Story = {
50
+ args: {
51
+ error: {
52
+ header: 'Our own custom error',
53
+ message: 'With a nice header and descriptive error message',
54
+ status: 500,
55
+ },
56
+ withStatus: true,
35
57
  },
36
- withStatus: true,
58
+ render: (args) => <AUErrorComponent {...args} />,
37
59
  };
38
60
 
39
- export const Fetch_Error = Template.bind({});
40
- Fetch_Error.args = {
41
- fetchError: {
42
- error: 'Something horrible has happened on the server...',
43
- status: 'FETCH_ERROR',
61
+ export const Fetch_Error: Story = {
62
+ args: {
63
+ fetchError: {
64
+ error: 'Something horrible has happened on the server...',
65
+ status: 'FETCH_ERROR',
66
+ },
67
+ withStatus: false,
44
68
  },
69
+ render: (args) => <AUErrorComponent {...args} />,
45
70
  };
46
71
 
47
- export const Fetch_Error_With_Status = Template.bind({});
48
- Fetch_Error_With_Status.args = {
49
- fetchError: {
50
- error: 'Something horrible has happened on the server...',
51
- status: 'FETCH_ERROR',
72
+ export const Fetch_Error_With_Status: Story = {
73
+ args: {
74
+ fetchError: {
75
+ error: 'Something horrible has happened on the server...',
76
+ status: 'FETCH_ERROR',
77
+ },
78
+ withStatus: true,
52
79
  },
53
- withStatus: true,
80
+ render: (args) => <AUErrorComponent {...args} />,
54
81
  };
55
82
 
56
- export const Fetch_Error_With_Data = Template.bind({});
57
- Fetch_Error_With_Data.args = {
58
- fetchError: {
59
- data: {
60
- status: 'Error',
61
- message: 'This could be anything...',
62
- somethingElse: 'Even this...',
83
+ export const Fetch_Error_With_Data: Story = {
84
+ args: {
85
+ fetchError: {
86
+ data: {
87
+ status: 'Error',
88
+ message: 'This could be anything...',
89
+ somethingElse: 'Even this...',
90
+ },
91
+ status: 500,
63
92
  },
64
- status: 500,
93
+ withStatus: false,
65
94
  },
66
- withStatus: false,
95
+ render: (args) => <AUErrorComponent {...args} />,
67
96
  };
68
97
 
69
- export const Fetch_Error_With_Data_And_Status = Template.bind({});
70
- Fetch_Error_With_Data_And_Status.args = {
71
- fetchError: {
72
- data: {
73
- status: 'Error',
74
- message: 'This could be anything...',
75
- somethingElse: 'Even this...',
98
+ export const Fetch_Error_With_Data_And_Status: Story = {
99
+ args: {
100
+ fetchError: {
101
+ data: {
102
+ status: 'Error',
103
+ message: 'This could be anything...',
104
+ somethingElse: 'Even this...',
105
+ },
106
+ status: 500,
76
107
  },
77
- status: 500,
108
+ withStatus: true,
78
109
  },
79
- withStatus: true,
110
+ render: (args) => <AUErrorComponent {...args} />,
80
111
  };
81
112
 
82
- export const Serialized_Error = Template.bind({});
83
- Serialized_Error.args = {
84
- serializedError: {
85
- message: 'Something funky has happened in the code...',
86
- code: '500',
113
+ export const Serialized_Error: Story = {
114
+ args: {
115
+ serializedError: {
116
+ message: 'Something funky has happened in the code...',
117
+ code: '500',
118
+ },
119
+ withStatus: false,
87
120
  },
88
- withStatus: false,
121
+ render: (args) => <AUErrorComponent {...args} />,
89
122
  };
90
123
 
91
- export const Serialized_Error_With_Code = Template.bind({});
92
- Serialized_Error_With_Code.args = {
93
- serializedError: {
94
- message: 'Something funky has happened in the code...',
95
- code: '500',
124
+ export const Serialized_Error_With_Code: Story = {
125
+ args: {
126
+ serializedError: {
127
+ message: 'Something funky has happened in the code...',
128
+ code: '500',
129
+ },
130
+ withStatus: true,
96
131
  },
97
- withStatus: true,
98
- };
132
+ render: (args) => <AUErrorComponent {...args} />,
133
+ };
@@ -1,10 +1,21 @@
1
1
  import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
3
- import { useArgs } from '@storybook/client-api';
2
+ import { StoryObj, Meta } from '@storybook/react';
3
+ import { useArgs } from '@storybook/preview-api';
4
4
  import AUModalComponent from '../src/components/AUModalComponent';
5
5
  import AUButtonComponent from '../src/components/AUButtonComponent';
6
6
  import { ThemeWrapper } from './lib/helpers';
7
7
 
8
+ const modalContent = (
9
+ <>
10
+ <h2 className="modal-view__header">
11
+ The quick brown fox jumps over the lazy dog
12
+ </h2>
13
+ <div className="modal-view__content">
14
+ <p>"The quick brown fox jumps over the lazy dog" is an English-language pangram—a sentence that contains all of the letters of the alphabet. It is commonly used for touch-typing practice, testing typewriters and computer keyboards, displaying examples of fonts, and other applications involving text where the use of all letters in the alphabet is desired. Owing to its brevity and coherence, it has become widely known.</p><h3>History</h3><p>The earliest known appearance of the phrase is from The Boston Journal. In an article titled "Current Notes" in the February 10, 1885, morning edition, the phrase is mentioned as a good practice sentence for writing students: "A favorite copy set by writing teachers for their pupils is the following, because it contains every letter of the alphabet: 'A quick brown fox jumps over the lazy dog.'"[1] Dozens of other newspapers published the phrase over the next few months, all using the version of the sentence starting with "A" rather than "The".[2] The earliest known use of the phrase in its modern form (starting with "The") is from the 1888 book Illustrative Shorthand by Linda Bronson.[3] The modern form (starting with "The") became more common despite the fact that it is slightly longer than the original (starting with "A").</p>
15
+ </div>
16
+ </>
17
+ );
18
+
8
19
  // More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
9
20
  export default {
10
21
  title: 'Delphinus/Modal',
@@ -23,62 +34,127 @@ export default {
23
34
  </ThemeWrapper>
24
35
  )
25
36
  ],
26
- } as ComponentMeta<typeof AUModalComponent>;
37
+ } as Meta<typeof AUModalComponent>;
27
38
 
28
39
  const fakeBtn = document.createElement('button');
29
40
 
30
- const Template: ComponentStory<typeof AUModalComponent> = (args) => {
31
- const [_, updateArgs] = useArgs();
32
- return (
33
- <div className="page__content__block">
34
- <AUButtonComponent
35
- label="Open modal"
36
- ariaHasPopup
37
- onClick={() => updateArgs({ ...args, show: true })}
38
- />
39
- <AUModalComponent {...args} onClose={() => updateArgs({ ...args, show: false })}>
40
- <>
41
- <h2 className="modal-view__header">
42
- The quick brown fox jumps over the lazy dog
43
- </h2>
44
- <div className="modal-view__content">
45
- <p>"The quick brown fox jumps over the lazy dog" is an English-language pangram—a sentence that contains all of the letters of the alphabet. It is commonly used for touch-typing practice, testing typewriters and computer keyboards, displaying examples of fonts, and other applications involving text where the use of all letters in the alphabet is desired. Owing to its brevity and coherence, it has become widely known.</p><h3>History</h3><p>The earliest known appearance of the phrase is from The Boston Journal. In an article titled "Current Notes" in the February 10, 1885, morning edition, the phrase is mentioned as a good practice sentence for writing students: "A favorite copy set by writing teachers for their pupils is the following, because it contains every letter of the alphabet: 'A quick brown fox jumps over the lazy dog.'"[1] Dozens of other newspapers published the phrase over the next few months, all using the version of the sentence starting with "A" rather than "The".[2] The earliest known use of the phrase in its modern form (starting with "The") is from the 1888 book Illustrative Shorthand by Linda Bronson.[3] The modern form (starting with "The") became more common despite the fact that it is slightly longer than the original (starting with "A").</p>
46
- </div>
47
- </>
48
- </AUModalComponent>
49
- </div>
50
- )
51
- };
41
+ type Story = StoryObj<typeof AUModalComponent>;
42
+
43
+ export const Default: Story = {
44
+ args: {
45
+ show: true,
46
+ sender: fakeBtn,
47
+ closeButtonDisabled: false,
48
+ },
49
+ render: (args) => {
50
+ const [_, updateArgs] = useArgs();
52
51
 
53
- export const Default = Template.bind({});
54
- Default.args = {
55
- show: true,
56
- sender: fakeBtn,
52
+ return (
53
+ <div className="page__content__block">
54
+ <AUButtonComponent
55
+ label="Open modal"
56
+ ariaHasPopup
57
+ onClick={() => updateArgs({ ...args, show: true })}
58
+ />
59
+ <AUModalComponent {...args} onClose={() => updateArgs({ ...args, show: false })}>
60
+ {modalContent}
61
+ </AUModalComponent>
62
+ </div>
63
+ );
64
+ },
57
65
  };
58
66
 
59
- export const Hidden = Template.bind({});
60
- Hidden.args = {
61
- show: false,
62
- sender: fakeBtn,
67
+ export const Hidden: Story = {
68
+ args: {
69
+ show: false,
70
+ sender: fakeBtn,
71
+ },
72
+ render: (args) => {
73
+ const [_, updateArgs] = useArgs();
74
+
75
+ return (
76
+ <div className="page__content__block">
77
+ <AUButtonComponent
78
+ label="Open modal"
79
+ ariaHasPopup
80
+ onClick={() => updateArgs({ ...args, show: true })}
81
+ />
82
+ <AUModalComponent {...args} onClose={() => updateArgs({ ...args, show: false })}>
83
+ {modalContent}
84
+ </AUModalComponent>
85
+ </div>
86
+ );
87
+ },
63
88
  };
64
89
 
65
- export const Wide = Template.bind({});
66
- Wide.args = {
67
- className: 'modal-view modal-view--wide',
68
- show: true,
69
- sender: fakeBtn,
90
+ export const Wide: Story = {
91
+ args: {
92
+ className: 'modal-view modal-view--wide',
93
+ show: true,
94
+ sender: fakeBtn,
95
+ },
96
+ render: (args) => {
97
+ const [_, updateArgs] = useArgs();
98
+
99
+ return (
100
+ <div className="page__content__block">
101
+ <AUButtonComponent
102
+ label="Open modal"
103
+ ariaHasPopup
104
+ onClick={() => updateArgs({ ...args, show: true })}
105
+ />
106
+ <AUModalComponent {...args} onClose={() => updateArgs({ ...args, show: false })}>
107
+ {modalContent}
108
+ </AUModalComponent>
109
+ </div>
110
+ );
111
+ },
70
112
  };
71
113
 
72
- export const High = Template.bind({});
73
- High.args = {
74
- className: 'modal-view modal-view--high',
75
- show: true,
76
- sender: fakeBtn,
114
+ export const High: Story = {
115
+ args: {
116
+ className: 'modal-view modal-view--high',
117
+ show: true,
118
+ sender: fakeBtn,
119
+ },
120
+ render: (args) => {
121
+ const [_, updateArgs] = useArgs();
122
+
123
+ return (
124
+ <div className="page__content__block">
125
+ <AUButtonComponent
126
+ label="Open modal"
127
+ ariaHasPopup
128
+ onClick={() => updateArgs({ ...args, show: true })}
129
+ />
130
+ <AUModalComponent {...args} onClose={() => updateArgs({ ...args, show: false })}>
131
+ {modalContent}
132
+ </AUModalComponent>
133
+ </div>
134
+ );
135
+ },
77
136
  };
78
137
 
79
- export const Non_Closable = Template.bind({});
80
- Non_Closable.args = {
81
- show: true,
82
- sender: fakeBtn,
83
- closeButtonDisabled: true,
138
+ export const Non_Closable: Story = {
139
+ args: {
140
+ show: true,
141
+ sender: fakeBtn,
142
+ closeButtonDisabled: true,
143
+ },
144
+ render: (args) => {
145
+ const [_, updateArgs] = useArgs();
146
+
147
+ return (
148
+ <div className="page__content__block">
149
+ <AUButtonComponent
150
+ label="Open modal"
151
+ ariaHasPopup
152
+ onClick={() => updateArgs({ ...args, show: true })}
153
+ />
154
+ <AUModalComponent {...args} onClose={() => updateArgs({ ...args, show: false })}>
155
+ {modalContent}
156
+ </AUModalComponent>
157
+ </div>
158
+ );
159
+ },
84
160
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
2
+ import { StoryObj, Meta } from '@storybook/react';
3
3
  import AUNotificationComponent from '../src/components/AUNotificationComponent';
4
4
  import AUButtonComponent from '../src/components/AUButtonComponent';
5
5
  import { ThemeWrapper } from './lib/helpers';
@@ -18,7 +18,27 @@ export default {
18
18
  'attention',
19
19
  'confirm',
20
20
  ],
21
- }
21
+ },
22
+ header: {
23
+ table: {
24
+ disable: true,
25
+ }
26
+ },
27
+ content: {
28
+ table: {
29
+ disable: true,
30
+ }
31
+ },
32
+ actions: {
33
+ table: {
34
+ disable: true,
35
+ }
36
+ },
37
+ classNames: {
38
+ table: {
39
+ disable: true,
40
+ }
41
+ },
22
42
  },
23
43
  decorators: [
24
44
  (Story, context) => (
@@ -27,90 +47,106 @@ export default {
27
47
  </ThemeWrapper>
28
48
  )
29
49
  ],
30
- } as ComponentMeta<typeof AUNotificationComponent>;
50
+ } as Meta<typeof AUNotificationComponent>;
31
51
 
32
- const Template: ComponentStory<typeof AUNotificationComponent> = (args) => <AUNotificationComponent {...args} />;
52
+ type Story = StoryObj<typeof AUNotificationComponent>;
33
53
 
34
- export const Default = Template.bind({});
35
- Default.args = {
36
- header: 'This is a notification',
37
- content: [
38
- <p>This might be of importance...</p>
39
- ],
40
- };
41
-
42
- export const Warning = Template.bind({});
43
- Warning.args = {
44
- header: 'Oops! An error has occurred',
45
- type: 'warning',
46
- content: [
47
- <p>Shit's fucked, yo!</p>
48
- ],
54
+ export const Default: Story = {
55
+ args: {
56
+ header: 'This is a notification',
57
+ content: [
58
+ <p>This might be of importance...</p>
59
+ ],
60
+ },
61
+ render: (args) => <AUNotificationComponent {...args} />,
49
62
  };
50
63
 
51
- export const Attention = Template.bind({});
52
- Attention.args = {
53
- header: 'Please read this',
54
- type: 'attention',
55
- content: [
56
- <p>We really want you to read this.</p>
57
- ],
64
+ export const Warning: Story = {
65
+ args: {
66
+ header: 'Oops! An error has occurred',
67
+ type: 'warning',
68
+ content: [
69
+ <p>Shit's fucked, yo!</p>
70
+ ],
71
+ },
72
+ render: (args) => <AUNotificationComponent {...args} />,
58
73
  };
59
74
 
60
- export const Confirm = Template.bind({});
61
- Confirm.args = {
62
- header: 'Great success',
63
- type: 'confirm',
64
- content: [
65
- <p>You the man now, dawg!</p>
66
- ],
75
+ export const Attention: Story = {
76
+ args: {
77
+ header: 'Please read this',
78
+ type: 'attention',
79
+ content: [
80
+ <p>We really want you to read this.</p>
81
+ ],
82
+ },
83
+ render: (args) => <AUNotificationComponent {...args} />,
67
84
  };
68
85
 
69
- export const Single_Action = Template.bind({});
70
- Single_Action.args = {
71
- header: 'Do you want to do this?',
72
- type: 'attention',
73
- content: [
74
- <p>Please confirm.</p>
75
- ],
76
- actions: [
77
- <AUButtonComponent
78
- label="Ok"
79
- />
80
- ],
86
+ export const Confirm: Story = {
87
+ args: {
88
+ header: 'Great success',
89
+ type: 'confirm',
90
+ content: [
91
+ <p>You the man now, dawg!</p>
92
+ ],
93
+ },
94
+ render: (args) => <AUNotificationComponent {...args} />,
81
95
  };
82
96
 
83
- export const Multiple_Actions = Template.bind({});
84
- Multiple_Actions.args = {
85
- header: 'Do you want to do this?',
86
- type: 'attention',
87
- content: [
88
- <p>Please confirm.</p>
89
- ],
90
- actions: [
91
- <div className="button-container">
97
+ export const Single_Action: Story = {
98
+ args: {
99
+ header: 'Do you want to do this?',
100
+ type: 'attention',
101
+ content: [
102
+ <p>Please confirm.</p>
103
+ ],
104
+ actions: [
92
105
  <AUButtonComponent
93
106
  label="Ok"
94
107
  />
95
- <AUButtonComponent
96
- label="Cancel"
97
- type="text"
98
- />
99
- </div>,
100
- ],
108
+ ],
109
+ },
110
+ render: (args) => <AUNotificationComponent {...args} />,
101
111
  };
102
112
 
103
- export const No_Header = Template.bind({});
104
- No_Header.args = {
105
- content: [
106
- <p>This might be of importance...</p>
107
- ],
113
+ export const Multiple_Actions: Story = {
114
+ args: {
115
+ header: 'Do you want to do this?',
116
+ type: 'attention',
117
+ content: [
118
+ <p>Please confirm.</p>
119
+ ],
120
+ actions: [
121
+ <div className="button-container">
122
+ <AUButtonComponent
123
+ label="Ok"
124
+ />
125
+ <AUButtonComponent
126
+ label="Cancel"
127
+ type="text"
128
+ />
129
+ </div>,
130
+ ],
131
+ },
132
+ render: (args) => <AUNotificationComponent {...args} />,
108
133
  };
109
134
 
110
- export const Constrained_Width = Template.bind({});
111
- Constrained_Width.args = {
112
- content: [
113
- <p>This might be of importance...</p>
114
- ],
115
- classNames: ['notification--constrain-width'],
135
+ export const No_Header: Story = {
136
+ args: {
137
+ content: [
138
+ <p>This might be of importance...</p>
139
+ ],
140
+ },
141
+ render: (args) => <AUNotificationComponent {...args} />,
116
142
  };
143
+
144
+ export const Constrained_Width: Story = {
145
+ args: {
146
+ header: 'This is a notification',
147
+ content: [
148
+ <p>This might be of importance...</p>
149
+ ],
150
+ },
151
+ render: (args) => <AUNotificationComponent {...args} />,
152
+ };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
2
+ import { StoryObj, Meta } from '@storybook/react';
3
3
  import AUSpinnerComponent from '../src/components/AUSpinnerComponent';
4
4
  import { ThemeWrapper } from './lib/helpers';
5
5
 
@@ -17,6 +17,11 @@ export default {
17
17
  'table',
18
18
  ],
19
19
  },
20
+ className: {
21
+ table: {
22
+ disable: true,
23
+ }
24
+ },
20
25
  },
21
26
  decorators: [
22
27
  (Story, context) => (
@@ -25,17 +30,15 @@ export default {
25
30
  </ThemeWrapper>
26
31
  )
27
32
  ],
28
- } as ComponentMeta<typeof AUSpinnerComponent>;
33
+ } as Meta<typeof AUSpinnerComponent>;
29
34
 
30
- const Template: ComponentStory<typeof AUSpinnerComponent> = (args) => (
31
- <AUSpinnerComponent {...args}>
32
- <p>Child content</p>
33
- </AUSpinnerComponent>
34
- );
35
+ type Story = StoryObj<typeof AUSpinnerComponent>;
35
36
 
36
- export const Spinner = Template.bind({});
37
- Spinner.args = {
38
- loaded: false,
39
- height: '20rem',
40
- init: 'box',
37
+ export const Spinner: Story = {
38
+ args: {
39
+ loaded: false,
40
+ height: '20rem',
41
+ init: 'box',
42
+ },
43
+ render: (args) => <AUSpinnerComponent {...args}><p>Child content</p></AUSpinnerComponent>,
41
44
  };