@redocly/theme 0.30.1-beta.1 → 0.30.2

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.
@@ -256,10 +256,9 @@ function collectFilterOptions(items, filters) {
256
256
  }
257
257
  }
258
258
  }
259
- const options = Object.entries(usedOptions).map(([value, count]) => ({ value, count }));
260
- if (!staticOptions) {
261
- options.sort((a, b) => b.value.localeCompare(a.value));
262
- }
259
+ const options = Object.entries(usedOptions)
260
+ .map(([value, count]) => ({ value, count }))
261
+ .sort((a, b) => b.value.localeCompare(a.value));
263
262
  if (othersCount) {
264
263
  options.push({
265
264
  value: filter.missingCategoryNameTranslationKey || filter.missingCategoryName || 'Others',
@@ -52,7 +52,7 @@ function Filter({ filter, filterValuesCasing, }) {
52
52
  return;
53
53
  filter.selectOption(Object.assign(Object.assign({}, filter.selectedOptions), { to: formatDateWithNoTimeZone(to) }));
54
54
  } })))) : (filter.filteredOptions.map((value) => {
55
- const id = 'filter--' + filter.property + '--' + value.value;
55
+ const id = 'filter--' + filter.property + '--' + slug(value.value);
56
56
  return (react_1.default.createElement(FilterOption, { key: id, role: "link", onClick: () => filter.toggleOption(value.value) },
57
57
  react_1.default.createElement(icons_1.CheckboxIcon, { checked: filter.selectedOptions.has(value.value) }),
58
58
  react_1.default.createElement(FilterOptionLabel, null, changeCasing(translate(value.value), filterValuesCasing)),
@@ -133,6 +133,10 @@ const StyledSelect = (0, styled_components_1.default)(Select_1.Select) `
133
133
  margin: var(--filter-select-option-margin);
134
134
  }
135
135
  `;
136
+ // TODO: import from portal
137
+ function slug(str) {
138
+ return str.replace(/\s/g, '-').toLowerCase();
139
+ }
136
140
  const DatePickerWrapper = styled_components_1.default.div `
137
141
  color: var(--filter-date-picker-color);
138
142
  display: flex;
@@ -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,4 +1,2 @@
1
- export declare const ScorecardCard: import("styled-components").StyledComponent<"div", any, {
2
- 'data-component-name': string;
3
- }, "data-component-name">;
1
+ export declare const ScorecardCard: import("styled-components").StyledComponent<"div", any, {}, never>;
4
2
  export declare const ScorecardCardTitle: import("styled-components").StyledComponent<"h3", any, {}, never>;
@@ -5,11 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ScorecardCardTitle = exports.ScorecardCard = void 0;
7
7
  const styled_components_1 = __importDefault(require("styled-components"));
8
- exports.ScorecardCard = styled_components_1.default.div.attrs({
9
- 'data-component-name': 'Scorecard/ScorecardCard',
10
- }) `
8
+ exports.ScorecardCard = styled_components_1.default.div `
11
9
  color: var(--text-primary);
12
- background-color: var(--bg-raised);
10
+ background-color: var(--thin-tile-background-color);
13
11
  border-radius: 4px;
14
12
 
15
13
  border: 1px solid var(--border-primary);
@@ -1,11 +1,8 @@
1
1
  /// <reference types="react" />
2
- export interface GaugeProps {
2
+ export declare function Gauge({ chunks, }: {
3
3
  chunks: {
4
4
  share: number;
5
5
  color: string;
6
- title?: string;
7
6
  }[];
8
- className?: string;
9
- }
10
- export declare function Gauge({ chunks, className }: GaugeProps): JSX.Element;
7
+ }): JSX.Element;
11
8
  export declare const GaugeValue: import("styled-components").StyledComponent<"span", any, {}, never>;
@@ -29,12 +29,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.GaugeValue = exports.Gauge = void 0;
30
30
  const React = __importStar(require("react"));
31
31
  const styled_components_1 = __importDefault(require("styled-components"));
32
- function Gauge({ chunks, className }) {
33
- const title = chunks
34
- .map((chunk) => chunk.title)
35
- .filter(Boolean)
36
- .join(', ');
37
- return (React.createElement(GaugeWrapper, { "data-component-name": "Scorecard/StatusByLevelWidget", className: className, title: title }, chunks.map((chunk, i) => (React.createElement(GaugeChunk, { key: i, share: chunk.share, color: chunk.color })))));
32
+ function Gauge({ chunks, }) {
33
+ return (React.createElement(GaugeWrapper, null, chunks.map((chunk, i) => (React.createElement(GaugeChunk, Object.assign({ key: i }, chunk))))));
38
34
  }
39
35
  exports.Gauge = Gauge;
40
36
  exports.GaugeValue = styled_components_1.default.span `
@@ -7,6 +7,5 @@ export interface StatusByLevelWidgetProps {
7
7
  warnings: number;
8
8
  total: number;
9
9
  }[];
10
- className?: string;
11
10
  }
12
11
  export declare function StatusByLevelWidget(props: StatusByLevelWidgetProps): JSX.Element;
@@ -32,8 +32,8 @@ const styled_components_1 = __importDefault(require("styled-components"));
32
32
  const Gauge_1 = require("../../components/Scorecard/Gauge");
33
33
  const Card_1 = require("../../components/Scorecard/Card");
34
34
  function StatusByLevelWidget(props) {
35
- const { levels, title, className } = props;
36
- return (React.createElement(Card_1.ScorecardCard, { "data-component-name": "Scorecard/StatusByLevelWidget", className: className },
35
+ const { levels, title } = props;
36
+ return (React.createElement(Card_1.ScorecardCard, null,
37
37
  React.createElement(Card_1.ScorecardCardTitle, null, title),
38
38
  React.createElement(CardBody, null, levels.map((level) => {
39
39
  const success = level.total - level.errors - level.warnings;
@@ -43,17 +43,14 @@ function StatusByLevelWidget(props) {
43
43
  {
44
44
  share: (success / level.total) * 100,
45
45
  color: 'var(--scorecard-color-success)',
46
- title: `${success} passed`,
47
46
  },
48
47
  {
49
48
  share: (level.warnings / level.total) * 100,
50
49
  color: 'var(--scorecard-color-warning)',
51
- title: `${level.warnings} ${level.warnings === 1 ? 'warning' : 'warnings'}`,
52
50
  },
53
51
  {
54
52
  share: (level.errors / level.total) * 100,
55
53
  color: 'var(--scorecard-color-error)',
56
- title: `${level.errors} ${level.errors === 1 ? 'error' : 'errors'}`,
57
54
  },
58
55
  ] }),
59
56
  React.createElement(Gauge_1.GaugeValue, null,
@@ -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)));
@@ -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
@@ -282,7 +282,7 @@ declare const scorecardConfigSchema: {
282
282
  readonly additionalProperties: true;
283
283
  readonly required: readonly ["levels"];
284
284
  readonly properties: {
285
- readonly failBuildIfBelowMinimum: {
285
+ readonly ignoreNonCompliant: {
286
286
  readonly type: "boolean";
287
287
  readonly default: false;
288
288
  };
@@ -309,9 +309,6 @@ declare const scorecardConfigSchema: {
309
309
  readonly name: {
310
310
  readonly type: "string";
311
311
  };
312
- readonly color: {
313
- readonly type: "string";
314
- };
315
312
  readonly extends: {
316
313
  readonly type: "array";
317
314
  readonly items: {
@@ -1854,7 +1851,7 @@ export declare const themeConfigSchema: {
1854
1851
  readonly additionalProperties: true;
1855
1852
  readonly required: readonly ["levels"];
1856
1853
  readonly properties: {
1857
- readonly failBuildIfBelowMinimum: {
1854
+ readonly ignoreNonCompliant: {
1858
1855
  readonly type: "boolean";
1859
1856
  readonly default: false;
1860
1857
  };
@@ -1881,9 +1878,6 @@ export declare const themeConfigSchema: {
1881
1878
  readonly name: {
1882
1879
  readonly type: "string";
1883
1880
  };
1884
- readonly color: {
1885
- readonly type: "string";
1886
- };
1887
1881
  readonly extends: {
1888
1882
  readonly type: "array";
1889
1883
  readonly items: {
package/lib/config.js CHANGED
@@ -264,7 +264,7 @@ const scorecardConfigSchema = {
264
264
  additionalProperties: true,
265
265
  required: ['levels'],
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: {
@@ -280,7 +280,6 @@ const scorecardConfigSchema = {
280
280
  required: ['name'],
281
281
  properties: {
282
282
  name: { type: 'string' },
283
- color: { type: 'string' },
284
283
  extends: { type: 'array', items: { type: 'string' } },
285
284
  rules: {
286
285
  type: 'object',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.30.1-beta.1",
3
+ "version": "0.30.2",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -299,12 +299,9 @@ function collectFilterOptions(
299
299
  }
300
300
  }
301
301
 
302
- const options = Object.entries(usedOptions).map(([value, count]) => ({ value, count }));
303
-
304
- if (!staticOptions) {
305
- options.sort((a, b) => b.value.localeCompare(a.value));
306
- }
307
-
302
+ const options = Object.entries(usedOptions)
303
+ .map(([value, count]) => ({ value, count }))
304
+ .sort((a, b) => b.value.localeCompare(a.value));
308
305
  if (othersCount) {
309
306
  options.push({
310
307
  value: filter.missingCategoryNameTranslationKey || filter.missingCategoryName || 'Others',
@@ -109,7 +109,7 @@ export function Filter({
109
109
  </>
110
110
  ) : (
111
111
  filter.filteredOptions.map((value: any) => {
112
- const id = 'filter--' + filter.property + '--' + value.value;
112
+ const id = 'filter--' + filter.property + '--' + slug(value.value);
113
113
  return (
114
114
  <FilterOption key={id} role="link" onClick={() => filter.toggleOption(value.value)}>
115
115
  <CheckboxIcon checked={filter.selectedOptions.has(value.value)} />
@@ -210,6 +210,11 @@ const StyledSelect = styled(Select)`
210
210
  }
211
211
  `;
212
212
 
213
+ // TODO: import from portal
214
+ function slug(str: string): string {
215
+ return str.replace(/\s/g, '-').toLowerCase();
216
+ }
217
+
213
218
  const DatePickerWrapper = styled.div`
214
219
  color: var(--filter-date-picker-color);
215
220
  display: flex;
@@ -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>
@@ -1,10 +1,8 @@
1
1
  import styled from 'styled-components';
2
2
 
3
- export const ScorecardCard = styled.div.attrs({
4
- 'data-component-name': 'Scorecard/ScorecardCard',
5
- })`
3
+ export const ScorecardCard = styled.div`
6
4
  color: var(--text-primary);
7
- background-color: var(--bg-raised);
5
+ background-color: var(--thin-tile-background-color);
8
6
  border-radius: 4px;
9
7
 
10
8
  border: 1px solid var(--border-primary);
@@ -1,27 +1,18 @@
1
1
  import * as React from 'react';
2
2
  import styled from 'styled-components';
3
- export interface GaugeProps {
3
+
4
+ export function Gauge({
5
+ chunks,
6
+ }: {
4
7
  chunks: {
5
8
  share: number;
6
9
  color: string;
7
- title?: string;
8
10
  }[];
9
- className?: string;
10
- }
11
-
12
- export function Gauge({ chunks, className }: GaugeProps) {
13
- const title = chunks
14
- .map((chunk) => chunk.title)
15
- .filter(Boolean)
16
- .join(', ');
11
+ }) {
17
12
  return (
18
- <GaugeWrapper
19
- data-component-name="Scorecard/StatusByLevelWidget"
20
- className={className}
21
- title={title}
22
- >
13
+ <GaugeWrapper>
23
14
  {chunks.map((chunk, i) => (
24
- <GaugeChunk key={i} share={chunk.share} color={chunk.color} />
15
+ <GaugeChunk key={i} {...chunk} />
25
16
  ))}
26
17
  </GaugeWrapper>
27
18
  );
@@ -7,13 +7,12 @@ import { ScorecardCard, ScorecardCardTitle } from '@theme/components/Scorecard/C
7
7
  export interface StatusByLevelWidgetProps {
8
8
  title: string;
9
9
  levels: { name: string; errors: number; warnings: number; total: number }[];
10
- className?: string;
11
10
  }
12
11
 
13
12
  export function StatusByLevelWidget(props: StatusByLevelWidgetProps) {
14
- const { levels, title, className } = props;
13
+ const { levels, title } = props;
15
14
  return (
16
- <ScorecardCard data-component-name="Scorecard/StatusByLevelWidget" className={className}>
15
+ <ScorecardCard>
17
16
  <ScorecardCardTitle>{title}</ScorecardCardTitle>
18
17
  <CardBody>
19
18
  {levels.map((level) => {
@@ -26,17 +25,14 @@ export function StatusByLevelWidget(props: StatusByLevelWidgetProps) {
26
25
  {
27
26
  share: (success / level.total) * 100,
28
27
  color: 'var(--scorecard-color-success)',
29
- title: `${success} passed`,
30
28
  },
31
29
  {
32
30
  share: (level.warnings / level.total) * 100,
33
31
  color: 'var(--scorecard-color-warning)',
34
- title: `${level.warnings} ${level.warnings === 1 ? 'warning' : 'warnings'}`,
35
32
  },
36
33
  {
37
34
  share: (level.errors / level.total) * 100,
38
35
  color: 'var(--scorecard-color-error)',
39
- title: `${level.errors} ${level.errors === 1 ? 'error' : 'errors'}`,
40
36
  },
41
37
  ]}
42
38
  />
@@ -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} />
@@ -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
@@ -303,7 +303,7 @@ const scorecardConfigSchema = {
303
303
  additionalProperties: true,
304
304
  required: ['levels'],
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: {
@@ -319,7 +319,6 @@ const scorecardConfigSchema = {
319
319
  required: ['name'],
320
320
  properties: {
321
321
  name: { type: 'string' },
322
- color: { type: 'string' },
323
322
  extends: { type: 'array', items: { type: 'string' } },
324
323
  rules: {
325
324
  type: 'object',