@redocly/theme 0.25.0 → 0.25.1-beta.4
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.
- package/lib/components/Catalog/useCatalog.js +4 -3
- package/lib/components/Filter/Filter.js +1 -5
- package/lib/components/Scorecard/Card.d.ts +3 -1
- package/lib/components/Scorecard/Card.js +4 -2
- package/lib/components/Scorecard/Gauge.d.ts +5 -2
- package/lib/components/Scorecard/Gauge.js +6 -2
- package/lib/components/Scorecard/StatusByLevelWidget.d.ts +1 -0
- package/lib/components/Scorecard/StatusByLevelWidget.js +5 -2
- package/lib/config.d.ts +6 -0
- package/lib/config.js +1 -0
- package/package.json +1 -1
- package/src/components/Catalog/useCatalog.ts +6 -3
- package/src/components/Filter/Filter.tsx +1 -6
- package/src/components/Scorecard/Card.tsx +4 -2
- package/src/components/Scorecard/Gauge.tsx +16 -7
- package/src/components/Scorecard/StatusByLevelWidget.tsx +6 -2
- package/src/config.ts +1 -0
|
@@ -256,9 +256,10 @@ function collectFilterOptions(items, filters) {
|
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
const options = Object.entries(usedOptions)
|
|
260
|
-
|
|
261
|
-
.sort((a, b) => b.value.localeCompare(a.value));
|
|
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
|
+
}
|
|
262
263
|
if (othersCount) {
|
|
263
264
|
options.push({
|
|
264
265
|
value: filter.missingCategoryNameTranslationKey || filter.missingCategoryName || 'Others',
|
|
@@ -56,7 +56,7 @@ function Filter({ filter, filterValuesCasing, }) {
|
|
|
56
56
|
return;
|
|
57
57
|
filter.selectOption(Object.assign(Object.assign({}, filter.selectedOptions), { to: formatDateWithNoTimeZone(to) }));
|
|
58
58
|
} })))) : (filter.filteredOptions.map((value) => {
|
|
59
|
-
const id = 'filter--' + filter.property + '--' +
|
|
59
|
+
const id = 'filter--' + filter.property + '--' + value.value;
|
|
60
60
|
return (react_1.default.createElement(FilterOption, { key: id, role: "link", onClick: () => filter.toggleOption(value.value) },
|
|
61
61
|
react_1.default.createElement(icons_1.CheckboxIcon, { checked: filter.selectedOptions.has(value.value) }),
|
|
62
62
|
react_1.default.createElement(FilterOptionLabel, null, changeCasing(translate(value.value), filterValuesCasing)),
|
|
@@ -137,10 +137,6 @@ const StyledSelect = (0, styled_components_1.default)(Select_1.Select) `
|
|
|
137
137
|
margin: var(--filter-select-option-margin);
|
|
138
138
|
}
|
|
139
139
|
`;
|
|
140
|
-
// TODO: import from portal
|
|
141
|
-
function slug(str) {
|
|
142
|
-
return str.replace(/\s/g, '-').toLowerCase();
|
|
143
|
-
}
|
|
144
140
|
const DatePickerWrapper = styled_components_1.default.div `
|
|
145
141
|
color: var(--filter-date-picker-color);
|
|
146
142
|
display: flex;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export declare const ScorecardCard: import("styled-components").StyledComponent<"div", any, {
|
|
1
|
+
export declare const ScorecardCard: import("styled-components").StyledComponent<"div", any, {
|
|
2
|
+
'data-component-name': string;
|
|
3
|
+
}, "data-component-name">;
|
|
2
4
|
export declare const ScorecardCardTitle: import("styled-components").StyledComponent<"h3", any, {}, never>;
|
|
@@ -5,9 +5,11 @@ 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
|
|
8
|
+
exports.ScorecardCard = styled_components_1.default.div.attrs({
|
|
9
|
+
'data-component-name': 'Scorecard/ScorecardCard',
|
|
10
|
+
}) `
|
|
9
11
|
color: var(--text-primary);
|
|
10
|
-
background-color: var(--
|
|
12
|
+
background-color: var(--bg-raised);
|
|
11
13
|
border-radius: 4px;
|
|
12
14
|
|
|
13
15
|
border: 1px solid var(--border-primary);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export
|
|
2
|
+
export interface GaugeProps {
|
|
3
3
|
chunks: {
|
|
4
4
|
share: number;
|
|
5
5
|
color: string;
|
|
6
|
+
title?: string;
|
|
6
7
|
}[];
|
|
7
|
-
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function Gauge({ chunks, className }: GaugeProps): JSX.Element;
|
|
8
11
|
export declare const GaugeValue: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -29,8 +29,12 @@ 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, }) {
|
|
33
|
-
|
|
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 })))));
|
|
34
38
|
}
|
|
35
39
|
exports.Gauge = Gauge;
|
|
36
40
|
exports.GaugeValue = styled_components_1.default.span `
|
|
@@ -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 } = props;
|
|
36
|
-
return (React.createElement(Card_1.ScorecardCard,
|
|
35
|
+
const { levels, title, className } = props;
|
|
36
|
+
return (React.createElement(Card_1.ScorecardCard, { "data-component-name": "Scorecard/StatusByLevelWidget", className: className },
|
|
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,14 +43,17 @@ function StatusByLevelWidget(props) {
|
|
|
43
43
|
{
|
|
44
44
|
share: (success / level.total) * 100,
|
|
45
45
|
color: 'var(--scorecard-color-success)',
|
|
46
|
+
title: `${success} passed`,
|
|
46
47
|
},
|
|
47
48
|
{
|
|
48
49
|
share: (level.warnings / level.total) * 100,
|
|
49
50
|
color: 'var(--scorecard-color-warning)',
|
|
51
|
+
title: `${level.warnings} ${level.warnings === 1 ? 'warning' : 'warnings'}`,
|
|
50
52
|
},
|
|
51
53
|
{
|
|
52
54
|
share: (level.errors / level.total) * 100,
|
|
53
55
|
color: 'var(--scorecard-color-error)',
|
|
56
|
+
title: `${level.errors} ${level.errors === 1 ? 'error' : 'errors'}`,
|
|
54
57
|
},
|
|
55
58
|
] }),
|
|
56
59
|
React.createElement(Gauge_1.GaugeValue, null,
|
package/lib/config.d.ts
CHANGED
|
@@ -309,6 +309,9 @@ declare const scorecardConfigSchema: {
|
|
|
309
309
|
readonly name: {
|
|
310
310
|
readonly type: "string";
|
|
311
311
|
};
|
|
312
|
+
readonly color: {
|
|
313
|
+
readonly type: "string";
|
|
314
|
+
};
|
|
312
315
|
readonly extends: {
|
|
313
316
|
readonly type: "array";
|
|
314
317
|
readonly items: {
|
|
@@ -1862,6 +1865,9 @@ export declare const themeConfigSchema: {
|
|
|
1862
1865
|
readonly name: {
|
|
1863
1866
|
readonly type: "string";
|
|
1864
1867
|
};
|
|
1868
|
+
readonly color: {
|
|
1869
|
+
readonly type: "string";
|
|
1870
|
+
};
|
|
1865
1871
|
readonly extends: {
|
|
1866
1872
|
readonly type: "array";
|
|
1867
1873
|
readonly items: {
|
package/lib/config.js
CHANGED
package/package.json
CHANGED
|
@@ -299,9 +299,12 @@ function collectFilterOptions(
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
const options = Object.entries(usedOptions)
|
|
303
|
-
|
|
304
|
-
|
|
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
|
+
|
|
305
308
|
if (othersCount) {
|
|
306
309
|
options.push({
|
|
307
310
|
value: filter.missingCategoryNameTranslationKey || filter.missingCategoryName || 'Others',
|
|
@@ -111,7 +111,7 @@ export function Filter({
|
|
|
111
111
|
</>
|
|
112
112
|
) : (
|
|
113
113
|
filter.filteredOptions.map((value: any) => {
|
|
114
|
-
const id = 'filter--' + filter.property + '--' +
|
|
114
|
+
const id = 'filter--' + filter.property + '--' + value.value;
|
|
115
115
|
return (
|
|
116
116
|
<FilterOption key={id} role="link" onClick={() => filter.toggleOption(value.value)}>
|
|
117
117
|
<CheckboxIcon checked={filter.selectedOptions.has(value.value)} />
|
|
@@ -212,11 +212,6 @@ const StyledSelect = styled(Select)`
|
|
|
212
212
|
}
|
|
213
213
|
`;
|
|
214
214
|
|
|
215
|
-
// TODO: import from portal
|
|
216
|
-
function slug(str: string): string {
|
|
217
|
-
return str.replace(/\s/g, '-').toLowerCase();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
215
|
const DatePickerWrapper = styled.div`
|
|
221
216
|
color: var(--filter-date-picker-color);
|
|
222
217
|
display: flex;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
|
|
3
|
-
export const ScorecardCard = styled.div
|
|
3
|
+
export const ScorecardCard = styled.div.attrs({
|
|
4
|
+
'data-component-name': 'Scorecard/ScorecardCard',
|
|
5
|
+
})`
|
|
4
6
|
color: var(--text-primary);
|
|
5
|
-
background-color: var(--
|
|
7
|
+
background-color: var(--bg-raised);
|
|
6
8
|
border-radius: 4px;
|
|
7
9
|
|
|
8
10
|
border: 1px solid var(--border-primary);
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
|
|
4
|
-
export function Gauge({
|
|
5
|
-
chunks,
|
|
6
|
-
}: {
|
|
3
|
+
export interface GaugeProps {
|
|
7
4
|
chunks: {
|
|
8
5
|
share: number;
|
|
9
6
|
color: string;
|
|
7
|
+
title?: string;
|
|
10
8
|
}[];
|
|
11
|
-
|
|
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(', ');
|
|
12
17
|
return (
|
|
13
|
-
<GaugeWrapper
|
|
18
|
+
<GaugeWrapper
|
|
19
|
+
data-component-name="Scorecard/StatusByLevelWidget"
|
|
20
|
+
className={className}
|
|
21
|
+
title={title}
|
|
22
|
+
>
|
|
14
23
|
{chunks.map((chunk, i) => (
|
|
15
|
-
<GaugeChunk key={i} {
|
|
24
|
+
<GaugeChunk key={i} share={chunk.share} color={chunk.color} />
|
|
16
25
|
))}
|
|
17
26
|
</GaugeWrapper>
|
|
18
27
|
);
|
|
@@ -7,12 +7,13 @@ 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;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export function StatusByLevelWidget(props: StatusByLevelWidgetProps) {
|
|
13
|
-
const { levels, title } = props;
|
|
14
|
+
const { levels, title, className } = props;
|
|
14
15
|
return (
|
|
15
|
-
<ScorecardCard>
|
|
16
|
+
<ScorecardCard data-component-name="Scorecard/StatusByLevelWidget" className={className}>
|
|
16
17
|
<ScorecardCardTitle>{title}</ScorecardCardTitle>
|
|
17
18
|
<CardBody>
|
|
18
19
|
{levels.map((level) => {
|
|
@@ -25,14 +26,17 @@ export function StatusByLevelWidget(props: StatusByLevelWidgetProps) {
|
|
|
25
26
|
{
|
|
26
27
|
share: (success / level.total) * 100,
|
|
27
28
|
color: 'var(--scorecard-color-success)',
|
|
29
|
+
title: `${success} passed`,
|
|
28
30
|
},
|
|
29
31
|
{
|
|
30
32
|
share: (level.warnings / level.total) * 100,
|
|
31
33
|
color: 'var(--scorecard-color-warning)',
|
|
34
|
+
title: `${level.warnings} ${level.warnings === 1 ? 'warning' : 'warnings'}`,
|
|
32
35
|
},
|
|
33
36
|
{
|
|
34
37
|
share: (level.errors / level.total) * 100,
|
|
35
38
|
color: 'var(--scorecard-color-error)',
|
|
39
|
+
title: `${level.errors} ${level.errors === 1 ? 'error' : 'errors'}`,
|
|
36
40
|
},
|
|
37
41
|
]}
|
|
38
42
|
/>
|
package/src/config.ts
CHANGED