@itcase/storybook-config 1.0.36 → 1.0.38

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.
@@ -0,0 +1,12 @@
1
+ const ADDON_THEMES = {
2
+ defaultTheme: 'am',
3
+ themes: {
4
+ am: 'am',
5
+ baikal: 'baikal',
6
+ dark: 'dark',
7
+ itcase: 'itcase',
8
+ light: 'light',
9
+ },
10
+ }
11
+
12
+ export { ADDON_THEMES }
@@ -3,6 +3,7 @@ const ADDONS_NEXTJS = [
3
3
  '@storybook/addon-essentials',
4
4
  '@storybook/addon-interactions',
5
5
  '@itcase/storybook-addon-auth',
6
+ '@storybook/addon-themes',
6
7
  '@storybook/addon-designs',
7
8
  'storybook-addon-source-link',
8
9
  '@etchteam/storybook-addon-status',
@@ -5,6 +5,7 @@ const ADDONS_REACT = [
5
5
  '@storybook/addon-interactions',
6
6
  '@storybook/addon-designs',
7
7
  'storybook-addon-source-link',
8
+ '@storybook/addon-themes',
8
9
  '@etchteam/storybook-addon-status',
9
10
  {
10
11
  name: '@storybook/addon-styling-webpack',
@@ -2,6 +2,7 @@ const ADDONS_REACT_VITE = [
2
2
  '@storybook/addon-links',
3
3
  '@storybook/addon-essentials',
4
4
  '@storybook/addon-interactions',
5
+ '@storybook/addon-themes',
5
6
  '@storybook/addon-designs',
6
7
  'storybook-addon-source-link',
7
8
  '@etchteam/storybook-addon-status',
package/config/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ADDONS_NEXTJS } from './addonsNextJs'
2
2
  import { ADDONS_REACT } from './addonsReact'
3
3
  import { ADDONS_REACT_VITE } from './addonsReactVite'
4
+ import { ADDON_THEMES } from './addonThemes'
4
5
  import { AUTHORIZATION } from './authorization'
5
6
  import { BACKGROUNDS } from './backgrounds'
6
7
  import { FRAMEWORK_NEXTJS } from './frameworkNextJs'
@@ -19,6 +20,7 @@ import { VIEWPORTS } from './viewports'
19
20
 
20
21
  export {
21
22
  AUTHORIZATION,
23
+ ADDON_THEMES,
22
24
  ADDONS_NEXTJS,
23
25
  STATIC_DIRS_REACT,
24
26
  STATIC_DIRS_NEXTJS,
@@ -0,0 +1,12 @@
1
+ const ADDON_THEMES = {
2
+ defaultTheme: 'am',
3
+ themes: {
4
+ am: 'am',
5
+ baikal: 'baikal',
6
+ dark: 'dark',
7
+ itcase: 'itcase',
8
+ light: 'light',
9
+ },
10
+ }
11
+
12
+ export { ADDON_THEMES }
@@ -3,6 +3,7 @@ const ADDONS_NEXTJS = [
3
3
  '@storybook/addon-essentials',
4
4
  '@storybook/addon-interactions',
5
5
  '@itcase/storybook-addon-auth',
6
+ '@storybook/addon-themes',
6
7
  '@storybook/addon-designs',
7
8
  'storybook-addon-source-link',
8
9
  '@etchteam/storybook-addon-status',
@@ -5,6 +5,7 @@ const ADDONS_REACT = [
5
5
  '@storybook/addon-interactions',
6
6
  '@storybook/addon-designs',
7
7
  'storybook-addon-source-link',
8
+ '@storybook/addon-themes',
8
9
  '@etchteam/storybook-addon-status',
9
10
  {
10
11
  name: '@storybook/addon-styling-webpack',
@@ -2,6 +2,7 @@ const ADDONS_REACT_VITE = [
2
2
  '@storybook/addon-links',
3
3
  '@storybook/addon-essentials',
4
4
  '@storybook/addon-interactions',
5
+ '@storybook/addon-themes',
5
6
  '@storybook/addon-designs',
6
7
  'storybook-addon-source-link',
7
8
  '@etchteam/storybook-addon-status',
@@ -1,6 +1,7 @@
1
1
  import { ADDONS_NEXTJS } from './addonsNextJs'
2
2
  import { ADDONS_REACT } from './addonsReact'
3
3
  import { ADDONS_REACT_VITE } from './addonsReactVite'
4
+ import { ADDON_THEMES } from './addonThemes'
4
5
  import { AUTHORIZATION } from './authorization'
5
6
  import { BACKGROUNDS } from './backgrounds'
6
7
  import { FRAMEWORK_NEXTJS } from './frameworkNextJs'
@@ -19,6 +20,7 @@ import { VIEWPORTS } from './viewports'
19
20
 
20
21
  export {
21
22
  AUTHORIZATION,
23
+ ADDON_THEMES,
22
24
  ADDONS_NEXTJS,
23
25
  STATIC_DIRS_REACT,
24
26
  STATIC_DIRS_NEXTJS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/storybook-config",
3
- "version": "1.0.36",
3
+ "version": "1.0.38",
4
4
  "author": "ITCase",
5
5
  "description": "Code style linter configuration presets",
6
6
  "engines": {
@@ -43,6 +43,7 @@
43
43
  "files": [
44
44
  "README.md",
45
45
  "config",
46
+ "utils",
46
47
  "dist"
47
48
  ],
48
49
  "publishConfig": {
@@ -0,0 +1,55 @@
1
+ import axios from 'axios'
2
+ import camelCase from 'lodash/camelCase'
3
+
4
+ async function getStoryInfoblocks(infoBlockSlugsList: string[] = []) {
5
+ const slugsList: string[] = []
6
+ const regExpsList: RegExp[] = []
7
+
8
+ infoBlockSlugsList.forEach((slug: string | RegExp) => {
9
+ if (slug instanceof RegExp) {
10
+ regExpsList.push(slug)
11
+ } else {
12
+ slugsList.push(slug)
13
+ }
14
+ })
15
+
16
+ const restBaseUrl = process.env.REST_BASE_URL
17
+ const slugsQuery = slugsList.join(',')
18
+ const response = await axios.get(`${restBaseUrl}rest/infoblocks/?active=true&slugs=${slugsQuery}`)
19
+ const infoBlocksList = response.data.results || []
20
+ const infoBlocks = infoBlocksList.reduce((resultData: any, infoBlockItem: any) => {
21
+ const targetSlugRegExp = regExpsList.find((slugRegExp) => {
22
+ return slugRegExp.test(infoBlockItem.slug)
23
+ })
24
+
25
+ if (targetSlugRegExp) {
26
+ const key = camelCase(infoBlockItem.slug)
27
+ if (resultData[key]) {
28
+ resultData[key].push(infoBlockItem)
29
+ } else {
30
+ resultData[key] = [infoBlockItem]
31
+ }
32
+ return resultData
33
+ }
34
+
35
+ const targetSlug = slugsList.find((slug) => {
36
+ return slug === infoBlockItem.slug
37
+ })
38
+
39
+ if (targetSlug) {
40
+ const key = camelCase(targetSlug)
41
+ resultData[key] = infoBlockItem
42
+ return resultData
43
+ }
44
+
45
+ // If no specific infoBlocks are assigned to this page,
46
+ // then we use the "slug" as a key for the infoBlocks dictionary.
47
+ const infoBlockKey = camelCase(infoBlockItem.slug)
48
+ resultData[infoBlockKey] = infoBlockItem
49
+ return resultData
50
+ }, {})
51
+
52
+ return infoBlocks
53
+ }
54
+
55
+ export { getStoryInfoblocks }