@redocly/theme 0.24.0 → 0.25.0

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.
@@ -29,8 +29,6 @@ const ScorecardBadgesWrapper = styled_components_1.default.div `
29
29
  function ComplianceTag(props) {
30
30
  const { level, status, slug } = props;
31
31
  return (react_1.default.createElement(Link_1.Link, { to: slug },
32
- react_1.default.createElement(Tag_1.Tag, { color: (0, CatalogCard_1.statusToColor)(status), size: "large", onClick: () => telemetry_1.telemetry.send('scorecard_link_clicked', { action: 'click' }) },
33
- level,
34
- " oops")));
32
+ react_1.default.createElement(Tag_1.Tag, { color: (0, CatalogCard_1.statusToColor)(status), size: "large", onClick: () => telemetry_1.telemetry.send('scorecard_link_clicked', { action: 'click' }) }, level)));
35
33
  }
36
34
  //# sourceMappingURL=ScorecardBadges.js.map
@@ -0,0 +1,2 @@
1
+ export declare const ScorecardCard: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const ScorecardCardTitle: import("styled-components").StyledComponent<"h3", any, {}, never>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ScorecardCardTitle = exports.ScorecardCard = void 0;
7
+ const styled_components_1 = __importDefault(require("styled-components"));
8
+ exports.ScorecardCard = styled_components_1.default.div `
9
+ color: var(--text-primary);
10
+ background-color: var(--thin-tile-background-color);
11
+ border-radius: 4px;
12
+
13
+ border: 1px solid var(--border-primary);
14
+ box-shadow: 0 0 10px 0 rgba(35, 35, 35, 0.05);
15
+
16
+ flex: 1;
17
+ min-width: 300px;
18
+ padding: 20px;
19
+ `;
20
+ exports.ScorecardCardTitle = styled_components_1.default.h3 `
21
+ font-size: 1.2rem;
22
+ font-weight: bold;
23
+ margin-bottom: 10px;
24
+ margin-top: 0;
25
+ `;
26
+ //# sourceMappingURL=Card.js.map
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export declare function Gauge({ chunks, }: {
3
+ chunks: {
4
+ share: number;
5
+ color: string;
6
+ }[];
7
+ }): JSX.Element;
8
+ export declare const GaugeValue: import("styled-components").StyledComponent<"span", any, {}, never>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.GaugeValue = exports.Gauge = void 0;
30
+ const React = __importStar(require("react"));
31
+ const styled_components_1 = __importDefault(require("styled-components"));
32
+ function Gauge({ chunks, }) {
33
+ return (React.createElement(GaugeWrapper, null, chunks.map((chunk, i) => (React.createElement(GaugeChunk, Object.assign({ key: i }, chunk))))));
34
+ }
35
+ exports.Gauge = Gauge;
36
+ exports.GaugeValue = styled_components_1.default.span `
37
+ font-size: var(--font-size-lg);
38
+ line-height: var(line-height-regular);
39
+
40
+ margin-right: 5px;
41
+ vertical-align: middle;
42
+ display: inline-block;
43
+ margin-right: 0;
44
+ text-align: right;
45
+ width: 70px;
46
+ `;
47
+ const GaugeWrapper = styled_components_1.default.div `
48
+ display: flex;
49
+ flex-direction: row;
50
+ height: 10px;
51
+ width: 100%;
52
+ `;
53
+ const GaugeChunk = styled_components_1.default.div `
54
+ width: ${(props) => props.share}%;
55
+ background-color: ${(props) => props.color};
56
+ height: 10px;
57
+ `;
58
+ //# sourceMappingURL=Gauge.js.map
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ export interface StatusByLevelWidgetProps {
3
+ title: string;
4
+ levels: {
5
+ name: string;
6
+ errors: number;
7
+ warnings: number;
8
+ total: number;
9
+ }[];
10
+ }
11
+ export declare function StatusByLevelWidget(props: StatusByLevelWidgetProps): JSX.Element;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.StatusByLevelWidget = void 0;
30
+ const React = __importStar(require("react"));
31
+ const styled_components_1 = __importDefault(require("styled-components"));
32
+ const Gauge_1 = require("../../components/Scorecard/Gauge");
33
+ const Card_1 = require("../../components/Scorecard/Card");
34
+ function StatusByLevelWidget(props) {
35
+ const { levels, title } = props;
36
+ return (React.createElement(Card_1.ScorecardCard, null,
37
+ React.createElement(Card_1.ScorecardCardTitle, null, title),
38
+ React.createElement(CardBody, null, levels.map((level) => {
39
+ const success = level.total - level.errors - level.warnings;
40
+ return (React.createElement(CardRow, { key: level.name },
41
+ React.createElement("span", null, level.name),
42
+ React.createElement(Gauge_1.Gauge, { chunks: [
43
+ {
44
+ share: (success / level.total) * 100,
45
+ color: 'var(--scorecard-color-success)',
46
+ },
47
+ {
48
+ share: (level.warnings / level.total) * 100,
49
+ color: 'var(--scorecard-color-warning)',
50
+ },
51
+ {
52
+ share: (level.errors / level.total) * 100,
53
+ color: 'var(--scorecard-color-error)',
54
+ },
55
+ ] }),
56
+ React.createElement(Gauge_1.GaugeValue, null,
57
+ success,
58
+ "/",
59
+ level.total)));
60
+ }))));
61
+ }
62
+ exports.StatusByLevelWidget = StatusByLevelWidget;
63
+ const CardBody = styled_components_1.default.div `
64
+ display: flex;
65
+ flex-direction: column;
66
+ gap: 5px;
67
+ `;
68
+ const CardRow = styled_components_1.default.div `
69
+ display: flex;
70
+ flex-direction: row;
71
+ gap: 10px;
72
+
73
+ align-items: center;
74
+
75
+ > span:first-child {
76
+ text-align: right;
77
+ width: 100px;
78
+ }
79
+ `;
80
+ //# sourceMappingURL=StatusByLevelWidget.js.map
@@ -27,7 +27,7 @@ const Tooltip_1 = require("./components/Tooltip");
27
27
  const LastUpdated_1 = require("./components/LastUpdated");
28
28
  const NavbarLogo_1 = require("./components/NavbarLogo");
29
29
  const themeColors = (0, styled_components_1.css) `
30
- /* === Palette === */
30
+ /* === Palette === */
31
31
  /**
32
32
  * @tokens Base Colors
33
33
  * @presenter Color
@@ -290,8 +290,8 @@ const typography = (0, styled_components_1.css) `
290
290
  * @tokens Font Rendering
291
291
  */
292
292
 
293
- --text-smoothing: antialiased; // text-smoothing
294
- --text-rendering: optimizeSpeed; // text-rendering
293
+ --text-smoothing: antialiased; // text-smoothing
294
+ --text-rendering: optimizeSpeed; // text-rendering
295
295
 
296
296
  // @tokens End
297
297
  `;
@@ -385,7 +385,6 @@ const headingsTypography = (0, styled_components_1.css) `
385
385
  --heading-anchor-color: var(--color-primary); // @presenter Color
386
386
  --heading-anchor-icon: none;
387
387
 
388
-
389
388
  /**
390
389
  * @tokens Heading level 1
391
390
  */
@@ -702,7 +701,6 @@ const badges = (0, styled_components_1.css) `
702
701
  --badge-deprecated-border: 1px solid var(--badge-deprecated-border-color); // @presenter Border
703
702
  --badge-deprecated-border-radius: var(--border-radius); // @presenter BorderRadius
704
703
 
705
-
706
704
  // @tokens End
707
705
  `;
708
706
  const loadProgressBar = (0, styled_components_1.css) `
@@ -788,7 +786,8 @@ const docsDropdown = (0, styled_components_1.css) `
788
786
  --docs-dropdown-padding-vertical: 6px;
789
787
  --docs-dropdown-padding-left: 10px;
790
788
  --docs-dropdown-padding-right: 26px;
791
- --docs-dropdown-padding: var(--docs-dropdown-padding-vertical) var(--docs-dropdown-padding-right) var(--docs-dropdown-padding-vertical) var(--docs-dropdown-padding-left);
789
+ --docs-dropdown-padding: var(--docs-dropdown-padding-vertical) var(--docs-dropdown-padding-right)
790
+ var(--docs-dropdown-padding-vertical) var(--docs-dropdown-padding-left);
792
791
  --docs-dropdown-border: 1px solid var(--border-primary);
793
792
  `;
794
793
  const tile = (0, styled_components_1.css) `
@@ -839,11 +838,11 @@ const pages = (0, styled_components_1.css) `
839
838
  --page-403-description-margin: 0; // @presenter Spacing
840
839
 
841
840
  --page-403-button-margin: 4em; // @presenter Spacing
842
-
841
+
843
842
  --page-403-oidc-description-font-size: var(--font-size-lg);
844
843
  --page-403-oidc-description-margin: var(--spacing-md) var(--spacing-sm);
845
844
 
846
- // @tokens End
845
+ // @tokens End
847
846
  `;
848
847
  const error = (0, styled_components_1.css) `
849
848
  --error-bubble-padding: var(--spacing-md);
@@ -914,6 +913,11 @@ const zIndexDepth = (0, styled_components_1.css) `
914
913
  --z-index-popover: 200;
915
914
  --z-index-overlay: 1000;
916
915
  `;
916
+ const scorecardColors = (0, styled_components_1.css) `
917
+ --scorecard-color-error: var(--color-error);
918
+ --scorecard-color-warning: var(--color-warning);
919
+ --scorecard-color-success: var(--color-green-7);
920
+ `;
917
921
  exports.styles = (0, styled_components_1.css) `
918
922
  :root {
919
923
  ${Markdown_1.admonition}
@@ -961,6 +965,7 @@ exports.styles = (0, styled_components_1.css) `
961
965
  ${Profile_1.userProfileDropdown}
962
966
  ${Sidebar_1.versionPicker}
963
967
  ${zIndexDepth}
968
+ ${scorecardColors}
964
969
 
965
970
  --api-catalog-card-min-width: 250px;
966
971
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -48,7 +48,7 @@ function ComplianceTag(props: { level: string; status: string; slug: string }) {
48
48
  size="large"
49
49
  onClick={() => telemetry.send('scorecard_link_clicked', { action: 'click' })}
50
50
  >
51
- {level} oops
51
+ {level}
52
52
  </Tag>
53
53
  </Link>
54
54
  );
@@ -0,0 +1,21 @@
1
+ import styled from 'styled-components';
2
+
3
+ export const ScorecardCard = styled.div`
4
+ color: var(--text-primary);
5
+ background-color: var(--thin-tile-background-color);
6
+ border-radius: 4px;
7
+
8
+ border: 1px solid var(--border-primary);
9
+ box-shadow: 0 0 10px 0 rgba(35, 35, 35, 0.05);
10
+
11
+ flex: 1;
12
+ min-width: 300px;
13
+ padding: 20px;
14
+ `;
15
+
16
+ export const ScorecardCardTitle = styled.h3`
17
+ font-size: 1.2rem;
18
+ font-weight: bold;
19
+ margin-bottom: 10px;
20
+ margin-top: 0;
21
+ `;
@@ -0,0 +1,44 @@
1
+ import * as React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ export function Gauge({
5
+ chunks,
6
+ }: {
7
+ chunks: {
8
+ share: number;
9
+ color: string;
10
+ }[];
11
+ }) {
12
+ return (
13
+ <GaugeWrapper>
14
+ {chunks.map((chunk, i) => (
15
+ <GaugeChunk key={i} {...chunk} />
16
+ ))}
17
+ </GaugeWrapper>
18
+ );
19
+ }
20
+
21
+ export const GaugeValue = styled.span`
22
+ font-size: var(--font-size-lg);
23
+ line-height: var(line-height-regular);
24
+
25
+ margin-right: 5px;
26
+ vertical-align: middle;
27
+ display: inline-block;
28
+ margin-right: 0;
29
+ text-align: right;
30
+ width: 70px;
31
+ `;
32
+
33
+ const GaugeWrapper = styled.div`
34
+ display: flex;
35
+ flex-direction: row;
36
+ height: 10px;
37
+ width: 100%;
38
+ `;
39
+
40
+ const GaugeChunk = styled.div<{ share: number; color: string }>`
41
+ width: ${(props) => props.share}%;
42
+ background-color: ${(props) => props.color};
43
+ height: 10px;
44
+ `;
@@ -0,0 +1,67 @@
1
+ import * as React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import { Gauge, GaugeValue } from '@theme/components/Scorecard/Gauge';
5
+ import { ScorecardCard, ScorecardCardTitle } from '@theme/components/Scorecard/Card';
6
+
7
+ export interface StatusByLevelWidgetProps {
8
+ title: string;
9
+ levels: { name: string; errors: number; warnings: number; total: number }[];
10
+ }
11
+
12
+ export function StatusByLevelWidget(props: StatusByLevelWidgetProps) {
13
+ const { levels, title } = props;
14
+ return (
15
+ <ScorecardCard>
16
+ <ScorecardCardTitle>{title}</ScorecardCardTitle>
17
+ <CardBody>
18
+ {levels.map((level) => {
19
+ const success = level.total - level.errors - level.warnings;
20
+ return (
21
+ <CardRow key={level.name}>
22
+ <span>{level.name}</span>
23
+ <Gauge
24
+ chunks={[
25
+ {
26
+ share: (success / level.total) * 100,
27
+ color: 'var(--scorecard-color-success)',
28
+ },
29
+ {
30
+ share: (level.warnings / level.total) * 100,
31
+ color: 'var(--scorecard-color-warning)',
32
+ },
33
+ {
34
+ share: (level.errors / level.total) * 100,
35
+ color: 'var(--scorecard-color-error)',
36
+ },
37
+ ]}
38
+ />
39
+ <GaugeValue>
40
+ {success}/{level.total}
41
+ </GaugeValue>
42
+ </CardRow>
43
+ );
44
+ })}
45
+ </CardBody>
46
+ </ScorecardCard>
47
+ );
48
+ }
49
+
50
+ const CardBody = styled.div`
51
+ display: flex;
52
+ flex-direction: column;
53
+ gap: 5px;
54
+ `;
55
+
56
+ const CardRow = styled.div`
57
+ display: flex;
58
+ flex-direction: row;
59
+ gap: 10px;
60
+
61
+ align-items: center;
62
+
63
+ > span:first-child {
64
+ text-align: right;
65
+ width: 100px;
66
+ }
67
+ `;
@@ -2,17 +2,17 @@ import { createGlobalStyle, css } from 'styled-components';
2
2
 
3
3
  import { darkMode } from '@theme/ui/darkColors';
4
4
  import { breakpoints } from '@portal/media-css';
5
- import { footer } from "@theme/components/Footer";
6
- import { sidebar, versionPicker } from "@theme/components/Sidebar";
7
- import { breadcrumbs } from "@theme/components/Breadcrumbs";
5
+ import { footer } from '@theme/components/Footer';
6
+ import { sidebar, versionPicker } from '@theme/components/Sidebar';
7
+ import { breadcrumbs } from '@theme/components/Breadcrumbs';
8
8
  import { button } from '@theme/components/Button';
9
9
  import { tag } from '@theme/components/Tag';
10
10
  import { toc } from '@theme/components/TableOfContent';
11
- import { navbar } from "@theme/components/Navbar";
12
- import { search } from "@theme/components/Search";
13
- import { catalog } from "@theme/components/Catalog";
14
- import { filter } from "@theme/components/Filter";
15
- import { menu, mobileMenu } from "@theme/components/Menu";
11
+ import { navbar } from '@theme/components/Navbar';
12
+ import { search } from '@theme/components/Search';
13
+ import { catalog } from '@theme/components/Catalog';
14
+ import { filter } from '@theme/components/Filter';
15
+ import { menu, mobileMenu } from '@theme/components/Menu';
16
16
  import { apiReferencePanels, responsePanelColors } from '@theme/components/Panel';
17
17
  import { code } from '@theme/components/CodeBlock';
18
18
  import { product, productPicker } from '@theme/components/Product';
@@ -26,7 +26,7 @@ import { lastUpdated } from '@theme/components/LastUpdated';
26
26
  import { logo } from '@theme/components/NavbarLogo';
27
27
 
28
28
  const themeColors = css`
29
- /* === Palette === */
29
+ /* === Palette === */
30
30
  /**
31
31
  * @tokens Base Colors
32
32
  * @presenter Color
@@ -290,8 +290,8 @@ const typography = css`
290
290
  * @tokens Font Rendering
291
291
  */
292
292
 
293
- --text-smoothing: antialiased; // text-smoothing
294
- --text-rendering: optimizeSpeed; // text-rendering
293
+ --text-smoothing: antialiased; // text-smoothing
294
+ --text-rendering: optimizeSpeed; // text-rendering
295
295
 
296
296
  // @tokens End
297
297
  `;
@@ -363,7 +363,7 @@ const borders = css`
363
363
  --border-radius-md: calc(var(--border-radius) * 1.5);
364
364
  --border-radius-lg: calc(var(--border-radius) * 2);
365
365
  --border-radius-xlg: calc(var(--border-radius) * 3);
366
- `
366
+ `;
367
367
 
368
368
  const headingsTypography = css`
369
369
  * {
@@ -388,7 +388,6 @@ const headingsTypography = css`
388
388
  --heading-anchor-color: var(--color-primary); // @presenter Color
389
389
  --heading-anchor-icon: none;
390
390
 
391
-
392
391
  /**
393
392
  * @tokens Heading level 1
394
393
  */
@@ -708,7 +707,6 @@ const badges = css`
708
707
  --badge-deprecated-border: 1px solid var(--badge-deprecated-border-color); // @presenter Border
709
708
  --badge-deprecated-border-radius: var(--border-radius); // @presenter BorderRadius
710
709
 
711
-
712
710
  // @tokens End
713
711
  `;
714
712
 
@@ -797,7 +795,8 @@ const docsDropdown = css`
797
795
  --docs-dropdown-padding-vertical: 6px;
798
796
  --docs-dropdown-padding-left: 10px;
799
797
  --docs-dropdown-padding-right: 26px;
800
- --docs-dropdown-padding: var(--docs-dropdown-padding-vertical) var(--docs-dropdown-padding-right) var(--docs-dropdown-padding-vertical) var(--docs-dropdown-padding-left);
798
+ --docs-dropdown-padding: var(--docs-dropdown-padding-vertical) var(--docs-dropdown-padding-right)
799
+ var(--docs-dropdown-padding-vertical) var(--docs-dropdown-padding-left);
801
800
  --docs-dropdown-border: 1px solid var(--border-primary);
802
801
  `;
803
802
 
@@ -850,12 +849,12 @@ const pages = css`
850
849
  --page-403-description-margin: 0; // @presenter Spacing
851
850
 
852
851
  --page-403-button-margin: 4em; // @presenter Spacing
853
-
852
+
854
853
  --page-403-oidc-description-font-size: var(--font-size-lg);
855
854
  --page-403-oidc-description-margin: var(--spacing-md) var(--spacing-sm);
856
855
 
857
- // @tokens End
858
- `
856
+ // @tokens End
857
+ `;
859
858
 
860
859
  const error = css`
861
860
  --error-bubble-padding: var(--spacing-md);
@@ -929,6 +928,12 @@ const zIndexDepth = css`
929
928
  --z-index-overlay: 1000;
930
929
  `;
931
930
 
931
+ const scorecardColors = css`
932
+ --scorecard-color-error: var(--color-error);
933
+ --scorecard-color-warning: var(--color-warning);
934
+ --scorecard-color-success: var(--color-green-7);
935
+ `;
936
+
932
937
  export const styles = css`
933
938
  :root {
934
939
  ${admonition}
@@ -976,6 +981,7 @@ export const styles = css`
976
981
  ${userProfileDropdown}
977
982
  ${versionPicker}
978
983
  ${zIndexDepth}
984
+ ${scorecardColors}
979
985
 
980
986
  --api-catalog-card-min-width: 250px;
981
987