@redocly/theme 0.70.0 → 0.70.1

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.
@@ -1,21 +1,57 @@
1
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  exports.DocumentationLayout = DocumentationLayout;
7
40
  const react_1 = __importDefault(require("react"));
8
- const styled_components_1 = __importDefault(require("styled-components"));
41
+ const styled_components_1 = __importStar(require("styled-components"));
9
42
  const utils_1 = require("../core/utils");
43
+ const hooks_1 = require("../core/hooks");
10
44
  const constants_1 = require("../core/constants");
11
45
  const CodeSnippetContext_1 = require("../core/contexts/CodeSnippetContext");
12
46
  const DocumentationLayoutTop_1 = require("../layouts/DocumentationLayoutTop");
13
47
  const DocumentationLayoutBottom_1 = require("../layouts/DocumentationLayoutBottom");
14
48
  function DocumentationLayout({ tableOfContent, feedback, config, editPage, lastModified, nextPage, prevPage, className, children, }) {
15
- var _a;
49
+ var _a, _b;
50
+ const { markdown } = (0, hooks_1.useThemeConfig)();
51
+ const withToc = Boolean(tableOfContent) && !((_b = (_a = (config !== null && config !== void 0 ? config : markdown)) === null || _a === void 0 ? void 0 : _a.toc) === null || _b === void 0 ? void 0 : _b.hide);
16
52
  return (react_1.default.createElement(CodeSnippetContext_1.CodeSnippetProvider, null,
17
- react_1.default.createElement(LayoutWrapper, { "data-component-name": "Layout/DocumentationLayout", className: className },
18
- react_1.default.createElement(ContentWrapper, { $withToc: !((_a = config === null || config === void 0 ? void 0 : config.toc) === null || _a === void 0 ? void 0 : _a.hide) },
53
+ react_1.default.createElement(LayoutWrapper, { "data-component-name": "Layout/DocumentationLayout", className: className, $withToc: withToc },
54
+ react_1.default.createElement(ContentWrapper, null,
19
55
  react_1.default.createElement(DocumentationLayoutTop_1.DocumentationLayoutTop, { config: config, editPage: editPage, lastModified: lastModified }),
20
56
  children,
21
57
  react_1.default.createElement(DocumentationLayoutBottom_1.DocumentationLayoutBottom, { feedback: feedback, nextPage: nextPage, prevPage: prevPage })),
@@ -27,6 +63,14 @@ const LayoutWrapper = styled_components_1.default.div.attrs(({ className }) => (
27
63
  display: flex;
28
64
  flex: 1;
29
65
  width: 100%;
66
+
67
+ @media screen and (min-width: ${utils_1.breakpoints.medium}) {
68
+ ${({ $withToc }) => $withToc &&
69
+ (0, styled_components_1.css) `
70
+ display: grid;
71
+ grid-template-columns: minmax(0, 1fr) var(--toc-width);
72
+ `}
73
+ }
30
74
  `;
31
75
  const ContentWrapper = styled_components_1.default.section `
32
76
  --md-content-font-size: var(--font-size-lg);
@@ -47,9 +91,5 @@ const ContentWrapper = styled_components_1.default.section `
47
91
  // disable margin top for h1 on the title heading
48
92
  margin-top: 0;
49
93
  }
50
-
51
- @media screen and (min-width: ${utils_1.breakpoints.medium}) {
52
- width: ${({ $withToc }) => ($withToc ? `calc(90% - var(--toc-width))` : '90%')};
53
- }
54
94
  `;
55
95
  //# sourceMappingURL=DocumentationLayout.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.70.0",
3
+ "version": "0.70.1",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
- import styled from 'styled-components';
2
+ import styled, { css } from 'styled-components';
3
3
 
4
4
  import type { JSX } from 'react';
5
5
  import type { ResolvedNavItemWithLink, MarkdownConfig } from '@redocly/config';
6
6
 
7
7
  import { breakpoints } from '@redocly/theme/core/utils';
8
+ import { useThemeConfig } from '@redocly/theme/core/hooks';
8
9
  import { H1_CLASS } from '@redocly/theme/core/constants';
9
10
  import { CodeSnippetProvider } from '@redocly/theme/core/contexts/CodeSnippetContext';
10
11
  import { DocumentationLayoutTop } from '@redocly/theme/layouts/DocumentationLayoutTop';
@@ -35,10 +36,17 @@ export function DocumentationLayout({
35
36
  className,
36
37
  children,
37
38
  }: React.PropsWithChildren<DocumentationLayoutProps>): JSX.Element {
39
+ const { markdown } = useThemeConfig();
40
+ const withToc = Boolean(tableOfContent) && !(config ?? markdown)?.toc?.hide;
41
+
38
42
  return (
39
43
  <CodeSnippetProvider>
40
- <LayoutWrapper data-component-name="Layout/DocumentationLayout" className={className}>
41
- <ContentWrapper $withToc={!config?.toc?.hide}>
44
+ <LayoutWrapper
45
+ data-component-name="Layout/DocumentationLayout"
46
+ className={className}
47
+ $withToc={withToc}
48
+ >
49
+ <ContentWrapper>
42
50
  <DocumentationLayoutTop config={config} editPage={editPage} lastModified={lastModified} />
43
51
  {children}
44
52
  <DocumentationLayoutBottom feedback={feedback} nextPage={nextPage} prevPage={prevPage} />
@@ -51,13 +59,22 @@ export function DocumentationLayout({
51
59
 
52
60
  const LayoutWrapper = styled.div.attrs(({ className }) => ({
53
61
  className,
54
- }))`
62
+ }))<{ $withToc: boolean }>`
55
63
  display: flex;
56
64
  flex: 1;
57
65
  width: 100%;
66
+
67
+ @media screen and (min-width: ${breakpoints.medium}) {
68
+ ${({ $withToc }) =>
69
+ $withToc &&
70
+ css`
71
+ display: grid;
72
+ grid-template-columns: minmax(0, 1fr) var(--toc-width);
73
+ `}
74
+ }
58
75
  `;
59
76
 
60
- const ContentWrapper = styled.section<{ $withToc: boolean }>`
77
+ const ContentWrapper = styled.section`
61
78
  --md-content-font-size: var(--font-size-lg);
62
79
  --md-content-line-height: var(--line-height-lg);
63
80
  --md-table-font-size: var(--md-content-font-size);
@@ -76,8 +93,4 @@ const ContentWrapper = styled.section<{ $withToc: boolean }>`
76
93
  // disable margin top for h1 on the title heading
77
94
  margin-top: 0;
78
95
  }
79
-
80
- @media screen and (min-width: ${breakpoints.medium}) {
81
- width: ${({ $withToc }) => ($withToc ? `calc(90% - var(--toc-width))` : '90%')};
82
- }
83
96
  `;