forked from carbon-design-system/ibm-products
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
42 lines (38 loc) · 1.67 KB
/
config.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
/**
* Copyright IBM Corp. 2020, 2020
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
export const storybookPrefixCanary = 'Cloud & Cognitive/Canary';
export const storybookPrefixReleased = 'Cloud & Cognitive/Released';
export const storybookPrefixInternal = 'Cloud & Cognitive/Internal';
export const getStorybookPrefix = (pkg, componentName) => {
return pkg.isComponentEnabled(componentName, true)
? storybookPrefixReleased
: pkg.isComponentPublic(componentName, true)
? storybookPrefixCanary
: storybookPrefixInternal;
};
/**
* A helper function to return the slug (structure path name reduced to lower
* case text and hyphens) which identifies story instances.
* @param {string} pkg The package settings instance.
* @param {string} componentName The name of the component.
* @param {string} scenario The scenario name, also as a slug.
* @param {string} folders The names of any sub-folders being used. This param
* can be omitted (or falsy) if the component appears directly within the
* category. Where applicable, the folders should be specified as a slug (all
* lower case, with hyphens rather than / to separate multiple folder levels).
* @returns The story id.
*/
export const getStorybookSlug = (pkg, componentName, scenario, folders) => {
const hFolders = folders ? folders + '-' : '';
const lcName = componentName.toLocaleLowerCase();
const state = pkg.isComponentEnabled(componentName, true)
? 'released'
: pkg.isComponentPublic(componentName, true)
? 'canary'
: 'internal';
return `cloud-cognitive-${state}-${hFolders}${lcName}--${scenario}`;
};