@redocly/theme 0.61.0-next.1 → 0.61.0-next.3

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 (97) hide show
  1. package/lib/components/Catalog/CatalogEntity/CatalogEntity.js +5 -0
  2. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.js +9 -0
  3. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton.d.ts +6 -0
  4. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton.js +144 -0
  5. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.d.ts +8 -0
  6. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.js +161 -0
  7. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityRevisionItem.d.ts +8 -0
  8. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityRevisionItem.js +67 -0
  9. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.d.ts +9 -0
  10. package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.js +212 -0
  11. package/lib/components/Catalog/CatalogEntity/CatalogEntityMetadata.js +2 -25
  12. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +12 -1
  13. package/lib/components/Catalog/CatalogEntity/ShowMoreButton.d.ts +8 -0
  14. package/lib/components/Catalog/CatalogEntity/ShowMoreButton.js +35 -0
  15. package/lib/components/Catalog/CatalogTableView/CatalogTableViewRow.d.ts +2 -0
  16. package/lib/components/Catalog/CatalogTableView/CatalogTableViewRow.js +4 -1
  17. package/lib/components/Catalog/variables.js +112 -0
  18. package/lib/components/ColorModeSwitcher/ColorModeIcon.d.ts +2 -1
  19. package/lib/components/ColorModeSwitcher/ColorModeIcon.js +3 -2
  20. package/lib/components/ColorModeSwitcher/ColorModeSwitcher.js +1 -4
  21. package/lib/components/Menu/variables.js +1 -0
  22. package/lib/components/Product/utils.d.ts +1 -0
  23. package/lib/components/Product/utils.js +10 -0
  24. package/lib/components/Tooltip/Tooltip.js +2 -0
  25. package/lib/core/constants/catalog.d.ts +1 -0
  26. package/lib/core/constants/catalog.js +2 -1
  27. package/lib/core/constants/common.d.ts +4 -0
  28. package/lib/core/constants/common.js +5 -1
  29. package/lib/core/hooks/catalog/use-catalog-entity-details.d.ts +3 -1
  30. package/lib/core/hooks/catalog/use-catalog-entity-details.js +12 -5
  31. package/lib/core/hooks/index.d.ts +1 -0
  32. package/lib/core/hooks/index.js +1 -0
  33. package/lib/core/hooks/search/use-recent-searches.js +14 -41
  34. package/lib/core/hooks/use-color-switcher.d.ts +0 -1
  35. package/lib/core/hooks/use-color-switcher.js +19 -13
  36. package/lib/core/hooks/use-page-actions.js +37 -6
  37. package/lib/core/hooks/use-product-picker.js +12 -2
  38. package/lib/core/hooks/use-store.d.ts +17 -0
  39. package/lib/core/hooks/use-store.js +64 -0
  40. package/lib/core/hooks/use-telemetry-fallback.d.ts +2 -0
  41. package/lib/core/hooks/use-telemetry-fallback.js +2 -0
  42. package/lib/core/types/catalog.d.ts +33 -4
  43. package/lib/core/types/common.d.ts +2 -0
  44. package/lib/core/types/hooks.d.ts +14 -3
  45. package/lib/core/types/l10n.d.ts +1 -1
  46. package/lib/core/utils/build-revision-url.d.ts +1 -0
  47. package/lib/core/utils/build-revision-url.js +15 -0
  48. package/lib/core/utils/date.d.ts +14 -0
  49. package/lib/core/utils/date.js +39 -0
  50. package/lib/core/utils/index.d.ts +2 -0
  51. package/lib/core/utils/index.js +2 -0
  52. package/lib/core/utils/load-and-navigate.js +7 -2
  53. package/lib/core/utils/transform-revisions-to-version-history.d.ts +8 -0
  54. package/lib/core/utils/transform-revisions-to-version-history.js +110 -0
  55. package/lib/icons/NavaidMilitaryIcon/NavaidMilitaryIcon.d.ts +9 -0
  56. package/lib/icons/NavaidMilitaryIcon/NavaidMilitaryIcon.js +26 -0
  57. package/lib/index.d.ts +2 -0
  58. package/lib/index.js +2 -0
  59. package/package.json +5 -5
  60. package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +7 -1
  61. package/src/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.tsx +12 -0
  62. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton.tsx +147 -0
  63. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.tsx +180 -0
  64. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityRevisionItem.tsx +93 -0
  65. package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.tsx +284 -0
  66. package/src/components/Catalog/CatalogEntity/CatalogEntityMetadata.tsx +3 -25
  67. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx +15 -2
  68. package/src/components/Catalog/CatalogEntity/ShowMoreButton.tsx +47 -0
  69. package/src/components/Catalog/CatalogTableView/CatalogTableViewRow.tsx +6 -1
  70. package/src/components/Catalog/variables.ts +112 -0
  71. package/src/components/ColorModeSwitcher/ColorModeIcon.tsx +5 -3
  72. package/src/components/ColorModeSwitcher/ColorModeSwitcher.tsx +2 -7
  73. package/src/components/Menu/variables.ts +1 -0
  74. package/src/components/Product/utils.ts +6 -0
  75. package/src/components/Tooltip/Tooltip.tsx +2 -0
  76. package/src/core/constants/catalog.ts +2 -0
  77. package/src/core/constants/common.ts +5 -0
  78. package/src/core/hooks/__mocks__/use-theme-hooks.ts +1 -0
  79. package/src/core/hooks/catalog/use-catalog-entity-details.ts +22 -6
  80. package/src/core/hooks/index.ts +1 -0
  81. package/src/core/hooks/search/use-recent-searches.ts +38 -65
  82. package/src/core/hooks/use-color-switcher.ts +29 -15
  83. package/src/core/hooks/use-page-actions.ts +63 -6
  84. package/src/core/hooks/use-product-picker.ts +12 -0
  85. package/src/core/hooks/use-store.ts +95 -0
  86. package/src/core/hooks/use-telemetry-fallback.ts +2 -0
  87. package/src/core/types/catalog.ts +38 -10
  88. package/src/core/types/common.ts +4 -0
  89. package/src/core/types/hooks.ts +23 -4
  90. package/src/core/types/l10n.ts +10 -0
  91. package/src/core/utils/build-revision-url.ts +16 -0
  92. package/src/core/utils/date.ts +33 -0
  93. package/src/core/utils/index.ts +2 -0
  94. package/src/core/utils/load-and-navigate.ts +6 -1
  95. package/src/core/utils/transform-revisions-to-version-history.ts +163 -0
  96. package/src/icons/NavaidMilitaryIcon/NavaidMilitaryIcon.tsx +43 -0
  97. package/src/index.ts +2 -0
@@ -0,0 +1,93 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import type { CatalogEntityRevision } from '@redocly/theme/core/types';
5
+
6
+ import { Link } from '@redocly/theme/components/Link/Link';
7
+ import { Tag } from '@redocly/theme/components/Tag/Tag';
8
+ import { buildRevisionUrl } from '@redocly/theme/core/utils';
9
+ import { useThemeHooks } from '@redocly/theme/core/hooks';
10
+
11
+ export type CatalogEntityRevisionItemProps = {
12
+ revisionItem: CatalogEntityRevision;
13
+ basePath: string;
14
+ version?: string | null;
15
+ };
16
+
17
+ export function CatalogEntityRevisionItem({
18
+ revisionItem,
19
+ basePath,
20
+ version,
21
+ }: CatalogEntityRevisionItemProps): React.ReactElement {
22
+ const { useTranslate } = useThemeHooks();
23
+ const { translate } = useTranslate();
24
+ const revisionFilter = buildRevisionUrl(basePath, revisionItem.revisionDate, version) ?? basePath;
25
+ const isActive = revisionItem.isActive ?? false;
26
+
27
+ return (
28
+ <RevisionItemWrapper to={revisionFilter} $isActive={isActive}>
29
+ <RevisionNameRow>
30
+ <RevisionName>{revisionItem.name}</RevisionName>
31
+ {revisionItem.isCurrent && (
32
+ <Tag
33
+ color="grey"
34
+ borderless
35
+ textTransform="none"
36
+ style={{
37
+ fontSize: 'var(--font-size-xs)',
38
+ borderRadius: 'var(--catalog-history-sidebar-revision-tag-border-radius)',
39
+ }}
40
+ >
41
+ {translate('catalog.history.revision.current', 'current')}
42
+ </Tag>
43
+ )}
44
+ </RevisionNameRow>
45
+ <RevisionDate>{revisionItem.date}</RevisionDate>
46
+ </RevisionItemWrapper>
47
+ );
48
+ }
49
+
50
+ const RevisionItemWrapper = styled(Link)<{ $isActive?: boolean }>`
51
+ display: flex;
52
+ justify-content: space-between;
53
+ align-items: center;
54
+ padding: var(--catalog-history-sidebar-revision-item-padding);
55
+ margin-left: calc(-1 * var(--catalog-history-sidebar-revisions-padding-left));
56
+ padding-left: var(--catalog-history-sidebar-revisions-padding-left);
57
+ border-radius: var(--catalog-history-sidebar-revision-item-border-radius);
58
+ transition: 0.2s ease;
59
+ text-decoration: none;
60
+ color: inherit;
61
+ cursor: pointer;
62
+ background-color: ${({ $isActive }) =>
63
+ $isActive ? 'var(--catalog-history-sidebar-revision-item-bg-color-active)' : 'transparent'};
64
+
65
+ &:hover {
66
+ background-color: ${({ $isActive }) =>
67
+ $isActive
68
+ ? 'var(--catalog-history-sidebar-revision-item-bg-color-active)'
69
+ : 'var(--catalog-history-sidebar-revision-item-bg-color-hover)'};
70
+ }
71
+ `;
72
+
73
+ const RevisionNameRow = styled.div`
74
+ display: flex;
75
+ align-items: center;
76
+ gap: var(--spacing-xs, 8px);
77
+ `;
78
+
79
+ const RevisionName = styled.span`
80
+ font-family: var(--catalog-history-sidebar-revision-name-font-family);
81
+ font-size: var(--catalog-history-sidebar-revision-name-font-size);
82
+ font-weight: var(--catalog-history-sidebar-revision-name-font-weight);
83
+ line-height: var(--catalog-history-sidebar-revision-name-line-height);
84
+ color: var(--catalog-history-sidebar-revision-name-color);
85
+ `;
86
+
87
+ const RevisionDate = styled.span`
88
+ font-family: var(--catalog-history-sidebar-revision-date-font-family);
89
+ font-size: var(--catalog-history-sidebar-revision-date-font-size);
90
+ font-weight: var(--catalog-history-sidebar-revision-date-font-weight);
91
+ line-height: var(--catalog-history-sidebar-revision-date-line-height);
92
+ color: var(--catalog-history-sidebar-revision-date-color);
93
+ `;
@@ -0,0 +1,284 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import type { CatalogEntityVersionHistoryGroup } from '@redocly/theme/core/types';
5
+
6
+ import { ChevronDownIcon } from '@redocly/theme/icons/ChevronDownIcon/ChevronDownIcon';
7
+ import { ChevronRightIcon } from '@redocly/theme/icons/ChevronRightIcon/ChevronRightIcon';
8
+ import { CheckmarkOutlineIcon } from '@redocly/theme/icons/CheckmarkOutlineIcon/CheckmarkOutlineIcon';
9
+ import { NavaidMilitaryIcon } from '@redocly/theme/icons/NavaidMilitaryIcon/NavaidMilitaryIcon';
10
+ import { Link } from '@redocly/theme/components/Link/Link';
11
+ import { Tag } from '@redocly/theme/components/Tag/Tag';
12
+ import { useThemeHooks } from '@redocly/theme/core/hooks';
13
+ import { ShowMoreButton } from '@redocly/theme/components/Catalog/CatalogEntity/ShowMoreButton';
14
+ import { CatalogEntityRevisionItem } from '@redocly/theme/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityRevisionItem';
15
+ import { buildRevisionUrl } from '@redocly/theme/core/utils';
16
+ import { VERSION_NOT_SPECIFIED } from '@redocly/theme/core/constants';
17
+
18
+ const MAX_INITIAL_REVISIONS = 5;
19
+ const MAX_REVISIONS = 20;
20
+
21
+ export type CatalogEntityVersionItemProps = {
22
+ group: CatalogEntityVersionHistoryGroup;
23
+ basePath: string;
24
+ isExpanded: boolean;
25
+ onToggle: (version: string) => void;
26
+ };
27
+
28
+ export function CatalogEntityVersionItem({
29
+ group,
30
+ basePath,
31
+ isExpanded,
32
+ onToggle,
33
+ }: CatalogEntityVersionItemProps): React.ReactElement {
34
+ const { useTranslate } = useThemeHooks();
35
+ const { translate } = useTranslate();
36
+ const [showAllRevisions, setShowAllRevisions] = useState(false);
37
+
38
+ const revisions = group.revisions || [];
39
+ const hasRevisions = revisions.length > 0;
40
+ const hasMoreThanMax = revisions.length > MAX_INITIAL_REVISIONS;
41
+ const hasMoreThanLimit = revisions.length > MAX_REVISIONS;
42
+ const displayedRevisions = showAllRevisions
43
+ ? revisions.slice(0, MAX_REVISIONS)
44
+ : revisions.slice(0, MAX_INITIAL_REVISIONS);
45
+
46
+ useEffect(() => {
47
+ if (!isExpanded) {
48
+ setShowAllRevisions(false);
49
+ }
50
+ }, [isExpanded]);
51
+
52
+ const isNotSpecifiedVersion = group.version === VERSION_NOT_SPECIFIED;
53
+
54
+ const singleRevisionLink = buildRevisionUrl(basePath, group.singleRevisionDate, group.version);
55
+
56
+ const isClickable = hasRevisions || Boolean(singleRevisionLink);
57
+ const isSingleRevisionActive = Boolean(singleRevisionLink && group.isCurrent);
58
+
59
+ const versionTitle = isNotSpecifiedVersion
60
+ ? `${translate('catalog.history.version.label', 'Version')}: ${translate('catalog.history.version.notSpecified', 'not specified')}`
61
+ : `${translate('catalog.history.version.label', 'Version')}: ${group.version}`;
62
+
63
+ const versionButton = (
64
+ <VersionButton
65
+ type="button"
66
+ onClick={() => hasRevisions && onToggle(group.version)}
67
+ $isClickable={isClickable}
68
+ $isCurrent={group.isCurrent}
69
+ $isActive={isSingleRevisionActive}
70
+ >
71
+ <VersionIcon $isCurrent={group.isCurrent}>
72
+ {group.isCurrent ? (
73
+ <CheckmarkOutlineIcon
74
+ size="16px"
75
+ color="--catalog-history-sidebar-version-icon-color-current"
76
+ />
77
+ ) : (
78
+ <NavaidMilitaryIcon size="16px" color="--catalog-history-sidebar-version-icon-color" />
79
+ )}
80
+ </VersionIcon>
81
+ <VersionInfo>
82
+ <VersionTitleRow>
83
+ <VersionTitle>{versionTitle}</VersionTitle>
84
+ {group.isDefaultVersion && (
85
+ <Tag
86
+ color="grey"
87
+ borderless
88
+ textTransform="none"
89
+ style={{
90
+ fontSize: 'var(--font-size-xs)',
91
+ borderRadius: 'var(--catalog-history-sidebar-version-tag-border-radius)',
92
+ flexShrink: 0,
93
+ }}
94
+ >
95
+ {translate('catalog.history.version.default', 'default')}
96
+ </Tag>
97
+ )}
98
+ </VersionTitleRow>
99
+ {!isNotSpecifiedVersion && <VersionDate>{group.date}</VersionDate>}
100
+ </VersionInfo>
101
+ {hasRevisions && (
102
+ <ChevronIcon>
103
+ {isExpanded ? (
104
+ <ChevronDownIcon size="16px" color="--catalog-history-sidebar-chevron-icon-color" />
105
+ ) : (
106
+ <ChevronRightIcon size="16px" color="--catalog-history-sidebar-chevron-icon-color" />
107
+ )}
108
+ </ChevronIcon>
109
+ )}
110
+ </VersionButton>
111
+ );
112
+
113
+ return (
114
+ <li>
115
+ {singleRevisionLink ? <Link to={singleRevisionLink}>{versionButton}</Link> : versionButton}
116
+
117
+ {hasRevisions && isExpanded && (
118
+ <RevisionsList>
119
+ {displayedRevisions.map((revisionItem) => (
120
+ <CatalogEntityRevisionItem
121
+ key={revisionItem.name}
122
+ revisionItem={revisionItem}
123
+ basePath={basePath}
124
+ version={group.version}
125
+ />
126
+ ))}
127
+ {hasMoreThanLimit && showAllRevisions && (
128
+ <RevisionsLimitMessage>
129
+ {translate(
130
+ 'catalog.history.revisions.limitMessage',
131
+ 'Older revisions are not stored.',
132
+ )}
133
+ </RevisionsLimitMessage>
134
+ )}
135
+ {hasMoreThanMax && (
136
+ <ShowMoreButton
137
+ onClick={() => setShowAllRevisions(!showAllRevisions)}
138
+ isExpanded={showAllRevisions}
139
+ >
140
+ {showAllRevisions
141
+ ? translate('catalog.history.revisions.showLess', 'Show less')
142
+ : translate('catalog.history.revisions.showMore', {
143
+ defaultValue: 'Show more',
144
+ count: Math.min(
145
+ revisions.length - MAX_INITIAL_REVISIONS,
146
+ MAX_REVISIONS - MAX_INITIAL_REVISIONS,
147
+ ),
148
+ })}
149
+ </ShowMoreButton>
150
+ )}
151
+ </RevisionsList>
152
+ )}
153
+ </li>
154
+ );
155
+ }
156
+
157
+ const VersionButton = styled.button<{
158
+ $isClickable?: boolean;
159
+ $isCurrent?: boolean;
160
+ $isActive?: boolean;
161
+ }>`
162
+ all: unset;
163
+ display: flex;
164
+ align-items: center;
165
+ width: calc(100% - var(--catalog-history-sidebar-version-icon-margin-right));
166
+ padding: var(--catalog-history-sidebar-version-header-padding);
167
+ cursor: ${({ $isClickable }) => ($isClickable ? 'pointer' : 'default')};
168
+ border-radius: var(--catalog-history-sidebar-version-header-border-radius);
169
+ transition: 0.2s ease;
170
+ text-decoration: none;
171
+ color: inherit;
172
+ background-color: ${({ $isActive }) =>
173
+ $isActive ? 'var(--catalog-history-sidebar-revision-item-bg-color-active)' : 'transparent'};
174
+
175
+ ${({ $isClickable, $isActive }) =>
176
+ $isClickable &&
177
+ `
178
+ &:hover {
179
+ background-color: ${
180
+ $isActive
181
+ ? 'var(--catalog-history-sidebar-revision-item-bg-color-active)'
182
+ : 'var(--catalog-history-sidebar-version-header-bg-color-hover)'
183
+ };
184
+ }
185
+ `}
186
+
187
+ ${({ $isCurrent }) =>
188
+ !$isCurrent &&
189
+ `
190
+ &:hover ${VersionIcon} {
191
+ background-color: var(--color-static-white);
192
+ }
193
+ `}
194
+ `;
195
+
196
+ const VersionIcon = styled.div<{ $isCurrent?: boolean }>`
197
+ display: flex;
198
+ align-items: center;
199
+ justify-content: center;
200
+ width: var(--catalog-history-sidebar-version-icon-size);
201
+ height: var(--catalog-history-sidebar-version-icon-size);
202
+ flex-shrink: 0;
203
+ border-radius: 50%;
204
+ background-color: ${({ $isCurrent }) =>
205
+ $isCurrent ? 'var(--color-primary-base)' : 'var(--catalog-avatar-bg-color)'};
206
+ transition: background-color 0.2s ease;
207
+ margin-right: var(--catalog-history-sidebar-version-icon-margin-right);
208
+
209
+ svg path {
210
+ transition: fill 0.2s ease;
211
+ }
212
+ `;
213
+
214
+ const VersionInfo = styled.div`
215
+ display: flex;
216
+ flex-direction: column;
217
+ align-items: flex-start;
218
+ gap: var(--catalog-history-sidebar-version-info-gap);
219
+ `;
220
+
221
+ const VersionTitleRow = styled.div`
222
+ display: flex;
223
+ align-items: center;
224
+ gap: var(--spacing-xs, 8px);
225
+ `;
226
+
227
+ const VersionTitle = styled.span`
228
+ font-family: var(--catalog-history-sidebar-version-title-font-family);
229
+ font-size: var(--catalog-history-sidebar-version-title-font-size);
230
+ font-weight: var(--catalog-history-sidebar-version-title-font-weight);
231
+ line-height: var(--catalog-history-sidebar-version-title-line-height);
232
+ color: var(--catalog-history-sidebar-version-title-color);
233
+ flex-shrink: 1;
234
+ min-width: 0;
235
+ `;
236
+
237
+ const VersionDate = styled.span`
238
+ font-family: var(--catalog-history-sidebar-version-date-font-family);
239
+ font-size: var(--catalog-history-sidebar-version-date-font-size);
240
+ font-weight: var(--catalog-history-sidebar-version-date-font-weight);
241
+ line-height: var(--catalog-history-sidebar-version-date-line-height);
242
+ color: var(--catalog-history-sidebar-version-date-color);
243
+ `;
244
+
245
+ const ChevronIcon = styled.div`
246
+ display: flex;
247
+ align-items: center;
248
+ justify-content: center;
249
+ flex-shrink: 0;
250
+ margin-left: auto;
251
+ `;
252
+
253
+ const RevisionsList = styled.ul`
254
+ list-style: none;
255
+ margin: 0;
256
+ padding: 0;
257
+ padding-left: var(--catalog-history-sidebar-revisions-padding-left);
258
+ position: relative;
259
+
260
+ &::before {
261
+ content: '';
262
+ position: absolute;
263
+ left: 22px;
264
+ top: 0;
265
+ bottom: 0;
266
+ width: 1px;
267
+ background-color: var(
268
+ --catalog-history-sidebar-revision-line-color,
269
+ var(--border-color-secondary)
270
+ );
271
+ }
272
+ `;
273
+
274
+ const RevisionsLimitMessage = styled.div`
275
+ padding: var(--catalog-history-sidebar-revision-item-padding);
276
+ margin-left: calc(-1 * var(--catalog-history-sidebar-revisions-padding-left));
277
+ padding-left: var(--catalog-history-sidebar-revisions-padding-left);
278
+ font-family: var(--catalog-history-sidebar-revision-name-font-family);
279
+ font-size: var(--font-size-sm);
280
+ font-weight: var(--catalog-history-sidebar-revision-name-font-weight);
281
+ line-height: var(--catalog-history-sidebar-revision-name-line-height);
282
+ color: var(--catalog-history-sidebar-revisions-limit-message-color);
283
+ text-align: center;
284
+ `;
@@ -2,11 +2,11 @@ import React, { useState } from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import { BffCatalogEntity } from '@redocly/theme/core/types';
5
- import { ChevronDownIcon } from '@redocly/theme/icons/ChevronDownIcon/ChevronDownIcon';
6
5
  import { JsonViewer } from '@redocly/theme/components/JsonViewer/JsonViewer';
7
6
  import { capitalize, isPlainObject } from '@redocly/theme/core/utils';
8
7
  import { useThemeHooks } from '@redocly/theme/core/hooks';
9
8
  import { CatalogEntityInfoBar } from '@redocly/theme/components/Catalog/CatalogEntity/CatalogEntityInfoBar';
9
+ import { ShowMoreButton } from '@redocly/theme/components/Catalog/CatalogEntity/ShowMoreButton';
10
10
 
11
11
  const MAX_INITIAL_ITEMS = 4;
12
12
 
@@ -67,8 +67,8 @@ export function CatalogEntityMetadata({ entity }: CatalogEntityMetadataProps) {
67
67
  />
68
68
  ))}
69
69
  {hasMoreItems && (
70
- <ShowMoreButton onClick={() => setIsOn(!isOn)}>
71
- {isOn ? 'Show less' : 'Show more'} <ChevronIcon $isExpanded={isOn} />
70
+ <ShowMoreButton onClick={() => setIsOn(!isOn)} isExpanded={isOn}>
71
+ {isOn ? 'Show less' : 'Show more'}
72
72
  </ShowMoreButton>
73
73
  )}
74
74
  </MetadataWrapper>
@@ -108,25 +108,3 @@ const Heading = styled.h2`
108
108
  margin-top: 0;
109
109
  font-size: var(--catalog-metadata-heading-size);
110
110
  `;
111
-
112
- const ChevronIcon = styled(ChevronDownIcon)<{ $isExpanded: boolean }>`
113
- transform: ${({ $isExpanded }) => ($isExpanded ? 'rotate(180deg)' : 'rotate(0)')};
114
- transition: transform 0.2s ease;
115
- `;
116
-
117
- const ShowMoreButton = styled.button`
118
- background: none;
119
- border: none;
120
- display: flex;
121
- align-items: center;
122
- gap: var(--catalog-metadata-button-gap, 0.5rem);
123
- cursor: pointer;
124
- color: var(--catalog-metadata-button-color);
125
- padding: 0;
126
- font-weight: var(--font-weight-medium);
127
- margin-top: var(--spacing-unit);
128
-
129
- &:hover {
130
- color: var(--catalog-metadata-button-color-hover);
131
- }
132
- `;
@@ -1,4 +1,4 @@
1
- import React, { JSX, useState, useEffect } from 'react';
1
+ import React, { JSX, useState, useEffect, useMemo } from 'react';
2
2
 
3
3
  import type { CatalogEntityConfig, EntitiesCatalogConfig } from '@redocly/config';
4
4
  import type { BffCatalogEntity, BffCatalogRelatedEntityList } from '@redocly/theme/core/types';
@@ -40,12 +40,25 @@ export function CatalogEntityRelations({
40
40
  setFilter(ENTITY_DEFAULT_FILTERS[entity.key]);
41
41
  }, [entity.key]);
42
42
 
43
+ const combinedFilter = useMemo(() => {
44
+ const baseFilter = filter ?? ENTITY_DEFAULT_FILTERS[entity.type];
45
+ if (entity.version && entity.revision) {
46
+ const versionFilter = `version:"${entity.version}"`;
47
+ const revisionFilter = `revision:"${entity.revision}"`;
48
+ return baseFilter
49
+ ? `${baseFilter} AND ${versionFilter} AND ${revisionFilter}`
50
+ : `${versionFilter} AND ${revisionFilter}`;
51
+ }
52
+
53
+ return baseFilter;
54
+ }, [filter, entity.version, entity.type, entity.revision]);
55
+
43
56
  const { items: relations, query } = useFetchCatalogEntitiesRelations(
44
57
  {
45
58
  entityKey: entity.key,
46
59
  search: searchQuery,
47
60
  sort: sortOption ?? undefined,
48
- filter: filter ?? ENTITY_DEFAULT_FILTERS[entity.type],
61
+ filter: combinedFilter,
49
62
  limit: 10,
50
63
  },
51
64
  initialRelations,
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import { ChevronDownIcon } from '@redocly/theme/icons/ChevronDownIcon/ChevronDownIcon';
5
+
6
+ export type ShowMoreButtonProps = {
7
+ onClick: () => void;
8
+ children: React.ReactNode;
9
+ className?: string;
10
+ isExpanded?: boolean;
11
+ };
12
+
13
+ export function ShowMoreButton({
14
+ onClick,
15
+ children,
16
+ className,
17
+ isExpanded = false,
18
+ }: ShowMoreButtonProps): React.ReactElement {
19
+ return (
20
+ <BaseShowMoreButton type="button" onClick={onClick} className={className}>
21
+ {children}
22
+ <ChevronIcon $isExpanded={isExpanded} />
23
+ </BaseShowMoreButton>
24
+ );
25
+ }
26
+
27
+ const BaseShowMoreButton = styled.button`
28
+ all: unset;
29
+ display: flex;
30
+ align-items: center;
31
+ cursor: pointer;
32
+ background: none;
33
+ border: none;
34
+ gap: var(--catalog-show-more-button-gap);
35
+ color: var(--catalog-show-more-button-color);
36
+ padding: 0;
37
+ margin-top: var(--spacing-unit);
38
+
39
+ &:hover {
40
+ color: var(--catalog-show-more-button-color-hover);
41
+ }
42
+ `;
43
+
44
+ const ChevronIcon = styled(ChevronDownIcon)<{ $isExpanded: boolean }>`
45
+ transform: ${({ $isExpanded }) => ($isExpanded ? 'rotate(180deg)' : 'rotate(0)')};
46
+ transition: transform 0.2s ease;
47
+ `;
@@ -19,6 +19,8 @@ export type BaseEntity = {
19
19
  type: string;
20
20
  title: string;
21
21
  summary?: string | null;
22
+ revision?: string | null;
23
+ version?: string | null;
22
24
  };
23
25
 
24
26
  export type CatalogTableViewRowProps<T extends BaseEntity> = {
@@ -95,14 +97,17 @@ export const CatalogTableViewRow = <T extends BaseEntity>({
95
97
  const { getEntityDetailsLink } = useCatalogEntityDetails({
96
98
  catalogConfig,
97
99
  entitiesCatalogConfig,
100
+ revision: entity.revision,
101
+ version: entity.version,
98
102
  });
103
+ const link = getEntityDetailsLink({ key: entity.key, type: entity.type });
99
104
 
100
105
  return (
101
106
  <TableRow
102
107
  key={entity.id}
103
108
  $columnsWidths={columns.map((column) => column.width || '1fr')}
104
109
  $columnsMinWidths={columns.map((column) => column.minWidth || 'auto')}
105
- to={getEntityDetailsLink(entity) + '?search='}
110
+ to={link}
106
111
  onClick={() => onRowClick(entity)}
107
112
  style={{ color: 'var(--catalog-page-wrapper-text-color)' }}
108
113
  data-component-name="Catalog/CatalogTableView/CatalogTableViewRow"
@@ -235,6 +235,13 @@ export const catalog = css`
235
235
  --catalog-metadata-column-half-gap: var(--spacing-sm);
236
236
  --catalog-metadata-heading-size: var(--font-size-md);
237
237
 
238
+ /**
239
+ * @tokens Catalog show more button
240
+ */
241
+ --catalog-show-more-button-gap: 0.5rem;
242
+ --catalog-show-more-button-color: var(--text-color-primary);
243
+ --catalog-show-more-button-color-hover: var(--text-color-secondary);
244
+
238
245
  /**
239
246
  * @tokens Catalog arrow circle
240
247
  */
@@ -427,5 +434,110 @@ export const catalog = css`
427
434
  --catalog-entity-relations-edge-label-font-size: 12px;
428
435
  --catalog-entity-relations-edge-label-line-height: 1.2;
429
436
  // @tokens End
437
+
438
+ /**
439
+ * @tokens Catalog history button
440
+ */
441
+ --catalog-history-separator-border-color: var(--border-color-secondary);
442
+ --catalog-history-separator-margin-bottom: var(--spacing-sm);
443
+ --catalog-history-item-padding: var(--spacing-xxs);
444
+ --catalog-history-item-margin-bottom: calc(var(--spacing-xxs) * -1);
445
+ --catalog-history-item-gap: var(--spacing-xxs);
446
+ --catalog-history-item-border-radius: var(--menu-item-label-border-radius);
447
+ --catalog-history-item-bg-color-hover: var(--menu-item-bg-color-hover);
448
+ --catalog-history-icon-size: 16px;
449
+ --catalog-history-text-font-family: var(--font-family-base);
450
+ --catalog-history-text-font-size: var(--font-size-base);
451
+ --catalog-history-text-font-weight: var(--font-weight-regular);
452
+ --catalog-history-text-line-height: var(--line-height-base);
453
+ --catalog-history-text-color: var(--text-color-primary);
454
+ --catalog-history-pill-gap: var(--spacing-xxs);
455
+ --catalog-history-pill-padding-vertical: 1px;
456
+ --catalog-history-pill-padding-horizontal: var(--spacing-xs);
457
+ --catalog-history-pill-border-color: var(--border-color-primary);
458
+ --catalog-history-pill-border-radius: 12px;
459
+ --catalog-history-pill-icon-size: 14px;
460
+ --catalog-history-pill-icon-color: var(--color-green-8);
461
+ --catalog-history-pill-font-family: var(--font-family-base);
462
+ --catalog-history-pill-font-size: var(--font-size-base);
463
+ --catalog-history-pill-line-height: var(--line-height-base);
464
+ --catalog-history-pill-text-color: var(--text-color-primary);
465
+ // @tokens End
466
+
467
+ /**
468
+ * @tokens Catalog history sidebar
469
+ */
470
+ --catalog-history-sidebar-width: 320px;
471
+ --catalog-history-sidebar-bg-color: var(--sidebar-bg-color);
472
+ --catalog-history-sidebar-border-color: var(--border-color-secondary);
473
+
474
+ --catalog-history-sidebar-header-padding: var(--spacing-base) var(--spacing-sm) var(--spacing-base);
475
+ --catalog-history-sidebar-header-font-family: var(--font-family-base);
476
+ --catalog-history-sidebar-header-font-size: var(--font-size-base);
477
+ --catalog-history-sidebar-header-font-weight: var(--font-weight-semibold);
478
+ --catalog-history-sidebar-header-line-height: var(--line-height-base);
479
+ --catalog-history-sidebar-header-letter-spacing: 0;
480
+ --catalog-history-sidebar-header-color: var(--text-color-primary);
481
+
482
+ --catalog-history-sidebar-close-button-size: 32px;
483
+ --catalog-history-sidebar-close-button-border-radius: var(--border-radius-md);
484
+ --catalog-history-sidebar-close-button-bg-color-hover: var(--color-hover-base);
485
+ --catalog-history-sidebar-close-icon-color: var(--text-color-primary);
486
+
487
+ --catalog-history-sidebar-content-padding: 0 var(--spacing-sm);
488
+ --catalog-history-sidebar-content-margin-top: calc(var(--spacing-xxs) * -1);
489
+
490
+ --catalog-history-sidebar-version-header-padding: var(--spacing-xs) var(--spacing-xxs);
491
+ --catalog-history-sidebar-version-header-border-radius: var(--border-radius-md);
492
+ --catalog-history-sidebar-version-header-bg-color-hover: var(--color-hover-base);
493
+
494
+ --catalog-history-sidebar-version-icon-size: 32px;
495
+ --catalog-history-sidebar-version-icon-color: var(--text-color-secondary);
496
+ --catalog-history-sidebar-version-icon-color-current: var(--color-static-white);
497
+ --catalog-history-sidebar-version-icon-margin-right: var(--spacing-xs);
498
+ --catalog-history-sidebar-chevron-icon-color: var(--text-color-secondary);
499
+ --catalog-history-sidebar-version-info-gap: 2px;
500
+
501
+ --catalog-history-sidebar-version-title-font-family: var(--font-family-base);
502
+ --catalog-history-sidebar-version-title-font-size: var(--font-size-base);
503
+ --catalog-history-sidebar-version-title-font-weight: var(--font-weight-medium);
504
+ --catalog-history-sidebar-version-title-line-height: var(--line-height-base);
505
+ --catalog-history-sidebar-version-title-color: var(--color-warm-grey-7);
506
+
507
+ --catalog-history-sidebar-version-date-font-family: var(--font-family-base);
508
+ --catalog-history-sidebar-version-date-font-size: var(--font-size-sm);
509
+ --catalog-history-sidebar-version-date-font-weight: var(--font-weight-regular);
510
+ --catalog-history-sidebar-version-date-line-height: var(--line-height-sm);
511
+ --catalog-history-sidebar-version-date-color: var(--color-warm-grey-7);
512
+
513
+ --catalog-history-sidebar-revisions-padding-left: 40px;
514
+
515
+ --catalog-history-sidebar-revision-item-padding: var(--spacing-xs) var(--spacing-sm);
516
+ --catalog-history-sidebar-revision-item-border-radius: var(--border-radius-md);
517
+ --catalog-history-sidebar-revision-item-bg-color-hover: var(--bg-color-hover);
518
+
519
+ --catalog-history-sidebar-revision-name-font-family: var(--font-family-base);
520
+ --catalog-history-sidebar-revision-name-font-size: var(--font-size-base);
521
+ --catalog-history-sidebar-revision-name-font-weight: var(--font-weight-regular);
522
+ --catalog-history-sidebar-revision-name-line-height: var(--line-height-base);
523
+ --catalog-history-sidebar-revision-name-color: var(--text-color-primary);
524
+
525
+ --catalog-history-sidebar-revision-date-font-family: var(--font-family-base);
526
+ --catalog-history-sidebar-revision-date-font-size: var(--font-size-sm);
527
+ --catalog-history-sidebar-revision-date-font-weight: var(--font-weight-regular);
528
+ --catalog-history-sidebar-revision-date-line-height: var(--line-height-sm);
529
+ --catalog-history-sidebar-revision-date-color: var(--color-warm-grey-7);
530
+
531
+ --catalog-history-sidebar-revision-line-color: var(--border-color-secondary);
532
+ --catalog-history-sidebar-revision-item-bg-color-active: var(--bg-color-active);
533
+
534
+ --catalog-history-sidebar-revisions-limit-message-color: var(--color-warm-grey-6);
535
+
536
+ /**
537
+ * @tokens Catalog history tag border radius
538
+ */
539
+ --catalog-history-sidebar-version-tag-border-radius: var(--border-radius-xl);
540
+ --catalog-history-sidebar-revision-tag-border-radius: var(--border-radius-xl);
541
+ // @tokens End
430
542
  `;
431
543
  /* eslint-enable theme/no-raw-colors-in-styles */
@@ -2,13 +2,15 @@ import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import type { JSX } from 'react';
5
+ import type { ColorMode } from '@redocly/theme/core/types';
5
6
 
6
7
  import { ContrastIcon } from '@redocly/theme/icons/ContrastIcon/ContrastIcon';
7
8
  import { MoonIcon } from '@redocly/theme/icons/MoonIcon/MoonIcon';
8
9
  import { SunIcon } from '@redocly/theme/icons/SunIcon/SunIcon';
10
+ import { DEFAULT_COLOR_MODES } from '@redocly/theme/core/constants';
9
11
 
10
12
  export type ColorModeIconProps = {
11
- mode?: 'dark' | 'light' | string;
13
+ mode?: ColorMode | string;
12
14
  className?: string;
13
15
  };
14
16
 
@@ -20,9 +22,9 @@ export function ColorModeIcon(props: ColorModeIconProps): JSX.Element {
20
22
 
21
23
  function Icon({ mode, className }: ColorModeIconProps) {
22
24
  switch (mode) {
23
- case 'dark':
25
+ case DEFAULT_COLOR_MODES.DARK:
24
26
  return <SunIcon data-testid="dark" />;
25
- case 'light':
27
+ case DEFAULT_COLOR_MODES.LIGHT:
26
28
  return <MoonIcon data-testid="light" />;
27
29
  default:
28
30
  return <ContrastIcon data-testid="custom" className={className + (mode ? ' ' + mode : '')} />;