@aarhus-university/au-lib-react-components 10.9.2 → 10.12.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.
- package/.storybook/main.js +4 -4
- package/.storybook/preview.js +7 -1
- package/package.json +3 -1
- package/src/lib/context.ts +13 -0
- package/stories/AUButtonComponent.stories.tsx +64 -28
- package/stories/AUErrorComponent.stories.tsx +7 -26
- package/stories/AUModalComponent.stories.tsx +13 -22
- package/stories/AUNotificationComponent.stories.tsx +21 -21
- package/stories/AUSpinnerComponent.stories.tsx +18 -18
- package/stories/AUToolbarComponent.stories.tsx +21 -22
- package/stories/lib/helpers.tsx +55 -0
package/.storybook/main.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
'stories': ['../**/*.stories.mdx', '../**/*.stories.@(js|jsx|ts|tsx)'],
|
|
5
|
+
'addons': ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions', '@storybook/addon-a11y'],
|
|
6
|
+
'framework': '@storybook/react',
|
|
7
7
|
core: {
|
|
8
|
-
builder:
|
|
8
|
+
builder: 'webpack5'
|
|
9
9
|
},
|
|
10
10
|
webpackFinal: async (config) => {
|
|
11
11
|
config.module.rules.push({
|
package/.storybook/preview.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import '@aarhus-university/au-designsystem-delphinus/build/style.css';
|
|
2
|
+
import { globalTheme, globalLang } from '../stories/lib/helpers';
|
|
2
3
|
|
|
3
4
|
export const parameters = {
|
|
4
5
|
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
@@ -8,4 +9,9 @@ export const parameters = {
|
|
|
8
9
|
date: /Date$/,
|
|
9
10
|
},
|
|
10
11
|
},
|
|
11
|
-
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const globalTypes = {
|
|
15
|
+
theme: globalTheme.theme,
|
|
16
|
+
lang: globalLang().lang,
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sideEffects": false,
|
|
3
3
|
"name": "@aarhus-university/au-lib-react-components",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.12.0",
|
|
5
5
|
"description": "Library for shared React components for various applications on au.dk",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "jest",
|
|
@@ -26,12 +26,14 @@
|
|
|
26
26
|
"@babel/preset-react": "^7.16.7",
|
|
27
27
|
"@babel/preset-typescript": "^7.16.7",
|
|
28
28
|
"@mdx-js/react": "^2.1.2",
|
|
29
|
+
"@storybook/addon-a11y": "^6.5.9",
|
|
29
30
|
"@storybook/addon-actions": "^6.5.4",
|
|
30
31
|
"@storybook/addon-essentials": "^6.5.4",
|
|
31
32
|
"@storybook/addon-interactions": "^6.5.4",
|
|
32
33
|
"@storybook/addon-links": "^6.5.4",
|
|
33
34
|
"@storybook/builder-webpack4": "^6.5.4",
|
|
34
35
|
"@storybook/builder-webpack5": "^6.5.4",
|
|
36
|
+
"@storybook/jest": "^0.0.10",
|
|
35
37
|
"@storybook/manager-webpack4": "^6.5.4",
|
|
36
38
|
"@storybook/manager-webpack5": "^6.5.4",
|
|
37
39
|
"@storybook/react": "^6.5.4",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
export const LangContext = createContext<string>('da');
|
|
4
|
+
export const useLangContext = (): string => {
|
|
5
|
+
const lang = useContext(LangContext);
|
|
6
|
+
return lang;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const UserContext = createContext<AU.IUserContext | null>(null);
|
|
10
|
+
export const useUserContext = (): AU.IUserContext | null => {
|
|
11
|
+
const user = useContext(UserContext);
|
|
12
|
+
return user;
|
|
13
|
+
};
|
|
@@ -1,34 +1,70 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
|
-
|
|
4
3
|
import AUButtonComponent from '../src/components/AUButtonComponent';
|
|
4
|
+
import { ThemeWrapper } from './lib/helpers';
|
|
5
5
|
|
|
6
|
-
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
7
6
|
export default {
|
|
8
7
|
title: 'Delphinus/Button',
|
|
9
8
|
component: AUButtonComponent,
|
|
10
|
-
|
|
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
|
+
iconPosition: {
|
|
31
|
+
control: {
|
|
32
|
+
type: 'select',
|
|
33
|
+
},
|
|
34
|
+
options: [
|
|
35
|
+
'left',
|
|
36
|
+
'right',
|
|
37
|
+
],
|
|
38
|
+
if: {
|
|
39
|
+
arg: 'icon',
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
hideLabel: {
|
|
43
|
+
control: {
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
},
|
|
46
|
+
if: {
|
|
47
|
+
arg: 'icon',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
mode: {
|
|
51
|
+
table: {
|
|
52
|
+
disable: true,
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
},
|
|
11
56
|
decorators: [
|
|
12
|
-
(Story
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<div>
|
|
20
|
-
{Story()}
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
]
|
|
57
|
+
(Story, context) => (
|
|
58
|
+
<ThemeWrapper theme={context.globals.theme}>
|
|
59
|
+
{Story()}
|
|
60
|
+
</ThemeWrapper>
|
|
61
|
+
)
|
|
62
|
+
],
|
|
25
63
|
} as ComponentMeta<typeof AUButtonComponent>;
|
|
26
64
|
|
|
27
|
-
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
28
65
|
const Template: ComponentStory<typeof AUButtonComponent> = (args) => <AUButtonComponent {...args} />;
|
|
29
66
|
|
|
30
67
|
export const Default = Template.bind({});
|
|
31
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
32
68
|
Default.args = {
|
|
33
69
|
label: 'Button',
|
|
34
70
|
type: 'default',
|
|
@@ -38,10 +74,10 @@ Default.args = {
|
|
|
38
74
|
|
|
39
75
|
export const With_Icon = Template.bind({});
|
|
40
76
|
With_Icon.args = {
|
|
41
|
-
label: 'Button',
|
|
77
|
+
label: 'Button',
|
|
42
78
|
type: 'default',
|
|
43
79
|
size: 'default',
|
|
44
|
-
mode: 'none',
|
|
80
|
+
mode: 'none',
|
|
45
81
|
icon: '',
|
|
46
82
|
iconPosition: 'left',
|
|
47
83
|
hideLabel: false,
|
|
@@ -49,10 +85,10 @@ With_Icon.args = {
|
|
|
49
85
|
|
|
50
86
|
export const Icon_Only = Template.bind({});
|
|
51
87
|
Icon_Only.args = {
|
|
52
|
-
label: 'Button',
|
|
88
|
+
label: 'Button',
|
|
53
89
|
type: 'default',
|
|
54
90
|
size: 'default',
|
|
55
|
-
mode: 'none',
|
|
91
|
+
mode: 'none',
|
|
56
92
|
icon: '',
|
|
57
93
|
iconPosition: 'left',
|
|
58
94
|
hideLabel: true,
|
|
@@ -60,27 +96,27 @@ Icon_Only.args = {
|
|
|
60
96
|
|
|
61
97
|
export const Irreversible_Action = Template.bind({});
|
|
62
98
|
Irreversible_Action.args = {
|
|
63
|
-
label: 'Button',
|
|
99
|
+
label: 'Button',
|
|
64
100
|
type: 'default',
|
|
65
101
|
size: 'default',
|
|
66
|
-
mode: 'ireversable-action',
|
|
102
|
+
mode: 'ireversable-action',
|
|
67
103
|
icon: '',
|
|
68
104
|
};
|
|
69
105
|
|
|
70
106
|
export const Confirmable_Action = Template.bind({});
|
|
71
107
|
Confirmable_Action.args = {
|
|
72
|
-
label: 'Button',
|
|
108
|
+
label: 'Button',
|
|
73
109
|
type: 'default',
|
|
74
110
|
size: 'default',
|
|
75
|
-
mode: 'confirmable-action',
|
|
111
|
+
mode: 'confirmable-action',
|
|
76
112
|
icon: '',
|
|
77
113
|
};
|
|
78
114
|
|
|
79
115
|
export const Processing = Template.bind({});
|
|
80
116
|
Processing.args = {
|
|
81
|
-
label: 'Button',
|
|
117
|
+
label: 'Button',
|
|
82
118
|
type: 'default',
|
|
83
119
|
size: 'default',
|
|
84
|
-
mode: 'processing',
|
|
120
|
+
mode: 'processing',
|
|
85
121
|
disabled: true,
|
|
86
122
|
};
|
|
@@ -1,34 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
|
-
|
|
4
3
|
import AUErrorComponent from '../src/components/AUErrorComponent';
|
|
4
|
+
import { ThemeWrapper } from './lib/helpers';
|
|
5
5
|
|
|
6
|
-
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
7
6
|
export default {
|
|
8
7
|
title: 'Delphinus/Error',
|
|
9
8
|
component: AUErrorComponent,
|
|
10
|
-
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
|
|
11
9
|
decorators: [
|
|
12
|
-
(Story
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<div>
|
|
20
|
-
{Story()}
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
]
|
|
10
|
+
(Story, context) => (
|
|
11
|
+
<ThemeWrapper theme={context.globals.theme}>
|
|
12
|
+
{Story()}
|
|
13
|
+
</ThemeWrapper>
|
|
14
|
+
)
|
|
15
|
+
],
|
|
25
16
|
} as ComponentMeta<typeof AUErrorComponent>;
|
|
26
17
|
|
|
27
|
-
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
28
18
|
const Template: ComponentStory<typeof AUErrorComponent> = (args) => <AUErrorComponent {...args} />;
|
|
29
19
|
|
|
30
20
|
export const AU_Error = Template.bind({});
|
|
31
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
32
21
|
AU_Error.args = {
|
|
33
22
|
error: {
|
|
34
23
|
header: 'Our own custom error',
|
|
@@ -38,7 +27,6 @@ AU_Error.args = {
|
|
|
38
27
|
};
|
|
39
28
|
|
|
40
29
|
export const AU_Error_With_Status = Template.bind({});
|
|
41
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
42
30
|
AU_Error_With_Status.args = {
|
|
43
31
|
error: {
|
|
44
32
|
header: 'Our own custom error',
|
|
@@ -49,7 +37,6 @@ AU_Error_With_Status.args = {
|
|
|
49
37
|
};
|
|
50
38
|
|
|
51
39
|
export const Fetch_Error = Template.bind({});
|
|
52
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
53
40
|
Fetch_Error.args = {
|
|
54
41
|
fetchError: {
|
|
55
42
|
error: 'Something horrible has happened on the server...',
|
|
@@ -58,7 +45,6 @@ Fetch_Error.args = {
|
|
|
58
45
|
};
|
|
59
46
|
|
|
60
47
|
export const Fetch_Error_With_Status = Template.bind({});
|
|
61
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
62
48
|
Fetch_Error_With_Status.args = {
|
|
63
49
|
fetchError: {
|
|
64
50
|
error: 'Something horrible has happened on the server...',
|
|
@@ -68,7 +54,6 @@ Fetch_Error_With_Status.args = {
|
|
|
68
54
|
};
|
|
69
55
|
|
|
70
56
|
export const Fetch_Error_With_Data = Template.bind({});
|
|
71
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
72
57
|
Fetch_Error_With_Data.args = {
|
|
73
58
|
fetchError: {
|
|
74
59
|
data: {
|
|
@@ -82,7 +67,6 @@ Fetch_Error_With_Data.args = {
|
|
|
82
67
|
};
|
|
83
68
|
|
|
84
69
|
export const Fetch_Error_With_Data_And_Status = Template.bind({});
|
|
85
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
86
70
|
Fetch_Error_With_Data_And_Status.args = {
|
|
87
71
|
fetchError: {
|
|
88
72
|
data: {
|
|
@@ -96,7 +80,6 @@ Fetch_Error_With_Data_And_Status.args = {
|
|
|
96
80
|
};
|
|
97
81
|
|
|
98
82
|
export const Serialized_Error = Template.bind({});
|
|
99
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
100
83
|
Serialized_Error.args = {
|
|
101
84
|
serializedError: {
|
|
102
85
|
message: 'Something funky has happened in the code...',
|
|
@@ -106,7 +89,6 @@ Serialized_Error.args = {
|
|
|
106
89
|
};
|
|
107
90
|
|
|
108
91
|
export const Serialized_Error_With_Code = Template.bind({});
|
|
109
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
110
92
|
Serialized_Error_With_Code.args = {
|
|
111
93
|
serializedError: {
|
|
112
94
|
message: 'Something funky has happened in the code...',
|
|
@@ -114,4 +96,3 @@ Serialized_Error_With_Code.args = {
|
|
|
114
96
|
},
|
|
115
97
|
withStatus: true,
|
|
116
98
|
};
|
|
117
|
-
|
|
@@ -1,35 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
3
|
import { useArgs } from '@storybook/client-api';
|
|
4
|
-
|
|
5
4
|
import AUModalComponent from '../src/components/AUModalComponent';
|
|
6
5
|
import AUButtonComponent from '../src/components/AUButtonComponent';
|
|
6
|
+
import { ThemeWrapper } from './lib/helpers';
|
|
7
7
|
|
|
8
8
|
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
9
9
|
export default {
|
|
10
10
|
title: 'Delphinus/Modal',
|
|
11
11
|
component: AUModalComponent,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const { args: { themeColor, themeMode } } = context;
|
|
18
|
-
const themeColorClass = themeColor === 'none' ? '' : `theme--${themeColor}`;
|
|
19
|
-
const themeModeClass = themeMode === 'light' ? '' : `theme--${themeMode}`;
|
|
20
|
-
*/
|
|
21
|
-
return (
|
|
22
|
-
<div className="page">
|
|
23
|
-
{Story()}
|
|
24
|
-
</div>
|
|
25
|
-
);
|
|
12
|
+
argTypes: {
|
|
13
|
+
sender: {
|
|
14
|
+
table: {
|
|
15
|
+
disable: true,
|
|
16
|
+
},
|
|
26
17
|
},
|
|
18
|
+
},
|
|
19
|
+
decorators: [
|
|
20
|
+
(Story, context) => (
|
|
21
|
+
<ThemeWrapper theme={context.globals.theme}>
|
|
22
|
+
{Story()}
|
|
23
|
+
</ThemeWrapper>
|
|
24
|
+
)
|
|
27
25
|
],
|
|
28
26
|
} as ComponentMeta<typeof AUModalComponent>;
|
|
29
27
|
|
|
30
28
|
const fakeBtn = document.createElement('button');
|
|
31
29
|
|
|
32
|
-
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
33
30
|
const Template: ComponentStory<typeof AUModalComponent> = (args) => {
|
|
34
31
|
const [_, updateArgs] = useArgs();
|
|
35
32
|
return (
|
|
@@ -53,21 +50,18 @@ const Template: ComponentStory<typeof AUModalComponent> = (args) => {
|
|
|
53
50
|
};
|
|
54
51
|
|
|
55
52
|
export const Default = Template.bind({});
|
|
56
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
57
53
|
Default.args = {
|
|
58
54
|
show: true,
|
|
59
55
|
sender: fakeBtn,
|
|
60
56
|
};
|
|
61
57
|
|
|
62
58
|
export const Hidden = Template.bind({});
|
|
63
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
64
59
|
Hidden.args = {
|
|
65
60
|
show: false,
|
|
66
61
|
sender: fakeBtn,
|
|
67
62
|
};
|
|
68
63
|
|
|
69
64
|
export const Wide = Template.bind({});
|
|
70
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
71
65
|
Wide.args = {
|
|
72
66
|
className: 'modal-view modal-view--wide',
|
|
73
67
|
show: true,
|
|
@@ -75,7 +69,6 @@ Wide.args = {
|
|
|
75
69
|
};
|
|
76
70
|
|
|
77
71
|
export const High = Template.bind({});
|
|
78
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
79
72
|
High.args = {
|
|
80
73
|
className: 'modal-view modal-view--high',
|
|
81
74
|
show: true,
|
|
@@ -83,10 +76,8 @@ High.args = {
|
|
|
83
76
|
};
|
|
84
77
|
|
|
85
78
|
export const Non_Closable = Template.bind({});
|
|
86
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
87
79
|
Non_Closable.args = {
|
|
88
80
|
show: true,
|
|
89
81
|
sender: fakeBtn,
|
|
90
82
|
closeButtonDisabled: true,
|
|
91
83
|
};
|
|
92
|
-
|
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
|
-
|
|
4
3
|
import AUNotificationComponent from '../src/components/AUNotificationComponent';
|
|
5
4
|
import AUButtonComponent from '../src/components/AUButtonComponent';
|
|
5
|
+
import { ThemeWrapper } from './lib/helpers';
|
|
6
6
|
|
|
7
|
-
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
8
7
|
export default {
|
|
9
8
|
title: 'Delphinus/Notification',
|
|
10
9
|
component: AUNotificationComponent,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
10
|
+
argTypes: {
|
|
11
|
+
type: {
|
|
12
|
+
control: {
|
|
13
|
+
type: 'radio',
|
|
14
|
+
},
|
|
15
|
+
options: [
|
|
16
|
+
'default',
|
|
17
|
+
'warning',
|
|
18
|
+
'attention',
|
|
19
|
+
'confirm',
|
|
20
|
+
],
|
|
24
21
|
}
|
|
25
|
-
|
|
22
|
+
},
|
|
23
|
+
decorators: [
|
|
24
|
+
(Story, context) => (
|
|
25
|
+
<ThemeWrapper theme={context.globals.theme}>
|
|
26
|
+
{Story()}
|
|
27
|
+
</ThemeWrapper>
|
|
28
|
+
)
|
|
29
|
+
],
|
|
26
30
|
} as ComponentMeta<typeof AUNotificationComponent>;
|
|
27
31
|
|
|
28
|
-
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
29
32
|
const Template: ComponentStory<typeof AUNotificationComponent> = (args) => <AUNotificationComponent {...args} />;
|
|
30
33
|
|
|
31
34
|
export const Default = Template.bind({});
|
|
32
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
33
35
|
Default.args = {
|
|
34
36
|
header: 'This is a notification',
|
|
35
37
|
content: [
|
|
@@ -99,7 +101,6 @@ Multiple_Actions.args = {
|
|
|
99
101
|
};
|
|
100
102
|
|
|
101
103
|
export const No_Header = Template.bind({});
|
|
102
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
103
104
|
No_Header.args = {
|
|
104
105
|
content: [
|
|
105
106
|
<p>This might be of importance...</p>
|
|
@@ -107,10 +108,9 @@ No_Header.args = {
|
|
|
107
108
|
};
|
|
108
109
|
|
|
109
110
|
export const Constrained_Width = Template.bind({});
|
|
110
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
111
111
|
Constrained_Width.args = {
|
|
112
112
|
content: [
|
|
113
113
|
<p>This might be of importance...</p>
|
|
114
114
|
],
|
|
115
115
|
classNames: ['notification--constrain-width'],
|
|
116
|
-
};
|
|
116
|
+
};
|
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
|
-
|
|
4
3
|
import AUSpinnerComponent from '../src/components/AUSpinnerComponent';
|
|
4
|
+
import { ThemeWrapper } from './lib/helpers';
|
|
5
5
|
|
|
6
|
-
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
7
6
|
export default {
|
|
8
7
|
title: 'Delphinus/Spinner',
|
|
9
8
|
component: AUSpinnerComponent,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<div>
|
|
21
|
-
{Story()}
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
9
|
+
argTypes: {
|
|
10
|
+
init: {
|
|
11
|
+
control: {
|
|
12
|
+
type: 'radio',
|
|
13
|
+
},
|
|
14
|
+
options: [
|
|
15
|
+
'',
|
|
16
|
+
'box',
|
|
17
|
+
'table',
|
|
18
|
+
],
|
|
24
19
|
},
|
|
20
|
+
},
|
|
21
|
+
decorators: [
|
|
22
|
+
(Story, context) => (
|
|
23
|
+
<ThemeWrapper theme={context.globals.theme}>
|
|
24
|
+
{Story()}
|
|
25
|
+
</ThemeWrapper>
|
|
26
|
+
)
|
|
25
27
|
],
|
|
26
28
|
} as ComponentMeta<typeof AUSpinnerComponent>;
|
|
27
29
|
|
|
28
|
-
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
29
30
|
const Template: ComponentStory<typeof AUSpinnerComponent> = (args) => (
|
|
30
31
|
<AUSpinnerComponent {...args}>
|
|
31
32
|
<p>Child content</p>
|
|
@@ -33,7 +34,6 @@ const Template: ComponentStory<typeof AUSpinnerComponent> = (args) => (
|
|
|
33
34
|
);
|
|
34
35
|
|
|
35
36
|
export const Spinner = Template.bind({});
|
|
36
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
37
37
|
Spinner.args = {
|
|
38
38
|
loaded: false,
|
|
39
39
|
height: '20rem',
|
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
|
-
|
|
4
3
|
import AUToolbarComponent from '../src/components/AUToolbarComponent';
|
|
5
4
|
import AUButtonComponent from '../src/components/AUButtonComponent';
|
|
5
|
+
import { ThemeWrapper } from './lib/helpers';
|
|
6
6
|
|
|
7
|
-
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
8
7
|
export default {
|
|
9
8
|
title: 'Delphinus/Toolbar',
|
|
10
9
|
component: AUToolbarComponent,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<div>
|
|
22
|
-
{Story()}
|
|
23
|
-
<div className="box theme--background-secondary"><p>Content goes here...</p></div>
|
|
24
|
-
</div>
|
|
25
|
-
);
|
|
10
|
+
argTypes: {
|
|
11
|
+
lang: {
|
|
12
|
+
control: {
|
|
13
|
+
type: 'radio',
|
|
14
|
+
},
|
|
15
|
+
options: [
|
|
16
|
+
'da',
|
|
17
|
+
'en',
|
|
18
|
+
],
|
|
26
19
|
},
|
|
20
|
+
},
|
|
21
|
+
decorators: [
|
|
22
|
+
(Story, context) => (
|
|
23
|
+
<ThemeWrapper theme={context.globals.theme}>
|
|
24
|
+
{Story()}
|
|
25
|
+
</ThemeWrapper>
|
|
26
|
+
)
|
|
27
27
|
],
|
|
28
28
|
} as ComponentMeta<typeof AUToolbarComponent>;
|
|
29
29
|
|
|
30
|
-
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
31
30
|
const Template: ComponentStory<typeof AUToolbarComponent> = (args) => (
|
|
32
|
-
|
|
31
|
+
<>
|
|
32
|
+
<AUToolbarComponent {...args} />
|
|
33
|
+
<div className="box theme--background-secondary"><p>Content goes here...</p></div>
|
|
34
|
+
</>
|
|
33
35
|
);
|
|
34
36
|
|
|
35
37
|
export const Form_Field_and_Buttons_and_Link = Template.bind({});
|
|
36
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
37
38
|
Form_Field_and_Buttons_and_Link.args = {
|
|
38
39
|
lang: 'da',
|
|
39
40
|
elements: [
|
|
@@ -52,14 +53,12 @@ Form_Field_and_Buttons_and_Link.args = {
|
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
export const Many_Actions = Template.bind({});
|
|
55
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
56
56
|
Many_Actions.args = {
|
|
57
57
|
lang: 'da',
|
|
58
58
|
elements: Array(25).fill(null).map((_, i) => <AUButtonComponent label={`Action ${i + 1}`} />),
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
export const Groupings = Template.bind({});
|
|
62
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
63
62
|
Groupings.args = {
|
|
64
63
|
lang: 'da',
|
|
65
64
|
elements: [
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const globalTheme = {
|
|
4
|
+
theme: {
|
|
5
|
+
name: 'Theme',
|
|
6
|
+
description: 'Global theme for components',
|
|
7
|
+
defaultValue: 'light',
|
|
8
|
+
toolbar: {
|
|
9
|
+
icon: 'circlehollow',
|
|
10
|
+
items: ['normal', 'dark'],
|
|
11
|
+
showName: true,
|
|
12
|
+
dynamicTitle: true,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const globalLang = (items = ['da', 'en'], defaultValue = 'da') => ({
|
|
18
|
+
lang: {
|
|
19
|
+
name: 'Language',
|
|
20
|
+
description: 'Global language for components',
|
|
21
|
+
defaultValue,
|
|
22
|
+
toolbar: {
|
|
23
|
+
icon: 'circlehollow',
|
|
24
|
+
items,
|
|
25
|
+
showName: true,
|
|
26
|
+
dynamicTitle: true,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const ThemeWrapper = ({ theme, children }) => {
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const body = document.querySelector('body');
|
|
34
|
+
if (body) {
|
|
35
|
+
body.classList.remove('theme--normal');
|
|
36
|
+
body.classList.remove('theme--dark');
|
|
37
|
+
body.classList.add(`theme--${theme}`);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return (
|
|
41
|
+
<main className={`theme--${theme}`}>
|
|
42
|
+
<div className="page">
|
|
43
|
+
<div className="page__content__block">
|
|
44
|
+
{children}
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</main>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
globalTheme,
|
|
53
|
+
globalLang,
|
|
54
|
+
ThemeWrapper,
|
|
55
|
+
};
|