@aarhus-university/au-lib-react-components 11.3.1 → 11.3.3

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 (96) hide show
  1. package/.eslintrc.js +34 -34
  2. package/.storybook/main.js +20 -20
  3. package/.storybook/preview.js +17 -17
  4. package/README.md +19 -19
  5. package/__tests__/jest/AUButtonComponent.test.tsx +165 -165
  6. package/__tests__/jest/AUErrorComponent.test.tsx +142 -142
  7. package/__tests__/jest/AUModalComponent.test.tsx +186 -186
  8. package/__tests__/jest/AUNotificationComponent.test.tsx +115 -115
  9. package/__tests__/jest/AUSpinnerComponent.test.tsx +57 -57
  10. package/__tests__/jest/AUToolbarComponent.test.tsx +46 -46
  11. package/__tests__/jest/context.test.ts +25 -25
  12. package/__tests__/jest/helpers.test.ts +15 -15
  13. package/__tests__/jest/setupTests.ts +2 -2
  14. package/babel.config.js +8 -8
  15. package/build/umd/all.css +2 -2
  16. package/build/umd/all.js +1 -1
  17. package/build/umd/alphabox.js +1 -1
  18. package/build/umd/databox.js +1 -1
  19. package/build/umd/diagramme.js +1 -1
  20. package/build/umd/flowbox.js +1 -1
  21. package/build/umd/universe.js +1 -1
  22. package/build-storybook.log +367 -367
  23. package/package.json +114 -114
  24. package/src/components/AUAlertComponent.tsx +70 -70
  25. package/src/components/AUAutoSuggestComponent.js +158 -158
  26. package/src/components/AUButtonComponent.tsx +84 -84
  27. package/src/components/AUCalendarComponent.tsx +493 -493
  28. package/src/components/AUContentToggleComponent.tsx +47 -47
  29. package/src/components/AUDatepickerComponent.tsx +121 -121
  30. package/src/components/AUErrorComponent.tsx +78 -78
  31. package/src/components/AUMobilePrefixComponent.tsx +15 -15
  32. package/src/components/AUModalComponent.tsx +68 -68
  33. package/src/components/AUNotificationComponent.tsx +43 -43
  34. package/src/components/AUReceiptComponent.tsx +33 -33
  35. package/src/components/AUSpinnerComponent.tsx +36 -36
  36. package/src/components/AUStepComponent.tsx +47 -41
  37. package/src/components/AUSubNavComponent.tsx +48 -48
  38. package/src/components/AUSubmitButtonContainerComponent.tsx +29 -29
  39. package/src/components/AUTabbedContentComponent.tsx +145 -145
  40. package/src/components/AUTableComponent.tsx +24 -24
  41. package/src/components/AUToastComponent.tsx +104 -104
  42. package/src/components/AUToolbarComponent.tsx +101 -101
  43. package/src/components/AUTruncatorComponent.tsx +129 -129
  44. package/src/components/wrapping/AUEmbedComponent.js +47 -47
  45. package/src/layout-2016/components/alphabox/AlphaBoxComponent.js +143 -143
  46. package/src/layout-2016/components/alphabox/AlphaBoxContentComponent.js +136 -136
  47. package/src/layout-2016/components/common/AUCollapsibleComponent.js +152 -152
  48. package/src/layout-2016/components/common/AUSpinnerComponent.js +103 -103
  49. package/src/layout-2016/components/databox/DataBoxAlphabetComponent.js +144 -144
  50. package/src/layout-2016/components/databox/DataBoxAssociationComponent.js +122 -122
  51. package/src/layout-2016/components/databox/DataBoxButtonComponent.js +157 -157
  52. package/src/layout-2016/components/databox/DataBoxComponent.js +297 -297
  53. package/src/layout-2016/components/databox/DataBoxGroupingComponent.js +64 -64
  54. package/src/layout-2016/components/databox/DataBoxSearchResultComponent.js +36 -36
  55. package/src/layout-2016/components/databox/DataBoxStackedAssociationComponent.js +54 -54
  56. package/src/layout-2016/components/databox/DataBoxSuggestionComponent.js +39 -39
  57. package/src/layout-2016/components/diagramme/AUDiagrammeComponent.js +309 -309
  58. package/src/layout-2016/components/flowbox/FlowBoxComponent.js +126 -126
  59. package/src/layout-2016/components/flowbox/FlowBoxPhoneComponent.js +104 -104
  60. package/src/layout-2016/components/profile/AUProfileAvatar2016Component.js +103 -103
  61. package/src/layout-2016/components/universe/StaffTopComponent.js +363 -363
  62. package/src/layout-2016/components/universe/StudentTopComponent.js +137 -137
  63. package/src/layout-2016/components/universe/UniverseContainerComponent.js +65 -65
  64. package/src/layout-2016/lib/all.js +3 -3
  65. package/src/layout-2016/lib/au-alphabox.js +100 -100
  66. package/src/layout-2016/lib/au-databox.js +400 -400
  67. package/src/layout-2016/lib/au-diagramme.js +85 -85
  68. package/src/layout-2016/lib/au-flowbox.js +93 -93
  69. package/src/layout-2016/lib/universe.js +9 -9
  70. package/src/lib/context.tsx +51 -50
  71. package/src/lib/dates.ts +50 -50
  72. package/src/lib/helpers.ts +208 -208
  73. package/src/lib/hooks.ts +75 -75
  74. package/src/lib/i18n.ts +600 -600
  75. package/src/lib/portals.tsx +119 -103
  76. package/src/lib/tracking.ts +69 -69
  77. package/src/lib/wrapping.ts +21 -21
  78. package/src/styles/_settings.scss +10 -10
  79. package/src/styles/alphabox.scss +222 -222
  80. package/src/styles/app.scss +7 -7
  81. package/src/styles/autosuggest.scss +57 -57
  82. package/src/styles/databox.scss +563 -563
  83. package/src/styles/diagramme.scss +119 -119
  84. package/src/styles/flowbox.scss +72 -72
  85. package/src/styles/maps.scss +395 -395
  86. package/stories/AUButtonComponent.stories.tsx +127 -127
  87. package/stories/AUContentToggleComponent.stories.tsx +63 -63
  88. package/stories/AUErrorComponent.stories.tsx +98 -98
  89. package/stories/AUModalComponent.stories.tsx +83 -83
  90. package/stories/AUNotificationComponent.stories.tsx +116 -116
  91. package/stories/AUSpinnerComponent.stories.tsx +41 -41
  92. package/stories/AUStepComponent.stories.tsx +40 -40
  93. package/stories/AUToolbarComponent.stories.tsx +326 -326
  94. package/stories/lib/helpers.tsx +128 -128
  95. package/tsconfig.json +46 -46
  96. package/webpack.config.js +89 -89
@@ -1,128 +1,128 @@
1
- import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
3
- import AUButtonComponent from '../src/components/AUButtonComponent';
4
- import { ThemeWrapper } from './lib/helpers';
5
-
6
- export default {
7
- title: 'Delphinus/Button',
8
- component: AUButtonComponent,
9
- argTypes: {
10
- type: {
11
- control: {
12
- type: 'radio',
13
- },
14
- options: [
15
- 'default',
16
- 'text',
17
- 'dimmed',
18
- ]
19
- },
20
- size: {
21
- control: {
22
- type: 'radio',
23
- },
24
- options: [
25
- 'small',
26
- 'default',
27
- 'large',
28
- ]
29
- },
30
- icon: {
31
- control: {
32
- type: 'select',
33
- },
34
- options: ['add', 'attachment', 'award', 'bike', 'bookmark', 'brand-linkedin', 'brand-mendeley', 'brand-orcid', 'brand-researchgate', 'brand-twitter', 'calendar', 'camera', 'car', 'class', 'close', 'collapse', 'confirm', 'confirm-circle', 'context-menu', 'copy', 'current-semester', 'dark-mode', 'delphinus', 'delete', 'design', 'download', 'edit', 'email', 'exam', 'expand', 'failed', 'failed-circle', 'file', 'filter', 'finish', 'heart', 'hide', 'infinity', 'info', 'info-circle', 'instructor', 'instructor-with-class', 'language', 'location', 'link-chain', 'link-internal', 'link-external', 'link-external-square', 'lms-course-common', 'lms-course-sections', 'lms-course-additional', 'lms-course-merge-with', 'lms-course-merged', 'mailbox', 'menu', 'news', 'next', 'note', 'notifications', 'passed-exemption', 'phone', 'phone-landline', 'previous', 'print', 'public-transport', 'receipt', 'refresh', 'reorder', 'replay', 'route', 'search', 'season-autumn', 'season-christmas', 'season-easter', 'season-halloween', 'season-spring', 'season-summer', 'season-winter', 'send', 'settings', 'source-system', 'student-place-accepted', 'student-place-not-offered', 'student-place-offered', 'student-place-rejected', 'student-place-standby', 'sign-in', 'sign-out', 'spock', 'sync', 'theme-chooser', 'tip', 'tools', 'tooltip', 'upload', 'user-profile', 'user-impersonation', 'view', 'viewport-default', 'viewport-medium', 'viewport-wide', 'walking', 'warning', 'warning-triangle'],
35
- },
36
- iconPosition: {
37
- control: {
38
- type: 'select',
39
- },
40
- options: [
41
- 'left',
42
- 'right',
43
- ],
44
- if: {
45
- arg: 'icon',
46
- }
47
- },
48
- hideLabel: {
49
- control: {
50
- type: 'boolean',
51
- },
52
- if: {
53
- arg: 'icon',
54
- },
55
- },
56
- mode: {
57
- table: {
58
- disable: true,
59
- }
60
- },
61
- },
62
- decorators: [
63
- (Story, context) => (
64
- <ThemeWrapper theme={context.globals.theme}>
65
- {Story()}
66
- </ThemeWrapper>
67
- )
68
- ],
69
- } as ComponentMeta<typeof AUButtonComponent>;
70
-
71
- const Template: ComponentStory<typeof AUButtonComponent> = (args) => <AUButtonComponent {...args} />;
72
-
73
- export const Default = Template.bind({});
74
- Default.args = {
75
- label: 'Button',
76
- type: 'default',
77
- size: 'default',
78
- mode: 'none',
79
- };
80
-
81
- export const With_Icon = Template.bind({});
82
- With_Icon.args = {
83
- label: 'Button',
84
- type: 'default',
85
- size: 'default',
86
- mode: 'none',
87
- icon: 'delphinus',
88
- iconPosition: 'left',
89
- hideLabel: false,
90
- };
91
-
92
- export const Icon_Only = Template.bind({});
93
- Icon_Only.args = {
94
- label: 'Button',
95
- type: 'default',
96
- size: 'default',
97
- mode: 'none',
98
- icon: 'delphinus',
99
- iconPosition: 'left',
100
- hideLabel: true,
101
- };
102
-
103
- export const Irreversible_Action = Template.bind({});
104
- Irreversible_Action.args = {
105
- label: 'Button',
106
- type: 'default',
107
- size: 'default',
108
- mode: 'ireversable-action',
109
- icon: 'delphinus',
110
- };
111
-
112
- export const Confirmable_Action = Template.bind({});
113
- Confirmable_Action.args = {
114
- label: 'Button',
115
- type: 'default',
116
- size: 'default',
117
- mode: 'confirmable-action',
118
- icon: 'delphinus',
119
- };
120
-
121
- export const Processing = Template.bind({});
122
- Processing.args = {
123
- label: 'Button',
124
- type: 'default',
125
- size: 'default',
126
- mode: 'processing',
127
- disabled: true,
1
+ import React from 'react';
2
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
3
+ import AUButtonComponent from '../src/components/AUButtonComponent';
4
+ import { ThemeWrapper } from './lib/helpers';
5
+
6
+ export default {
7
+ title: 'Delphinus/Button',
8
+ component: AUButtonComponent,
9
+ argTypes: {
10
+ type: {
11
+ control: {
12
+ type: 'radio',
13
+ },
14
+ options: [
15
+ 'default',
16
+ 'text',
17
+ 'dimmed',
18
+ ]
19
+ },
20
+ size: {
21
+ control: {
22
+ type: 'radio',
23
+ },
24
+ options: [
25
+ 'small',
26
+ 'default',
27
+ 'large',
28
+ ]
29
+ },
30
+ icon: {
31
+ control: {
32
+ type: 'select',
33
+ },
34
+ options: ['add', 'attachment', 'award', 'bike', 'bookmark', 'brand-linkedin', 'brand-mendeley', 'brand-orcid', 'brand-researchgate', 'brand-twitter', 'calendar', 'camera', 'car', 'class', 'close', 'collapse', 'confirm', 'confirm-circle', 'context-menu', 'copy', 'current-semester', 'dark-mode', 'delphinus', 'delete', 'design', 'download', 'edit', 'email', 'exam', 'expand', 'failed', 'failed-circle', 'file', 'filter', 'finish', 'heart', 'hide', 'infinity', 'info', 'info-circle', 'instructor', 'instructor-with-class', 'language', 'location', 'link-chain', 'link-internal', 'link-external', 'link-external-square', 'lms-course-common', 'lms-course-sections', 'lms-course-additional', 'lms-course-merge-with', 'lms-course-merged', 'mailbox', 'menu', 'news', 'next', 'note', 'notifications', 'passed-exemption', 'phone', 'phone-landline', 'previous', 'print', 'public-transport', 'receipt', 'refresh', 'reorder', 'replay', 'route', 'search', 'season-autumn', 'season-christmas', 'season-easter', 'season-halloween', 'season-spring', 'season-summer', 'season-winter', 'send', 'settings', 'source-system', 'student-place-accepted', 'student-place-not-offered', 'student-place-offered', 'student-place-rejected', 'student-place-standby', 'sign-in', 'sign-out', 'spock', 'sync', 'theme-chooser', 'tip', 'tools', 'tooltip', 'upload', 'user-profile', 'user-impersonation', 'view', 'viewport-default', 'viewport-medium', 'viewport-wide', 'walking', 'warning', 'warning-triangle'],
35
+ },
36
+ iconPosition: {
37
+ control: {
38
+ type: 'select',
39
+ },
40
+ options: [
41
+ 'left',
42
+ 'right',
43
+ ],
44
+ if: {
45
+ arg: 'icon',
46
+ }
47
+ },
48
+ hideLabel: {
49
+ control: {
50
+ type: 'boolean',
51
+ },
52
+ if: {
53
+ arg: 'icon',
54
+ },
55
+ },
56
+ mode: {
57
+ table: {
58
+ disable: true,
59
+ }
60
+ },
61
+ },
62
+ decorators: [
63
+ (Story, context) => (
64
+ <ThemeWrapper theme={context.globals.theme}>
65
+ {Story()}
66
+ </ThemeWrapper>
67
+ )
68
+ ],
69
+ } as ComponentMeta<typeof AUButtonComponent>;
70
+
71
+ const Template: ComponentStory<typeof AUButtonComponent> = (args) => <AUButtonComponent {...args} />;
72
+
73
+ export const Default = Template.bind({});
74
+ Default.args = {
75
+ label: 'Button',
76
+ type: 'default',
77
+ size: 'default',
78
+ mode: 'none',
79
+ };
80
+
81
+ export const With_Icon = Template.bind({});
82
+ With_Icon.args = {
83
+ label: 'Button',
84
+ type: 'default',
85
+ size: 'default',
86
+ mode: 'none',
87
+ icon: 'delphinus',
88
+ iconPosition: 'left',
89
+ hideLabel: false,
90
+ };
91
+
92
+ export const Icon_Only = Template.bind({});
93
+ Icon_Only.args = {
94
+ label: 'Button',
95
+ type: 'default',
96
+ size: 'default',
97
+ mode: 'none',
98
+ icon: 'delphinus',
99
+ iconPosition: 'left',
100
+ hideLabel: true,
101
+ };
102
+
103
+ export const Irreversible_Action = Template.bind({});
104
+ Irreversible_Action.args = {
105
+ label: 'Button',
106
+ type: 'default',
107
+ size: 'default',
108
+ mode: 'ireversable-action',
109
+ icon: 'delphinus',
110
+ };
111
+
112
+ export const Confirmable_Action = Template.bind({});
113
+ Confirmable_Action.args = {
114
+ label: 'Button',
115
+ type: 'default',
116
+ size: 'default',
117
+ mode: 'confirmable-action',
118
+ icon: 'delphinus',
119
+ };
120
+
121
+ export const Processing = Template.bind({});
122
+ Processing.args = {
123
+ label: 'Button',
124
+ type: 'default',
125
+ size: 'default',
126
+ mode: 'processing',
127
+ disabled: true,
128
128
  };
@@ -1,63 +1,63 @@
1
- import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
3
- import AUContentToggleComponent from '../src/components/AUContentToggleComponent';
4
- import { ThemeWrapper } from './lib/helpers';
5
-
6
- export default {
7
- title: 'Delphinus/Content Toggle',
8
- component: AUContentToggleComponent,
9
- argTypes: {
10
- toggled: {
11
- table: {
12
- disable: true,
13
- }
14
- },
15
- children: {
16
- table: {
17
- disable: true,
18
- }
19
- },
20
- },
21
- decorators: [
22
- (Story, context) => (
23
- <ThemeWrapper theme={context.globals.theme}>
24
- {Story()}
25
- </ThemeWrapper>
26
- )
27
- ],
28
- } as ComponentMeta<typeof AUContentToggleComponent>;
29
-
30
- const Template: ComponentStory<typeof AUContentToggleComponent> = (args) => <AUContentToggleComponent {...args} />;
31
-
32
- export const Hidden_when_loaded = Template.bind({});
33
- Hidden_when_loaded.args = {
34
- toggled: false,
35
- children: (
36
- <div className="box theme--background-secondary box--constrain-width">
37
- <button className="content-toggle__toggle button button--small" aria-expanded="false">
38
- Very interesting content is hidden
39
- </button>
40
- <div className="content-toggle__content vertical-spacing-top" hidden>
41
- <h4 className="text--label-header text--pull">The content that is toggled</h4>
42
- <p>Collapsible sections are perhaps the most rudimentary of interactive design patterns on the web. All they do is let you toggle the visibility of content by clicking that content's label. Big whoop.</p>
43
- </div>
44
- </div>
45
- ),
46
- };
47
-
48
- export const Shown_when_loaded = Template.bind({});
49
- Shown_when_loaded.args = {
50
- toggled: true,
51
- children: (
52
- <div className="box theme--background-secondary box--constrain-width">
53
- <button className="content-toggle__toggle button button--small" aria-expanded="true">
54
- Very interesting content is hidden
55
- </button>
56
- <div className="content-toggle__content vertical-spacing-top">
57
- <h4 className="text--label-header text--pull">The content that is toggled</h4>
58
- <p>Collapsible sections are perhaps the most rudimentary of interactive design patterns on the web. All they do is let you toggle the visibility of content by clicking that content's label. Big whoop.</p>
59
- </div>
60
- </div>
61
- ),
62
- };
63
-
1
+ import React from 'react';
2
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
3
+ import AUContentToggleComponent from '../src/components/AUContentToggleComponent';
4
+ import { ThemeWrapper } from './lib/helpers';
5
+
6
+ export default {
7
+ title: 'Delphinus/Content Toggle',
8
+ component: AUContentToggleComponent,
9
+ argTypes: {
10
+ toggled: {
11
+ table: {
12
+ disable: true,
13
+ }
14
+ },
15
+ children: {
16
+ table: {
17
+ disable: true,
18
+ }
19
+ },
20
+ },
21
+ decorators: [
22
+ (Story, context) => (
23
+ <ThemeWrapper theme={context.globals.theme}>
24
+ {Story()}
25
+ </ThemeWrapper>
26
+ )
27
+ ],
28
+ } as ComponentMeta<typeof AUContentToggleComponent>;
29
+
30
+ const Template: ComponentStory<typeof AUContentToggleComponent> = (args) => <AUContentToggleComponent {...args} />;
31
+
32
+ export const Hidden_when_loaded = Template.bind({});
33
+ Hidden_when_loaded.args = {
34
+ toggled: false,
35
+ children: (
36
+ <div className="box theme--background-secondary box--constrain-width">
37
+ <button className="content-toggle__toggle button button--small" aria-expanded="false">
38
+ Very interesting content is hidden
39
+ </button>
40
+ <div className="content-toggle__content vertical-spacing-top" hidden>
41
+ <h4 className="text--label-header text--pull">The content that is toggled</h4>
42
+ <p>Collapsible sections are perhaps the most rudimentary of interactive design patterns on the web. All they do is let you toggle the visibility of content by clicking that content's label. Big whoop.</p>
43
+ </div>
44
+ </div>
45
+ ),
46
+ };
47
+
48
+ export const Shown_when_loaded = Template.bind({});
49
+ Shown_when_loaded.args = {
50
+ toggled: true,
51
+ children: (
52
+ <div className="box theme--background-secondary box--constrain-width">
53
+ <button className="content-toggle__toggle button button--small" aria-expanded="true">
54
+ Very interesting content is hidden
55
+ </button>
56
+ <div className="content-toggle__content vertical-spacing-top">
57
+ <h4 className="text--label-header text--pull">The content that is toggled</h4>
58
+ <p>Collapsible sections are perhaps the most rudimentary of interactive design patterns on the web. All they do is let you toggle the visibility of content by clicking that content's label. Big whoop.</p>
59
+ </div>
60
+ </div>
61
+ ),
62
+ };
63
+
@@ -1,98 +1,98 @@
1
- import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
3
- import AUErrorComponent from '../src/components/AUErrorComponent';
4
- import { ThemeWrapper } from './lib/helpers';
5
-
6
- export default {
7
- title: 'Delphinus/Error',
8
- component: AUErrorComponent,
9
- decorators: [
10
- (Story, context) => (
11
- <ThemeWrapper theme={context.globals.theme}>
12
- {Story()}
13
- </ThemeWrapper>
14
- )
15
- ],
16
- } as ComponentMeta<typeof AUErrorComponent>;
17
-
18
- const Template: ComponentStory<typeof AUErrorComponent> = (args) => <AUErrorComponent {...args} />;
19
-
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,
26
- },
27
- };
28
-
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,
35
- },
36
- withStatus: true,
37
- };
38
-
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',
44
- },
45
- };
46
-
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',
52
- },
53
- withStatus: true,
54
- };
55
-
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...',
63
- },
64
- status: 500,
65
- },
66
- withStatus: false,
67
- };
68
-
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...',
76
- },
77
- status: 500,
78
- },
79
- withStatus: true,
80
- };
81
-
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',
87
- },
88
- withStatus: false,
89
- };
90
-
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',
96
- },
97
- withStatus: true,
98
- };
1
+ import React from 'react';
2
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
3
+ import AUErrorComponent from '../src/components/AUErrorComponent';
4
+ import { ThemeWrapper } from './lib/helpers';
5
+
6
+ export default {
7
+ title: 'Delphinus/Error',
8
+ component: AUErrorComponent,
9
+ decorators: [
10
+ (Story, context) => (
11
+ <ThemeWrapper theme={context.globals.theme}>
12
+ {Story()}
13
+ </ThemeWrapper>
14
+ )
15
+ ],
16
+ } as ComponentMeta<typeof AUErrorComponent>;
17
+
18
+ const Template: ComponentStory<typeof AUErrorComponent> = (args) => <AUErrorComponent {...args} />;
19
+
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,
26
+ },
27
+ };
28
+
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,
35
+ },
36
+ withStatus: true,
37
+ };
38
+
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',
44
+ },
45
+ };
46
+
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',
52
+ },
53
+ withStatus: true,
54
+ };
55
+
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...',
63
+ },
64
+ status: 500,
65
+ },
66
+ withStatus: false,
67
+ };
68
+
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...',
76
+ },
77
+ status: 500,
78
+ },
79
+ withStatus: true,
80
+ };
81
+
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',
87
+ },
88
+ withStatus: false,
89
+ };
90
+
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',
96
+ },
97
+ withStatus: true,
98
+ };