@redocly/theme 0.2.2 → 0.4.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.
Files changed (192) hide show
  1. package/Button/Button.js +3 -3
  2. package/CodeBlock/CodeBlock.js +1 -1
  3. package/ColorModeSwitcher/ColorModeSwitcher.d.ts +2 -0
  4. package/ColorModeSwitcher/ColorModeSwitcher.js +80 -0
  5. package/ColorModeSwitcher/index.d.ts +1 -0
  6. package/ColorModeSwitcher/index.js +17 -0
  7. package/CopyButton/CopyButtonWrapper.d.ts +2 -1
  8. package/CopyButton/CopyButtonWrapper.js +3 -2
  9. package/Footer/Footer.js +1 -1
  10. package/Footer/FooterColumn.js +4 -4
  11. package/Footer/FooterColumns.js +1 -1
  12. package/Footer/FooterCopyright.js +1 -1
  13. package/JsonViewer/JsonViewer.js +1 -1
  14. package/Markdown/Admonition.js +3 -3
  15. package/Markdown/CodeSample/CodeSample.js +3 -3
  16. package/Markdown/ContainerWrapper.d.ts +5 -0
  17. package/Markdown/ContainerWrapper.js +21 -0
  18. package/Markdown/Details.d.ts +6 -0
  19. package/Markdown/Details.js +22 -0
  20. package/Markdown/MarkdownLayout.d.ts +3 -1
  21. package/Markdown/MarkdownLayout.js +4 -4
  22. package/Markdown/MarkdownWrapper.js +3 -3
  23. package/Markdown/index.d.ts +1 -1
  24. package/Markdown/index.js +1 -1
  25. package/Navbar/MobileNavbarItem.js +1 -1
  26. package/Navbar/MobileNavbarMenu.js +6 -6
  27. package/Navbar/Navbar.d.ts +1 -0
  28. package/Navbar/Navbar.js +11 -7
  29. package/Navbar/NavbarDropdown.js +1 -1
  30. package/Navbar/NavbarItem.d.ts +3 -3
  31. package/Navbar/NavbarItem.js +17 -14
  32. package/Navbar/NavbarMenu.js +2 -2
  33. package/NavbarLogo/NavbarLogo.js +1 -1
  34. package/OperationBadge/OperationBadge.js +1 -1
  35. package/PageNavigation/PageNavigation.d.ts +6 -1
  36. package/PageNavigation/PageNavigation.js +4 -3
  37. package/Panel/Panel.d.ts +2 -1
  38. package/Panel/Panel.js +8 -3
  39. package/Panel/PanelBody.js +1 -1
  40. package/Panel/PanelComponent.d.ts +3 -2
  41. package/Panel/PanelComponent.js +3 -2
  42. package/Panel/PanelHeader.d.ts +1 -1
  43. package/Panel/PanelHeader.js +3 -3
  44. package/Panel/PanelHeaderTitle.js +1 -1
  45. package/Panel/index.d.ts +0 -3
  46. package/Panel/index.js +0 -3
  47. package/Profile/Profile.js +1 -1
  48. package/SamplesPanelControls/SamplesPanelControls.js +6 -4
  49. package/Search/Autocomplete.js +1 -1
  50. package/Search/Input.js +1 -1
  51. package/Search/Parameters.js +1 -1
  52. package/Search/Popover.js +1 -1
  53. package/Search/Search.js +1 -1
  54. package/Search/SearchItem.js +3 -3
  55. package/Search/utils.js +1 -1
  56. package/Sidebar/ApiCallItem.js +1 -1
  57. package/Sidebar/ArrowBack.js +1 -1
  58. package/Sidebar/BackButton.js +1 -1
  59. package/Sidebar/Drilldown.js +1 -1
  60. package/Sidebar/DrilldownMenu.js +2 -2
  61. package/Sidebar/DrilldownMenuItem.js +3 -3
  62. package/Sidebar/ExternalIcon.js +1 -1
  63. package/Sidebar/Menu.js +1 -1
  64. package/Sidebar/MenuContainer.js +1 -1
  65. package/Sidebar/MenuGroup.js +6 -2
  66. package/Sidebar/MenuItemLabel.js +1 -1
  67. package/Sidebar/MenuLink.js +1 -1
  68. package/Sidebar/SeparatorItem.js +1 -1
  69. package/Sidebar/SeparatorLine.js +1 -1
  70. package/Sidebar/Sidebar.js +1 -1
  71. package/SidebarLogo/SidebarLogo.js +1 -1
  72. package/SourceCode/SourceCode.js +5 -5
  73. package/TableOfContent/TableOfContent.js +5 -5
  74. package/Tooltip/Tooltip.js +1 -1
  75. package/Typography/H1.js +1 -1
  76. package/Typography/H2.js +1 -1
  77. package/Typography/H3.js +1 -1
  78. package/Typography/SectionHeader.js +1 -1
  79. package/Typography/Typography.js +1 -1
  80. package/globalStyle.d.ts +1 -0
  81. package/globalStyle.js +29 -25
  82. package/hooks/useActiveHeading.js +6 -5
  83. package/icons/ArrowIcon/ArrowIcon.js +1 -1
  84. package/icons/ColorModeIcon/ColorModeIcon.d.ts +10 -0
  85. package/icons/ColorModeIcon/ColorModeIcon.js +30 -0
  86. package/icons/ColorModeIcon/index.d.ts +2 -0
  87. package/icons/ColorModeIcon/index.js +5 -0
  88. package/icons/index.d.ts +1 -0
  89. package/icons/index.js +1 -0
  90. package/index.d.ts +1 -0
  91. package/index.js +1 -0
  92. package/mocks/hooks/index.js +4 -0
  93. package/package.json +1 -1
  94. package/src/Button/Button.tsx +14 -6
  95. package/src/CodeBlock/CodeBlock.ts +2 -4
  96. package/src/ColorModeSwitcher/ColorModeSwitcher.tsx +48 -0
  97. package/src/ColorModeSwitcher/index.ts +1 -0
  98. package/src/CopyButton/CopyButtonWrapper.tsx +6 -3
  99. package/src/Footer/Footer.tsx +3 -2
  100. package/src/Footer/FooterColumn.tsx +13 -9
  101. package/src/Footer/FooterColumns.tsx +2 -2
  102. package/src/Footer/FooterCopyright.tsx +1 -1
  103. package/src/JsonViewer/JsonViewer.tsx +5 -5
  104. package/src/Markdown/Admonition.tsx +3 -2
  105. package/src/Markdown/CodeSample/CodeSample.tsx +18 -17
  106. package/src/Markdown/{ContentWrapper.tsx → ContainerWrapper.tsx} +4 -4
  107. package/src/Markdown/Details.tsx +19 -0
  108. package/src/Markdown/MarkdownLayout.tsx +8 -4
  109. package/src/Markdown/MarkdownWrapper.tsx +87 -47
  110. package/src/Markdown/index.ts +1 -1
  111. package/src/Navbar/MobileNavbarItem.tsx +1 -3
  112. package/src/Navbar/MobileNavbarMenu.tsx +19 -17
  113. package/src/Navbar/Navbar.tsx +20 -9
  114. package/src/Navbar/NavbarDropdown.tsx +2 -1
  115. package/src/Navbar/NavbarItem.tsx +41 -24
  116. package/src/Navbar/NavbarMenu.tsx +3 -3
  117. package/src/NavbarLogo/NavbarLogo.tsx +4 -4
  118. package/src/OperationBadge/OperationBadge.ts +8 -9
  119. package/src/PageNavigation/PageNavigation.tsx +11 -3
  120. package/src/Panel/Panel.ts +17 -3
  121. package/src/Panel/PanelBody.ts +13 -5
  122. package/src/Panel/PanelComponent.tsx +3 -0
  123. package/src/Panel/PanelHeader.ts +13 -6
  124. package/src/Panel/PanelHeaderTitle.ts +6 -4
  125. package/src/Panel/index.ts +0 -3
  126. package/src/Profile/Profile.tsx +1 -1
  127. package/src/SamplesPanelControls/SamplesPanelControls.ts +9 -9
  128. package/src/Search/Autocomplete.tsx +1 -1
  129. package/src/Search/Input.tsx +7 -2
  130. package/src/Search/Parameters.tsx +1 -1
  131. package/src/Search/Popover.tsx +3 -3
  132. package/src/Search/Search.tsx +3 -1
  133. package/src/Search/SearchItem.tsx +14 -9
  134. package/src/Search/utils.tsx +1 -1
  135. package/src/Sidebar/ApiCallItem.tsx +7 -0
  136. package/src/Sidebar/ArrowBack.tsx +1 -1
  137. package/src/Sidebar/BackButton.tsx +10 -5
  138. package/src/Sidebar/Drilldown.tsx +1 -3
  139. package/src/Sidebar/DrilldownMenu.tsx +2 -2
  140. package/src/Sidebar/DrilldownMenuItem.tsx +12 -8
  141. package/src/Sidebar/ExternalIcon.tsx +1 -1
  142. package/src/Sidebar/Menu.tsx +1 -1
  143. package/src/Sidebar/MenuContainer.tsx +1 -1
  144. package/src/Sidebar/MenuGroup.tsx +12 -2
  145. package/src/Sidebar/MenuItemLabel.tsx +7 -7
  146. package/src/Sidebar/MenuLink.tsx +1 -1
  147. package/src/Sidebar/SeparatorItem.tsx +5 -1
  148. package/src/Sidebar/SeparatorLine.tsx +2 -2
  149. package/src/Sidebar/Sidebar.tsx +4 -4
  150. package/src/SidebarLogo/SidebarLogo.tsx +3 -3
  151. package/src/SourceCode/SourceCode.tsx +4 -4
  152. package/src/TableOfContent/TableOfContent.tsx +18 -16
  153. package/src/Tooltip/Tooltip.tsx +2 -2
  154. package/src/Typography/H1.ts +2 -2
  155. package/src/Typography/H2.ts +2 -2
  156. package/src/Typography/H3.ts +2 -1
  157. package/src/Typography/SectionHeader.ts +4 -4
  158. package/src/Typography/Typography.ts +1 -1
  159. package/src/globalStyle.ts +1424 -337
  160. package/src/hooks/useActiveHeading.ts +41 -34
  161. package/src/icons/ArrowIcon/ArrowIcon.tsx +3 -3
  162. package/src/icons/ColorModeIcon/ColorModeIcon.tsx +53 -0
  163. package/src/icons/ColorModeIcon/index.ts +2 -0
  164. package/src/icons/index.ts +1 -0
  165. package/src/index.ts +1 -0
  166. package/src/mocks/hooks/index.ts +4 -0
  167. package/src/settings.yaml +6 -0
  168. package/src/ui/Background.tsx +1 -1
  169. package/src/ui/Dropdown.tsx +6 -6
  170. package/src/ui/Jumbotron.tsx +1 -1
  171. package/src/ui/Tiles/TileHeader.ts +5 -5
  172. package/src/ui/Tiles/TileText.tsx +1 -1
  173. package/src/ui/UniversalLink.tsx +1 -1
  174. package/src/utils/theme-helpers.ts +1 -1
  175. package/ui/Background.js +1 -1
  176. package/ui/Dropdown.js +4 -4
  177. package/ui/Jumbotron.js +1 -1
  178. package/ui/Tiles/TileHeader.js +1 -1
  179. package/ui/Tiles/TileText.js +1 -1
  180. package/ui/UniversalLink.js +1 -1
  181. package/utils/theme-helpers.js +1 -1
  182. package/Markdown/ContentWrapper.d.ts +0 -5
  183. package/Markdown/ContentWrapper.js +0 -21
  184. package/Panel/CodePanel.d.ts +0 -5
  185. package/Panel/CodePanel.js +0 -21
  186. package/Panel/ContentPanel.d.ts +0 -5
  187. package/Panel/ContentPanel.js +0 -20
  188. package/Panel/DarkHeader.d.ts +0 -1
  189. package/Panel/DarkHeader.js +0 -10
  190. package/src/Panel/CodePanel.ts +0 -34
  191. package/src/Panel/ContentPanel.ts +0 -44
  192. package/src/Panel/DarkHeader.ts +0 -8
@@ -34,14 +34,14 @@ function useActiveHeading(contentElement, displayedHeaders) {
34
34
  }
35
35
  return visibleHeadings;
36
36
  };
37
- var getIndexFromId = function (id) {
37
+ var getIndexFromId = (0, react_1.useCallback)(function (id) {
38
38
  return headingElements.findIndex(function (item) { return item.id === id; });
39
- };
39
+ }, [headingElements]);
40
40
  var findHeaders = function (allContent) {
41
41
  var allHeaders = allContent.querySelectorAll('.heading-anchor');
42
42
  return Array.from(allHeaders);
43
43
  };
44
- var intersectionCallback = function (headings) {
44
+ var intersectionCallback = (0, react_1.useCallback)(function (headings) {
45
45
  var _a;
46
46
  headingElementsRef.current = headings.reduce(function (map, headingElement) {
47
47
  map[headingElement.target.id] = headingElement;
@@ -66,7 +66,7 @@ function useActiveHeading(contentElement, displayedHeaders) {
66
66
  return getIndexFromId(a.target.id) - getIndexFromId(b.target.id);
67
67
  });
68
68
  setHeading(visibleHeadings[0].target.id);
69
- };
69
+ }, [getIndexFromId, headingElements]);
70
70
  (0, react_1.useEffect)(function () {
71
71
  if (!contentElement) {
72
72
  return;
@@ -76,6 +76,7 @@ function useActiveHeading(contentElement, displayedHeaders) {
76
76
  setHeadingElements(findHeaders(contentElement));
77
77
  });
78
78
  return function () { return unlisten(); };
79
+ // eslint-disable-next-line react-hooks/exhaustive-deps
79
80
  }, [contentElement]);
80
81
  (0, react_1.useEffect)(function () {
81
82
  if (!(headingElements === null || headingElements === void 0 ? void 0 : headingElements.length)) {
@@ -93,7 +94,7 @@ function useActiveHeading(contentElement, displayedHeaders) {
93
94
  }
94
95
  });
95
96
  return function () { return observer.disconnect(); };
96
- }, [headingElements, displayedHeaders]);
97
+ }, [headingElements, displayedHeaders, intersectionCallback]);
97
98
  return heading;
98
99
  }
99
100
  exports.useActiveHeading = useActiveHeading;
@@ -29,5 +29,5 @@ var Icon = function (_a) {
29
29
  react_1.default.createElement("svg", { fill: "none", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 7 5", className: className },
30
30
  react_1.default.createElement("path", { d: "M3.5 2.51L5.806.205a.7.7 0 01.99.99l-2.8 2.8a.698.698 0 01-.99 0l-2.8-2.8a.7.7 0 11.99-.99L3.5 2.51z" }))));
31
31
  };
32
- exports.ArrowIcon = (0, styled_components_1.default)(Icon)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: var(--sidebar-chevron-size);\n height: var(--sidebar-chevron-size);\n fill: var(--sidebar-chevron-color);\n transform: rotate(", "deg);\n\n vertical-align: middle;\n"], ["\n width: var(--sidebar-chevron-size);\n height: var(--sidebar-chevron-size);\n fill: var(--sidebar-chevron-color);\n transform: rotate(", "deg);\n\n vertical-align: middle;\n"])), directionToTransform);
32
+ exports.ArrowIcon = (0, styled_components_1.default)(Icon)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: var(--sidebar-group-item-chevron-size);\n height: var(--sidebar-group-item-chevron-size);\n fill: var(--sidebar-group-item-chevron-color);\n transform: rotate(", "deg);\n\n vertical-align: middle;\n"], ["\n width: var(--sidebar-group-item-chevron-size);\n height: var(--sidebar-group-item-chevron-size);\n fill: var(--sidebar-group-item-chevron-color);\n transform: rotate(", "deg);\n\n vertical-align: middle;\n"])), directionToTransform);
33
33
  var templateObject_1;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ export interface ColorModeIconProps {
3
+ mode?: 'dark' | 'light' | string;
4
+ className?: string;
5
+ }
6
+ declare function Icon({ mode, className }: ColorModeIconProps): JSX.Element;
7
+ export declare const ColorModeIcon: import("styled-components").StyledComponent<typeof Icon, any, {
8
+ 'data-component-name': string;
9
+ }, "data-component-name">;
10
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ColorModeIcon = void 0;
11
+ var react_1 = __importDefault(require("react"));
12
+ var styled_components_1 = __importDefault(require("styled-components"));
13
+ function Icon(_a) {
14
+ var mode = _a.mode, className = _a.className;
15
+ switch (mode) {
16
+ case 'dark':
17
+ return (react_1.default.createElement("svg", { className: className, "data-testid": "dark", viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg" },
18
+ react_1.default.createElement("path", { d: "M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278z" })));
19
+ case 'light':
20
+ return (react_1.default.createElement("svg", { "data-testid": "light", className: className, viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg" },
21
+ react_1.default.createElement("path", { d: "M12 8a4 4 0 1 1-8 0 4 4 0 0 1 8 0zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z" })));
22
+ default:
23
+ return (react_1.default.createElement("svg", { "data-testid": "custom", className: className, viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg" },
24
+ react_1.default.createElement("path", { d: "M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1zm0 13V2a6 6 0 1 1 0 12z" })));
25
+ }
26
+ }
27
+ exports.ColorModeIcon = (0, styled_components_1.default)(Icon).attrs(function () { return ({
28
+ 'data-component-name': 'icons/ColorModeIcon/ColorModeIcon',
29
+ }); })(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: var(--navbar-item-font-size);\n box-sizing: border-box;\n fill: var(--navbar-text-color);\n"], ["\n width: var(--navbar-item-font-size);\n box-sizing: border-box;\n fill: var(--navbar-text-color);\n"])));
30
+ var templateObject_1;
@@ -0,0 +1,2 @@
1
+ export { ColorModeIcon } from '../../icons/ColorModeIcon/ColorModeIcon';
2
+ export type { ColorModeIconProps } from '../../icons/ColorModeIcon/ColorModeIcon';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ColorModeIcon = void 0;
4
+ var ColorModeIcon_1 = require("../../icons/ColorModeIcon/ColorModeIcon");
5
+ Object.defineProperty(exports, "ColorModeIcon", { enumerable: true, get: function () { return ColorModeIcon_1.ColorModeIcon; } });
package/icons/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from '../icons/ShelfIcon';
2
2
  export * from '../icons/AlertIcon';
3
3
  export * from '../icons/ArrowIcon';
4
+ export * from '../icons/ColorModeIcon';
package/icons/index.js CHANGED
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("../icons/ShelfIcon"), exports);
18
18
  __exportStar(require("../icons/AlertIcon"), exports);
19
19
  __exportStar(require("../icons/ArrowIcon"), exports);
20
+ __exportStar(require("../icons/ColorModeIcon"), exports);
package/index.d.ts CHANGED
@@ -15,3 +15,4 @@ export * from './globalStyle';
15
15
  export * from './OperationBadge';
16
16
  export * from './TableOfContent';
17
17
  export * from './Profile';
18
+ export * from './ColorModeSwitcher';
package/index.js CHANGED
@@ -31,3 +31,4 @@ __exportStar(require("./globalStyle"), exports);
31
31
  __exportStar(require("./OperationBadge"), exports);
32
32
  __exportStar(require("./TableOfContent"), exports);
33
33
  __exportStar(require("./Profile"), exports);
34
+ __exportStar(require("./ColorModeSwitcher"), exports);
@@ -8,6 +8,10 @@ function useThemeSettings(_) {
8
8
  nextPageLink: { label: 'next page theme settings label' },
9
9
  previousPageLink: { label: 'prev page theme settings label' },
10
10
  },
11
+ colorMode: {
12
+ modes: ['light', 'dark'],
13
+ default: 'light',
14
+ },
11
15
  };
12
16
  }
13
17
  exports.useThemeSettings = useThemeSettings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "description": "Shared UI components",
5
5
  "author": "team@redocly.com",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -57,7 +57,7 @@ export const baseButtonStyles = css`
57
57
  box-shadow: var(--button-box-shadow);
58
58
 
59
59
  &:hover {
60
- box-shadow: var(--button-active-box-shadow);
60
+ box-shadow: var(--button-hover-box-shadow);
61
61
  }
62
62
 
63
63
  &:active {
@@ -80,15 +80,21 @@ const StyledButton = styled.button.attrs(({ color = 'default', extraClass }: But
80
80
  variant === 'outlined'
81
81
  ? css`
82
82
  color: var(--button-background-color);
83
- border: 2px solid var(--button-background-color);
83
+ border: 2px solid var(--button-border-color);
84
84
  background-color: transparent;
85
85
  &:hover {
86
- border: 2px solid var(--button-active-background-color);
87
- background-color: transparent;
86
+ color: var(--button-hover-background-color);
87
+ border: 2px solid var(--button-hover-border-color);
88
88
  }
89
89
 
90
90
  &:active {
91
- border: 2px solid var(--button-outlined-active-border-color);
91
+ color: var(--button-active-background-color);
92
+ border: 2px solid var(--button-active-border-color);
93
+ }
94
+
95
+ &:disabled {
96
+ color: var(--button-disabled-background-color);
97
+ background-color: transparent;
92
98
  }
93
99
  `
94
100
  : css`
@@ -125,7 +131,9 @@ const StyledButton = styled.button.attrs(({ color = 'default', extraClass }: But
125
131
  &,
126
132
  &:hover {
127
133
  cursor: default;
128
- color: #999;
134
+ color: var(--button-disabled-color);
135
+ background-color: var(--button-disabled-background-color);
136
+ border-color: var(--button-disabled-background-color);
129
137
  pointer-events: none;
130
138
  }
131
139
  `}
@@ -12,8 +12,6 @@ export const CodeBlock = styled.div.attrs(() => ({
12
12
  */
13
13
  code[class*='language-'],
14
14
  pre[class*='language-'] {
15
- /* color: white;
16
- background: none; */
17
15
  text-shadow: 0 -0.1em 0.2em black;
18
16
  text-align: left;
19
17
  white-space: pre;
@@ -62,13 +60,13 @@ export const CodeBlock = styled.div.attrs(() => ({
62
60
  .token.inserted {
63
61
  & + a,
64
62
  & + a:visited {
65
- color: #4ed2ba;
63
+ color: var(--code-block-tokens-link-color);
66
64
  text-decoration: underline;
67
65
  }
68
66
  }
69
67
 
70
68
  .token.property.string {
71
- color: #9efaa7;
69
+ color: var(--code-block-tokens-property-string-color);
72
70
  }
73
71
 
74
72
  .token.important,
@@ -0,0 +1,48 @@
1
+ import React, { useState } from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import { useThemeSettings } from '@portal/hooks';
5
+ import { DEFAULT_THEME_NAME } from '@portal/constants';
6
+ import { ColorModeIcon } from '@theme/icons/ColorModeIcon';
7
+ import { useMount } from '@theme/hooks';
8
+
9
+ export function ColorModeSwitcher(): JSX.Element | null {
10
+ const themeSettings = useThemeSettings(DEFAULT_THEME_NAME);
11
+ const colorMode = themeSettings.colorMode;
12
+ const [activeColorMode, setActiveColorMode] = useState('');
13
+
14
+ useMount(() => {
15
+ setActiveColorMode(document.documentElement.className || colorMode?.default);
16
+ });
17
+
18
+ if (!colorMode?.modes || colorMode?.hide) {
19
+ return null;
20
+ }
21
+
22
+ const handelChangeColorMode = () => {
23
+ const activeIndex = colorMode.modes.indexOf(activeColorMode);
24
+ const mode =
25
+ activeIndex < colorMode.modes.length - 1
26
+ ? colorMode.modes[activeIndex + 1]
27
+ : colorMode.modes[0];
28
+ setActiveColorMode(mode);
29
+ localStorage.setItem('colorSchema', mode);
30
+ document.documentElement.className = mode;
31
+ };
32
+
33
+ return (
34
+ <Wrapper
35
+ data-component-name="ColorModeSwitcher/ColorModeSwitcher"
36
+ onClick={handelChangeColorMode}
37
+ >
38
+ <ColorModeIcon mode={activeColorMode} />
39
+ </Wrapper>
40
+ );
41
+ }
42
+
43
+ const Wrapper = styled.div`
44
+ margin-left: var(--navbar-item-padding-horizontal);
45
+ display: flex;
46
+ align-items: center;
47
+ cursor: pointer;
48
+ `;
@@ -0,0 +1 @@
1
+ export * from '@theme/ColorModeSwitcher/ColorModeSwitcher';
@@ -1,13 +1,15 @@
1
1
  import React, { memo } from 'react';
2
2
 
3
3
  import { SamplesControlButton } from '@theme/SamplesPanelControls';
4
- import { Tooltip } from '@theme/Tooltip';
4
+ import { Tooltip, TooltipProps } from '@theme/Tooltip';
5
5
  import { useControl } from '@theme/hooks';
6
6
  import { ClipboardService } from '@theme/utils';
7
7
 
8
8
  export interface CopyButtonWrapperProps {
9
9
  data: unknown;
10
- children: (props: { renderCopyButton: () => JSX.Element }) => JSX.Element;
10
+ children: (props: {
11
+ renderCopyButton: (placement?: TooltipProps['placement']) => JSX.Element;
12
+ }) => JSX.Element;
11
13
  dataTestId?: string;
12
14
  }
13
15
 
@@ -32,12 +34,13 @@ function CopyButtonWrapperComponent({
32
34
  showTooltip();
33
35
  };
34
36
 
35
- const renderCopyButton = (): JSX.Element => {
37
+ const renderCopyButton = (placement: TooltipProps['placement'] = 'top'): JSX.Element => {
36
38
  return (
37
39
  <Tooltip
38
40
  className="copy-button"
39
41
  tip={ClipboardService.isSupported() ? 'Copied' : 'Not supported in your browser'}
40
42
  isOpen={tooltip.isOpened}
43
+ placement={placement}
41
44
  >
42
45
  <SamplesControlButton onClick={copy} data-cy={dataTestId}>
43
46
  Copy
@@ -29,11 +29,12 @@ export function Footer({ data: { columns, copyrightText } }: FooterProps): JSX.E
29
29
  }
30
30
 
31
31
  const FooterContainer = styled.footer`
32
- font-size: 1rem;
32
+ font-size: var(--footer-font-size);
33
33
  flex-shrink: 0;
34
34
  background-color: var(--footer-background-color);
35
35
  color: var(--footer-text-color);
36
- font-family: var(--font-family-base);
36
+ font-family: var(--footer-font-family);
37
+ font-weight: var(--footer-font-weight);
37
38
  a,
38
39
  a:hover {
39
40
  color: var(--footer-text-color);
@@ -34,10 +34,11 @@ export function FooterColumn({ column }: FooterColumnProps): JSX.Element {
34
34
 
35
35
  const FooterColumnTitle = styled.p`
36
36
  display: inline-block;
37
- font-weight: var(--font-weight-regular);
38
- font-size: 24px;
39
- margin-bottom: 1.5em;
40
- font-family: var(--h-font-family);
37
+ font-weight: var(--footer-title-font-weight);
38
+ font-size: var(--footer-title-font-size);
39
+ margin-bottom: var(--footer-title-margin-vertical);
40
+ font-family: var(--footer-font-family);
41
+ color: var(--footer-title-text-color);
41
42
  `;
42
43
 
43
44
  const FooterSeparator = styled.div`
@@ -45,21 +46,24 @@ const FooterSeparator = styled.div`
45
46
  margin: 10px 0 5px 0;
46
47
  font-size: 0.75em;
47
48
  text-transform: uppercase;
48
- font-family: var(--h-font-family);
49
+ font-family: var(--footer-font-family);
49
50
  `;
50
51
 
51
52
  const FooterColumnContainer = styled.div`
52
53
  display: flex;
53
54
  flex-direction: column;
54
55
  text-align: left;
55
- margin: 0 20px;
56
- width: 20%;
56
+ margin: var(--footer-column-margin-horizontal) var(--footer-column-margin-vertical);
57
+ width: var(--footer-column-width);
57
58
  word-break: break-word;
58
59
  `;
59
60
 
60
61
  const FooterLink = styled(Link)`
61
62
  font-weight: var(--font-weight-bold);
62
- padding-bottom: 0.75em;
63
- color: var(--footer-text-color);
63
+ padding: var(--footer-item-padding-vertical) var(--footer-item-padding-horizontal);
64
+ color: var(--footer-link-text-color);
64
65
  text-decoration: none;
66
+ &:hover {
67
+ color: var(--footer-link-hover-color);
68
+ }
65
69
  `;
@@ -26,11 +26,11 @@ export function FooterColumns({ columns }: FooterColumnsProps): JSX.Element | nu
26
26
  }
27
27
 
28
28
  export const FooterColumnsContainer = styled.div`
29
- padding: 3em 20px 1em 20px;
29
+ padding: var(--footer-padding-vertical) var(--footer-padding-horizontal);
30
30
  display: flex;
31
31
  flex-direction: column;
32
32
  justify-content: center;
33
- max-width: 1200px;
33
+ max-width: var(--footer-container-max-width);
34
34
  margin: 0 auto;
35
35
 
36
36
  ${({ theme }) => theme.mediaQueries.small} {
@@ -23,6 +23,6 @@ const Wrapper = styled.section`
23
23
  color: var(--footer-text-color);
24
24
  text-align: center;
25
25
  span {
26
- max-width: 1200px;
26
+ max-width: var(--footer-container-max-width);
27
27
  }
28
28
  `;
@@ -115,8 +115,8 @@ export const JsonViewer = styled(Json).attrs(() => ({
115
115
  'data-component-name': 'JsonViewer/JsonViewer',
116
116
  }))<JsonProps>`
117
117
  .redoc-json code {
118
- background-color: var(--samples-panel-controls-background-color);
119
- color: var(--color-content-inverse);
118
+ background-color: var(--panel-samples-code-block-background-color);
119
+ color: var(--text-color-inverse);
120
120
  padding: inherit;
121
121
  border: none;
122
122
  }
@@ -125,9 +125,9 @@ export const JsonViewer = styled(Json).attrs(() => ({
125
125
  overflow-x: auto;
126
126
  position: relative;
127
127
  padding: 10px;
128
- border-radius: var(--global-border-radius);
129
- background-color: var(--samples-panel-controls-background-color);
130
- color: var(--color-content-inverse);
128
+ border-radius: var(--border-radius);
129
+ background-color: var(--panel-samples-code-block-background-color);
130
+ color: var(--text-color-inverse);
131
131
  font-size: var(--code-font-size);
132
132
  font-family: var(--code-font-family);
133
133
  white-space: var(--code-wrap, pre);
@@ -39,6 +39,7 @@ const Wrapper = styled.div<AdmonitionTypeProps>`
39
39
  ${({ type }) => `
40
40
  background-color: var(--admonition-${type}-background-color);
41
41
  color: var(--admonition-${type}-text-color);
42
+ border: var(--admonition-${type}-border);
42
43
  `}
43
44
  `;
44
45
 
@@ -47,13 +48,13 @@ const Heading = styled.h5<AdmonitionTypeProps>`
47
48
  margin: 0 0 10px;
48
49
 
49
50
  letter-spacing: var(--admonition-heading-letter-spacing);
50
- color: ${({ type }) => `var(--admonition-${type}-text-color)`};
51
+ color: ${({ type }) => `var(--admonition-${type}-heading-text-color)`};
51
52
 
52
53
  && {
53
54
  font-size: var(--admonition-heading-font-size);
54
55
  font-weight: var(--admonition-heading-font-weight);
55
56
  line-height: var(--admonition-line-height);
56
- transform: var(--admonition-heading-transform);
57
+ text-transform: var(--admonition-heading-transform);
57
58
  }
58
59
  `;
59
60
 
@@ -40,17 +40,20 @@ const CodeSampleButtonContainer = styled.div`
40
40
  `;
41
41
 
42
42
  const CopyCodeButton = styled.div`
43
- padding: 0 5px;
44
- border-radius: 4px;
45
- display: none;
43
+ padding: var(--code-block-controls-padding);
44
+ border-radius: var(--code-block-controls-border-radius);
45
+ font-size: var(--code-block-controls-font-size);
46
+ font-family: var(--code-block-controls-font-family);
46
47
  &:hover {
47
48
  cursor: pointer;
48
49
  }
49
50
  `;
50
51
 
51
52
  const DoneIndicator = styled.div`
52
- padding: 0 5px;
53
- border-radius: 4px;
53
+ padding: var(--code-block-controls-padding);
54
+ border-radius: var(--code-block-controls-border-radius);
55
+ font-size: var(--code-block-controls-font-size);
56
+ font-family: var(--code-block-controls-font-family);
54
57
  cursor: default;
55
58
  `;
56
59
 
@@ -111,32 +114,30 @@ const Wrapper = styled.div`
111
114
 
112
115
  ${CopyCodeButton},
113
116
  ${DoneIndicator} {
114
- color: rgba(255, 255, 255, 0.15);
117
+ color: var(--code-block-controls-text-color);
118
+ background-color: var(--code-block-controls-background-color);
119
+ opacity: var(--code-block-controls-opacity);
115
120
  }
116
121
  ${CopyCodeButton}:hover {
117
- color: #fff;
118
- background-color: rgba(255, 255, 255, 0.15);
122
+ color: var(--code-block-controls-hover-text-color);
123
+ background-color: var(--code-block-controls-hover-background-color);
124
+ opacity: var(--code-block-controls-active-opacity);
119
125
  }
120
126
 
121
- &:hover {
122
- ${CodeSampleButtonContainer} ${CopyCodeButton} {
123
- display: block;
124
- }
125
- }
126
127
  pre {
127
128
  white-space: var(--code-wrap);
128
129
  color: white;
129
130
  padding: 12px 14px 15px 14px;
130
131
  overflow-x: auto;
131
132
  line-height: normal;
132
- border-radius: 4px;
133
+ border-radius: var(--code-block-border-radius);
133
134
  font-family: var(--code-font-family);
134
- background-color: var(--code-block-preformatted-background-color);
135
+ background-color: var(--code-block-background-color);
135
136
  code {
136
137
  background-color: transparent;
137
138
  border: 0;
138
139
  padding: 0;
139
- color: white;
140
+ color: var(--code-block-text-color);
140
141
  &:before,
141
142
  &:after {
142
143
  content: none;
@@ -148,7 +149,7 @@ const Wrapper = styled.div`
148
149
  margin: 0.5em 0;
149
150
  overflow: auto;
150
151
  border: 0;
151
- border-radius: var(--global-border-radius);
152
+ border-radius: var(--border-radius);
152
153
  }
153
154
  code[class='language-text'] {
154
155
  line-height: 1.2em;
@@ -1,13 +1,13 @@
1
1
  import styled from 'styled-components';
2
2
 
3
- export const ContentWrapper = styled.section.attrs(() => ({
4
- 'data-component-name': 'Markdown/ContentWrapper',
3
+ export const ContainerWrapper = styled.section.attrs(() => ({
4
+ 'data-component-name': 'Markdown/ContainerWrapper',
5
5
  }))<{ withToc: boolean }>`
6
- max-width: var(--content-wrapper-max-width);
6
+ max-width: var(--md-container-max-width);
7
7
  width: 90%;
8
8
  margin: 0 auto;
9
9
 
10
- padding: var(--content-wrapper-padding-vertical) var(--content-wrapper-padding-horizontal);
10
+ padding: var(--md-container-padding-vertical) var(--md-container-padding-horizontal);
11
11
 
12
12
  & > article:first-child > h1:first-child {
13
13
  // disable margin top for h1 on the title heading if there is no "Last updated at" block
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ type DetailsProps = {
5
+ summary: string;
6
+ };
7
+
8
+ export function Details({ summary, children }: React.PropsWithChildren<DetailsProps>): JSX.Element {
9
+ return (
10
+ <StyledDetails>
11
+ <summary>{summary}</summary>
12
+ <StyledDetailsContent>{children}</StyledDetailsContent>
13
+ </StyledDetails>
14
+ );
15
+ }
16
+
17
+ const StyledDetails = styled.details``;
18
+
19
+ const StyledDetailsContent = styled.div``;
@@ -1,24 +1,28 @@
1
1
  import React from 'react';
2
2
 
3
3
  import { PageWrapper } from '@theme/Markdown/PageWrapper';
4
- import { ContentWrapper } from '@theme/Markdown/ContentWrapper';
4
+ import { ContainerWrapper } from '@theme/Markdown/ContainerWrapper';
5
5
  import { PageNavigation } from '@theme/PageNavigation/PageNavigation';
6
6
 
7
7
  type MarkdownLayoutProps = {
8
8
  tableOfContent: React.ReactNode;
9
9
  markdownWrapper: React.ReactNode;
10
+ showPrevButton?: boolean;
11
+ showNextButton?: boolean;
10
12
  };
11
13
 
12
14
  export function MarkdownLayout({
13
15
  tableOfContent,
14
16
  markdownWrapper,
17
+ showPrevButton,
18
+ showNextButton,
15
19
  }: MarkdownLayoutProps): JSX.Element {
16
20
  return (
17
21
  <PageWrapper data-component-name="Markdown/MarkdownLayout">
18
- <ContentWrapper withToc={true}>
22
+ <ContainerWrapper withToc={true}>
19
23
  {markdownWrapper}
20
- <PageNavigation />
21
- </ContentWrapper>
24
+ <PageNavigation showPrevButton={showPrevButton} showNextButton={showNextButton} />
25
+ </ContainerWrapper>
22
26
  {tableOfContent}
23
27
  </PageWrapper>
24
28
  );