@redocly/theme 0.30.1 → 0.30.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.
@@ -41,12 +41,13 @@ const FORMATS = {
41
41
  function LastUpdated(props) {
42
42
  const { markdown: { lastUpdatedBlock = {} } = {} } = (0, useThemeConfig_1.useThemeConfig)();
43
43
  const { translate } = (0, hooks_1.useTranslate)();
44
+ const { currentLocale } = (0, hooks_1.useI18nConfig)();
44
45
  if (lastUpdatedBlock === null || lastUpdatedBlock === void 0 ? void 0 : lastUpdatedBlock.hide) {
45
46
  return null;
46
47
  }
47
48
  const lastModified = props.lastModified;
48
49
  const format = props.format || lastUpdatedBlock.format || 'timeago';
49
- const locale = props.locale || lastUpdatedBlock.locale || 'en-US';
50
+ const locale = props.locale || lastUpdatedBlock.locale || currentLocale || 'en-US';
50
51
  const isoDate = lastModified.toISOString().split('T')[0];
51
52
  const lastUpdatedString = FORMATS[format](lastModified, locale);
52
53
  const translationKey = format === 'timeago' ? 'theme.page.lastUpdated.timeago' : 'theme.page.lastUpdated.on';
@@ -16,7 +16,7 @@ const MenuItem_1 = require("../../components/Menu/MenuItem");
16
16
  function MenuItemSwitch(props) {
17
17
  var _a;
18
18
  const type = (0, getMenuType_1.getMenuType)(props.item);
19
- const { Drilldown, handleBack, handleExpand, isExpanded: drilldownIsExpanded, prevActiveItem, } = (0, useDrilldown_1.useDrilldown)(props);
19
+ const { Drilldown, handleBack, handleExpand, isExpanded: drilldownIsExpanded, } = (0, useDrilldown_1.useDrilldown)(props);
20
20
  const { MenuGroup, handleGroupClick, isExpanded } = (0, useMenuGroup_1.useMenuGroup)(props.item);
21
21
  switch (type) {
22
22
  case types_1.MenuType.Separator:
@@ -31,7 +31,7 @@ function MenuItemSwitch(props) {
31
31
  }
32
32
  return (react_1.default.createElement(Group, { item: props.item, isExpanded: isExpanded, toggleExpanded: handleGroupClick }, props.children));
33
33
  case types_1.MenuType.DrillDown:
34
- return (react_1.default.createElement(Drilldown, { item: props.item, isExpanded: drilldownIsExpanded, back: handleBack, expand: handleExpand, prevActiveItem: prevActiveItem }, props.children));
34
+ return (react_1.default.createElement(Drilldown, { item: props.item, isExpanded: drilldownIsExpanded, back: handleBack, expand: handleExpand }, props.children));
35
35
  default:
36
36
  return react_1.default.createElement(MenuItem_1.MenuItem, Object.assign({}, props));
37
37
  }
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import type { DrilldownMenuProps } from '../../components/Sidebar/types';
3
- export declare function DrilldownMenu({ item, back, prevActiveItem, children, className, }: React.PropsWithChildren<DrilldownMenuProps>): JSX.Element;
3
+ export declare function DrilldownMenu({ item, back, children, className, }: React.PropsWithChildren<DrilldownMenuProps>): JSX.Element;
@@ -33,15 +33,12 @@ const BackButton_1 = require("../../components/Sidebar/BackButton");
33
33
  const DrilldownMenuItem_1 = require("../../components/Sidebar/DrilldownMenuItem");
34
34
  const hooks_1 = require("../../mocks/hooks");
35
35
  const Menu_1 = require("../../components/Menu");
36
- function DrilldownMenu({ item, back, prevActiveItem, children, className, }) {
36
+ function DrilldownMenu({ item, back, children, className, }) {
37
37
  const { translate } = (0, hooks_1.useTranslate)();
38
- const label = item.label === (prevActiveItem === null || prevActiveItem === void 0 ? void 0 : prevActiveItem.label) || !(prevActiveItem === null || prevActiveItem === void 0 ? void 0 : prevActiveItem.label)
39
- ? translate('theme.sidebar.menu.backLabel', 'Back')
40
- : prevActiveItem === null || prevActiveItem === void 0 ? void 0 : prevActiveItem.label;
41
38
  return (react_1.default.createElement(MenuContainer, { "data-component-name": "Sidebar/DrilldownMenu", className: className },
42
39
  react_1.default.createElement(MenuContent, null,
43
40
  react_1.default.createElement(MenuWrapper, null,
44
- react_1.default.createElement(BackButton_1.BackButton, { back: back, "data-translation-key": "theme.sidebar.menu.backLabel" }, label),
41
+ react_1.default.createElement(BackButton_1.BackButton, { back: back, "data-translation-key": "theme.sidebar.menu.backLabel" }, translate('theme.sidebar.menu.backLabel', 'Back')),
45
42
  react_1.default.createElement(Menu_1.MenuLinkItem, { item: item },
46
43
  react_1.default.createElement(DrilldownMenuItem_1.DrilldownMenuItem, { item: item }))),
47
44
  children)));
@@ -16,7 +16,7 @@ exports.sidebar = (0, styled_components_1.css) `
16
16
  /**
17
17
  * @tokens Sidebar typography
18
18
  */
19
- --sidebar-word-break: inherit; // @presenter WordBreak
19
+ --sidebar-word-break: inherit;
20
20
 
21
21
  /**
22
22
  * @tokens Sidebar colors
@@ -10,7 +10,6 @@ export interface ItemState extends NavItem {
10
10
  export interface DrilldownMenuProps {
11
11
  back: () => void;
12
12
  item: ItemState;
13
- prevActiveItem?: ItemState;
14
13
  className?: string;
15
14
  }
16
15
  export interface MenuItemProps {
package/lib/config.d.ts CHANGED
@@ -24,7 +24,6 @@ declare const markdownConfigSchema: {
24
24
  };
25
25
  readonly locale: {
26
26
  readonly type: "string";
27
- readonly default: "en-US";
28
27
  };
29
28
  };
30
29
  readonly additionalProperties: false;
@@ -280,9 +279,9 @@ declare const catalogFilterSchema: {
280
279
  declare const scorecardConfigSchema: {
281
280
  readonly type: "object";
282
281
  readonly additionalProperties: true;
283
- readonly required: readonly ["levels"];
282
+ readonly required: readonly [];
284
283
  readonly properties: {
285
- readonly failBuildIfBelowMinimum: {
284
+ readonly ignoreNonCompliant: {
286
285
  readonly type: "boolean";
287
286
  readonly default: false;
288
287
  };
@@ -871,14 +870,6 @@ export declare const themeConfigSchema: {
871
870
  };
872
871
  readonly additionalProperties: false;
873
872
  };
874
- readonly seo: {
875
- readonly type: "object";
876
- readonly properties: {
877
- readonly title: {
878
- readonly type: "string";
879
- };
880
- };
881
- };
882
873
  readonly scripts: {
883
874
  readonly type: "object";
884
875
  readonly properties: {
@@ -1315,7 +1306,6 @@ export declare const themeConfigSchema: {
1315
1306
  };
1316
1307
  readonly locale: {
1317
1308
  readonly type: "string";
1318
- readonly default: "en-US";
1319
1309
  };
1320
1310
  };
1321
1311
  readonly additionalProperties: false;
@@ -1849,9 +1839,9 @@ export declare const themeConfigSchema: {
1849
1839
  readonly scorecard: {
1850
1840
  readonly type: "object";
1851
1841
  readonly additionalProperties: true;
1852
- readonly required: readonly ["levels"];
1842
+ readonly required: readonly [];
1853
1843
  readonly properties: {
1854
- readonly failBuildIfBelowMinimum: {
1844
+ readonly ignoreNonCompliant: {
1855
1845
  readonly type: "boolean";
1856
1846
  readonly default: false;
1857
1847
  };
package/lib/config.js CHANGED
@@ -73,7 +73,7 @@ const markdownConfigSchema = {
73
73
  type: 'string',
74
74
  enum: ['timeago', 'iso', 'long', 'short'],
75
75
  default: 'timeago',
76
- }, locale: { type: 'string', default: 'en-US' } }, hideConfigSchema.properties),
76
+ }, locale: { type: 'string' } }, hideConfigSchema.properties),
77
77
  additionalProperties: false,
78
78
  default: {},
79
79
  },
@@ -262,9 +262,9 @@ const catalogFilterSchema = {
262
262
  const scorecardConfigSchema = {
263
263
  type: 'object',
264
264
  additionalProperties: true,
265
- required: ['levels'],
265
+ required: [],
266
266
  properties: {
267
- failBuildIfBelowMinimum: { type: 'boolean', default: false },
267
+ ignoreNonCompliant: { type: 'boolean', default: false },
268
268
  teamMetadataProperty: {
269
269
  type: 'object',
270
270
  properties: {
@@ -371,12 +371,6 @@ exports.themeConfigSchema = {
371
371
  } }, hideConfigSchema.properties),
372
372
  additionalProperties: false,
373
373
  },
374
- seo: {
375
- type: 'object',
376
- properties: {
377
- title: { type: 'string' },
378
- },
379
- },
380
374
  scripts: {
381
375
  type: 'object',
382
376
  properties: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.30.1",
3
+ "version": "0.30.3",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -28,19 +28,18 @@
28
28
  "styled-system": "^5.1.5"
29
29
  },
30
30
  "devDependencies": {
31
- "@storybook/addon-actions": "^6.5.9",
32
- "@storybook/addon-essentials": "^6.5.9",
33
- "@storybook/addon-interactions": "^6.5.9",
34
- "@storybook/addon-links": "^6.5.9",
35
- "@storybook/addon-viewport": "^6.5.9",
36
- "@storybook/addons": "^6.5.9",
37
- "@storybook/builder-webpack5": "^6.5.9",
38
- "@storybook/core-common": "^6.5.9",
39
- "@storybook/manager-webpack5": "^6.5.9",
40
- "@storybook/node-logger": "^6.5.9",
41
- "@storybook/react": "^6.5.9",
42
- "@storybook/testing-library": "^0.0.13",
43
- "@storybook/theming": "^6.5.9",
31
+ "@storybook/addon-actions": "^7.4.6",
32
+ "@storybook/addon-essentials": "^7.4.6",
33
+ "@storybook/addon-interactions": "^7.4.6",
34
+ "@storybook/addon-links": "^7.4.6",
35
+ "@storybook/addon-viewport": "^7.4.6",
36
+ "@storybook/addons": "^7.4.6",
37
+ "@storybook/core-common": "^7.4.6",
38
+ "@storybook/node-logger": "^7.4.6",
39
+ "@storybook/react": "^7.4.6",
40
+ "@storybook/react-webpack5": "^7.4.6",
41
+ "@storybook/testing-library": "^0.2.2",
42
+ "@storybook/theming": "^7.4.6",
44
43
  "@testing-library/jest-dom": "^5.16.5",
45
44
  "@testing-library/react": "^12.1.4",
46
45
  "@testing-library/react-hooks": "^8.0.1",
@@ -69,8 +68,9 @@
69
68
  "npm-run-all": "^4.1.5",
70
69
  "react-refresh": "^0.14.0",
71
70
  "react-router-dom": "^6.10.0",
72
- "storybook-addon-pseudo-states": "^1.15.1",
73
- "storybook-design-token": "^2.9.0",
71
+ "storybook": "^7.4.6",
72
+ "storybook-addon-pseudo-states": "^2.1.2",
73
+ "storybook-design-token": "3.0.0-beta.6",
74
74
  "styled-components": "^5.3.7",
75
75
  "styled-system": "^5.1.5",
76
76
  "ts-jest": "^29.0.3",
@@ -105,8 +105,8 @@
105
105
  "test:coverage": "jest --coverage",
106
106
  "test:coverage:html": "jest --coverage --coverageReporters html",
107
107
  "e2e": "npx chromatic -b storybook:build --auto-accept-changes main --exit-once-uploaded",
108
- "storybook": "start-storybook -p 6006",
109
- "storybook:build": "npm run storybook:tokens && build-storybook",
108
+ "storybook": "storybook dev -p 6006",
109
+ "storybook:build": "npm run storybook:tokens && storybook build",
110
110
  "storybook:tokens": "ts-node scripts/generate-css-tokens.ts",
111
111
  "storybook:tokens:watch": "ts-node-dev --respawn scripts/generate-css-tokens.ts",
112
112
  "chromatic": "chromatic --exit-zero-on-changes"
@@ -3,7 +3,7 @@ import styled from 'styled-components';
3
3
  import { format } from 'timeago.js';
4
4
 
5
5
  import { useThemeConfig } from '@theme/hooks/useThemeConfig';
6
- import { useTranslate } from '@portal/hooks';
6
+ import { useI18nConfig, useTranslate } from '@portal/hooks';
7
7
 
8
8
  const FORMATS = {
9
9
  timeago: (date: Date, locale: string) => format(date, locale),
@@ -24,6 +24,7 @@ export interface LastUpdatedProps {
24
24
  export function LastUpdated(props: LastUpdatedProps): JSX.Element | null {
25
25
  const { markdown: { lastUpdatedBlock = {} } = {} } = useThemeConfig();
26
26
  const { translate } = useTranslate();
27
+ const { currentLocale } = useI18nConfig();
27
28
 
28
29
  if (lastUpdatedBlock?.hide) {
29
30
  return null;
@@ -31,7 +32,8 @@ export function LastUpdated(props: LastUpdatedProps): JSX.Element | null {
31
32
 
32
33
  const lastModified = props.lastModified;
33
34
  const format = props.format || lastUpdatedBlock.format || 'timeago';
34
- const locale = props.locale || lastUpdatedBlock.locale || 'en-US';
35
+ const locale = props.locale || lastUpdatedBlock.locale || currentLocale || 'en-US';
36
+
35
37
  const isoDate = lastModified.toISOString().split('T')[0];
36
38
 
37
39
  const lastUpdatedString = FORMATS[format as keyof typeof FORMATS](lastModified, locale);
@@ -19,7 +19,6 @@ export function MenuItemSwitch(props: PropsWithChildren<MenuItemProps>) {
19
19
  handleBack,
20
20
  handleExpand,
21
21
  isExpanded: drilldownIsExpanded,
22
- prevActiveItem,
23
22
  } = useDrilldown(props);
24
23
 
25
24
  const { MenuGroup, handleGroupClick, isExpanded } = useMenuGroup(props.item);
@@ -52,7 +51,6 @@ export function MenuItemSwitch(props: PropsWithChildren<MenuItemProps>) {
52
51
  isExpanded={drilldownIsExpanded}
53
52
  back={handleBack}
54
53
  expand={handleExpand}
55
- prevActiveItem={prevActiveItem}
56
54
  >
57
55
  {props.children}
58
56
  </Drilldown>
@@ -10,22 +10,17 @@ import { MenuLinkItem } from '@theme/components/Menu';
10
10
  export function DrilldownMenu({
11
11
  item,
12
12
  back,
13
- prevActiveItem,
14
13
  children,
15
14
  className,
16
15
  }: React.PropsWithChildren<DrilldownMenuProps>): JSX.Element {
17
16
  const { translate } = useTranslate();
18
- const label =
19
- item.label === prevActiveItem?.label || !prevActiveItem?.label
20
- ? translate('theme.sidebar.menu.backLabel', 'Back')
21
- : prevActiveItem?.label;
22
17
 
23
18
  return (
24
19
  <MenuContainer data-component-name="Sidebar/DrilldownMenu" className={className}>
25
20
  <MenuContent>
26
21
  <MenuWrapper>
27
22
  <BackButton back={back} data-translation-key="theme.sidebar.menu.backLabel">
28
- {label}
23
+ {translate('theme.sidebar.menu.backLabel', 'Back')}
29
24
  </BackButton>
30
25
  <MenuLinkItem item={item}>
31
26
  <DrilldownMenuItem item={item} />
@@ -14,7 +14,7 @@ export const sidebar = css`
14
14
  /**
15
15
  * @tokens Sidebar typography
16
16
  */
17
- --sidebar-word-break: inherit; // @presenter WordBreak
17
+ --sidebar-word-break: inherit;
18
18
 
19
19
  /**
20
20
  * @tokens Sidebar colors
@@ -12,7 +12,6 @@ export interface ItemState extends NavItem {
12
12
  export interface DrilldownMenuProps {
13
13
  back: () => void;
14
14
  item: ItemState;
15
- prevActiveItem?: ItemState;
16
15
  className?: string;
17
16
  }
18
17
 
package/src/config.ts CHANGED
@@ -80,7 +80,7 @@ const markdownConfigSchema = {
80
80
  enum: ['timeago', 'iso', 'long', 'short'],
81
81
  default: 'timeago',
82
82
  },
83
- locale: { type: 'string', default: 'en-US' },
83
+ locale: { type: 'string' },
84
84
  ...hideConfigSchema.properties,
85
85
  },
86
86
  additionalProperties: false,
@@ -301,9 +301,9 @@ const catalogFilterSchema = {
301
301
  const scorecardConfigSchema = {
302
302
  type: 'object',
303
303
  additionalProperties: true,
304
- required: ['levels'],
304
+ required: [],
305
305
  properties: {
306
- failBuildIfBelowMinimum: { type: 'boolean', default: false },
306
+ ignoreNonCompliant: { type: 'boolean', default: false },
307
307
  teamMetadataProperty: {
308
308
  type: 'object',
309
309
  properties: {
@@ -425,12 +425,6 @@ export const themeConfigSchema = {
425
425
  },
426
426
  additionalProperties: false,
427
427
  },
428
- seo: {
429
- type: 'object',
430
- properties: {
431
- title: { type: 'string' },
432
- },
433
- },
434
428
  scripts: {
435
429
  type: 'object',
436
430
  properties: {