-
Notifications
You must be signed in to change notification settings - Fork 314
/
Copy pathpreview.js
97 lines (92 loc) · 2.14 KB
/
preview.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// load global styles
import { breakpoints } from '@carbon/layout';
// Add compodoc
import { setCompodocJson } from "@storybook/addon-docs/angular";
import {
classes,
components,
directives,
interfaces,
miscellaneous,
pipes
} from "../dist/docs/documentation.json";
/**
* Remove public properties from docs Json for each component.
* This is to prevent properties like `onTouched = () => {...}` & `propagateChange = () => {}`
* from being rewritten as string by storybook.
*/
components = components.map(comp => ({
...comp,
inputsClass: comp.inputsClass.map((input) => ({
...input,
// Storybook does not seem to display deprecated message currently
// Bypassing this by updating rawdescription
// Using `description` to display formatted code
rawdescription: input.deprecated ? `**@Deprecatated**\n\n${input.deprecationMessage}` : input.description
})),
// Removes properties
propertiesClass: [],
outputsClass: comp.outputsClass.map((output) => ({
...output,
// Prevents control type appearing as `string`
defaultValue: undefined,
// Storybook does not seem to display deprecated message currently
// Bypassing this by updating rawdescription
// Using `description` to display formatted code
rawdescription: output.deprecated ? `**@Deprecatated**\n\n${output.deprecationMessage}` : output.description
}))
}));
// Integrate compodoc documentation with storybook
setCompodocJson({
classes,
components,
directives,
interfaces,
miscellaneous,
pipes
});
// Set carbon viewports options
export const parameters = {
viewport: {
viewports: {
sm: {
name: 'Small',
styles: {
width: breakpoints.sm.width,
height: '100%',
},
},
md: {
name: 'Medium',
styles: {
width: breakpoints.md.width,
height: '100%',
},
},
lg: {
name: 'Large',
styles: {
width: breakpoints.lg.width,
height: '100%',
},
},
xlg: {
name: 'X-Large',
styles: {
width: breakpoints.xlg.width,
height: '100%',
},
},
max: {
name: 'Max',
styles: {
width: breakpoints.max.width,
height: '100%',
},
},
},
},
controls: {
expanded: true
}
};